diff --git a/debian/changelog b/debian/changelog index 9f89726a..34f86795 100644 --- a/debian/changelog +++ b/debian/changelog @@ -5,6 +5,11 @@ livecd-rootfs (2.466) UNRELEASED; urgency=medium * move snap assertion handling into the generic build script (and, in the process, from the subiquity overlay to the base squashfs). * add ubuntu-mate to the set of projects we add snap model assertions to. + * Factor out grub-related diversions and use them consistently, so we + don't end up with wrong os-probe output in our grub.cfg. + * Fix the force-partuuid handling to create the file under + /etc/default/grub.d/ with a .cfg extension as grub expects; it's unclear + how this ever worked without. -- Steve Langasek Wed, 04 Oct 2017 22:57:11 -0700 diff --git a/live-build/functions b/live-build/functions index 7fe52f30..4b316eb5 100644 --- a/live-build/functions +++ b/live-build/functions @@ -277,9 +277,38 @@ replace_grub_root_with_label() { # If boot by partuuid has been requested, don't override. if [ -f $CHROOT_ROOT/etc/default/grub.d/40-partuuid ] && \ - grep -q ^GRUB_FORCE_PARTUUID= $CHROOT_ROOT/etc/default/grub.d/40-partuuid; then + grep -q ^GRUB_FORCE_PARTUUID= $CHROOT_ROOT/etc/default/grub.d/40-partuuid.cfg; then return 0 fi sed -i -e "s,root=[^ ]\+,root=LABEL=${fs_label}," \ "$CHROOT_ROOT/boot/grub/grub.cfg" } + + +# When running update-grub in a chroot on a build host, we don't want it to +# probe for disks or probe for other installed OSes. Extract common +# diversion wrappers, so this isn't reinvented differently for each image. +divert_grub() { + CHROOT_ROOT="$1" + + chroot "$CHROOT_ROOT" dpkg-divert --local \ + --rename /usr/sbin/grub-probe + chroot "$CHROOT_ROOT" touch /usr/sbin/grub-probe + chroot "$CHROOT_ROOT" chmod +x /usr/sbin/grub-probe + + chroot "$CHROOT_ROOT" dpkg-divert --local \ + --divert /etc/grub.d/30_os-prober.dpkg-divert \ + --rename /etc/grub.d/30_os-prober +} + +undivert_grub() { + CHROOT_ROOT="$1" + + chroot "$CHROOT_ROOT" rm /usr/sbin/grub-probe + chroot "$CHROOT_ROOT" dpkg-divert --remove --local \ + --rename /usr/sbin/grub-probe + + chroot "$CHROOT_ROOT" dpkg-divert --remove --local \ + --divert /etc/grub.d/30_os-prober.dpkg-divert \ + --rename /etc/grub.d/30_os-prober +} diff --git a/live-build/ubuntu-cpc/hooks/032-disk-image.binary b/live-build/ubuntu-cpc/hooks/032-disk-image.binary index bb8bfc11..e369dfc9 100755 --- a/live-build/ubuntu-cpc/hooks/032-disk-image.binary +++ b/live-build/ubuntu-cpc/hooks/032-disk-image.binary @@ -124,8 +124,10 @@ if [ "${should_install_grub}" -eq 1 ]; then if [ "${SUBPROJECT:-}" = minimized ] && [ -n "$partuuid" ]; then echo "partuuid found for root device; forcing it in Grub" mkdir -p mountpoint/etc/default/grub.d - echo "GRUB_FORCE_PARTUUID=$partuuid" >> mountpoint/etc/default/grub.d/40-force-partuuid + echo "GRUB_FORCE_PARTUUID=$partuuid" >> mountpoint/etc/default/grub.d/40-force-partuuid.cfg + divert_grub mountpoint chroot mountpoint update-grub + undivert_grub mountpoint fi fi diff --git a/live-build/ubuntu-cpc/hooks/033-disk-image-uefi.binary b/live-build/ubuntu-cpc/hooks/033-disk-image-uefi.binary index 932484ea..8e8b0070 100755 --- a/live-build/ubuntu-cpc/hooks/033-disk-image-uefi.binary +++ b/live-build/ubuntu-cpc/hooks/033-disk-image-uefi.binary @@ -67,7 +67,7 @@ install_grub() { # and 033-disk-image-uefi.binary. We want to fix this to not # have initramfs-tools installed at all on these images. echo "partuuid found for root device; omitting initrd" - echo "GRUB_FORCE_PARTUUID=$partuuid" >> mountpoint/etc/default/grub.d/40-force-partuuid + echo "GRUB_FORCE_PARTUUID=$partuuid" >> mountpoint/etc/default/grub.d/40-force-partuuid.cfg fi chroot mountpoint apt-get -y update @@ -110,10 +110,10 @@ install_grub() { chroot mountpoint grub-install --target=i386-pc "${loop_device}" fi - chroot mountpoint dpkg-divert --local --rename /etc/grub.d/30_os-prober + divert_grub mountpoint chroot mountpoint update-grub replace_grub_root_with_label mountpoint - chroot mountpoint dpkg-divert --remove --local --rename /etc/grub.d/30_os-prober + undivert_grub mountpoint chroot mountpoint apt-get -y clean diff --git a/live-build/ubuntu-cpc/hooks/034-disk-image-ppc64el.binary b/live-build/ubuntu-cpc/hooks/034-disk-image-ppc64el.binary index 62a02094..649843e4 100755 --- a/live-build/ubuntu-cpc/hooks/034-disk-image-ppc64el.binary +++ b/live-build/ubuntu-cpc/hooks/034-disk-image-ppc64el.binary @@ -52,10 +52,10 @@ EOF --boot-directory=/boot \ --target=powerpc-ieee1275 - chroot mountpoint dpkg-divert --local --rename /etc/grub.d/30_os-prober + divert_grub mountpoint chroot mountpoint update-grub replace_grub_root_with_label mountpoint - chroot mountpoint dpkg-divert --remove --local --rename /etc/grub.d/30_os-prober + undivert_grub mountpoint umount_partition mountpoint rmdir mountpoint