Merge lp:~rbalint/livecd-rootfs/minimize-fix-grub into lp:~ubuntu-core-dev/livecd-rootfs/xenial-proposed

Proposed by Balint Reczey
Status: Merged
Merged at revision: 1434
Proposed branch: lp:~rbalint/livecd-rootfs/minimize-fix-grub
Merge into: lp:~ubuntu-core-dev/livecd-rootfs/xenial-proposed
Diff against target: 121 lines (+45/-8)
5 files modified
debian/changelog (+5/-0)
live-build/ubuntu-cpc/functions (+32/-2)
live-build/ubuntu-cpc/hooks/032-disk-image.binary (+3/-1)
live-build/ubuntu-cpc/hooks/033-disk-image-uefi.binary (+3/-3)
live-build/ubuntu-cpc/hooks/034-disk-image-ppc64el.binary (+2/-2)
To merge this branch: bzr merge lp:~rbalint/livecd-rootfs/minimize-fix-grub
Reviewer Review Type Date Requested Status
Steve Langasek Approve
Review via email: mp+331872@code.launchpad.net

Description of the change

Fix grub config before releasing 2.408.19

To post a comment you must log in.
Revision history for this message
Balint Reczey (rbalint) wrote :

I'm boot-testing the fix, hence the WIP.

Revision history for this message
Steve Langasek (vorlon) wrote :

A grep for suspicious strings also turns up this entry in live-build/ubuntu-cpc/hooks/030-root-tarball.binary (xenial only):

chroot binary/boot/filesystem.dir dpkg-divert --local --rename /usr/sbin/grub-probe

However this is being done while /removing/ kernel packages + grub, so I think this can be ignored.

