Fix grub divert for multilayer images

grub-probe must not be called during image build so grub is diverted. In
multilayer image the chroot is always the tip of the filesystem, so we
divert grub at the beginning of each pass and undivdert it as the end.
For flat images, it's diverted just before building the chroot and
undiverted after.
snap-tool-base-none
Jean-Baptiste Lallement 6 years ago
parent 41c342ebe2
commit 38bb0b3301

@ -261,14 +261,14 @@ EOF
chmod +x chroot/usr/bin/man
fi
divert_grub chroot
if [ -n "${PASSES}" ]; then
PATH="config/:$PATH" lb chroot_layered "$@"
else
divert_grub chroot
divert_update_initramfs
lb chroot "$@"
fi
undivert_grub chroot
fi
# Let all configuration non multi-layered project here.
# If those are moving to a multi-layer layout, this needs to be

@ -175,6 +175,10 @@ create_chroot_pass () {
lb chroot_devpts install ${*}
lb chroot_proc install ${*}
lb chroot_sysfs install ${*}
# grub-probe should not be called as part of an image build so divert it
divert_grub chroot
# We run chroot_hacks only on root layers (update-initramfs diverted)
if $(is_root_layer $pass); then
divert_update_initramfs
@ -245,6 +249,9 @@ create_chroot_pass () {
Chroot chroot "dpkg-query -W" > chroot.packages.${pass}
# Restore grub
undivert_grub chroot
# Deconfiguring chroot
if $(is_root_layer $pass); then
lb chroot_archives chroot remove ${*}

Loading…
Cancel
Save