From ba686350ef981c47488bb9c2ea7f9855c49289cf Mon Sep 17 00:00:00 2001 From: Will Woods Date: Wed, 6 Jul 2011 13:03:03 -0400 Subject: [PATCH] Revive code/hacks for building F15 images To build F15 images we need to remove systemd and set up loader as init (see runtime-cleanup and runtime-postinstall). We also need to add a hack to dracut so loader won't freak out when it gets started by anaconda - see the file we're adding to the initramfs in treebuilder.py. (There's also an extra bonus hack for working around a bug in dracut if /proc/cmdline is empty - SEE IF YOU CAN SPOT IT!!!) --- share/runtime-cleanup.tmpl | 49 +++++++++++++++++++++------------- share/runtime-postinstall.tmpl | 20 ++++++++++---- src/pylorax/treebuilder.py | 15 +++++++++++ 3 files changed, 60 insertions(+), 24 deletions(-) diff --git a/share/runtime-cleanup.tmpl b/share/runtime-cleanup.tmpl index 25f79e54..56e75233 100644 --- a/share/runtime-cleanup.tmpl +++ b/share/runtime-cleanup.tmpl @@ -78,25 +78,36 @@ arch/x86/kvm %endfor remove /modules/*/{build,source,*.map} -## Clean up systemd -removefrom ConsoleKit /lib/systemd/* -removefrom avahi /lib/systemd/* -removefrom chkconfig /sbin/chkconfig /usr/sbin/alternatives -removefrom chkconfig /usr/sbin/update-alternatives /var/lib/alternatives -removefrom initscripts /lib/systemd/system/fedora-readonly.service -removefrom initscripts /lib/systemd/system/fedora-storage-init.service -removefrom initscripts /lib/systemd/system/fedora-wait-storage.service -removefrom systemd-units /lib/systemd/system/bluetooth.target -removefrom systemd-units /lib/systemd/system/http-daemon.target -removefrom systemd-units /lib/systemd/system/kexec* -removefrom systemd-units /lib/systemd/system/local-fs.target.wants/media.mount -removefrom systemd-units /lib/systemd/system/mail-transfer-agent.target -removefrom systemd-units /lib/systemd/system/media.mount -removefrom systemd-units /lib/systemd/system/printer* -removefrom systemd-units /lib/systemd/system/*plymouth* -removefrom systemd-units /lib/systemd/system/quota* -removefrom systemd-units /lib/systemd/system/smartcard* -removefrom systemd-units /lib/systemd/system/systemd-remount-api-vfs.service +%if int(product.version) >= 15: + ## Clean up systemd + removefrom ConsoleKit /lib/systemd/* + removefrom avahi /lib/systemd/* + removefrom chkconfig /sbin/chkconfig /usr/sbin/alternatives + removefrom chkconfig /usr/sbin/update-alternatives /var/lib/alternatives + removefrom initscripts /lib/systemd/system/fedora-readonly.service + removefrom initscripts /lib/systemd/system/fedora-storage-init.service + removefrom initscripts /lib/systemd/system/fedora-wait-storage.service + removefrom systemd-units /lib/systemd/system/bluetooth.target + removefrom systemd-units /lib/systemd/system/http-daemon.target + removefrom systemd-units /lib/systemd/system/kexec* + removefrom systemd-units /lib/systemd/system/local-fs.target.wants/media.mount + removefrom systemd-units /lib/systemd/system/mail-transfer-agent.target + removefrom systemd-units /lib/systemd/system/media.mount + removefrom systemd-units /lib/systemd/system/printer* + removefrom systemd-units /lib/systemd/system/*plymouth* + removefrom systemd-units /lib/systemd/system/quota* + removefrom systemd-units /lib/systemd/system/smartcard* + removefrom systemd-units /lib/systemd/system/systemd-remount-api-vfs.service +%else: + ## F15 - remove systemd init stuff + remove /cgroup /var/cache /var/log + removepkg chkconfig filesystem systemd-units + removefrom NetworkManager /lib/systemd/* + removefrom dbus /lib/systemd/* + removefrom initscripts /lib/systemd/* + removefrom systemd /bin/* /lib/systemd/* /usr/share/systemd/* + removefrom util-linux /sbin/agetty +%endif ## other package specific removals removefrom ConsoleKit /etc/ConsoleKit* /etc/init/* /usr/bin/* /usr/lib/* diff --git a/share/runtime-postinstall.tmpl b/share/runtime-postinstall.tmpl index fcaf66a3..693f9866 100644 --- a/share/runtime-postinstall.tmpl +++ b/share/runtime-postinstall.tmpl @@ -29,13 +29,23 @@ move ${PYTHONDIR}/site-packages/pyanaconda/sitecustomize.py ${PYTHONDIR}/site-pa move etc/yum.repos.d etc/anaconda.repos.d ## misc_tree_modifications() -symlink /sbin/init init -remove etc/systemd/system/default.target -symlink /lib/systemd/system/anaconda.target etc/systemd/system/default.target +%if int(product.version) >= 15: + ## Configure systemd to start anaconda + symlink /sbin/init init + remove etc/systemd/system/default.target + symlink /lib/systemd/system/anaconda.target etc/systemd/system/default.target + append bin/login "#!/bin/bash" + append bin/login "exec -l /bin/bash" +%else: + ## Set up loader as init + copy usr/${libdir}/anaconda/init sbin/init + symlink init sbin/halt + symlink init sbin/poweroff + symlink init sbin/reboot + remove sbin/runlevel sbin/shutdown sbin/telinit +%endif install ${configdir}/network etc/sysconfig append etc/resolv.conf "" -append bin/login "#!/bin/bash" -append bin/login "exec -l /bin/bash" ## get_config_files(configdir) ## gconf stuff diff --git a/src/pylorax/treebuilder.py b/src/pylorax/treebuilder.py index 2ebe6525..b3837d32 100644 --- a/src/pylorax/treebuilder.py +++ b/src/pylorax/treebuilder.py @@ -146,6 +146,8 @@ class TreeBuilder(object): dracut.append("--force") # Hush some dracut warnings. TODO: bind-mount proc in place? open(joinpaths(self.vars.inroot,"/proc/modules"),"w") + # Add some extra bits to the dracut initramfs + dracut += self.anaconda_dracut_hack() # XXX FIXME: add anaconda dracut module! for kernel in self.kernels: logger.info("rebuilding %s", kernel.initrd.path) @@ -156,6 +158,19 @@ class TreeBuilder(object): dracut + [kernel.initrd.path, kernel.version]) os.unlink(joinpaths(self.vars.inroot,"/proc/modules")) + def anaconda_dracut_hack(self): + '''Hack to make F15 dracut able to boot F15 anaconda properly''' + hookfile = "/tmp/99anaconda-umount.sh" # path relative to inroot + with open(joinpaths(self.vars.inroot,hookfile), "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) + return ['--include', hookfile, "/lib/dracut/hooks/pre-pivot"] + def build(self): templatefile = templatemap[self.vars.arch.basearch] self._runner.run(templatefile, kernels=self.kernels)