Merge ~mkukri/grub:ubuntu into ~ubuntu-core-dev/grub/+git/ubuntu:ubuntu

Proposed by Mate Kukri
Status: Merged
Merged at revision: 6f08912cd3ccacc4a3e68d4ca546d5374a54b970
Proposed branch: ~mkukri/grub:ubuntu
Merge into: ~ubuntu-core-dev/grub/+git/ubuntu:ubuntu
Diff against target: 132 lines (+95/-4)
4 files modified
debian/changelog (+10/-0)
debian/patches/delay-copying-to-grubdir.patch (+84/-0)
debian/patches/series (+1/-0)
debian/postinst.in (+0/-4)
Reviewer Review Type Date Requested Status
Julian Andres Klode Needs Fixing
Steve Langasek Approve
Review via email: mp+455991@code.launchpad.net

Commit message

Addresses LP: #2043995 hopefully in full by:
- Making grub-install more robust by only touch /boot/grub after the install device was validated
- Removing the workaround and letting grub-pc postinst run grub-install

To post a comment you must log in.
Revision history for this message
Steve Langasek (vorlon) :
review: Approve
Revision history for this message
Julian Andres Klode (juliank) wrote :

So the changelog entry could be nicer, usually you'd want some text before the (LP: #...) saying what is fixed, it looks weird to just have the bug link there.

+ * (LP: #2043995)
+ - Remove workaround introduced by LP: 1889556
+ - Theoretically wasn't needed since /boot rollback was introduced upstream
+ - Also increase grub-install robustness by delaying the update of /boot after
+ install device validation

review: Needs Fixing

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/debian/changelog b/debian/changelog
2index f5ea66e..26aa431 100644
3--- a/debian/changelog
4+++ b/debian/changelog
5@@ -1,3 +1,13 @@
6+grub2 (2.12~rc1-12ubuntu3) noble; urgency=medium
7+
8+ * d/p/delay-copying-to-grubdir.patch: Improve grub-install robustness by
9+ delaying the update of /boot after install device validation
10+ * Remove workaround for LP: 1889556 (LP: #2043995)
11+ - Was not needed since /boot rollback was introduced upstream
12+ - Patch above ensures that this will not reoccur even if rollback fails
13+
14+ -- Mate Kukri <mate.kukri@canonical.com> Tue, 21 Nov 2023 15:35:55 +0000
15+
16 grub2 (2.12~rc1-12ubuntu2) noble; urgency=medium
17
18 * Merge from Debian unstable; remaining changes:
19diff --git a/debian/patches/delay-copying-to-grubdir.patch b/debian/patches/delay-copying-to-grubdir.patch
20new file mode 100644
21index 0000000..7a6380f
22--- /dev/null
23+++ b/debian/patches/delay-copying-to-grubdir.patch
24@@ -0,0 +1,84 @@
25+From: Mate Kukri <mate.kukri@canonical.com>
26+Date: Tue, 21 Nov 2023 14:58:28 +0000
27+Subject: grub-install: Delay copying files to {grubdir,platdir} after
28+ install_device was validated.
29+
30+Previously grub-install copied modules to grubdir before doing any validation on
31+the install_device.
32+
33+When grub-install was called with an invalid install_device, modules
34+were already copied to /boot before it found out and was forced to rely
35+on atexit rollback.
36+
37+This patch delays copying the modules after at least some install_device
38+validation was done, and thus reduces reliance on successful rollback.
39+
40+Signed-off-by: Mate Kukri <mate.kukri@canonical.com>
41+---
42+ util/grub-install.c | 38 ++++++++++++++++++++------------------
43+ 1 file changed, 20 insertions(+), 18 deletions(-)
44+
45+diff --git a/util/grub-install.c b/util/grub-install.c
46+index 565505f..db110fc 100644
47+--- a/util/grub-install.c
48++++ b/util/grub-install.c
49+@@ -1429,13 +1429,6 @@ main (int argc, char *argv[])
50+ }
51+ }
52+
53+- grub_install_copy_files (grub_install_source_directory,
54+- grubdir, platform);
55+-
56+- char *envfile = grub_util_path_concat (2, grubdir, "grubenv");
57+- if (!grub_util_is_regular (envfile))
58+- grub_util_create_envblk_file (envfile);
59+-
60+ size_t ndev = 0;
61+
62+ /* Write device to a variable so we don't have to traverse /dev every time. */
63+@@ -1522,18 +1515,7 @@ main (int argc, char *argv[])
64+ t);
65+ free (t);
66+ }
67+- load_cfg = grub_util_path_concat (2, platdir,
68+- "load.cfg");
69+-
70+- grub_util_unlink (load_cfg);
71+
72+- if (debug_image && debug_image[0])
73+- {
74+- load_cfg_f = grub_util_fopen (load_cfg, "wb");
75+- have_load_cfg = 1;
76+- fprintf (load_cfg_f, "set debug='%s'\n",
77+- debug_image);
78+- }
79+ char *prefix_drive = NULL;
80+ char *install_drive = NULL;
81+
82+@@ -1557,6 +1539,26 @@ main (int argc, char *argv[])
83+ }
84+ }
85+
86++ grub_install_copy_files (grub_install_source_directory,
87++ grubdir, platform);
88++
89++ char *envfile = grub_util_path_concat (2, grubdir, "grubenv");
90++ if (!grub_util_is_regular (envfile))
91++ grub_util_create_envblk_file (envfile);
92++
93++ load_cfg = grub_util_path_concat (2, platdir,
94++ "load.cfg");
95++
96++ grub_util_unlink (load_cfg);
97++
98++ if (debug_image && debug_image[0])
99++ {
100++ load_cfg_f = grub_util_fopen (load_cfg, "wb");
101++ have_load_cfg = 1;
102++ fprintf (load_cfg_f, "set debug='%s'\n",
103++ debug_image);
104++ }
105++
106+ char *efi_signed = NULL;
107+ switch (platform)
108+ {
109diff --git a/debian/patches/series b/debian/patches/series
110index 49e7a03..9746327 100644
111--- a/debian/patches/series
112+++ b/debian/patches/series
113@@ -108,3 +108,4 @@ suse-grub.texi-add-net_bootp6-document.patch
114 ubuntu-verifiers-last.patch
115 ubuntu-os-prober-auto.patch
116 grub-sort-version.patch
117+delay-copying-to-grubdir.patch
118diff --git a/debian/postinst.in b/debian/postinst.in
119index 8113ac2..8fced84 100644
120--- a/debian/postinst.in
121+++ b/debian/postinst.in
122@@ -584,10 +584,6 @@ case "$1" in
123 elif running_in_container; then
124 # Skip grub-install in containers.
125 :
126- elif dpkg --compare-versions "$2" ge 2.04-1ubuntu26 && [ -z "$DEBCONF_RECONFIGURE" ]; then
127- # Avoid the possibility of breaking grub on SRU update
128- # due to ABI change
129- :
130 elif test -e /boot/grub/core.img || \
131 test -e /boot/grub/@FIRST_CPU_PLATFORM@/core.img || \
132 test "$UPGRADE_FROM_GRUB_LEGACY" || test "$wubi_device"; then

Subscribers

People subscribed via source and target branches