rootfs: fix account removing and clean up
authorTimo Savola <tsavola@movial.fi>
Wed, 23 Jul 2008 10:46:02 +0000 (13:46 +0300)
committerTimo Savola <tsavola@movial.fi>
Wed, 23 Jul 2008 10:46:02 +0000 (13:46 +0300)
matrix/rootfs.py

index 76da00c..5f8badd 100644 (file)
@@ -254,8 +254,8 @@ class Builder(object):
 
                basepath = os.path.join(self.builddir, self.target)
 
-               if os.path.exists(os.path.join(basepath)):
-                       print os.path.join(basepath), "exists, please remove it and try again"
+               if os.path.exists(basepath):
+                       print basepath, "exists, please remove it and try again"
                        return
 
                # Copy the wanted files, strip binaries
@@ -269,7 +269,7 @@ class Builder(object):
                        f = f.replace(self.path, "", 1)
                        if f[0] == '/':
                                f = f[1:]
-                       path = os.path.join(self.builddir, self.target, os.path.dirname(f))
+                       path = os.path.join(basepath, os.path.dirname(f))
                        try:
                                os.makedirs(path)
                        except OSError, e:
@@ -336,7 +336,7 @@ class Builder(object):
 
                        file = open(path, 'w')
                        for line in lines:
-                               print >>file, line
+                               print >>file, line,
                        file.close()
 
                def filter_passwd(line):
@@ -390,7 +390,7 @@ class Builder(object):
                # Build rootfs
                if build_target == "all" or build_target == "rootfs":
                        print "Creating a rootfs..."
-                       os.system("%s -c --one-file-system -C %s -z -f %s.tgz ." % (self.tar, basepath, basepath))
+                       os.system("%s -c --one-file-system -C %s -z -f %s.tar.gz ." % (self.tar, basepath, basepath))
 
                # Build jffs2
                if build_target == "all" or build_target == "jffs2":
@@ -420,20 +420,23 @@ class Builder(object):
                # Build development rootfs
                if build_target == "all" or build_target == "devrootfs":
                        print "Creating a rootstrap..."
-                       os.system("%s -c --one-file-system -C %s -z -f %s-rootstrap.tgz ." % ("tar", self.path, basepath))
+                       os.system("%s -c --one-file-system -C %s -f %s-rootstrap.tar ." % ("tar", self.path, basepath))
+                       # override passwd/group with the modified versions
+                       os.system("%s -r -C %s -f %s-rootstrap.tar ./etc/passwd ./etc/group" % ("tar", basepath, basepath))
+                       os.system("%s -f %s-rootstrap.tar" % ("gzip", basepath))
 
                os.chdir(old_dir)
 
                print "Build finished:"
-               for targets, suffix in ((('rootfs', 'all'), '.tgz'),
+               for targets, suffix in ((('rootfs', 'all'), '.tar.gz'),
                                        (('jffs2', 'all'), '.jffs2'),
                                        (('ubi',), '.ubi'),
-                                       (('devrootfs', 'all'), '-rootstrap.tgz')):
+                                       (('devrootfs', 'all'), '-rootstrap.tar.gz')):
                        if build_target in targets:
                                fullname = basepath + suffix
                                s = os.stat(fullname)
                                size = s.st_size / 1024.0 / 1024.0
-                               print '  %-32s %.2f MiB' % (fullname, size)
+                               print '  %-40s %.2f MiB' % (fullname, size)
 
                if clean:
                        print "Cleaning up"