gnu: grub: Update to 2.04.

* gnu/packages/bootloaders.scm (grub): Update to 2.04.
[source]: Remove upstreamed patches.
[arguments]: Don't require Python.  Add a ‘disable-pixel-perfect-test’
phase to skip tests that fail with with our newer Unifont.
* gnu/packages/patches/grub-efi-fat-serial-number.patch: Adjust context.
* gnu/packages/patches/grub-binutils-compat.patch,
gnu/packages/patches/grub-check-error-efibootmgr.patch: Delete files.
* gnu/local.mk (dist_patch_DATA): Remove them.
This commit is contained in:
Tobias Geerinckx-Rice 2019-07-09 01:24:17 +02:00
parent 9b2644c292
commit 069ab3bbfd
No known key found for this signature in database
GPG key ID: 0DB0FF884F556D79
5 changed files with 26 additions and 266 deletions

View file

@ -893,8 +893,6 @@ dist_patch_DATA = \
%D%/packages/patches/grep-timing-sensitive-test.patch \
%D%/packages/patches/groff-source-date-epoch.patch \
%D%/packages/patches/groovy-add-exceptionutilsgenerator.patch \
%D%/packages/patches/grub-binutils-compat.patch \
%D%/packages/patches/grub-check-error-efibootmgr.patch \
%D%/packages/patches/grub-efi-fat-serial-number.patch \
%D%/packages/patches/gsl-test-i686.patch \
%D%/packages/patches/gspell-dash-test.patch \

View file

