self.settings.string(['owner'],
'the user who will own the image when the build '
'is complete.')
+ self.settings.boolean(['squash'],
+ 'use squashfs on the final image.')
def process_args(self, args):
if not self.settings['image'] and not self.settings['tarball']:
if self.settings['image']:
if self.settings['extlinux']:
self.install_extlinux(rootdev, rootdir)
+ self.append_serial_console(rootdir)
self.optimize_image(rootdir)
+ if self.settings['squash']:
+ self.squash()
if self.settings['foreign']:
os.unlink('%s/usr/bin/%s' %
f.close()
+ def append_serial_console(self, rootdir):
+ if self.settings['serial-console']:
+ serial_command = self.settings['serial-console-command']
+ logging.debug('adding getty to serial console')
+ inittab = os.path.join(rootdir, 'etc/inittab')
+ with open(inittab, 'a') as f:
+ f.write('\nS0:23:respawn:%s\n' % serial_command)
+
def install_extlinux(self, rootdev, rootdir):
self.message('Installing extlinux')
'extserial': 'serial 0 115200' if self.settings['serial-console'] else '',
})
f.close()
-
- if self.settings['serial-console']:
- serial_command = self.settings['serial-console-command']
- logging.debug('adding getty to serial console')
- inittab = os.path.join(rootdir, 'etc/inittab')
- with open(inittab, 'a') as f:
- f.write('\nS0:23:respawn:%s\n' % serial_command)
self.runcmd(['extlinux', '--install', rootdir])
self.runcmd(['sync'])
self.runcmd_unchecked(['dd', 'if=/dev/zero', 'of=' + zeros, 'bs=1M'])
self.runcmd(['rm', '-f', zeros])
+ def squash(self):
+ """
+ Run squashfs on the image.
+ """
+ if not os.path.exists('/usr/bin/mksquashfs'):
+ logging.warning("Squash selected but mksquashfs not found!")
+ return
+ self.message("Running mksquashfs")
+ suffixed = "%s.squashfs" % self.settings['image']
+ self.runcmd(['mksquashfs', self.settings['image'],
+ suffixed,
+ '-no-progress', '-comp', 'xz'], ignore_fail=False)
+ os.unlink(self.settings['image'])
+ self.settings['image'] = suffixed
def cleanup_system(self):
# Clean up after any errors.
self.message("Changing owner to %s" % self.settings["owner"])
subprocess.call(["chown",
self.settings["owner"],
- self.settings["image"]])
+ self.settings["image"]])
if __name__ == '__main__':