mirror of
https://git.launchpad.net/livecd-rootfs
synced 2025-05-08 17:31:38 +00:00
Merge lp:~rbalint/livecd-rootfs/minimize-fix-grub
This commit is contained in:
commit
cc3cb4e0d8
2
debian/changelog
vendored
2
debian/changelog
vendored
@ -32,6 +32,8 @@ livecd-rootfs (2.408.19) xenial; urgency=medium
|
|||||||
- If we're using SUBPROJECT=minimized, and tzdata is not installed,
|
- If we're using SUBPROJECT=minimized, and tzdata is not installed,
|
||||||
remove files that have been left behind. This is a workaround for a
|
remove files that have been left behind. This is a workaround for a
|
||||||
bug that should be fixed in tzdata.
|
bug that should be fixed in tzdata.
|
||||||
|
* Factor out grub-related diversions and use them consistently, so we
|
||||||
|
don't end up with wrong os-probe output in our grub.cfg.
|
||||||
|
|
||||||
[ Balint Reczey ]
|
[ Balint Reczey ]
|
||||||
* Mount using --make-rslave to ensure safe unmounts for rbind mounts
|
* Mount using --make-rslave to ensure safe unmounts for rbind mounts
|
||||||
|
@ -274,10 +274,40 @@ replace_grub_root_with_label() {
|
|||||||
CHROOT_ROOT="$1"
|
CHROOT_ROOT="$1"
|
||||||
|
|
||||||
# If boot by partuuid has been requested, don't override.
|
# If boot by partuuid has been requested, don't override.
|
||||||
if [ -f $CHROOT_ROOT/etc/default/grub.d/40-partuuid ] && \
|
if [ -f $CHROOT_ROOT/etc/default/grub.d/40-force-partuuid.cfg ] && \
|
||||||
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-force-partuuid.cfg
|
||||||
|
then
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
sed -i -e "s,root=[^ ]\+,root=LABEL=cloudimg-rootfs," \
|
sed -i -e "s,root=[^ ]\+,root=LABEL=cloudimg-rootfs," \
|
||||||
"$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
|
||||||
|
}
|
||||||
|
@ -119,8 +119,10 @@ if [ "${should_install_grub}" -eq 1 ]; then
|
|||||||
if [ "${SUBPROJECT:-}" = minimized ] && [ -n "$partuuid" ]; then
|
if [ "${SUBPROJECT:-}" = minimized ] && [ -n "$partuuid" ]; 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.cfg
|
||||||
|
divert_grub mountpoint
|
||||||
chroot mountpoint update-grub
|
chroot mountpoint update-grub
|
||||||
|
undivert_grub mountpoint
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -66,7 +66,7 @@ install_grub() {
|
|||||||
# and 033-disk-image-uefi.binary. We want to fix this to not
|
# and 033-disk-image-uefi.binary. We want to fix this to not
|
||||||
# have initramfs-tools installed at all on these images.
|
# have initramfs-tools installed at all on these images.
|
||||||
echo "partuuid found for root device; omitting initrd"
|
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
|
fi
|
||||||
|
|
||||||
chroot mountpoint apt-get -y update
|
chroot mountpoint apt-get -y update
|
||||||
@ -119,10 +119,10 @@ EOF
|
|||||||
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
|
||||||
|
|
||||||
|
@ -50,10 +50,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…
x
Reference in New Issue
Block a user