@ -82,19 +82,22 @@ (define unifont
(define-public grub
(package
(name "grub")
(version "2.02")
(version "2.04")
(source (origin
(method url-fetch)
(uri (string-append "mirror://gnu/grub/grub-" version ".tar.xz"))
(sha256
(base32
"03vvdfhdmf16121v7xs8is2krwnv15wpkhkf16a4yf8nsfc3f2w1"))
(patches (search-patches "grub-check-error-efibootmgr.patch"
"grub-binutils-compat.patch"
"grub-efi-fat-serial-number.patch"))))
"0zgp5m3hmc9jh8wpjx6czzkh5id2y8n1k823x2mjvm2sk6b28ag5"))
(patches (search-patches "grub-efi-fat-serial-number.patch"))))
(build-system gnu-build-system)
(arguments
`(#:phases (modify-phases %standard-phases
`(#:configure-flags
;; Counterintuitively, this *disables* a spurious Python dependency by
;; calling the true binary instead. Python is only needed during
;; bootstrapping (for genptl.py), not when building from a release.
(list "PYTHON=true")
#:phases (modify-phases %standard-phases
(add-after 'unpack 'patch-stuff
(lambda* (#:key inputs #:allow-other-keys)
(substitute* "grub-core/Makefile.in"
@ -127,6 +130,14 @@ (define-public grub
(substitute* "Makefile.in"
(("grub_cmd_date grub_cmd_set_date grub_cmd_sleep")
"grub_cmd_date grub_cmd_sleep"))
#t))
(add-before 'check 'disable-pixel-perfect-test
(lambda _
;; This test compares many screenshots rendered with an
;; older Unifont (9.0.06) than that packaged in Guix.
(substitute* "Makefile.in"
(("test_unset grub_func_test")
"test_unset"))
#t)))
;; Disable tests on ARM and AARCH64 platforms.
#:tests? ,(not (any (cute string-prefix? <> (or (%current-target-system)

View file

@ -1,53 +0,0 @@
Fix a relocation issue that shows up with recent binutils.
Patch taken from upstream:
https://git.sv.gnu.org/cgit/grub.git/commit/?id=842c390469e2c2e10b5aa36700324cd3bde25875
diff --git a/grub-core/efiemu/i386/loadcore64.c b/grub-core/efiemu/i386/loadcore64.c
index e49d0b6..18facf4 100644
--- a/grub-core/efiemu/i386/loadcore64.c
+++ b/grub-core/efiemu/i386/loadcore64.c
@@ -98,6 +98,7 @@ grub_arch_efiemu_relocate_symbols64 (grub_efiemu_segment_t segs,
break;
case R_X86_64_PC32:
+ case R_X86_64_PLT32:
err = grub_efiemu_write_value (addr,
*addr32 + rel->r_addend
+ sym.off
diff --git a/grub-core/kern/x86_64/dl.c b/grub-core/kern/x86_64/dl.c
index 4406906..3a73e6e 100644
--- a/grub-core/kern/x86_64/dl.c
+++ b/grub-core/kern/x86_64/dl.c
@@ -70,6 +70,7 @@ grub_arch_dl_relocate_symbols (grub_dl_t mod, void *ehdr,
break;
case R_X86_64_PC32:
+ case R_X86_64_PLT32:
{
grub_int64_t value;
value = ((grub_int32_t) *addr32) + rel->r_addend + sym->st_value -
diff --git a/util/grub-mkimagexx.c b/util/grub-mkimagexx.c
index a2bb054..39d7efb 100644
--- a/util/grub-mkimagexx.c
+++ b/util/grub-mkimagexx.c
@@ -841,6 +841,7 @@ SUFFIX (relocate_addresses) (Elf_Ehdr *e, Elf_Shdr *sections,
break;
case R_X86_64_PC32:
+ case R_X86_64_PLT32:
{
grub_uint32_t *t32 = (grub_uint32_t *) target;
*t32 = grub_host_to_target64 (grub_target_to_host32 (*t32)
diff --git a/util/grub-module-verifier.c b/util/grub-module-verifier.c
index 9179285..a79271f 100644
--- a/util/grub-module-verifier.c
+++ b/util/grub-module-verifier.c
@@ -19,6 +19,7 @@ struct grub_module_verifier_arch archs[] = {
-1
}, (int[]){
R_X86_64_PC32,
+ R_X86_64_PLT32,
-1
}
},

View file

@ -1,197 +0,0 @@
Without this patch, GRUB may proceed to wipe all firmware boot entries
and report a successful installation, even if efibootmgr hit an error.
Origin URL:
https://git.sv.gnu.org/cgit/grub.git/commit/?id=6400613ad0b463abc93362086a491cd2a5e99b0d
From 6400613ad0b463abc93362086a491cd2a5e99b0d Mon Sep 17 00:00:00 2001
From: Steve McIntyre <steve@einval.com>
Date: Wed, 31 Jan 2018 21:49:36 +0000
Subject: Make grub-install check for errors from efibootmgr
Code is currently ignoring errors from efibootmgr, giving users
clearly bogus output like:
Setting up grub-efi-amd64 (2.02~beta3-4) ...
Installing for x86_64-efi platform.
Could not delete variable: No space left on device
Could not prepare Boot variable: No space left on device
Installation finished. No error reported.
and then potentially unbootable systems. If efibootmgr fails, grub-install
should know that and report it!
We've been using similar patch in Debian now for some time, with no ill effects.
diff --git a/grub-core/osdep/unix/platform.c b/grub-core/osdep/unix/platform.c
index a3fcfca..ca448bc 100644
--- a/grub-core/osdep/unix/platform.c
+++ b/grub-core/osdep/unix/platform.c
@@ -78,19 +78,20 @@ get_ofpathname (const char *dev)
dev);
}
-static void
+static int
grub_install_remove_efi_entries_by_distributor (const char *efi_distributor)
{
int fd;
pid_t pid = grub_util_exec_pipe ((const char * []){ "efibootmgr", NULL }, &fd);
char *line = NULL;
size_t len = 0;
+ int rc;
if (!pid)
{
grub_util_warn (_("Unable to open stream from %s: %s"),
"efibootmgr", strerror (errno));
- return;
+ return errno;
}
FILE *fp = fdopen (fd, "r");
@@ -98,7 +99,7 @@ grub_install_remove_efi_entries_by_distributor (const char *efi_distributor)
{
grub_util_warn (_("Unable to open stream from %s: %s"),
"efibootmgr", strerror (errno));
- return;
+ return errno;
}
line = xmalloc (80);
@@ -119,23 +120,25 @@ grub_install_remove_efi_entries_by_distributor (const char *efi_distributor)
bootnum = line + sizeof ("Boot") - 1;
bootnum[4] = '\0';
if (!verbosity)
- grub_util_exec ((const char * []){ "efibootmgr", "-q",
+ rc = grub_util_exec ((const char * []){ "efibootmgr", "-q",
"-b", bootnum, "-B", NULL });
else
- grub_util_exec ((const char * []){ "efibootmgr",
+ rc = grub_util_exec ((const char * []){ "efibootmgr",
"-b", bootnum, "-B", NULL });
}
free (line);
+ return rc;
}
-void
+int
grub_install_register_efi (grub_device_t efidir_grub_dev,
const char *efifile_path,
const char *efi_distributor)
{
const char * efidir_disk;
int efidir_part;
+ int ret;
efidir_disk = grub_util_biosdisk_get_osdev (efidir_grub_dev->disk);
efidir_part = efidir_grub_dev->disk->partition ? efidir_grub_dev->disk->partition->number + 1 : 1;
@@ -151,23 +154,26 @@ grub_install_register_efi (grub_device_t efidir_grub_dev,
grub_util_exec ((const char * []){ "modprobe", "-q", "efivars", NULL });
#endif
/* Delete old entries from the same distributor. */
- grub_install_remove_efi_entries_by_distributor (efi_distributor);
+ ret = grub_install_remove_efi_entries_by_distributor (efi_distributor);
+ if (ret)
+ return ret;
char *efidir_part_str = xasprintf ("%d", efidir_part);
if (!verbosity)
- grub_util_exec ((const char * []){ "efibootmgr", "-q",
+ ret = grub_util_exec ((const char * []){ "efibootmgr", "-q",
"-c", "-d", efidir_disk,
"-p", efidir_part_str, "-w",
"-L", efi_distributor, "-l",
efifile_path, NULL });
else
- grub_util_exec ((const char * []){ "efibootmgr",
+ ret = grub_util_exec ((const char * []){ "efibootmgr",
"-c", "-d", efidir_disk,
"-p", efidir_part_str, "-w",
"-L", efi_distributor, "-l",
efifile_path, NULL });
free (efidir_part_str);
+ return ret;
}
void
diff --git a/include/grub/util/install.h b/include/grub/util/install.h
index 5910b0c..0dba8b6 100644
--- a/include/grub/util/install.h
+++ b/include/grub/util/install.h
@@ -210,7 +210,7 @@ grub_install_create_envblk_file (const char *name);
const char *
grub_install_get_default_x86_platform (void);
-void
+int
grub_install_register_efi (grub_device_t efidir_grub_dev,
const char *efifile_path,
const char *efi_distributor);
diff --git a/util/grub-install.c b/util/grub-install.c
index 5e4cdfd..690f180 100644
--- a/util/grub-install.c
+++ b/util/grub-install.c
@@ -1848,9 +1848,13 @@ main (int argc, char *argv[])
if (!removable && update_nvram)
{
/* Try to make this image bootable using the EFI Boot Manager, if available. */
- grub_install_register_efi (efidir_grub_dev,
- "\\System\\Library\\CoreServices",
- efi_distributor);
+ int ret;
+ ret = grub_install_register_efi (efidir_grub_dev,
+ "\\System\\Library\\CoreServices",
+ efi_distributor);
+ if (ret)
+ grub_util_error (_("efibootmgr failed to register the boot entry: %s"),
+ strerror (ret));
}
grub_device_close (ins_dev);
@@ -1871,6 +1875,7 @@ main (int argc, char *argv[])
{
char * efifile_path;
char * part;
+ int ret;
/* Try to make this image bootable using the EFI Boot Manager, if available. */
if (!efi_distributor || efi_distributor[0] == '\0')
@@ -1887,7 +1892,10 @@ main (int argc, char *argv[])
efidir_grub_dev->disk->name,
(part ? ",": ""), (part ? : ""));
grub_free (part);
- grub_install_register_efi (efidir_grub_dev,
- efifile_path, efi_distributor);
+ ret = grub_install_register_efi (efidir_grub_dev,
+ efifile_path, efi_distributor);
+ if (ret)
+ grub_util_error (_("efibootmgr failed to register the boot entry: %s"),
+ strerror (ret));
}
break;
Below is a followup to the patch above: the uninitialized variable could lead
grub-install to error out when it shouldnt (seen on an AArch64 box where
grub_install_remove_efi_entries_by_distributor didn't have any entry to
remove):
grub-install: error: efibootmgr failed to register the boot entry: Unknown error 65535.
See <http://lists.gnu.org/archive/html/bug-grub/2018-10/msg00006.html>.
--- grub-2.02/grub-core/osdep/unix/platform.c 2018-10-17 22:21:53.015284846 +0200
+++ grub-2.02/grub-core/osdep/unix/platform.c 2018-10-17 22:21:55.595271222 +0200
@@ -85,7 +85,7 @@ grub_install_remove_efi_entries_by_distr
pid_t pid = grub_util_exec_pipe ((const char * []){ "efibootmgr", NULL }, &fd);
char *line = NULL;
size_t len = 0;
- int rc;
+ int rc = 0;
if (!pid)
{

View file

@ -4,22 +4,23 @@ serial number (instead of the randomly chosen one) to create EFI
images (the 'efi.img' file) that are reproducible bit-for-bit.
Patch by Ludovic Courtès <ludo@gnu.org>.
Mangled (for GRUB 2.04) by Tobias Geerinckx-Rice <me@tobias.gr>.
--- grub-2.02/util/grub-mkrescue.c 2019-04-20 19:15:26.180242812 +0200
+++ grub-2.02/util/grub-mkrescue.c 2019-04-20 21:56:34.672370849 +0200
@@ -788,8 +788,15 @@ main (int argc, char *argv[])
--- grub-2.04/util/grub-mkrescue.c 2019-05-20 13:01:11.000000000 +0200
+++ grub-2.04/util/grub-mkrescue.c 2019-07-08 23:57:36.912104652 +0200
@@ -809,8 +809,15 @@
free (efidir_efi_boot);
efiimgfat = grub_util_path_concat (2, iso9660_dir, "efi.img");
int rv;
- rv = grub_util_exec ((const char * []) { "mformat", "-C", "-f", "2880", "-L", "16", "-i",
- efiimgfat, "::", NULL });
+
+ const char *fat_serial_number = getenv ("GRUB_FAT_SERIAL_NUMBER");
+ const char *mformat_args[] =
+ { "mformat", "-C", "-f", "2880", "-L", "16",
+ fat_serial_number != NULL ? "-N" : "-C",
+ fat_serial_number != NULL ? fat_serial_number : "-C",
+ "-i", efiimgfat, "::", NULL };
+ { "mformat", "-C", "-f", "2880", "-L", "16",
+ fat_serial_number != NULL ? "-N" : "-C",
+ fat_serial_number != NULL ? fat_serial_number : "-C",
+ "-i", efiimgfat, "::", NULL };
+
+ rv = grub_util_exec (mformat_args);
if (rv != 0)