Factor out grub-related diversions and use them consistently, so we

don't end up with wrong os-probe output in our grub.cfg.
ubuntu/artful
Steve Langasek 7 years ago
parent c300b35173
commit a5e27120c0

7
debian/changelog vendored

@ -1,3 +1,10 @@
livecd-rootfs (2.466) UNRELEASED; urgency=medium
* Factor out grub-related diversions and use them consistently, so we
don't end up with wrong os-probe output in our grub.cfg.
-- Steve Langasek <steve.langasek@ubuntu.com> Wed, 04 Oct 2017 22:31:40 -0700
livecd-rootfs (2.465) artful; urgency=medium livecd-rootfs (2.465) artful; urgency=medium
* Skip installation of kernel headers for all minimal images * Skip installation of kernel headers for all minimal images

@ -283,3 +283,32 @@ replace_grub_root_with_label() {
sed -i -e "s,root=[^ ]\+,root=LABEL=${fs_label}," \ sed -i -e "s,root=[^ ]\+,root=LABEL=${fs_label}," \
"$CHROOT_ROOT/boot/grub/grub.cfg" "$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
}

@ -125,7 +125,9 @@ if [ "${should_install_grub}" -eq 1 ]; then
echo "partuuid found for root device; forcing it in Grub" echo "partuuid found for root device; forcing it in Grub"
mkdir -p mountpoint/etc/default/grub.d 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
divert_grub mountpoint
chroot mountpoint update-grub chroot mountpoint update-grub
undivert_grub mountpoint
fi fi
fi fi

@ -110,10 +110,10 @@ install_grub() {
chroot mountpoint grub-install --target=i386-pc "${loop_device}" chroot mountpoint grub-install --target=i386-pc "${loop_device}"
fi fi
chroot mountpoint dpkg-divert --local --rename /etc/grub.d/30_os-prober divert_grub mountpoint
chroot mountpoint update-grub chroot mountpoint update-grub
replace_grub_root_with_label mountpoint 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 chroot mountpoint apt-get -y clean

@ -52,10 +52,10 @@ EOF
--boot-directory=/boot \ --boot-directory=/boot \
--target=powerpc-ieee1275 --target=powerpc-ieee1275
chroot mountpoint dpkg-divert --local --rename /etc/grub.d/30_os-prober divert_grub mountpoint
chroot mountpoint update-grub chroot mountpoint update-grub
replace_grub_root_with_label mountpoint 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 umount_partition mountpoint
rmdir mountpoint rmdir mountpoint

Loading…
Cancel
Save