make create_runtime() just build the image; remove initrd_append
create_runtime should just create the runtime image. We'll worry about making the big combined boot image in the arch-specific templates.
This commit is contained in:
parent
f2814d5c90
commit
996208f1c8
@ -218,24 +218,18 @@ class Lorax(BaseLoraxClass):
|
|||||||
rb.cleanup()
|
rb.cleanup()
|
||||||
|
|
||||||
logger.info("creating the runtime image")
|
logger.info("creating the runtime image")
|
||||||
# TODO: different img styles / create_runtime implementations
|
runtime = joinpaths(self.workdir, "install.img")
|
||||||
runtimedir = joinpaths(self.workdir, "runtime")
|
|
||||||
# FIXME: compression options (type, speed, etc.)
|
# FIXME: compression options (type, speed, etc.)
|
||||||
rb.create_runtime(runtimedir)
|
rb.create_runtime(runtime)
|
||||||
|
|
||||||
logger.info("preparing to build output tree and boot images")
|
logger.info("preparing to build output tree and boot images")
|
||||||
treebuilder = TreeBuilder(self.product, self.arch,
|
treebuilder = TreeBuilder(self.product, self.arch,
|
||||||
installroot, self.outputdir,
|
installroot, self.outputdir,
|
||||||
templatedir)
|
templatedir)
|
||||||
|
|
||||||
# TODO: different image styles may do this part differently
|
|
||||||
logger.info("rebuilding initramfs images")
|
logger.info("rebuilding initramfs images")
|
||||||
treebuilder.rebuild_initrds(add_args=["--xz"])
|
treebuilder.rebuild_initrds(add_args=["--xz"])
|
||||||
|
|
||||||
# TODO: keep small initramfs for split initramfs/runtime media?
|
|
||||||
logger.info("adding runtime to initrds")
|
|
||||||
treebuilder.initrd_append(runtimedir)
|
|
||||||
|
|
||||||
logger.info("populating output tree and building boot images")
|
logger.info("populating output tree and building boot images")
|
||||||
treebuilder.build()
|
treebuilder.build()
|
||||||
|
|
||||||
|
@ -128,36 +128,17 @@ class RuntimeBuilder(object):
|
|||||||
removelocales = locales.difference(keeplocales)
|
removelocales = locales.difference(keeplocales)
|
||||||
self.runtemplate("runtime-cleanup.tmpl", removelocales=removelocales)
|
self.runtemplate("runtime-cleanup.tmpl", removelocales=removelocales)
|
||||||
|
|
||||||
def create_runtime(self, outdir):
|
def create_runtime(self, outfile="/tmp/squashfs.img"):
|
||||||
runtime = "squashfs.img"
|
|
||||||
cmdline = "etc/cmdline"
|
|
||||||
# make live rootfs image - must be named "LiveOS/rootfs.img" for dracut
|
# make live rootfs image - must be named "LiveOS/rootfs.img" for dracut
|
||||||
workdir = joinpaths(outdir, "runtime-workdir")
|
workdir = joinpaths(basename(outfile), "runtime-workdir")
|
||||||
fssize = 2 * (1024*1024*1024) # 2GB sparse file compresses down to nothin'
|
fssize = 2 * (1024*1024*1024) # 2GB sparse file compresses down to nothin'
|
||||||
os.makedirs(joinpaths(workdir, "LiveOS"))
|
os.makedirs(joinpaths(workdir, "LiveOS"))
|
||||||
imgutils.mkext4img(self.vars.root, joinpaths(workdir, "LiveOS/rootfs.img"),
|
imgutils.mkext4img(self.vars.root, joinpaths(workdir, "LiveOS/rootfs.img"),
|
||||||
label="Anaconda", size=fssize)
|
label="Anaconda", size=fssize)
|
||||||
# squash the live rootfs and clean up workdir
|
# squash the live rootfs and clean up workdir
|
||||||
imgutils.mksquashfs(workdir, joinpaths(outdir, runtime))
|
imgutils.mksquashfs(workdir, outfile)
|
||||||
remove(workdir)
|
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):
|
class TreeBuilder(object):
|
||||||
'''Builds the arch-specific boot images.
|
'''Builds the arch-specific boot images.
|
||||||
inroot should be the installtree root (the newly-built runtime dir)'''
|
inroot should be the installtree root (the newly-built runtime dir)'''
|
||||||
@ -189,6 +170,7 @@ class TreeBuilder(object):
|
|||||||
dracut = ["/sbin/dracut", "--nomdadmconf", "--nolvmconf"] + add_args
|
dracut = ["/sbin/dracut", "--nomdadmconf", "--nolvmconf"] + add_args
|
||||||
if not backup:
|
if not backup:
|
||||||
dracut.append("--force")
|
dracut.append("--force")
|
||||||
|
# XXX FIXME: add anaconda dracut module!
|
||||||
for kernel in self.kernels:
|
for kernel in self.kernels:
|
||||||
logger.info("rebuilding %s", kernel.initrd.path)
|
logger.info("rebuilding %s", kernel.initrd.path)
|
||||||
if backup:
|
if backup:
|
||||||
@ -197,19 +179,6 @@ class TreeBuilder(object):
|
|||||||
check_call(["chroot", self.vars.inroot] + \
|
check_call(["chroot", self.vars.inroot] + \
|
||||||
dracut + [kernel.initrd.path, kernel.version])
|
dracut + [kernel.initrd.path, kernel.version])
|
||||||
|
|
||||||
def initrd_append(self, rootdir):
|
|
||||||
'''Place the given files into a cpio archive and append that archive
|
|
||||||
to the initrds.'''
|
|
||||||
cpio = NamedTemporaryFile(prefix="lorax.") # XXX workdir?
|
|
||||||
imgutils.mkcpio(rootdir, cpio.name, compression=None)
|
|
||||||
for kernel in self.kernels:
|
|
||||||
cpio.seek(0)
|
|
||||||
initrd_path = joinpaths(self.vars.inroot, kernel.initrd.path)
|
|
||||||
with open(initrd_path, "ab") as initrd:
|
|
||||||
logger.info("%s size before appending: %i",
|
|
||||||
kernel.initrd.path, getsize(initrd.name))
|
|
||||||
initrd.write(cpio.read())
|
|
||||||
|
|
||||||
def implantisomd5(self):
|
def implantisomd5(self):
|
||||||
for section, data in self.treeinfo_data.items():
|
for section, data in self.treeinfo_data.items():
|
||||||
if 'boot.iso' in data:
|
if 'boot.iso' in data:
|
||||||
|
Loading…
Reference in New Issue
Block a user