From 1976255e5cc98890ea03db344b3e1e3895820578 Mon Sep 17 00:00:00 2001 From: Steve Langasek Date: Tue, 31 Oct 2017 09:58:22 -0700 Subject: [PATCH] divert /usr/bin/systemd-detect-virt as part of the grub diversions, so that the grub kernel postinst hook is operational when we're building in a container. LP: #1729034. --- debian/changelog | 3 +++ live-build/functions | 13 +++++++++++++ 2 files changed, 16 insertions(+) diff --git a/debian/changelog b/debian/changelog index 64c70a2e..14d751c7 100644 --- a/debian/changelog +++ b/debian/changelog @@ -3,6 +3,9 @@ livecd-rootfs (2.479) UNRELEASED; urgency=medium * Purge initramfs-tools from minimized images. * Make sure to remove any initramfs that was generated in a minimized image. + * divert /usr/bin/systemd-detect-virt as part of the grub diversions, so + that the grub kernel postinst hook is operational when we're building + in a container. LP: #1729034. -- Steve Langasek Fri, 13 Oct 2017 17:14:58 -0400 diff --git a/live-build/functions b/live-build/functions index f05aaf8e..549f3be3 100644 --- a/live-build/functions +++ b/live-build/functions @@ -300,6 +300,15 @@ divert_grub() { chroot "$CHROOT_ROOT" dpkg-divert --local \ --divert /etc/grub.d/30_os-prober.dpkg-divert \ --rename /etc/grub.d/30_os-prober + + # Divert systemd-detect-virt; /etc/kernel/postinst.d/zz-update-grub + # no-ops if we are in a container, and the launchpad farm runs builds + # in lxd. We therefore pretend that we're never in a container (by + # exiting 1). + chroot "$CHROOT_ROOT" dpkg-divert --local \ + --rename /usr/bin/systemd-detect-virt + echo "exit 1" > "$CHROOT_ROOT"/usr/bin/systemd-detect-virt + chmod +x "$CHROOT_ROOT"/usr/bin/systemd-detect-virt } undivert_grub() { @@ -312,4 +321,8 @@ undivert_grub() { chroot "$CHROOT_ROOT" dpkg-divert --remove --local \ --divert /etc/grub.d/30_os-prober.dpkg-divert \ --rename /etc/grub.d/30_os-prober + + rm "$CHROOT_ROOT"/usr/bin/systemd-detect-virt + chroot "$CHROOT_ROOT" dpkg-divert --remove --local \ + --rename /usr/bin/systemd-detect-virt }