+1, this all looks correct, just awaiting the results of your boot test.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'debian/changelog'
2--- debian/changelog 2017-10-04 18:43:52 +0000
3+++ debian/changelog 2017-10-05 14:40:41 +0000
4@@ -32,6 +32,11 @@
5 - If we're using SUBPROJECT=minimized, and tzdata is not installed,
6 remove files that have been left behind. This is a workaround for a
7 bug that should be fixed in tzdata.
8+ * Factor out grub-related diversions and use them consistently, so we
9+ don't end up with wrong os-probe output in our grub.cfg.
10+ * Fix the force-partuuid handling to create the file under
11+ /etc/default/grub.d/ with a .cfg extension as grub expects; it's unclear
12+ how this ever worked without.
13
14 [ Balint Reczey ]
15 * Mount using --make-rslave to ensure safe unmounts for rbind mounts
16
17=== modified file 'live-build/ubuntu-cpc/functions'
18--- live-build/ubuntu-cpc/functions 2017-09-28 13:38:23 +0000
19+++ live-build/ubuntu-cpc/functions 2017-10-05 14:40:41 +0000
20@@ -274,10 +274,40 @@
21 CHROOT_ROOT="$1"
22
23 # If boot by partuuid has been requested, don't override.
24- if [ -f $CHROOT_ROOT/etc/default/grub.d/40-partuuid ] && \
25- grep -q ^GRUB_FORCE_PARTUUID= $CHROOT_ROOT/etc/default/grub.d/40-partuuid; then
26+ if [ -f $CHROOT_ROOT/etc/default/grub.d/40-force-partuuid.cfg ] && \
27+ grep -q ^GRUB_FORCE_PARTUUID= $CHROOT_ROOT/etc/default/grub.d/40-force-partuuid.cfg
28+ then
29 return 0
30 fi
31 sed -i -e "s,root=[^ ]\+,root=LABEL=cloudimg-rootfs," \
32 "$CHROOT_ROOT/boot/grub/grub.cfg"
33 }
34+
35+
36+# When running update-grub in a chroot on a build host, we don't want it to
37+# probe for disks or probe for other installed OSes. Extract common
38+# diversion wrappers, so this isn't reinvented differently for each image.
39+divert_grub() {
40+ CHROOT_ROOT="$1"
41+
42+ chroot "$CHROOT_ROOT" dpkg-divert --local \
43+ --rename /usr/sbin/grub-probe
44+ chroot "$CHROOT_ROOT" touch /usr/sbin/grub-probe
45+ chroot "$CHROOT_ROOT" chmod +x /usr/sbin/grub-probe
46+
47+ chroot "$CHROOT_ROOT" dpkg-divert --local \
48+ --divert /etc/grub.d/30_os-prober.dpkg-divert \
49+ --rename /etc/grub.d/30_os-prober
50+}
51+
52+undivert_grub() {
53+ CHROOT_ROOT="$1"
54+
55+ chroot "$CHROOT_ROOT" rm /usr/sbin/grub-probe
56+ chroot "$CHROOT_ROOT" dpkg-divert --remove --local \
57+ --rename /usr/sbin/grub-probe
58+
59+ chroot "$CHROOT_ROOT" dpkg-divert --remove --local \
60+ --divert /etc/grub.d/30_os-prober.dpkg-divert \
61+ --rename /etc/grub.d/30_os-prober
62+}
63
64=== modified file 'live-build/ubuntu-cpc/hooks/032-disk-image.binary'
65--- live-build/ubuntu-cpc/hooks/032-disk-image.binary 2017-10-03 15:31:27 +0000
66+++ live-build/ubuntu-cpc/hooks/032-disk-image.binary 2017-10-05 14:40:41 +0000
67@@ -119,8 +119,10 @@
68 if [ "${SUBPROJECT:-}" = minimized ] && [ -n "$partuuid" ]; then
69 echo "partuuid found for root device; forcing it in Grub"
70 mkdir -p mountpoint/etc/default/grub.d
71- echo "GRUB_FORCE_PARTUUID=$partuuid" >> mountpoint/etc/default/grub.d/40-force-partuuid
72+ echo "GRUB_FORCE_PARTUUID=$partuuid" >> mountpoint/etc/default/grub.d/40-force-partuuid.cfg
73+ divert_grub mountpoint
74 chroot mountpoint update-grub
75+ undivert_grub mountpoint
76 fi
77 fi
78
79
80=== modified file 'live-build/ubuntu-cpc/hooks/033-disk-image-uefi.binary'
81--- live-build/ubuntu-cpc/hooks/033-disk-image-uefi.binary 2017-10-03 15:31:26 +0000
82+++ live-build/ubuntu-cpc/hooks/033-disk-image-uefi.binary 2017-10-05 14:40:41 +0000
83@@ -66,7 +66,7 @@
84 # and 033-disk-image-uefi.binary. We want to fix this to not
85 # have initramfs-tools installed at all on these images.
86 echo "partuuid found for root device; omitting initrd"
87- echo "GRUB_FORCE_PARTUUID=$partuuid" >> mountpoint/etc/default/grub.d/40-force-partuuid
88+ echo "GRUB_FORCE_PARTUUID=$partuuid" >> mountpoint/etc/default/grub.d/40-force-partuuid.cfg
89 fi
90
91 chroot mountpoint apt-get -y update
92@@ -119,10 +119,10 @@
93 chroot mountpoint grub-install --target=i386-pc "${loop_device}"
94 fi
95
96- chroot mountpoint dpkg-divert --local --rename /etc/grub.d/30_os-prober
97+ divert_grub mountpoint
98 chroot mountpoint update-grub
99 replace_grub_root_with_label mountpoint
100- chroot mountpoint dpkg-divert --remove --local --rename /etc/grub.d/30_os-prober
101+ undivert_grub mountpoint
102
103 chroot mountpoint apt-get -y clean
104
105
106=== modified file 'live-build/ubuntu-cpc/hooks/034-disk-image-ppc64el.binary'
107--- live-build/ubuntu-cpc/hooks/034-disk-image-ppc64el.binary 2017-05-12 19:20:22 +0000
108+++ live-build/ubuntu-cpc/hooks/034-disk-image-ppc64el.binary 2017-10-05 14:40:41 +0000
109@@ -50,10 +50,10 @@
110 --boot-directory=/boot \
111 --target=powerpc-ieee1275
112
113- chroot mountpoint dpkg-divert --local --rename /etc/grub.d/30_os-prober
114+ divert_grub mountpoint
115 chroot mountpoint update-grub
116 replace_grub_root_with_label mountpoint
117- chroot mountpoint dpkg-divert --remove --local --rename /etc/grub.d/30_os-prober
118+ undivert_grub mountpoint
119
120 umount_partition mountpoint
121 rmdir mountpoint

Subscribers

People subscribed via source and target branches