From eec6073ef0540b3537f6607e1236b960105420ad Mon Sep 17 00:00:00 2001 From: Will Woods Date: Wed, 18 May 2011 13:53:54 -0400 Subject: [PATCH] move create_runtime into RuntimeBuilder --- src/pylorax/__init__.py | 36 +----------------------------------- src/pylorax/treebuilder.py | 30 ++++++++++++++++++++++++++++++ 2 files changed, 31 insertions(+), 35 deletions(-) diff --git a/src/pylorax/__init__.py b/src/pylorax/__init__.py index 01615447..fbd85458 100644 --- a/src/pylorax/__init__.py +++ b/src/pylorax/__init__.py @@ -220,10 +220,7 @@ class Lorax(BaseLoraxClass): # TODO: different img styles / create_runtime implementations runtimedir = joinpaths(self.workdir, "runtime") # FIXME: compression options (type, speed, etc.) - create_runtime(self.inroot, runtimedir) - # HACK FOR F15: Work around loader being a jerk about mounts/udev - if int(product.version) < 16: - anaconda_dracut_hack(runtimedir) + rb.create_runtime(runtimedir) logger.info("preparing to build output tree and boot images") treebuilder = TreeBuilder(self.product, self.arch, @@ -264,34 +261,3 @@ def get_buildarch(ybo): buildarch = os.uname()[4] return buildarch - -def create_runtime(inroot, outdir): - runtime = "squashfs.img" - cmdline = "etc/cmdline" - # make live rootfs image - must be named "LiveOS/rootfs.img" for dracut - workdir = joinpaths(outdir, "runtime-workdir") - fssize = 2 * (1024*1024*1024) # 2GB sparse file compresses down to nothin' - os.makedirs(joinpaths(workdir, "LiveOS")) - imgutils.mkext4img(inroot, joinpaths(workdir, "LiveOS/rootfs.img"), - label="Anaconda", size=fssize) - # squash the live rootfs and clean up workdir - imgutils.mksquashfs(workdir, joinpaths(outdir, runtime)) - remove(workdir) - # make "etc/cmdline" for dracut to use as default cmdline args - os.makedirs(joinpaths(outdir, os.path.dirname(cmdline))) - with open(joinpaths(outdir, cmdline), "w") as fobj: - fobj.write("root=live:/%s\n" % runtime) - return [runtime, cmdline] # return list of files to append to initrd - -def anaconda_dracut_hack(outdir): - '''Hack to make anaconda 15.x able to start up from dracut''' - hookdir = joinpaths(outdir, "lib/dracut/hooks/pre-pivot") - os.makedirs(hookdir) - with open(joinpaths(hookdir,"99anaconda-umount.sh"), "w") as f: - s = ['#!/bin/sh', - 'udevadm control --stop-exec-queue', - 'udevd=$(pidof udevd) && kill $udevd', - 'umount -l /proc /sys /dev/pts /dev', - 'echo "mustard=progress" > /proc/cmdline', - '[ "$udevd" ] && kill -9 $udevd'] - f.writelines([line+"\n" for line in s]) diff --git a/src/pylorax/treebuilder.py b/src/pylorax/treebuilder.py index f820227b..a10f135a 100644 --- a/src/pylorax/treebuilder.py +++ b/src/pylorax/treebuilder.py @@ -127,6 +127,36 @@ class RuntimeBuilder(object): removelocales = locales.difference(keeplocales) self.runtemplate("runtime-cleanup.tmpl", removelocales=removelocales) + def create_runtime(self, outdir): + runtime = "squashfs.img" + cmdline = "etc/cmdline" + # make live rootfs image - must be named "LiveOS/rootfs.img" for dracut + workdir = joinpaths(outdir, "runtime-workdir") + fssize = 2 * (1024*1024*1024) # 2GB sparse file compresses down to nothin' + os.makedirs(joinpaths(workdir, "LiveOS")) + imgutils.mkext4img(self.root, joinpaths(workdir, "LiveOS/rootfs.img"), + label="Anaconda", size=fssize) + # squash the live rootfs and clean up workdir + imgutils.mksquashfs(workdir, joinpaths(outdir, runtime)) + remove(workdir) + + # make "etc/cmdline" for dracut to use as default cmdline args + os.makedirs(joinpaths(outdir, os.path.dirname(cmdline))) + with open(joinpaths(outdir, cmdline), "w") as fobj: + fobj.write("root=live:/%s\n" % runtime) + # dracut hack to make anaconda 15.x start up properly + if self.vars.product.version <= 15: + hookdir = joinpaths(outdir, "lib/dracut/hooks/pre-pivot") + os.makedirs(hookdir) + with open(joinpaths(hookdir,"99anaconda-umount.sh"), "w") as f: + s = ['#!/bin/sh', + 'udevadm control --stop-exec-queue', + 'udevd=$(pidof udevd) && kill $udevd', + 'umount -l /proc /sys /dev/pts /dev', + 'echo "mustard=progress" > /proc/cmdline', + '[ "$udevd" ] && kill -9 $udevd'] + f.writelines([line+"\n" for line in s]) + class TreeBuilder(object): '''Builds the arch-specific boot images. inroot should be the installtree root (the newly-built runtime dir)'''