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

Subscribers

People subscribed via source and target branches