rootfs: don't die if passwd/group files don't exist
authorTimo Savola <tsavola@movial.fi>
Tue, 29 Jul 2008 12:15:25 +0000 (15:15 +0300)
committerTimo Savola <tsavola@movial.fi>
Tue, 29 Jul 2008 12:15:25 +0000 (15:15 +0300)
matrix/rootfs.py

index ed2f328..2acbf13 100644 (file)
@@ -348,13 +348,13 @@ class Builder(object):
                def filter_group(line):
                        return int(line.split(':')[2]) != rootfs.remove_gid
 
-               if rootfs.remove_uid is not None:
-                       path = os.path.join(basepath, 'etc/passwd')
-                       rewrite_accounts(path, filter_passwd)
+               passwd_path = os.path.join(basepath, 'etc/passwd')
+               if os.path.exists(passwd_path) and rootfs.remove_uid is not None:
+                       rewrite_accounts(passwd_path, filter_passwd)
 
-               if rootfs.remove_gid is not None:
-                       path = os.path.join(basepath, 'etc/group')
-                       rewrite_accounts(path, filter_group)
+               group_path = os.path.join(basepath, 'etc/group')
+               if os.path.exists(group_path) and rootfs.remove_gid is not None:
+                       rewrite_accounts(group_path, filter_group)
 
                # Create device nodes
                print "Creating device nodes..."