aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--main/grub/0001-osdep-Introduce-include-grub-osdep-major.h-and-use-i.patch144
-rw-r--r--main/grub/0002-efi-add-definition-of-LoadFile2-protocol.patch64
-rw-r--r--main/grub/0002-osdep-linux-hostdisk-Use-stat-instead-of-udevadm-for.patch79
-rw-r--r--main/grub/0003-build-Fix-build-error-with-binutils-2.36.patch (renamed from main/grub/0008-fix-build-error-in-binutils-2.36.patch)22
-rw-r--r--main/grub/0003-efi-implemented-LoadFile2-initrd-loading-protocol-fo.patch187
-rw-r--r--main/grub/0004-configure-Fix-misspelled-variable-BUILD_LDFAGS-BUILD.patch20
-rw-r--r--main/grub/0005-RISC-V-Adjust-march-flags-for-binutils-2.38.patch31
-rw-r--r--main/grub/0006-templates-Improve-initramfs-detection.patch42
-rw-r--r--main/grub/0007-loader-arm64-linux-Remove-magic-number-header-field-.patch21
-rw-r--r--main/grub/0008-loader-Drop-argv-argument-in-grub_initrd_load.patch (renamed from main/grub/0001-loader-drop-argv-argument-in-grub_initrd_load.patch)19
-rw-r--r--main/grub/0009-efi-Move-MS-DOS-stub-out-of-generic-PE-header-defini.patch69
-rw-r--r--main/grub/0009-fix-kernel-version-detection.patch64
-rw-r--r--main/grub/0010-arm-linux-Unify-ARM-arm64-vs-Xen-PE-COFF-header-hand.patch162
-rw-r--r--main/grub/0010-riscv-binutils-2.38.patch39
-rw-r--r--main/grub/0011-loader-arm64-linux-Account-for-COFF-headers-appearin.patch33
-rw-r--r--main/grub/0011-mkconfig-ignore-apk-new-files.patch30
-rw-r--r--main/grub/0012-arm64-efi-linux-Implement-LoadFile2-initrd-loading-p.patch276
-rw-r--r--main/grub/0012-remove-udevadm-usage.patch137
-rw-r--r--main/grub/0013-arm64-efi-linux-Ignore-FDT-unless-we-need-to-modify-.patch (renamed from main/grub/0004-linux-ignore-FDT-unless-we-need-to-modify-it.patch)37
-rw-r--r--main/grub/0013-prevent-vgs-warnings.patch37
-rw-r--r--main/grub/0014-loader-Move-arm64-linux-loader-to-common-code.patch (renamed from main/grub/0005-loader-Move-arm64-linux-loader-to-common-code.patch)42
-rw-r--r--main/grub/0015-RISC-V-Update-image-header.patch (renamed from main/grub/0006-RISC-V-Update-image-header.patch)15
-rw-r--r--main/grub/0016-RISC-V-Use-common-linux-loader.patch (renamed from main/grub/0007-RISC-V-Use-common-linux-loader.patch)14
-rw-r--r--main/grub/0017-Fix-grub-mkconfig-detection-of-linux-edge-virt.patch43
-rw-r--r--main/grub/0018-ensure-grub-mkconfig-ignores-.apk-new-files.patch22
-rw-r--r--main/grub/0019-prevent-harmless-LVM-warnings-from-grub-probe.patch20
-rw-r--r--main/grub/0020-Handle-encrypted-zfs-root-partition.patch (renamed from main/grub/0014-fix-encrypted-zfs.patch)28
-rw-r--r--main/grub/0021-Alpine-Linux-fixes-for-menu.patch (renamed from main/grub/alpine-mkconfig.patch)20
-rw-r--r--main/grub/0022-templates-fix-lang-locale-detection.patch (renamed from main/grub/lang-C.UTF-8.patch)9
-rw-r--r--main/grub/0023-build-force-no-pie.patch (renamed from main/grub/fix-gcc-no-pie-specs.patch)15
-rw-r--r--main/grub/APKBUILD84
31 files changed, 1092 insertions, 733 deletions
diff --git a/main/grub/0001-osdep-Introduce-include-grub-osdep-major.h-and-use-i.patch b/main/grub/0001-osdep-Introduce-include-grub-osdep-major.h-and-use-i.patch
new file mode 100644
index 00000000000..274d09c8093
--- /dev/null
+++ b/main/grub/0001-osdep-Introduce-include-grub-osdep-major.h-and-use-i.patch
@@ -0,0 +1,144 @@
+af51cf7ddf6256a38c4d9cba6db72c0a8f27c1bc osdep: Introduce include/grub/osdep/major.h and use it
+ configure.ac | 2 +-
+ grub-core/osdep/devmapper/getroot.c | 7 +-----
+ grub-core/osdep/devmapper/hostdisk.c | 7 +-----
+ grub-core/osdep/linux/getroot.c | 7 +-----
+ grub-core/osdep/unix/getroot.c | 7 +-----
+ include/grub/osdep/major.h | 33 ++++++++++++++++++++++++++++
+ 6 files changed, 38 insertions(+), 25 deletions(-)
+ create mode 100644 include/grub/osdep/major.h
+
+diff --git a/configure.ac b/configure.ac
+index 7517fc49d..63c333a2d 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -424,7 +424,7 @@ AC_CHECK_HEADERS(sys/param.h sys/mount.h sys/mnttab.h limits.h)
+
+ # glibc 2.25 still includes sys/sysmacros.h in sys/types.h but emits deprecation
+ # warning which causes compilation failure later with -Werror. So use -Werror here
+-# as well to force proper sys/sysmacros.h detection.
++# as well to force proper sys/sysmacros.h detection. Used in include/grub/osdep/major.h.
+ SAVED_CFLAGS="$CFLAGS"
+ CFLAGS="$HOST_CFLAGS -Werror"
+ AC_HEADER_MAJOR
+diff --git a/grub-core/osdep/devmapper/getroot.c b/grub-core/osdep/devmapper/getroot.c
+index a13a39c96..9ba5c9865 100644
+--- a/grub-core/osdep/devmapper/getroot.c
++++ b/grub-core/osdep/devmapper/getroot.c
+@@ -40,12 +40,7 @@
+ #include <limits.h>
+ #endif
+
+-#if defined(MAJOR_IN_MKDEV)
+-#include <sys/mkdev.h>
+-#elif defined(MAJOR_IN_SYSMACROS)
+-#include <sys/sysmacros.h>
+-#endif
+-
++#include <grub/osdep/major.h>
+ #include <libdevmapper.h>
+
+ #include <grub/types.h>
+diff --git a/grub-core/osdep/devmapper/hostdisk.c b/grub-core/osdep/devmapper/hostdisk.c
+index a8afc0c94..c8053728b 100644
+--- a/grub-core/osdep/devmapper/hostdisk.c
++++ b/grub-core/osdep/devmapper/hostdisk.c
+@@ -11,6 +11,7 @@
+ #include <grub/misc.h>
+ #include <grub/i18n.h>
+ #include <grub/list.h>
++#include <grub/osdep/major.h>
+
+ #include <stdio.h>
+ #include <stdlib.h>
+@@ -24,12 +25,6 @@
+ #include <errno.h>
+ #include <limits.h>
+
+-#if defined(MAJOR_IN_MKDEV)
+-#include <sys/mkdev.h>
+-#elif defined(MAJOR_IN_SYSMACROS)
+-#include <sys/sysmacros.h>
+-#endif
+-
+ #ifdef HAVE_DEVICE_MAPPER
+ # include <libdevmapper.h>
+
+diff --git a/grub-core/osdep/linux/getroot.c b/grub-core/osdep/linux/getroot.c
+index 001b818fe..cd588588e 100644
+--- a/grub-core/osdep/linux/getroot.c
++++ b/grub-core/osdep/linux/getroot.c
+@@ -35,12 +35,7 @@
+ #include <limits.h>
+ #endif
+
+-#if defined(MAJOR_IN_MKDEV)
+-#include <sys/mkdev.h>
+-#elif defined(MAJOR_IN_SYSMACROS)
+-#include <sys/sysmacros.h>
+-#endif
+-
++#include <grub/osdep/major.h>
+ #include <grub/types.h>
+ #include <sys/ioctl.h> /* ioctl */
+ #include <sys/mount.h>
+diff --git a/grub-core/osdep/unix/getroot.c b/grub-core/osdep/unix/getroot.c
+index 46d7116c6..74f69116d 100644
+--- a/grub-core/osdep/unix/getroot.c
++++ b/grub-core/osdep/unix/getroot.c
+@@ -51,12 +51,7 @@
+ #endif /* ! FLOPPY_MAJOR */
+ #endif
+
+-#include <sys/types.h>
+-#if defined(MAJOR_IN_MKDEV)
+-#include <sys/mkdev.h>
+-#elif defined(MAJOR_IN_SYSMACROS)
+-#include <sys/sysmacros.h>
+-#endif
++#include <grub/osdep/major.h>
+
+ #if defined(HAVE_LIBZFS) && defined(HAVE_LIBNVPAIR)
+ # include <grub/util/libzfs.h>
+diff --git a/include/grub/osdep/major.h b/include/grub/osdep/major.h
+new file mode 100644
+index 000000000..84a9159af
+--- /dev/null
++++ b/include/grub/osdep/major.h
+@@ -0,0 +1,33 @@
++/*
++ * GRUB -- GRand Unified Bootloader
++ * Copyright (C) 2021 Free Software Foundation, Inc.
++ *
++ * GRUB is free software: you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation, either version 3 of the License, or
++ * (at your option) any later version.
++ *
++ * GRUB is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
++ *
++ * Fix for glibc 2.25 which is deprecating the namespace pollution of
++ * sys/types.h injecting major(), minor(), and makedev() into the
++ * compilation environment.
++ */
++
++#ifndef GRUB_OSDEP_MAJOR_H
++#define GRUB_OSDEP_MAJOR_H 1
++
++#include <sys/types.h>
++
++#ifdef MAJOR_IN_MKDEV
++# include <sys/mkdev.h>
++#elif defined (MAJOR_IN_SYSMACROS)
++# include <sys/sysmacros.h>
++#endif
++#endif /* GRUB_OSDEP_MAJOR_H */
+--
+2.39.2
+
diff --git a/main/grub/0002-efi-add-definition-of-LoadFile2-protocol.patch b/main/grub/0002-efi-add-definition-of-LoadFile2-protocol.patch
deleted file mode 100644
index 7ee8e3d86bf..00000000000
--- a/main/grub/0002-efi-add-definition-of-LoadFile2-protocol.patch
+++ /dev/null
@@ -1,64 +0,0 @@
-From 54139ad5b7b30b408b925235383f453cb2dbb776 Mon Sep 17 00:00:00 2001
-From: Ard Biesheuvel <ard.biesheuvel@arm.com>
-Date: Thu, 3 Jun 2021 00:12:30 +0300
-Subject: [PATCH 2/7] efi: add definition of LoadFile2 protocol
-
-Incorporate the EFI_LOAD_FILE2_PROTOCOL GUID and C types from the
-UEFI spec.
-
-Signed-off-by: Ard Biesheuvel <ard.biesheuvel@arm.com>
-Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
-Signed-off-by: Nikita Ermakov <arei@altlinux.org>
----
- grub-core/commands/efi/lsefi.c | 1 +
- include/grub/efi/api.h | 15 +++++++++++++++
- 2 files changed, 16 insertions(+)
-
-diff --git a/grub-core/commands/efi/lsefi.c b/grub-core/commands/efi/lsefi.c
-index d1ce99af4..4085f5df2 100644
---- a/grub-core/commands/efi/lsefi.c
-+++ b/grub-core/commands/efi/lsefi.c
-@@ -55,6 +55,7 @@ struct known_protocol
- { GRUB_EFI_ABSOLUTE_POINTER_PROTOCOL_GUID, "absolute pointer" },
- { GRUB_EFI_DRIVER_BINDING_PROTOCOL_GUID, "EFI driver binding" },
- { GRUB_EFI_LOAD_FILE_PROTOCOL_GUID, "load file" },
-+ { GRUB_EFI_LOAD_FILE2_PROTOCOL_GUID, "load file2" },
- { GRUB_EFI_SIMPLE_FILE_SYSTEM_PROTOCOL_GUID, "simple FS" },
- { GRUB_EFI_TAPE_IO_PROTOCOL_GUID, "tape I/O" },
- { GRUB_EFI_UNICODE_COLLATION_PROTOCOL_GUID, "unicode collation" },
-diff --git a/include/grub/efi/api.h b/include/grub/efi/api.h
-index f1a52210c..3de0a7d12 100644
---- a/include/grub/efi/api.h
-+++ b/include/grub/efi/api.h
-@@ -149,6 +149,11 @@
- { 0x8E, 0x3F, 0x00, 0xA0, 0xC9, 0x69, 0x72, 0x3B } \
- }
-
-+#define GRUB_EFI_LOAD_FILE2_PROTOCOL_GUID \
-+ { 0x4006c0c1, 0xfcb3, 0x403e, \
-+ { 0x99, 0x6d, 0x4a, 0x6c, 0x87, 0x24, 0xe0, 0x6d } \
-+ }
-+
- #define GRUB_EFI_SIMPLE_FILE_SYSTEM_PROTOCOL_GUID \
- { 0x0964e5b22, 0x6459, 0x11d2, \
- { 0x8e, 0x39, 0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b } \
-@@ -1729,6 +1734,16 @@ struct grub_efi_rng_protocol
- };
- typedef struct grub_efi_rng_protocol grub_efi_rng_protocol_t;
-
-+struct grub_efi_load_file2
-+{
-+ grub_efi_status_t (*load_file)(struct grub_efi_load_file2 *this,
-+ grub_efi_device_path_t *file_path,
-+ grub_efi_boolean_t boot_policy,
-+ grub_efi_uintn_t *buffer_size,
-+ void *buffer);
-+};
-+typedef struct grub_efi_load_file2 grub_efi_load_file2_t;
-+
- #if (GRUB_TARGET_SIZEOF_VOID_P == 4) || defined (__ia64__) \
- || defined (__aarch64__) || defined (__MINGW64__) || defined (__CYGWIN__) \
- || defined(__riscv)
---
-2.33.0
-
diff --git a/main/grub/0002-osdep-linux-hostdisk-Use-stat-instead-of-udevadm-for.patch b/main/grub/0002-osdep-linux-hostdisk-Use-stat-instead-of-udevadm-for.patch
new file mode 100644
index 00000000000..ac58da5f535
--- /dev/null
+++ b/main/grub/0002-osdep-linux-hostdisk-Use-stat-instead-of-udevadm-for.patch
@@ -0,0 +1,79 @@
+4876f3fcfcda2720d2ff0cb99cf7c27d490e27c9 osdep/linux/hostdisk: Use stat() instead of udevadm for partition lookup
+ grub-core/osdep/linux/hostdisk.c | 52 ++++----------------------------
+ 1 file changed, 6 insertions(+), 46 deletions(-)
+
+diff --git a/grub-core/osdep/linux/hostdisk.c b/grub-core/osdep/linux/hostdisk.c
+index da62f924e..d3326d095 100644
+--- a/grub-core/osdep/linux/hostdisk.c
++++ b/grub-core/osdep/linux/hostdisk.c
+@@ -31,6 +31,7 @@
+ #include <grub/misc.h>
+ #include <grub/i18n.h>
+ #include <grub/list.h>
++#include <grub/osdep/major.h>
+
+ #include <stdio.h>
+ #include <stdlib.h>
+@@ -98,54 +99,13 @@ grub_util_get_fd_size_os (grub_util_fd_t fd, const char *name, unsigned *log_sec
+ static char *
+ sysfs_partition_path (const char *dev, const char *entry)
+ {
+- const char *argv[7];
+- int fd;
+- pid_t pid;
+- FILE *udevadm;
+- char *buf = NULL;
+- size_t len = 0;
+- char *path = NULL;
+-
+- argv[0] = "udevadm";
+- argv[1] = "info";
+- argv[2] = "--query";
+- argv[3] = "path";
+- argv[4] = "--name";
+- argv[5] = dev;
+- argv[6] = NULL;
+-
+- pid = grub_util_exec_pipe (argv, &fd);
+-
+- if (!pid)
+- return NULL;
+-
+- /* Parent. Read udevadm's output. */
+- udevadm = fdopen (fd, "r");
+- if (!udevadm)
+- {
+- grub_util_warn (_("Unable to open stream from %s: %s"),
+- "udevadm", strerror (errno));
+- close (fd);
+- goto out;
+- }
+-
+- if (getline (&buf, &len, udevadm) > 0)
+- {
+- char *newline;
+-
+- newline = strchr (buf, '\n');
+- if (newline)
+- *newline = '\0';
+- path = xasprintf ("/sys%s/%s", buf, entry);
+- }
++ struct stat st;
+
+-out:
+- if (udevadm)
+- fclose (udevadm);
+- waitpid (pid, NULL, 0);
+- free (buf);
++ if (stat (dev, &st) == 0 && S_ISBLK (st.st_mode))
++ return xasprintf ("/sys/dev/block/%u:%u/%s",
++ major (st.st_rdev), minor (st.st_rdev), entry);
+
+- return path;
++ return NULL;
+ }
+
+ static int
+--
+2.39.2
+
diff --git a/main/grub/0008-fix-build-error-in-binutils-2.36.patch b/main/grub/0003-build-Fix-build-error-with-binutils-2.36.patch
index 5cb327003ad..a15caf74270 100644
--- a/main/grub/0008-fix-build-error-in-binutils-2.36.patch
+++ b/main/grub/0003-build-Fix-build-error-with-binutils-2.36.patch
@@ -1,24 +1,9 @@
-From 5cea201f288246488e2189c49d969d00ebec2898 Mon Sep 17 00:00:00 2001
-From: Michael Chang <mchang@suse.com>
-Date: Fri, 19 Feb 2021 17:40:43 +0800
-Subject: [PATCH] Fix build error in binutils 2.36
-
-The build fails in binutils 2.36
-
-[ 520s] cat kernel_syms.lst > syminfo.lst.new
-[ 520s] /usr/lib64/gcc/x86_64-suse-linux/10/../../../../x86_64-suse-linux/bin/ld: section .note.gnu.property VMA [0000000000400158,0000000000400187] overlaps section .bss VMA [000000000000f000,000000000041e1af]
-
-It is caused by assembler now generates the GNU property notes section
-by default. Use the assmbler option -mx86-used-note=no to disable the
-section from being generated to workaround the ensuing linker issue.
-
-Signed-off-by: Michael Chang <mchang@suse.com>
----
+ea2db694508aa093207be77f2091706aa7b8e34c build: Fix build error with binutils 2.36
configure.ac | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/configure.ac b/configure.ac
-index fa8f74bb9..38ee5f579 100644
+index 63c333a2d..52c207909 100644
--- a/configure.ac
+++ b/configure.ac
@@ -836,6 +836,20 @@ if ( test "x$target_cpu" = xi386 || test "x$target_cpu" = xx86_64 ) && test "x$p
@@ -42,3 +27,6 @@ index fa8f74bb9..38ee5f579 100644
# GRUB doesn't use float or doubles at all. Yet some toolchains may decide
# that floats are a good fit to run instead of what's written in the code.
# Given that floating point unit is disabled (if present to begin with)
+--
+2.39.2
+
diff --git a/main/grub/0003-efi-implemented-LoadFile2-initrd-loading-protocol-fo.patch b/main/grub/0003-efi-implemented-LoadFile2-initrd-loading-protocol-fo.patch
deleted file mode 100644
index e399234732d..00000000000
--- a/main/grub/0003-efi-implemented-LoadFile2-initrd-loading-protocol-fo.patch
+++ /dev/null
@@ -1,187 +0,0 @@
-From 9e0f716b1536d3fe9c8860240c51d277531cfb92 Mon Sep 17 00:00:00 2001
-From: Ard Biesheuvel <ard.biesheuvel@arm.com>
-Date: Thu, 3 Jun 2021 00:12:31 +0300
-Subject: [PATCH 3/7] efi: implemented LoadFile2 initrd loading protocol for
- Linux
-
-Recent Linux kernels will invoke the LoadFile2 protocol installed on
-a well-known vendor media path to load the initrd if it is exposed by
-the firmware. Using this method is preferred for two reasons:
-- the Linux kernel is in charge of allocating the memory, and so it can
- implement any placement policy it wants (given that these tend to
- change between kernel versions),
-- it is no longer necessary to modify the device tree provided by the
- firmware.
-
-So let's install this protocol when handling the 'initrd' command if
-such a recent kernel was detected (based on the PE/COFF image version),
-and defer loading the initrd contents until the point where the kernel
-invokes the LoadFile2 protocol.
-
-Signed-off-by: Ard Biesheuvel <ard.biesheuvel@arm.com>
-Signed-off-by: Nikita Ermakov <arei@altlinux.org>
----
- grub-core/loader/arm64/linux.c | 117 ++++++++++++++++++++++++++++++++-
- 1 file changed, 116 insertions(+), 1 deletion(-)
-
-diff --git a/grub-core/loader/arm64/linux.c b/grub-core/loader/arm64/linux.c
-index aed7a200b..6b03455d1 100644
---- a/grub-core/loader/arm64/linux.c
-+++ b/grub-core/loader/arm64/linux.c
-@@ -48,9 +48,18 @@ static grub_uint32_t cmdline_size;
- static grub_addr_t initrd_start;
- static grub_addr_t initrd_end;
-
-+static struct grub_linux_initrd_context initrd_ctx = { 0, 0, 0 };
-+static grub_efi_handle_t initrd_lf2_handle;
-+static int initrd_use_loadfile2;
-+static grub_efi_guid_t load_file2_guid = GRUB_EFI_LOAD_FILE2_PROTOCOL_GUID;
-+static grub_efi_guid_t device_path_guid = GRUB_EFI_DEVICE_PATH_GUID;
-+
- grub_err_t
- grub_arch_efi_linux_check_image (struct linux_arch_kernel_header * lh)
- {
-+ struct grub_pe32_coff_header *coff_header;
-+ struct grub_pe32_optional_header *optional_header;
-+
- if (lh->magic != GRUB_LINUX_ARMXX_MAGIC_SIGNATURE)
- return grub_error(GRUB_ERR_BAD_OS, "invalid magic number");
-
-@@ -61,6 +70,21 @@ grub_arch_efi_linux_check_image (struct linux_arch_kernel_header * lh)
- grub_dprintf ("linux", "UEFI stub kernel:\n");
- grub_dprintf ("linux", "PE/COFF header @ %08x\n", lh->hdr_offset);
-
-+ coff_header = (struct grub_pe32_coff_header *)((unsigned long)lh + lh->hdr_offset);
-+ optional_header = (struct grub_pe32_optional_header *)(coff_header + 1);
-+
-+ /*
-+ * Linux kernels built for any architecture are guaranteed to support the
-+ * LoadFile2 based initrd loading protocol if the image version is >= 1.
-+ */
-+ if (optional_header->major_image_version >= 1)
-+ initrd_use_loadfile2 = 1;
-+ else
-+ initrd_use_loadfile2 = 0;
-+
-+ grub_dprintf ("linux", "LoadFile2 initrd loading %sabled\n",
-+ initrd_use_loadfile2 ? "en" : "dis");
-+
- return GRUB_ERR_NONE;
- }
-
-@@ -230,13 +254,86 @@ allocate_initrd_mem (int initrd_pages)
- GRUB_EFI_LOADER_DATA);
- }
-
-+struct initrd_media_device_path {
-+ grub_efi_vendor_media_device_path_t vendor;
-+ grub_efi_device_path_t end;
-+} GRUB_PACKED;
-+
-+#define LINUX_EFI_INITRD_MEDIA_GUID \
-+ { 0x5568e427, 0x68fc, 0x4f3d, \
-+ { 0xac, 0x74, 0xca, 0x55, 0x52, 0x31, 0xcc, 0x68 } \
-+ }
-+
-+static struct initrd_media_device_path initrd_lf2_device_path = {
-+ {
-+ {
-+ GRUB_EFI_MEDIA_DEVICE_PATH_TYPE,
-+ GRUB_EFI_VENDOR_MEDIA_DEVICE_PATH_SUBTYPE,
-+ sizeof(grub_efi_vendor_media_device_path_t),
-+ },
-+ LINUX_EFI_INITRD_MEDIA_GUID
-+ }, {
-+ GRUB_EFI_END_DEVICE_PATH_TYPE,
-+ GRUB_EFI_END_ENTIRE_DEVICE_PATH_SUBTYPE,
-+ sizeof(grub_efi_device_path_t)
-+ }
-+};
-+
-+static grub_efi_status_t
-+grub_efi_initrd_load_file2(grub_efi_load_file2_t *this,
-+ grub_efi_device_path_t *device_path,
-+ grub_efi_boolean_t boot_policy,
-+ grub_efi_uintn_t *buffer_size,
-+ void *buffer);
-+
-+static grub_efi_load_file2_t initrd_lf2 = {
-+ grub_efi_initrd_load_file2
-+};
-+
-+static grub_efi_status_t
-+grub_efi_initrd_load_file2(grub_efi_load_file2_t *this,
-+ grub_efi_device_path_t *device_path,
-+ grub_efi_boolean_t boot_policy,
-+ grub_efi_uintn_t *buffer_size,
-+ void *buffer)
-+{
-+ grub_efi_status_t status = GRUB_EFI_SUCCESS;
-+ grub_efi_uintn_t initrd_size;
-+
-+ if (!this || this != &initrd_lf2 || !buffer_size)
-+ return GRUB_EFI_INVALID_PARAMETER;
-+
-+ if (device_path->type != GRUB_EFI_END_DEVICE_PATH_TYPE ||
-+ device_path->subtype != GRUB_EFI_END_ENTIRE_DEVICE_PATH_SUBTYPE)
-+ return GRUB_EFI_NOT_FOUND;
-+
-+ if (boot_policy)
-+ return GRUB_EFI_UNSUPPORTED;
-+
-+ initrd_size = grub_get_initrd_size (&initrd_ctx);
-+ if (!buffer || *buffer_size < initrd_size)
-+ {
-+ *buffer_size = initrd_size;
-+ return GRUB_EFI_BUFFER_TOO_SMALL;
-+ }
-+
-+ grub_dprintf ("linux", "Providing initrd via LOAD_FILE2_PROTOCOL\n");
-+
-+ if (grub_initrd_load (&initrd_ctx, buffer))
-+ status = GRUB_EFI_LOAD_ERROR;
-+
-+ grub_initrd_close (&initrd_ctx);
-+ return status;
-+}
-+
- static grub_err_t
- grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)),
- int argc, char *argv[])
- {
-- struct grub_linux_initrd_context initrd_ctx = { 0, 0, 0 };
- int initrd_size, initrd_pages;
- void *initrd_mem = NULL;
-+ grub_efi_boot_services_t *b;
-+ grub_efi_status_t status;
-
- if (argc == 0)
- {
-@@ -254,6 +351,24 @@ grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)),
- if (grub_initrd_init (argc, argv, &initrd_ctx))
- goto fail;
-
-+ if (initrd_use_loadfile2 && !initrd_lf2_handle)
-+ {
-+ b = grub_efi_system_table->boot_services;
-+ status = b->install_multiple_protocol_interfaces (&initrd_lf2_handle,
-+ &load_file2_guid,
-+ &initrd_lf2,
-+ &device_path_guid,
-+ &initrd_lf2_device_path,
-+ NULL);
-+ if (status == GRUB_EFI_OUT_OF_RESOURCES)
-+ {
-+ grub_error (GRUB_ERR_OUT_OF_MEMORY, N_("out of memory"));
-+ return grub_errno;
-+ }
-+ grub_dprintf ("linux", "LoadFile2 initrd loading protocol installed\n");
-+ return GRUB_ERR_NONE;
-+ }
-+
- initrd_size = grub_get_initrd_size (&initrd_ctx);
- grub_dprintf ("linux", "Loading initrd\n");
-
---
-2.33.0
-
diff --git a/main/grub/0004-configure-Fix-misspelled-variable-BUILD_LDFAGS-BUILD.patch b/main/grub/0004-configure-Fix-misspelled-variable-BUILD_LDFAGS-BUILD.patch
new file mode 100644
index 00000000000..d35cff7a179
--- /dev/null
+++ b/main/grub/0004-configure-Fix-misspelled-variable-BUILD_LDFAGS-BUILD.patch
@@ -0,0 +1,20 @@
+f31e14d93e88e81da8c70f8750b4dba1b1d6f5cc configure: Fix misspelled variable BUILD_LDFAGS -> BUILD_LDFLAGS
+ configure.ac | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/configure.ac b/configure.ac
+index 52c207909..445be82ed 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -1645,7 +1645,7 @@ CC="$BUILD_CC"
+ CPP="$BUILD_CPP"
+ CFLAGS="$BUILD_CFLAGS"
+ CPPFLAGS="$BUILD_CPPFLAGS"
+-LDFLAGS="$BUILD_LDFAGS"
++LDFLAGS="$BUILD_LDFLAGS"
+
+ unset ac_cv_c_bigendian
+ unset ac_cv_header_ft2build_h
+--
+2.39.2
+
diff --git a/main/grub/0005-RISC-V-Adjust-march-flags-for-binutils-2.38.patch b/main/grub/0005-RISC-V-Adjust-march-flags-for-binutils-2.38.patch
new file mode 100644
index 00000000000..30e9b245fb3
--- /dev/null
+++ b/main/grub/0005-RISC-V-Adjust-march-flags-for-binutils-2.38.patch
@@ -0,0 +1,31 @@
+bc15b61fa5faa23575805706a9152cbab32f44ab RISC-V: Adjust -march flags for binutils 2.38
+ configure.ac | 8 ++++++++
+ 1 file changed, 8 insertions(+)
+
+diff --git a/configure.ac b/configure.ac
+index 445be82ed..9c5fa618d 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -866,11 +866,19 @@ if test x"$platform" != xemu ; then
+ CFLAGS="$TARGET_CFLAGS -march=rv32imac -mabi=ilp32 -Werror"
+ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
+ [grub_cv_target_cc_soft_float="-march=rv32imac -mabi=ilp32"], [])
++ # ISA spec version 20191213 factored out extensions Zicsr and Zifencei
++ CFLAGS="$TARGET_CFLAGS -march=rv32imac_zicsr_zifencei -mabi=ilp32 -Werror"
++ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
++ [grub_cv_target_cc_soft_float="-march=rv32imac_zicsr_zifencei -mabi=ilp32"], [])
+ fi
+ if test "x$target_cpu" = xriscv64; then
+ CFLAGS="$TARGET_CFLAGS -march=rv64imac -mabi=lp64 -Werror"
+ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
+ [grub_cv_target_cc_soft_float="-march=rv64imac -mabi=lp64"], [])
++ # ISA spec version 20191213 factored out extensions Zicsr and Zifencei
++ CFLAGS="$TARGET_CFLAGS -march=rv64imac_zicsr_zifencei -mabi=lp64 -Werror"
++ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
++ [grub_cv_target_cc_soft_float="-march=rv64imac_zicsr_zifencei -mabi=lp64"], [])
+ fi
+ if test "x$target_cpu" = xia64; then
+ CFLAGS="$TARGET_CFLAGS -mno-inline-float-divide -mno-inline-sqrt -Werror"
+--
+2.39.2
+
diff --git a/main/grub/0006-templates-Improve-initramfs-detection.patch b/main/grub/0006-templates-Improve-initramfs-detection.patch
new file mode 100644
index 00000000000..719672bad68
--- /dev/null
+++ b/main/grub/0006-templates-Improve-initramfs-detection.patch
@@ -0,0 +1,42 @@
+2a5464f1b63e94ea75039a65b19d5a4d369e932b templates: Improve initramfs detection
+ util/grub.d/10_linux.in | 6 ++++--
+ util/grub.d/20_linux_xen.in | 6 ++++--
+ 2 files changed, 8 insertions(+), 4 deletions(-)
+
+diff --git a/util/grub.d/10_linux.in b/util/grub.d/10_linux.in
+index e8b01c0d0..a694050df 100644
+--- a/util/grub.d/10_linux.in
++++ b/util/grub.d/10_linux.in
+@@ -211,8 +211,10 @@ while [ "x$list" != "x" ] ; do
+ done
+
+ initrd_real=
+- for i in "initrd.img-${version}" "initrd-${version}.img" "initrd-${version}.gz" \
+- "initrd-${version}" "initramfs-${version}.img" \
++ for i in "initrd.img-${version}" "initrd-${version}.img" \
++ "initrd-${alt_version}.img.old" "initrd-${version}.gz" \
++ "initrd-${alt_version}.gz.old" "initrd-${version}" \
++ "initramfs-${version}.img" "initramfs-${alt_version}.img.old" \
+ "initrd.img-${alt_version}" "initrd-${alt_version}.img" \
+ "initrd-${alt_version}" "initramfs-${alt_version}.img" \
+ "initramfs-genkernel-${version}" \
+diff --git a/util/grub.d/20_linux_xen.in b/util/grub.d/20_linux_xen.in
+index 3b1f47049..b6ea5bbd1 100644
+--- a/util/grub.d/20_linux_xen.in
++++ b/util/grub.d/20_linux_xen.in
+@@ -280,8 +280,10 @@ while [ "x${xen_list}" != "x" ] ; do
+ linux_root_device_thisversion="${LINUX_ROOT_DEVICE}"
+
+ initrd_real=
+- for i in "initrd.img-${version}" "initrd-${version}.img" "initrd-${version}.gz" \
+- "initrd-${version}" "initramfs-${version}.img" \
++ for i in "initrd.img-${version}" "initrd-${version}.img" \
++ "initrd-${alt_version}.img.old" "initrd-${version}.gz" \
++ "initrd-${alt_version}.gz.old" "initrd-${version}" \
++ "initramfs-${version}.img" "initramfs-${alt_version}.img.old" \
+ "initrd.img-${alt_version}" "initrd-${alt_version}.img" \
+ "initrd-${alt_version}" "initramfs-${alt_version}.img" \
+ "initramfs-genkernel-${version}" \
+--
+2.39.2
+
diff --git a/main/grub/0007-loader-arm64-linux-Remove-magic-number-header-field-.patch b/main/grub/0007-loader-arm64-linux-Remove-magic-number-header-field-.patch
new file mode 100644
index 00000000000..4c8916eea29
--- /dev/null
+++ b/main/grub/0007-loader-arm64-linux-Remove-magic-number-header-field-.patch
@@ -0,0 +1,21 @@
+6aa313e2c0c1f3602135e79442cfc9d192e88d1b loader/arm64/linux: Remove magic number header field check
+ grub-core/loader/arm64/linux.c | 3 ---
+ 1 file changed, 3 deletions(-)
+
+diff --git a/grub-core/loader/arm64/linux.c b/grub-core/loader/arm64/linux.c
+index ef3e9f944..4c92e48ac 100644
+--- a/grub-core/loader/arm64/linux.c
++++ b/grub-core/loader/arm64/linux.c
+@@ -51,9 +51,6 @@ static grub_addr_t initrd_end;
+ grub_err_t
+ grub_arch_efi_linux_check_image (struct linux_arch_kernel_header * lh)
+ {
+- if (lh->magic != GRUB_LINUX_ARMXX_MAGIC_SIGNATURE)
+- return grub_error(GRUB_ERR_BAD_OS, "invalid magic number");
+-
+ if ((lh->code0 & 0xffff) != GRUB_PE32_MAGIC)
+ return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET,
+ N_("plain image kernel not supported - rebuild with CONFIG_(U)EFI_STUB enabled"));
+--
+2.39.2
+
diff --git a/main/grub/0001-loader-drop-argv-argument-in-grub_initrd_load.patch b/main/grub/0008-loader-Drop-argv-argument-in-grub_initrd_load.patch
index 2d995092c27..37b93ea7335 100644
--- a/main/grub/0001-loader-drop-argv-argument-in-grub_initrd_load.patch
+++ b/main/grub/0008-loader-Drop-argv-argument-in-grub_initrd_load.patch
@@ -1,15 +1,4 @@
-From ba4a2d6979abbc42d22b64676e00652b7a88889d Mon Sep 17 00:00:00 2001
-From: Nikita Ermakov <arei@altlinux.org>
-Date: Thu, 3 Jun 2021 00:12:29 +0300
-Subject: [PATCH 1/7] loader: drop argv[] argument in grub_initrd_load()
-
-In the case of an error grub_initrd_load() uses argv[] to print the
-filename that caused the error. It is also possible to obtain the
-filename from the file handles and there is no need to duplicate that
-information in argv[], so let's drop it.
-
-Signed-off-by: Nikita Ermakov <arei@altlinux.org>
----
+91ff37f4e5efd2ae40f6d003178cc977f6bcc85a loader: Drop argv[] argument in grub_initrd_load()
grub-core/loader/arm/linux.c | 2 +-
grub-core/loader/arm64/linux.c | 2 +-
grub-core/loader/i386/linux.c | 2 +-
@@ -37,10 +26,10 @@ index ed23dc71e..1f7ab7578 100644
initrd_end = initrd_start + size;
diff --git a/grub-core/loader/arm64/linux.c b/grub-core/loader/arm64/linux.c
-index ef3e9f944..aed7a200b 100644
+index 4c92e48ac..b5b559c23 100644
--- a/grub-core/loader/arm64/linux.c
+++ b/grub-core/loader/arm64/linux.c
-@@ -266,7 +266,7 @@ grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)),
+@@ -263,7 +263,7 @@ grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)),
goto fail;
}
@@ -174,5 +163,5 @@ index 594a3f307..a96ac2048 100644
- char *argv[], void *target);
+ void *target);
--
-2.33.0
+2.39.2
diff --git a/main/grub/0009-efi-Move-MS-DOS-stub-out-of-generic-PE-header-defini.patch b/main/grub/0009-efi-Move-MS-DOS-stub-out-of-generic-PE-header-defini.patch
new file mode 100644
index 00000000000..7503da9f5db
--- /dev/null
+++ b/main/grub/0009-efi-Move-MS-DOS-stub-out-of-generic-PE-header-defini.patch
@@ -0,0 +1,69 @@
+2889fdad4a4af10dad6fc7ab90142a2a62a9aaa6 efi: Move MS-DOS stub out of generic PE header definition
+ grub-core/kern/efi/efi.c | 8 ++++++--
+ include/grub/efi/pe32.h | 16 ++++++++++++----
+ 2 files changed, 18 insertions(+), 6 deletions(-)
+
+diff --git a/grub-core/kern/efi/efi.c b/grub-core/kern/efi/efi.c
+index 8cff7be02..800373dc1 100644
+--- a/grub-core/kern/efi/efi.c
++++ b/grub-core/kern/efi/efi.c
+@@ -294,7 +294,8 @@ grub_addr_t
+ grub_efi_modules_addr (void)
+ {
+ grub_efi_loaded_image_t *image;
+- struct grub_pe32_header *header;
++ struct grub_msdos_image_header *header;
++ struct grub_pe_image_header *pe_image_header;
+ struct grub_pe32_coff_header *coff_header;
+ struct grub_pe32_section_table *sections;
+ struct grub_pe32_section_table *section;
+@@ -306,7 +307,10 @@ grub_efi_modules_addr (void)
+ return 0;
+
+ header = image->image_base;
+- coff_header = &(header->coff_header);
++ pe_image_header
++ = (struct grub_pe_image_header *) ((char *) header
++ + header->pe_image_header_offset);
++ coff_header = &(pe_image_header->coff_header);
+ sections
+ = (struct grub_pe32_section_table *) ((char *) coff_header
+ + sizeof (*coff_header)
+diff --git a/include/grub/efi/pe32.h b/include/grub/efi/pe32.h
+index 0ed8781f0..98c4ff177 100644
+--- a/include/grub/efi/pe32.h
++++ b/include/grub/efi/pe32.h
+@@ -48,6 +48,17 @@
+
+ #define GRUB_PE32_MAGIC 0x5a4d
+
++struct grub_msdos_image_header
++{
++ /* This is always 'MZ'. (GRUB_PE32_MAGIC) */
++ grub_uint16_t msdos_magic;
++
++ grub_uint16_t reserved[29];
++
++ /* The file offset of the PE image header. */
++ grub_uint32_t pe_image_header_offset;
++};
++
+ /* According to the spec, the minimal alignment is 512 bytes...
+ But some examples (such as EFI drivers in the Intel
+ Sample Implementation) use 32 bytes (0x20) instead, and it seems
+@@ -254,11 +265,8 @@ struct grub_pe32_section_table
+
+ #define GRUB_PE32_SIGNATURE_SIZE 4
+
+-struct grub_pe32_header
++struct grub_pe_image_header
+ {
+- /* This should be filled in with GRUB_PE32_MSDOS_STUB. */
+- grub_uint8_t msdos_stub[GRUB_PE32_MSDOS_STUB_SIZE];
+-
+ /* This is always PE\0\0. */
+ char signature[GRUB_PE32_SIGNATURE_SIZE];
+
+--
+2.39.2
+
diff --git a/main/grub/0009-fix-kernel-version-detection.patch b/main/grub/0009-fix-kernel-version-detection.patch
deleted file mode 100644
index f0141b8d01d..00000000000
--- a/main/grub/0009-fix-kernel-version-detection.patch
+++ /dev/null
@@ -1,64 +0,0 @@
-From: Dermot Bradley <dermot_bradley@yahoo.com>
-Date: Fri, 29 Oct 2021 18:51 +0100
-Subject: Fix grub-mkconfig detection of linux-edge-virt
-
-grub-mkconfig does not correctly handle the linux-edge-virt package
-when creating /boot/grub.grub.cfg. The 10_linux and 20_linux_xen
-files determine the "version" of the kernel using a regex pattern
-that does not correctly handle the presence of 2 "-" characters.
-
-As a result, when using the linux-edge-virt package grub-mkconfig
-incorrectly believes the version is "virt" rather than "edge-virt"
-and it searches for /boot/initramfs-edge which does not exist,
-resulting in no "initrd" line being placed in the grub.cfg to point
-to the initramfs.
-
-This issue does not appear with the linux-lts, linux-virt, linux-edge
-packages as their kernel and initramfs files only have a single "-"
-in their filenames.
-
-This is likely to be an Alpine-specific Grub issue as many/most other
-Linux distros include the actual kernel numeric version as part of
-the initramfs filenames (as, unlike Alpine they support multiple
-kernels being simultaneously installed and so need to distinguish
-between them).
-
-This fix simply changes the regex pattern to remove everything prior
-to, and including, the first "-" symbol, so leaving "lts", "edge",
-"edge-virt", or "virt" as appropriate.
-
----
-
-diff -aur a/util/grub.d/10_linux.in b/util/grub.d/10_linux.in
---- a/util/grub.d/10_linux.in
-+++ b/util/grub.d/10_linux.in
-@@ -201,7 +201,7 @@
- basename=`basename $linux`
- dirname=`dirname $linux`
- rel_dirname=`make_system_path_relative_to_its_root $dirname`
-- version=`echo $basename | sed -e "s,^[^0-9]*-,,g"`
-+ version=`echo $basename | sed -e "s,^[^-]*-,,g"`
- alt_version=`echo $version | sed -e "s,\.old$,,g"`
- linux_root_device_thisversion="${LINUX_ROOT_DEVICE}"
-
-diff -aur a/util/grub.d/20_linux_xen.in b/util/grub.d/20_linux_xen.in
---- a/util/grub.d/20_linux_xen.in
-+++ b/util/grub.d/20_linux_xen.in
-@@ -181,7 +181,7 @@
- for i in /boot/vmlinu[xz]-* /vmlinu[xz]-* /boot/kernel-*; do
- if grub_file_is_not_garbage "$i"; then
- basename=$(basename $i)
-- version=$(echo $basename | sed -e "s,^[^0-9]*-,,g")
-+ version=$(echo $basename | sed -e "s,^[^-]*-,,g")
- dirname=$(dirname $i)
- config=
- for j in "${dirname}/config-${version}" "${dirname}/config-${alt_version}" "/etc/kernels/kernel-config-${version}" ; do
-@@ -275,7 +275,7 @@
- basename=`basename $linux`
- dirname=`dirname $linux`
- rel_dirname=`make_system_path_relative_to_its_root $dirname`
-- version=`echo $basename | sed -e "s,^[^0-9]*-,,g"`
-+ version=`echo $basename | sed -e "s,^[^-]*-,,g"`
- alt_version=`echo $version | sed -e "s,\.old$,,g"`
- linux_root_device_thisversion="${LINUX_ROOT_DEVICE}"
-
diff --git a/main/grub/0010-arm-linux-Unify-ARM-arm64-vs-Xen-PE-COFF-header-hand.patch b/main/grub/0010-arm-linux-Unify-ARM-arm64-vs-Xen-PE-COFF-header-hand.patch
new file mode 100644
index 00000000000..5e669dc692b
--- /dev/null
+++ b/main/grub/0010-arm-linux-Unify-ARM-arm64-vs-Xen-PE-COFF-header-hand.patch
@@ -0,0 +1,162 @@
+5ec12d63114de94c04cf842704636c905a72aca5 arm/linux: Unify ARM/arm64 vs Xen PE/COFF header handling
+ grub-core/loader/arm64/linux.c | 12 +++++++-----
+ grub-core/loader/arm64/xen_boot.c | 23 ++++-------------------
+ include/grub/arm/linux.h | 5 +++++
+ include/grub/arm64/linux.h | 2 ++
+ include/grub/efi/efi.h | 4 +++-
+ 5 files changed, 21 insertions(+), 25 deletions(-)
+
+diff --git a/grub-core/loader/arm64/linux.c b/grub-core/loader/arm64/linux.c
+index b5b559c23..3733a69d6 100644
+--- a/grub-core/loader/arm64/linux.c
++++ b/grub-core/loader/arm64/linux.c
+@@ -49,8 +49,13 @@ static grub_addr_t initrd_start;
+ static grub_addr_t initrd_end;
+
+ grub_err_t
+-grub_arch_efi_linux_check_image (struct linux_arch_kernel_header * lh)
++grub_arch_efi_linux_load_image_header (grub_file_t file,
++ struct linux_arch_kernel_header * lh)
+ {
++ grub_file_seek (file, 0);
++ if (grub_file_read (file, lh, sizeof (*lh)) < (grub_ssize_t) sizeof (*lh))
++ return grub_error(GRUB_ERR_FILE_READ_ERROR, "failed to read Linux image header");
++
+ if ((lh->code0 & 0xffff) != GRUB_PE32_MAGIC)
+ return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET,
+ N_("plain image kernel not supported - rebuild with CONFIG_(U)EFI_STUB enabled"));
+@@ -301,10 +306,7 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)),
+
+ kernel_size = grub_file_size (file);
+
+- if (grub_file_read (file, &lh, sizeof (lh)) < (long) sizeof (lh))
+- return grub_errno;
+-
+- if (grub_arch_efi_linux_check_image (&lh) != GRUB_ERR_NONE)
++ if (grub_arch_efi_linux_load_image_header (file, &lh) != GRUB_ERR_NONE)
+ goto fail;
+
+ grub_loader_unset();
+diff --git a/grub-core/loader/arm64/xen_boot.c b/grub-core/loader/arm64/xen_boot.c
+index 22cc25ecc..763d87dcd 100644
+--- a/grub-core/loader/arm64/xen_boot.c
++++ b/grub-core/loader/arm64/xen_boot.c
+@@ -31,7 +31,6 @@
+ #include <grub/efi/efi.h>
+ #include <grub/efi/fdtload.h>
+ #include <grub/efi/memory.h>
+-#include <grub/efi/pe32.h> /* required by struct xen_hypervisor_header */
+ #include <grub/i18n.h>
+ #include <grub/lib/cmdline.h>
+
+@@ -65,18 +64,6 @@ enum module_type
+ };
+ typedef enum module_type module_type_t;
+
+-struct xen_hypervisor_header
+-{
+- struct linux_arm64_kernel_header efi_head;
+-
+- /* This is always PE\0\0. */
+- grub_uint8_t signature[GRUB_PE32_SIGNATURE_SIZE];
+- /* The COFF file header. */
+- struct grub_pe32_coff_header coff_header;
+- /* The Optional header. */
+- struct grub_pe64_optional_header optional_header;
+-};
+-
+ struct xen_boot_binary
+ {
+ struct xen_boot_binary *next;
+@@ -452,7 +439,7 @@ static grub_err_t
+ grub_cmd_xen_hypervisor (grub_command_t cmd __attribute__ ((unused)),
+ int argc, char *argv[])
+ {
+- struct xen_hypervisor_header sh;
++ struct linux_arm64_kernel_header lh;
+ grub_file_t file = NULL;
+
+ grub_dl_ref (my_mod);
+@@ -467,10 +454,7 @@ grub_cmd_xen_hypervisor (grub_command_t cmd __attribute__ ((unused)),
+ if (!file)
+ goto fail;
+
+- if (grub_file_read (file, &sh, sizeof (sh)) != (long) sizeof (sh))
+- goto fail;
+- if (grub_arch_efi_linux_check_image
+- ((struct linux_arch_kernel_header *) &sh) != GRUB_ERR_NONE)
++ if (grub_arch_efi_linux_load_image_header (file, &lh) != GRUB_ERR_NONE)
+ goto fail;
+ grub_file_seek (file, 0);
+
+@@ -484,7 +468,8 @@ grub_cmd_xen_hypervisor (grub_command_t cmd __attribute__ ((unused)),
+ return grub_errno;
+
+ xen_hypervisor->is_hypervisor = 1;
+- xen_hypervisor->align = (grub_size_t) sh.optional_header.section_alignment;
++ xen_hypervisor->align
++ = (grub_size_t) lh.pe_image_header.optional_header.section_alignment;
+
+ xen_boot_binary_load (xen_hypervisor, file, argc, argv);
+ if (grub_errno == GRUB_ERR_NONE)
+diff --git a/include/grub/arm/linux.h b/include/grub/arm/linux.h
+index bcd5a7eb1..f38e695b1 100644
+--- a/include/grub/arm/linux.h
++++ b/include/grub/arm/linux.h
+@@ -22,6 +22,8 @@
+
+ #include "system.h"
+
++#include <grub/efi/pe32.h>
++
+ #define GRUB_LINUX_ARM_MAGIC_SIGNATURE 0x016f2818
+
+ struct linux_arm_kernel_header {
+@@ -32,6 +34,9 @@ struct linux_arm_kernel_header {
+ grub_uint32_t end; /* _edata */
+ grub_uint32_t reserved2[3];
+ grub_uint32_t hdr_offset;
++#if defined GRUB_MACHINE_EFI
++ struct grub_pe_image_header pe_image_header;
++#endif
+ };
+
+ #if defined(__arm__)
+diff --git a/include/grub/arm64/linux.h b/include/grub/arm64/linux.h
+index 7e22b4ab6..3da71a512 100644
+--- a/include/grub/arm64/linux.h
++++ b/include/grub/arm64/linux.h
+@@ -20,6 +20,7 @@
+ #define GRUB_ARM64_LINUX_HEADER 1
+
+ #include <grub/types.h>
++#include <grub/efi/pe32.h>
+
+ #define GRUB_LINUX_ARM64_MAGIC_SIGNATURE 0x644d5241 /* 'ARM\x64' */
+
+@@ -36,6 +37,7 @@ struct linux_arm64_kernel_header
+ grub_uint64_t res4; /* reserved */
+ grub_uint32_t magic; /* Magic number, little endian, "ARM\x64" */
+ grub_uint32_t hdr_offset; /* Offset of PE/COFF header */
++ struct grub_pe_image_header pe_image_header;
+ };
+
+ #if defined(__aarch64__)
+diff --git a/include/grub/efi/efi.h b/include/grub/efi/efi.h
+index 83d958f99..36b90eded 100644
+--- a/include/grub/efi/efi.h
++++ b/include/grub/efi/efi.h
+@@ -100,7 +100,9 @@ extern void (*EXPORT_VAR(grub_efi_net_config)) (grub_efi_handle_t hnd,
+ void *EXPORT_FUNC(grub_efi_get_firmware_fdt)(void);
+ grub_err_t EXPORT_FUNC(grub_efi_get_ram_base)(grub_addr_t *);
+ #include <grub/cpu/linux.h>
+-grub_err_t grub_arch_efi_linux_check_image(struct linux_arch_kernel_header *lh);
++#include <grub/file.h>
++grub_err_t grub_arch_efi_linux_load_image_header(grub_file_t file,
++ struct linux_arch_kernel_header *lh);
+ grub_err_t grub_arch_efi_linux_boot_image(grub_addr_t addr, grub_size_t size,
+ char *args);
+ #endif
+--
+2.39.2
+
diff --git a/main/grub/0010-riscv-binutils-2.38.patch b/main/grub/0010-riscv-binutils-2.38.patch
deleted file mode 100644
index ab9bff99223..00000000000
--- a/main/grub/0010-riscv-binutils-2.38.patch
+++ /dev/null
@@ -1,39 +0,0 @@
-Patch-Source: https://lists.gnu.org/archive/html/grub-devel/2022-01/msg00173.html
-As of version 2.38 binutils defaults to ISA specification version
-2019-12-13. This version of the specification has has separated the
-the csr read/write (csrr*/csrw*) instructions and the fence.i from
-the I extension and put them into separate Zicsr and Zifencei
-extensions.
-
-This implies that we have to adjust the -march flag passed to the
-compiler accordingly.
-
-Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
----
- configure.ac | 8 ++++++++
- 1 file changed, 8 insertions(+)
-
- diff --git a/configure.ac b/configure.ac
- index 7517fc49d..7b094a63d 100644
---- a/configure.ac
-+++ b/configure.ac
-@@ -852,11 +866,19 @@
- CFLAGS="$TARGET_CFLAGS -march=rv32imac -mabi=ilp32 -Werror"
- AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
- [grub_cv_target_cc_soft_float="-march=rv32imac -mabi=ilp32"], [])
-+ # ISA spec version 20191213 factored out extensions Zicsr and Zifencei
-+ CFLAGS="$TARGET_CFLAGS -march=rv32imac_zicsr_zifencei -mabi=ilp32 -Werror"
-+ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
-+ [grub_cv_target_cc_soft_float="-march=rv64imac_zicsr_zifencei -mabi=lp64"], [])
- fi
- if test "x$target_cpu" = xriscv64; then
- CFLAGS="$TARGET_CFLAGS -march=rv64imac -mabi=lp64 -Werror"
- AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
- [grub_cv_target_cc_soft_float="-march=rv64imac -mabi=lp64"], [])
-+ # ISA spec version 20191213 factored out extensions Zicsr and Zifencei
-+ CFLAGS="$TARGET_CFLAGS -march=rv64imac_zicsr_zifencei -mabi=lp64 -Werror"
-+ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
-+ [grub_cv_target_cc_soft_float="-march=rv64imac_zicsr_zifencei -mabi=lp64"], [])
- fi
- if test "x$target_cpu" = xia64; then
- CFLAGS="$TARGET_CFLAGS -mno-inline-float-divide -mno-inline-sqrt -Werror"
diff --git a/main/grub/0011-loader-arm64-linux-Account-for-COFF-headers-appearin.patch b/main/grub/0011-loader-arm64-linux-Account-for-COFF-headers-appearin.patch
new file mode 100644
index 00000000000..f5b00442e1a
--- /dev/null
+++ b/main/grub/0011-loader-arm64-linux-Account-for-COFF-headers-appearin.patch
@@ -0,0 +1,33 @@
+74c3163f350beb9ff31e8da665bf96bcc6e4838f loader/arm64/linux: Account for COFF headers appearing at unexpected offsets
+ grub-core/loader/arm64/linux.c | 15 +++++++++++++++
+ 1 file changed, 15 insertions(+)
+
+diff --git a/grub-core/loader/arm64/linux.c b/grub-core/loader/arm64/linux.c
+index 3733a69d6..754db84a9 100644
+--- a/grub-core/loader/arm64/linux.c
++++ b/grub-core/loader/arm64/linux.c
+@@ -63,6 +63,21 @@ grub_arch_efi_linux_load_image_header (grub_file_t file,
+ grub_dprintf ("linux", "UEFI stub kernel:\n");
+ grub_dprintf ("linux", "PE/COFF header @ %08x\n", lh->hdr_offset);
+
++ /*
++ * The PE/COFF spec permits the COFF header to appear anywhere in the file, so
++ * we need to double check whether it was where we expected it, and if not, we
++ * must load it from the correct offset into the pe_image_header field of
++ * struct linux_arch_kernel_header.
++ */
++ if ((grub_uint8_t *) lh + lh->hdr_offset != (grub_uint8_t *) &lh->pe_image_header)
++ {
++ if (grub_file_seek (file, lh->hdr_offset) == (grub_off_t) -1
++ || grub_file_read (file, &lh->pe_image_header,
++ sizeof (struct grub_pe_image_header))
++ != sizeof (struct grub_pe_image_header))
++ return grub_error (GRUB_ERR_FILE_READ_ERROR, "failed to read COFF image header");
++ }
++
+ return GRUB_ERR_NONE;
+ }
+
+--
+2.39.2
+
diff --git a/main/grub/0011-mkconfig-ignore-apk-new-files.patch b/main/grub/0011-mkconfig-ignore-apk-new-files.patch
deleted file mode 100644
index 2d05783147a..00000000000
--- a/main/grub/0011-mkconfig-ignore-apk-new-files.patch
+++ /dev/null
@@ -1,30 +0,0 @@
-From: Dermot Bradley <dermot_bradley@yahoo.com>
-Date: Wed, 8 Jun 2022 18:28:13 +0100
-Subject: ensure grub-mkconfig ignores *.apk-new files
-
-If one of the Grub template files in /etc/grub.d/ is locally modified
-then whenever an updated version of the Alpine Grub package is next
-installed apk will place a stock version of the modified file in the
-same directory with a .apk-new suffix. Whenever grub-mkconfig is next
-triggered to regenerate grub.cfg it will use both the locally modified
-file and the stock file which will result in duplicate Grub menu
-entries.
-
-Modify grub-mkconfig to ignore *.apk-new files.
-
----
-
-diff -aur a/util/grub-mkconfig.in b/util/grub-mkconfig.in
---- a/util/grub-mkconfig.in
-+++ b/util/grub-mkconfig.in
-@@ -278,6 +278,10 @@
- *~) ;;
- # emacsen autosave files. FIXME: support other editors
- */\#*\#) ;;
-+ # Copy of a template file from Alpine Grub package where the stock file
-+ # was locally modified. Any such *.apk-new files should be ignored by
-+ # grub-mkconfig.
-+ *.apk-new) ;;
- *)
- if grub_file_is_not_garbage "$i" && test -x "$i" ; then
- echo
diff --git a/main/grub/0012-arm64-efi-linux-Implement-LoadFile2-initrd-loading-p.patch b/main/grub/0012-arm64-efi-linux-Implement-LoadFile2-initrd-loading-p.patch
new file mode 100644
index 00000000000..acdaeb08fb8
--- /dev/null
+++ b/main/grub/0012-arm64-efi-linux-Implement-LoadFile2-initrd-loading-p.patch
@@ -0,0 +1,276 @@
+3be3d862ebd34946979bcada4997b1cbbf66f3bb arm64/efi/linux: Implement LoadFile2 initrd loading protocol for Linux
+ grub-core/commands/efi/lsefi.c | 1 +
+ grub-core/loader/arm64/linux.c | 124 ++++++++++++++++++++++++++++++++-
+ include/grub/efi/api.h | 40 +++++++++++
+ 3 files changed, 164 insertions(+), 1 deletion(-)
+
+diff --git a/grub-core/commands/efi/lsefi.c b/grub-core/commands/efi/lsefi.c
+index d1ce99af4..4085f5df2 100644
+--- a/grub-core/commands/efi/lsefi.c
++++ b/grub-core/commands/efi/lsefi.c
+@@ -55,6 +55,7 @@ struct known_protocol
+ { GRUB_EFI_ABSOLUTE_POINTER_PROTOCOL_GUID, "absolute pointer" },
+ { GRUB_EFI_DRIVER_BINDING_PROTOCOL_GUID, "EFI driver binding" },
+ { GRUB_EFI_LOAD_FILE_PROTOCOL_GUID, "load file" },
++ { GRUB_EFI_LOAD_FILE2_PROTOCOL_GUID, "load file2" },
+ { GRUB_EFI_SIMPLE_FILE_SYSTEM_PROTOCOL_GUID, "simple FS" },
+ { GRUB_EFI_TAPE_IO_PROTOCOL_GUID, "tape I/O" },
+ { GRUB_EFI_UNICODE_COLLATION_PROTOCOL_GUID, "unicode collation" },
+diff --git a/grub-core/loader/arm64/linux.c b/grub-core/loader/arm64/linux.c
+index 754db84a9..9a4522d2f 100644
+--- a/grub-core/loader/arm64/linux.c
++++ b/grub-core/loader/arm64/linux.c
+@@ -33,6 +33,7 @@
+ #include <grub/i18n.h>
+ #include <grub/lib/cmdline.h>
+ #include <grub/verify.h>
++#include <stdbool.h>
+
+ GRUB_MOD_LICENSE ("GPLv3+");
+
+@@ -48,6 +49,39 @@ static grub_uint32_t cmdline_size;
+ static grub_addr_t initrd_start;
+ static grub_addr_t initrd_end;
+
++static struct grub_linux_initrd_context initrd_ctx = {0, 0, 0};
++static grub_efi_handle_t initrd_lf2_handle = NULL;
++static bool initrd_use_loadfile2 = false;
++
++static grub_efi_guid_t load_file2_guid = GRUB_EFI_LOAD_FILE2_PROTOCOL_GUID;
++static grub_efi_guid_t device_path_guid = GRUB_EFI_DEVICE_PATH_GUID;
++
++static initrd_media_device_path_t initrd_lf2_device_path = {
++ {
++ {
++ GRUB_EFI_MEDIA_DEVICE_PATH_TYPE,
++ GRUB_EFI_VENDOR_MEDIA_DEVICE_PATH_SUBTYPE,
++ sizeof(grub_efi_vendor_media_device_path_t),
++ },
++ LINUX_EFI_INITRD_MEDIA_GUID
++ }, {
++ GRUB_EFI_END_DEVICE_PATH_TYPE,
++ GRUB_EFI_END_ENTIRE_DEVICE_PATH_SUBTYPE,
++ sizeof(grub_efi_device_path_t)
++ }
++};
++
++static grub_efi_status_t __grub_efi_api
++grub_efi_initrd_load_file2 (grub_efi_load_file2_t *this,
++ grub_efi_device_path_t *device_path,
++ grub_efi_boolean_t boot_policy,
++ grub_efi_uintn_t *buffer_size,
++ void *buffer);
++
++static grub_efi_load_file2_t initrd_lf2 = {
++ grub_efi_initrd_load_file2
++};
++
+ grub_err_t
+ grub_arch_efi_linux_load_image_header (grub_file_t file,
+ struct linux_arch_kernel_header * lh)
+@@ -78,6 +112,18 @@ grub_arch_efi_linux_load_image_header (grub_file_t file,
+ return grub_error (GRUB_ERR_FILE_READ_ERROR, "failed to read COFF image header");
+ }
+
++ /*
++ * Linux kernels built for any architecture are guaranteed to support the
++ * LoadFile2 based initrd loading protocol if the image version is >= 1.
++ */
++ if (lh->pe_image_header.optional_header.major_image_version >= 1)
++ initrd_use_loadfile2 = true;
++ else
++ initrd_use_loadfile2 = false;
++
++ grub_dprintf ("linux", "LoadFile2 initrd loading %sabled\n",
++ initrd_use_loadfile2 ? "en" : "dis");
++
+ return GRUB_ERR_NONE;
+ }
+
+@@ -197,6 +243,8 @@ grub_linux_boot (void)
+ static grub_err_t
+ grub_linux_unload (void)
+ {
++ grub_efi_boot_services_t *b = grub_efi_system_table->boot_services;
++
+ grub_dl_unref (my_mod);
+ loaded = 0;
+ if (initrd_start)
+@@ -208,6 +256,18 @@ grub_linux_unload (void)
+ grub_efi_free_pages ((grub_addr_t) kernel_addr,
+ GRUB_EFI_BYTES_TO_PAGES (kernel_size));
+ grub_fdt_unload ();
++
++ if (initrd_lf2_handle != NULL)
++ {
++ b->uninstall_multiple_protocol_interfaces (initrd_lf2_handle,
++ &load_file2_guid,
++ &initrd_lf2,
++ &device_path_guid,
++ &initrd_lf2_device_path,
++ NULL);
++ initrd_lf2_handle = NULL;
++ initrd_use_loadfile2 = false;
++ }
+ return GRUB_ERR_NONE;
+ }
+
+@@ -247,13 +307,50 @@ allocate_initrd_mem (int initrd_pages)
+ GRUB_EFI_LOADER_DATA);
+ }
+
++static grub_efi_status_t __grub_efi_api
++grub_efi_initrd_load_file2 (grub_efi_load_file2_t *this,
++ grub_efi_device_path_t *device_path,
++ grub_efi_boolean_t boot_policy,
++ grub_efi_uintn_t *buffer_size,
++ void *buffer)
++{
++ grub_efi_status_t status = GRUB_EFI_SUCCESS;
++ grub_efi_uintn_t initrd_size;
++
++ if (this != &initrd_lf2 || buffer_size == NULL)
++ return GRUB_EFI_INVALID_PARAMETER;
++
++ if (device_path->type != GRUB_EFI_END_DEVICE_PATH_TYPE ||
++ device_path->subtype != GRUB_EFI_END_ENTIRE_DEVICE_PATH_SUBTYPE)
++ return GRUB_EFI_NOT_FOUND;
++
++ if (boot_policy)
++ return GRUB_EFI_UNSUPPORTED;
++
++ initrd_size = grub_get_initrd_size (&initrd_ctx);
++ if (buffer == NULL || *buffer_size < initrd_size)
++ {
++ *buffer_size = initrd_size;
++ return GRUB_EFI_BUFFER_TOO_SMALL;
++ }
++
++ grub_dprintf ("linux", "Providing initrd via EFI_LOAD_FILE2_PROTOCOL\n");
++
++ if (grub_initrd_load (&initrd_ctx, buffer))
++ status = GRUB_EFI_DEVICE_ERROR;
++
++ grub_initrd_close (&initrd_ctx);
++ return status;
++}
++
+ static grub_err_t
+ grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)),
+ int argc, char *argv[])
+ {
+- struct grub_linux_initrd_context initrd_ctx = { 0, 0, 0 };
+ int initrd_size, initrd_pages;
+ void *initrd_mem = NULL;
++ grub_efi_boot_services_t *b = grub_efi_system_table->boot_services;
++ grub_efi_status_t status;
+
+ if (argc == 0)
+ {
+@@ -271,6 +368,31 @@ grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)),
+ if (grub_initrd_init (argc, argv, &initrd_ctx))
+ goto fail;
+
++ if (initrd_use_loadfile2)
++ {
++ if (initrd_lf2_handle == NULL)
++ {
++ status = b->install_multiple_protocol_interfaces (&initrd_lf2_handle,
++ &load_file2_guid,
++ &initrd_lf2,
++ &device_path_guid,
++ &initrd_lf2_device_path,
++ NULL);
++ if (status == GRUB_EFI_OUT_OF_RESOURCES)
++ {
++ grub_error (GRUB_ERR_OUT_OF_MEMORY, N_("out of memory"));
++ goto fail;
++ }
++ else if (status != GRUB_EFI_SUCCESS)
++ {
++ grub_error (GRUB_ERR_BAD_ARGUMENT, N_("failed to install protocols"));
++ goto fail;
++ }
++ }
++ grub_dprintf ("linux", "Using LoadFile2 initrd loading protocol\n");
++ return GRUB_ERR_NONE;
++ }
++
+ initrd_size = grub_get_initrd_size (&initrd_ctx);
+ grub_dprintf ("linux", "Loading initrd\n");
+
+diff --git a/include/grub/efi/api.h b/include/grub/efi/api.h
+index f1a52210c..776541149 100644
+--- a/include/grub/efi/api.h
++++ b/include/grub/efi/api.h
+@@ -149,6 +149,11 @@
+ { 0x8E, 0x3F, 0x00, 0xA0, 0xC9, 0x69, 0x72, 0x3B } \
+ }
+
++#define GRUB_EFI_LOAD_FILE2_PROTOCOL_GUID \
++ { 0x4006c0c1, 0xfcb3, 0x403e, \
++ { 0x99, 0x6d, 0x4a, 0x6c, 0x87, 0x24, 0xe0, 0x6d } \
++ }
++
+ #define GRUB_EFI_SIMPLE_FILE_SYSTEM_PROTOCOL_GUID \
+ { 0x0964e5b22, 0x6459, 0x11d2, \
+ { 0x8e, 0x39, 0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b } \
+@@ -354,6 +359,11 @@
+ { 0x86, 0x2e, 0xc0, 0x1c, 0xdc, 0x29, 0x1f, 0x44 } \
+ }
+
++#define LINUX_EFI_INITRD_MEDIA_GUID \
++ { 0x5568e427, 0x68fc, 0x4f3d, \
++ { 0xac, 0x74, 0xca, 0x55, 0x52, 0x31, 0xcc, 0x68 } \
++ }
++
+ struct grub_efi_sal_system_table
+ {
+ grub_uint32_t signature;
+@@ -548,6 +558,20 @@ typedef grub_uint16_t grub_efi_char16_t;
+
+ typedef grub_efi_uintn_t grub_efi_status_t;
+
++/*
++ * On x86, the EFI calling convention may deviate from the local one, so
++ * callback functions exposed to the firmware must carry the follow attribute
++ * annotation. (This includes protocols implemented by GRUB that are installed
++ * into the EFI protocol database.)
++ */
++#if defined(__i386__)
++#define __grub_efi_api __attribute__((regparm(0)))
++#elif defined(__x86_64__)
++#define __grub_efi_api __attribute__((ms_abi))
++#else
++#define __grub_efi_api
++#endif
++
+ #define GRUB_EFI_ERROR_CODE(value) \
+ ((((grub_efi_status_t) 1) << (sizeof (grub_efi_status_t) * 8 - 1)) | (value))
+
+@@ -1729,6 +1753,22 @@ struct grub_efi_rng_protocol
+ };
+ typedef struct grub_efi_rng_protocol grub_efi_rng_protocol_t;
+
++struct grub_efi_load_file2
++{
++ grub_efi_status_t (__grub_efi_api *load_file)(struct grub_efi_load_file2 *this,
++ grub_efi_device_path_t *file_path,
++ grub_efi_boolean_t boot_policy,
++ grub_efi_uintn_t *buffer_size,
++ void *buffer);
++};
++typedef struct grub_efi_load_file2 grub_efi_load_file2_t;
++
++struct initrd_media_device_path {
++ grub_efi_vendor_media_device_path_t vendor;
++ grub_efi_device_path_t end;
++} GRUB_PACKED;
++typedef struct initrd_media_device_path initrd_media_device_path_t;
++
+ #if (GRUB_TARGET_SIZEOF_VOID_P == 4) || defined (__ia64__) \
+ || defined (__aarch64__) || defined (__MINGW64__) || defined (__CYGWIN__) \
+ || defined(__riscv)
+--
+2.39.2
+
diff --git a/main/grub/0012-remove-udevadm-usage.patch b/main/grub/0012-remove-udevadm-usage.patch
deleted file mode 100644
index b4f8cf25608..00000000000
--- a/main/grub/0012-remove-udevadm-usage.patch
+++ /dev/null
@@ -1,137 +0,0 @@
-From: Dermot Bradley <dermot_bradley@yahoo.com>
-Date: Wed, 8 Jun 2022 18:28:13 +0100
-Subject: [PATCH] remove use of udevadm
-
-These changes in this patch are copied from upstream's master repo
-based on commit 1ea4e5ef09c06552402bf676ce262a661372f08d.
-
-Replace the use of eudev's udevadm by grub-install/grub-probe with
-the use of the /sys/dev/block/ directory hierarchy instead. This
-patch enables grub-install (via grub-probe) to install onto a
-partitioned loop device inside a chroot.
-
-Currently when grub-probe runs to detect the device containing the
-boot filesystem it uses udevadm, if available, to do so and if not
-available it falls back to its own logic which cannot handle a
-partitioned loop device inside a chroot.
-
-Without this patch the only current workaround for a Alpine system
-using mdev in such a scenario is to temporarily install eudev (for
-the udevadm binary) prior to running grub-install and then to
-uninstall eudev afterwards.
-
-Based on upstream's timescale for releases it is likely that the next
-Grub release will be some time away in the future and so it would be
-useful to backport this change to Alpine.
-
----
-
-diff -Naur a/grub-core/osdep/linux/hostdisk.c b/grub-core/osdep/linux/hostdisk.c
---- a/grub-core/osdep/linux/hostdisk.c
-+++ b/grub-core/osdep/linux/hostdisk.c
-@@ -31,6 +31,7 @@
- #include <grub/misc.h>
- #include <grub/i18n.h>
- #include <grub/list.h>
-+#include <grub/osdep/major.h>
-
- #include <stdio.h>
- #include <stdlib.h>
-@@ -98,54 +99,13 @@
- static char *
- sysfs_partition_path (const char *dev, const char *entry)
- {
-- const char *argv[7];
-- int fd;
-- pid_t pid;
-- FILE *udevadm;
-- char *buf = NULL;
-- size_t len = 0;
-- char *path = NULL;
--
-- argv[0] = "udevadm";
-- argv[1] = "info";
-- argv[2] = "--query";
-- argv[3] = "path";
-- argv[4] = "--name";
-- argv[5] = dev;
-- argv[6] = NULL;
--
-- pid = grub_util_exec_pipe (argv, &fd);
--
-- if (!pid)
-- return NULL;
--
-- /* Parent. Read udevadm's output. */
-- udevadm = fdopen (fd, "r");
-- if (!udevadm)
-- {
-- grub_util_warn (_("Unable to open stream from %s: %s"),
-- "udevadm", strerror (errno));
-- close (fd);
-- goto out;
-- }
--
-- if (getline (&buf, &len, udevadm) > 0)
-- {
-- char *newline;
--
-- newline = strchr (buf, '\n');
-- if (newline)
-- *newline = '\0';
-- path = xasprintf ("/sys%s/%s", buf, entry);
-- }
--
--out:
-- if (udevadm)
-- fclose (udevadm);
-- waitpid (pid, NULL, 0);
-- free (buf);
-+ struct stat st;
-
-- return path;
-+ if (stat (dev, &st) == 0 && S_ISBLK (st.st_mode))
-+ return xasprintf ("/sys/dev/block/%u:%u/%s",
-+ major (st.st_rdev), minor (st.st_rdev), entry);
-+
-+ return NULL;
- }
-
- static int
-diff -Naur a/include/grub/osdep/major.h b/include/grub/osdep/major.h
---- a/include/grub/osdep/major.h
-+++ b/include/grub/osdep/major.h
-@@ -0,0 +1,33 @@
-+/*
-+ * GRUB -- GRand Unified Bootloader
-+ * Copyright (C) 2021 Free Software Foundation, Inc.
-+ *
-+ * GRUB is free software: you can redistribute it and/or modify
-+ * it under the terms of the GNU General Public License as published by
-+ * the Free Software Foundation, either version 3 of the License, or
-+ * (at your option) any later version.
-+ *
-+ * GRUB is distributed in the hope that it will be useful,
-+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
-+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-+ * GNU General Public License for more details.
-+ *
-+ * You should have received a copy of the GNU General Public License
-+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
-+ *
-+ * Fix for glibc 2.25 which is deprecating the namespace pollution of
-+ * sys/types.h injecting major(), minor(), and makedev() into the
-+ * compilation environment.
-+ */
-+
-+#ifndef GRUB_OSDEP_MAJOR_H
-+#define GRUB_OSDEP_MAJOR_H 1
-+
-+#include <sys/types.h>
-+
-+#ifdef MAJOR_IN_MKDEV
-+# include <sys/mkdev.h>
-+#elif defined (MAJOR_IN_SYSMACROS)
-+# include <sys/sysmacros.h>
-+#endif
-+#endif /* GRUB_OSDEP_MAJOR_H */
diff --git a/main/grub/0004-linux-ignore-FDT-unless-we-need-to-modify-it.patch b/main/grub/0013-arm64-efi-linux-Ignore-FDT-unless-we-need-to-modify-.patch
index 7d014ebd7e1..09e9117cd32 100644
--- a/main/grub/0004-linux-ignore-FDT-unless-we-need-to-modify-it.patch
+++ b/main/grub/0013-arm64-efi-linux-Ignore-FDT-unless-we-need-to-modify-.patch
@@ -1,28 +1,13 @@
-From c0c8c750b444e33205f7aff116aaf5a4336adca1 Mon Sep 17 00:00:00 2001
-From: Ard Biesheuvel <ard.biesheuvel@arm.com>
-Date: Thu, 3 Jun 2021 00:12:32 +0300
-Subject: [PATCH 4/7] linux: ignore FDT unless we need to modify it
-
-Now that we implemented supported for the LoadFile2 protocol for initrd
-loading, there is no longer a need to pass the initrd parameters via
-the device tree. This means there is no longer a reason to update the
-device tree in the first place, and so we can ignore it entirely.
-
-The only remaining reason to deal with the devicetree is if we are
-using the 'devicetree' command to load one from disk, so tweak the
-logic in grub_fdt_install() to take that into account.
-
-Signed-off-by: Ard Biesheuvel <ard.biesheuvel@arm.com>
----
+61e536ea4e15149e50422fecc026e1ee7449f05c arm64/efi/linux: Ignore FDT unless we need to modify it
grub-core/loader/arm64/linux.c | 22 +++++++++++-----------
grub-core/loader/efi/fdt.c | 7 +++++--
2 files changed, 16 insertions(+), 13 deletions(-)
diff --git a/grub-core/loader/arm64/linux.c b/grub-core/loader/arm64/linux.c
-index 6b03455d1..65f1275fb 100644
+index 9a4522d2f..9d0bacc85 100644
--- a/grub-core/loader/arm64/linux.c
+++ b/grub-core/loader/arm64/linux.c
-@@ -95,21 +95,21 @@ finalize_params_linux (void)
+@@ -134,21 +134,21 @@ finalize_params_linux (void)
void *fdt;
@@ -35,19 +20,19 @@ index 6b03455d1..65f1275fb 100644
- if (!fdt)
- goto failure;
+ if (!fdt)
-+ goto failure;
++ goto failure;
- node = grub_fdt_find_subnode (fdt, 0, "chosen");
- if (node < 0)
- node = grub_fdt_add_subnode (fdt, 0, "chosen");
+ node = grub_fdt_find_subnode (fdt, 0, "chosen");
+ if (node < 0)
-+ node = grub_fdt_add_subnode (fdt, 0, "chosen");
++ node = grub_fdt_add_subnode (fdt, 0, "chosen");
- if (node < 1)
- goto failure;
+ if (node < 1)
-+ goto failure;
++ goto failure;
- /* Set initrd info */
- if (initrd_start && initrd_end > initrd_start)
@@ -56,28 +41,28 @@ index 6b03455d1..65f1275fb 100644
(void *) initrd_start, (void *) initrd_end);
diff --git a/grub-core/loader/efi/fdt.c b/grub-core/loader/efi/fdt.c
-index c86f283d7..771d455c7 100644
+index c86f283d7..061f662fd 100644
--- a/grub-core/loader/efi/fdt.c
+++ b/grub-core/loader/efi/fdt.c
@@ -89,13 +89,16 @@ grub_fdt_install (void)
grub_efi_guid_t fdt_guid = GRUB_EFI_DEVICE_TREE_GUID;
grub_efi_status_t status;
-+ if (!fdt && !loaded_fdt)
++ if (fdt == NULL && loaded_fdt == NULL)
+ return GRUB_ERR_NONE;
+
b = grub_efi_system_table->boot_services;
- status = b->install_configuration_table (&fdt_guid, fdt);
-+ status = b->install_configuration_table (&fdt_guid, fdt ?: loaded_fdt);
++ status = b->install_configuration_table (&fdt_guid, fdt ? fdt : loaded_fdt);
if (status != GRUB_EFI_SUCCESS)
return grub_error (GRUB_ERR_IO, "failed to install FDT");
grub_dprintf ("fdt", "Installed/updated FDT configuration table @ %p\n",
- fdt);
-+ fdt ?: loaded_fdt);
++ fdt ? fdt : loaded_fdt);
return GRUB_ERR_NONE;
}
--
-2.33.0
+2.39.2
diff --git a/main/grub/0013-prevent-vgs-warnings.patch b/main/grub/0013-prevent-vgs-warnings.patch
deleted file mode 100644
index ebf125cbc43..00000000000
--- a/main/grub/0013-prevent-vgs-warnings.patch
+++ /dev/null
@@ -1,37 +0,0 @@
-From: Dermot Bradley <dermot_bradley@yahoo.com>
-Date: Tue, 6 Sep 2022 23:41:36 +0100
-Subject: [PATCH] prevent harmless LVM warnings from grub-probe
-
-Whenever grub-probe is run (by grub-mkconfig) and the root
-filesystem is on LVM then multiple warnings may be displayed:
-
- File descriptor 7 (socket:[24298]) leaked on vgs invocation.
- Parent PID 12489: /usr/sbin/grub-probe
-
-These warnings are harmless but annoying and may make users think
-there is an actual problem with their OS. If the environment
-variable LVM_SUPPRESS_FD_WARNINGS is set then grub-probe will not
-display these. However in the described situation grub-probe is not
-being called directly, but rather via grub-mkconfig and so this
-patch simply prefixes grub-probe's call to 'vgs' with setting this
-environment variable.
-
-I see numerous discussions of this "bug" across multiple distros
-(e.g. Debian from 2008, Ubuntu from 2015) over the years and indeed
-found two Grub bugs (39696 & 45279) regarding it (from 2013 & 2015)
-but no attempt appears to have been made to resolve this upstream.
-
----
-
-diff -aur a/grub-core/osdep/unix/getroot.c b/grub-core/osdep/unix/getroot.c
---- a/grub-core/osdep/unix/getroot.c
-+++ b/grub-core/osdep/unix/getroot.c
-@@ -614,7 +614,7 @@
- /* by default PV name is left aligned in 10 character field, meaning that
- we do not know where name ends. Using dummy --separator disables
- alignment. We have a single field, so separator itself is not output */
-- argv[0] = "vgs";
-+ argv[0] = "LVM_SUPPRESS_FD_WARNINGS=1 vgs";
- argv[1] = "--options";
- if (vgid)
- argv[2] = "vg_uuid,pv_name";
diff --git a/main/grub/0005-loader-Move-arm64-linux-loader-to-common-code.patch b/main/grub/0014-loader-Move-arm64-linux-loader-to-common-code.patch
index 3c39795078f..b59b29f180b 100644
--- a/main/grub/0005-loader-Move-arm64-linux-loader-to-common-code.patch
+++ b/main/grub/0014-loader-Move-arm64-linux-loader-to-common-code.patch
@@ -1,20 +1,10 @@
-From 8fd5e05e1b16fdf61ae154a4a1364154765b4498 Mon Sep 17 00:00:00 2001
-From: Atish Patra <atish.patra@wdc.com>
-Date: Thu, 3 Jun 2021 00:12:33 +0300
-Subject: [PATCH 5/7] loader: Move arm64 linux loader to common code
-
-ARM64 linux loader code is written in such a way that it can be reused
-across different architectures without much change. Move it to common
-code so that RISC-V doesn't have to define a separate loader.
-
-Signed-off-by: Atish Patra <atish.patra@wdc.com>
----
+8eeb75da64902398f6b79e0ea665a8b866c86165 loader: Move arm64 linux loader to common code
grub-core/Makefile.core.def | 4 ++--
- grub-core/loader/{arm64 => efi}/linux.c | 2 +-
+ grub-core/loader/{arm64 => efi}/linux.c | 0
include/grub/arm/linux.h | 2 +-
include/grub/arm64/linux.h | 2 +-
- 4 files changed, 5 insertions(+), 5 deletions(-)
- rename grub-core/loader/{arm64 => efi}/linux.c (99%)
+ 4 files changed, 4 insertions(+), 4 deletions(-)
+ rename grub-core/loader/{arm64 => efi}/linux.c (100%)
diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def
index 8022e1c0a..b36cf663a 100644
@@ -33,26 +23,14 @@ index 8022e1c0a..b36cf663a 100644
riscv64 = loader/riscv/linux.c;
common = loader/linux.c;
diff --git a/grub-core/loader/arm64/linux.c b/grub-core/loader/efi/linux.c
-similarity index 99%
+similarity index 100%
rename from grub-core/loader/arm64/linux.c
rename to grub-core/loader/efi/linux.c
-index 65f1275fb..60f0fa264 100644
---- a/grub-core/loader/arm64/linux.c
-+++ b/grub-core/loader/efi/linux.c
-@@ -60,7 +60,7 @@ grub_arch_efi_linux_check_image (struct linux_arch_kernel_header * lh)
- struct grub_pe32_coff_header *coff_header;
- struct grub_pe32_optional_header *optional_header;
-
-- if (lh->magic != GRUB_LINUX_ARMXX_MAGIC_SIGNATURE)
-+ if (lh->magic != GRUB_LINUX_ARCH_MAGIC_SIGNATURE)
- return grub_error(GRUB_ERR_BAD_OS, "invalid magic number");
-
- if ((lh->code0 & 0xffff) != GRUB_PE32_MAGIC)
diff --git a/include/grub/arm/linux.h b/include/grub/arm/linux.h
-index bcd5a7eb1..8c13978d2 100644
+index f38e695b1..a9509a997 100644
--- a/include/grub/arm/linux.h
+++ b/include/grub/arm/linux.h
-@@ -35,7 +35,7 @@ struct linux_arm_kernel_header {
+@@ -40,7 +40,7 @@ struct linux_arm_kernel_header {
};
#if defined(__arm__)
@@ -62,10 +40,10 @@ index bcd5a7eb1..8c13978d2 100644
#endif
diff --git a/include/grub/arm64/linux.h b/include/grub/arm64/linux.h
-index 7e22b4ab6..effd870ef 100644
+index 3da71a512..37238de7e 100644
--- a/include/grub/arm64/linux.h
+++ b/include/grub/arm64/linux.h
-@@ -39,7 +39,7 @@ struct linux_arm64_kernel_header
+@@ -41,7 +41,7 @@ struct linux_arm64_kernel_header
};
#if defined(__aarch64__)
@@ -75,5 +53,5 @@ index 7e22b4ab6..effd870ef 100644
#endif
--
-2.33.0
+2.39.2
diff --git a/main/grub/0006-RISC-V-Update-image-header.patch b/main/grub/0015-RISC-V-Update-image-header.patch
index 13cf7795de4..195f7d1702b 100644
--- a/main/grub/0006-RISC-V-Update-image-header.patch
+++ b/main/grub/0015-RISC-V-Update-image-header.patch
@@ -1,15 +1,4 @@
-From a4c8b60312216e3a6d72e903f9829eafd50d9142 Mon Sep 17 00:00:00 2001
-From: Atish Patra <atish.patra@wdc.com>
-Date: Thu, 3 Jun 2021 00:12:34 +0300
-Subject: [PATCH 6/7] RISC-V: Update image header
-
-Update the RISC-V Linux kernel image headers as per the current header.
-
-Reference:
-<Linux kernel source>/Documentation/riscv/boot-image-header.rst
-
-Signed-off-by: Atish Patra <atish.patra@wdc.com>
----
+8ad7ef13ce73f7c9a7a452cfd08b69199fdaaa6e RISC-V: Update image header
include/grub/riscv32/linux.h | 15 ++++++++-------
include/grub/riscv64/linux.h | 15 ++++++++-------
2 files changed, 16 insertions(+), 14 deletions(-)
@@ -83,5 +72,5 @@ index 3630c30fb..7c28bc922 100644
};
--
-2.33.0
+2.39.2
diff --git a/main/grub/0007-RISC-V-Use-common-linux-loader.patch b/main/grub/0016-RISC-V-Use-common-linux-loader.patch
index 4bc7ed6851c..8cf9fb09199 100644
--- a/main/grub/0007-RISC-V-Use-common-linux-loader.patch
+++ b/main/grub/0016-RISC-V-Use-common-linux-loader.patch
@@ -1,14 +1,4 @@
-From 81772eb884e9ab35b461bc9f0a38e1ab2b6a82a5 Mon Sep 17 00:00:00 2001
-From: Atish Patra <atish.patra@wdc.com>
-Date: Thu, 3 Jun 2021 00:12:35 +0300
-Subject: [PATCH 7/7] RISC-V: Use common linux loader
-
-RISC-V doesn't have to do anything very different from other architectures
-to loader EFI stub linux kernel. As a result, just use the common linux
-loader instead of defining a RISC-V specific linux loader.
-
-Signed-off-by: Atish Patra <atish.patra@wdc.com>
----
+84f52167e8b0325184bc1064634f7f546475cca2 RISC-V: Use common linux loader
grub-core/Makefile.core.def | 4 +--
grub-core/loader/riscv/linux.c | 59 ----------------------------------
include/grub/riscv32/linux.h | 1 +
@@ -119,5 +109,5 @@ index 7c28bc922..88d5df781 100644
#endif /* ! GRUB_RISCV64_LINUX_HEADER */
--
-2.33.0
+2.39.2
diff --git a/main/grub/0017-Fix-grub-mkconfig-detection-of-linux-edge-virt.patch b/main/grub/0017-Fix-grub-mkconfig-detection-of-linux-edge-virt.patch
new file mode 100644
index 00000000000..b7a49436116
--- /dev/null
+++ b/main/grub/0017-Fix-grub-mkconfig-detection-of-linux-edge-virt.patch
@@ -0,0 +1,43 @@
+8d370d5bd81c8467878cf88be24938a33efc06bf Fix grub-mkconfig detection of linux-edge-virt
+ util/grub.d/10_linux.in | 2 +-
+ util/grub.d/20_linux_xen.in | 4 ++--
+ 2 files changed, 3 insertions(+), 3 deletions(-)
+
+diff --git a/util/grub.d/10_linux.in b/util/grub.d/10_linux.in
+index a694050df..4e5f71f0b 100644
+--- a/util/grub.d/10_linux.in
++++ b/util/grub.d/10_linux.in
+@@ -198,7 +198,7 @@ while [ "x$list" != "x" ] ; do
+ basename=`basename $linux`
+ dirname=`dirname $linux`
+ rel_dirname=`make_system_path_relative_to_its_root $dirname`
+- version=`echo $basename | sed -e "s,^[^0-9]*-,,g"`
++ version=`echo $basename | sed -e "s,^[^-]*-,,g"`
+ alt_version=`echo $version | sed -e "s,\.old$,,g"`
+ linux_root_device_thisversion="${LINUX_ROOT_DEVICE}"
+
+diff --git a/util/grub.d/20_linux_xen.in b/util/grub.d/20_linux_xen.in
+index b6ea5bbd1..15319fe06 100644
+--- a/util/grub.d/20_linux_xen.in
++++ b/util/grub.d/20_linux_xen.in
+@@ -181,7 +181,7 @@ linux_list=
+ for i in /boot/vmlinu[xz]-* /vmlinu[xz]-* /boot/kernel-*; do
+ if grub_file_is_not_garbage "$i"; then
+ basename=$(basename $i)
+- version=$(echo $basename | sed -e "s,^[^0-9]*-,,g")
++ version=$(echo $basename | sed -e "s,^[^-]*-,,g")
+ dirname=$(dirname $i)
+ config=
+ for j in "${dirname}/config-${version}" "${dirname}/config-${alt_version}" "/etc/kernels/kernel-config-${version}" ; do
+@@ -275,7 +275,7 @@ while [ "x${xen_list}" != "x" ] ; do
+ basename=`basename $linux`
+ dirname=`dirname $linux`
+ rel_dirname=`make_system_path_relative_to_its_root $dirname`
+- version=`echo $basename | sed -e "s,^[^0-9]*-,,g"`
++ version=`echo $basename | sed -e "s,^[^-]*-,,g"`
+ alt_version=`echo $version | sed -e "s,\.old$,,g"`
+ linux_root_device_thisversion="${LINUX_ROOT_DEVICE}"
+
+--
+2.39.2
+
diff --git a/main/grub/0018-ensure-grub-mkconfig-ignores-.apk-new-files.patch b/main/grub/0018-ensure-grub-mkconfig-ignores-.apk-new-files.patch
new file mode 100644
index 00000000000..13b506743e5
--- /dev/null
+++ b/main/grub/0018-ensure-grub-mkconfig-ignores-.apk-new-files.patch
@@ -0,0 +1,22 @@
+65d6f17b0b6651007ded36dff9ba206fac8d7caa ensure grub-mkconfig ignores *.apk-new files
+ util/grub-mkconfig.in | 4 ++++
+ 1 file changed, 4 insertions(+)
+
+diff --git a/util/grub-mkconfig.in b/util/grub-mkconfig.in
+index f8cbb8d7a..8b6501209 100644
+--- a/util/grub-mkconfig.in
++++ b/util/grub-mkconfig.in
+@@ -278,6 +278,10 @@ for i in "${grub_mkconfig_dir}"/* ; do
+ *~) ;;
+ # emacsen autosave files. FIXME: support other editors
+ */\#*\#) ;;
++ # Copy of a template file from Alpine Grub package where the stock file
++ # was locally modified. Any such *.apk-new files should be ignored by
++ # grub-mkconfig.
++ *.apk-new) ;;
+ *)
+ if grub_file_is_not_garbage "$i" && test -x "$i" ; then
+ echo
+--
+2.39.2
+
diff --git a/main/grub/0019-prevent-harmless-LVM-warnings-from-grub-probe.patch b/main/grub/0019-prevent-harmless-LVM-warnings-from-grub-probe.patch
new file mode 100644
index 00000000000..009fc8bd9e3
--- /dev/null
+++ b/main/grub/0019-prevent-harmless-LVM-warnings-from-grub-probe.patch
@@ -0,0 +1,20 @@
+24552b8fd1291c9c8046d14dd813b9a4f22bf883 prevent harmless LVM warnings from grub-probe
+ grub-core/osdep/unix/getroot.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/grub-core/osdep/unix/getroot.c b/grub-core/osdep/unix/getroot.c
+index 74f69116d..8e143beb2 100644
+--- a/grub-core/osdep/unix/getroot.c
++++ b/grub-core/osdep/unix/getroot.c
+@@ -609,7 +609,7 @@ grub_util_pull_lvm_by_command (const char *os_dev)
+ /* by default PV name is left aligned in 10 character field, meaning that
+ we do not know where name ends. Using dummy --separator disables
+ alignment. We have a single field, so separator itself is not output */
+- argv[0] = "vgs";
++ argv[0] = "LVM_SUPPRESS_FD_WARNINGS=1 vgs";
+ argv[1] = "--options";
+ if (vgid)
+ argv[2] = "vg_uuid,pv_name";
+--
+2.39.2
+
diff --git a/main/grub/0014-fix-encrypted-zfs.patch b/main/grub/0020-Handle-encrypted-zfs-root-partition.patch
index 73261428f18..833fa371ba2 100644
--- a/main/grub/0014-fix-encrypted-zfs.patch
+++ b/main/grub/0020-Handle-encrypted-zfs-root-partition.patch
@@ -1,20 +1,13 @@
-From: Magnus Sandin <magnus.sandin@gmail.com>
-Date: Fri Feb 3 07:38:41 +0100
-Subject: [PATCH] Handle encrypted zfs root partition
-
-If the root partition is encrypted using zfs
-grub-probe will fail to get the zfs pool name since
-it doen't support encrypted zfs filesystems
-and it will thus return an empty pool name.
-
-If the root filesystem is zfs, then skip grub-probe
-altogether and use blkid instead to get the label
-which is what grub-probe tries to do but fails
-if the zfs filesystem is encrypted.
+0979d0808c8d977cebe4715c729295d485c12725 Handle encrypted zfs root partition
+ util/grub.d/10_linux.in | 2 +-
+ util/grub.d/20_linux_xen.in | 2 +-
+ 2 files changed, 2 insertions(+), 2 deletions(-)
+diff --git a/util/grub.d/10_linux.in b/util/grub.d/10_linux.in
+index 4e5f71f0b..7afa1fd2f 100644
--- a/util/grub.d/10_linux.in
+++ b/util/grub.d/10_linux.in
-@@ -74,7 +74,7 @@
+@@ -71,7 +71,7 @@ case x"$GRUB_FS" in
GRUB_CMDLINE_LINUX="rootflags=subvol=${rootsubvol} ${GRUB_CMDLINE_LINUX}"
fi;;
xzfs)
@@ -23,9 +16,11 @@ if the zfs filesystem is encrypted.
bootfs="`make_system_path_relative_to_its_root / | sed -e "s,@$,,"`"
LINUX_ROOT_DEVICE="ZFS=${rpool}${bootfs%/}"
;;
+diff --git a/util/grub.d/20_linux_xen.in b/util/grub.d/20_linux_xen.in
+index 15319fe06..8656bb453 100644
--- a/util/grub.d/20_linux_xen.in
+++ b/util/grub.d/20_linux_xen.in
-@@ -79,7 +79,7 @@
+@@ -79,7 +79,7 @@ case x"$GRUB_FS" in
GRUB_CMDLINE_LINUX="rootflags=subvol=${rootsubvol} ${GRUB_CMDLINE_LINUX}"
fi;;
xzfs)
@@ -34,3 +29,6 @@ if the zfs filesystem is encrypted.
bootfs="`make_system_path_relative_to_its_root / | sed -e "s,@$,,"`"
LINUX_ROOT_DEVICE="ZFS=${rpool}${bootfs%/}"
;;
+--
+2.39.2
+
diff --git a/main/grub/alpine-mkconfig.patch b/main/grub/0021-Alpine-Linux-fixes-for-menu.patch
index 276f8abddaa..eb2597d4684 100644
--- a/main/grub/alpine-mkconfig.patch
+++ b/main/grub/0021-Alpine-Linux-fixes-for-menu.patch
@@ -1,5 +1,10 @@
+7a71eaf97380e505520b8ef92b35ffb44e6c5227 Alpine Linux fixes for menu
+ util/grub.d/10_linux.in | 12 ++++++++----
+ util/grub.d/20_linux_xen.in | 5 +++--
+ 2 files changed, 11 insertions(+), 6 deletions(-)
+
diff --git a/util/grub.d/10_linux.in b/util/grub.d/10_linux.in
-index 4532266..42e0248 100644
+index 7afa1fd2f..76e006b99 100644
--- a/util/grub.d/10_linux.in
+++ b/util/grub.d/10_linux.in
@@ -21,17 +21,22 @@ prefix="@prefix@"
@@ -36,8 +41,8 @@ index 4532266..42e0248 100644
|| ( test -e "${GRUB_DEVICE}" && uses_abstraction "${GRUB_DEVICE}" lvm ); then
LINUX_ROOT_DEVICE=${GRUB_DEVICE}
elif [ "x${GRUB_DEVICE_UUID}" = "x" ] \
-@@ -215,6 +218,7 @@ while [ "x$list" != "x" ] ; do
- "initrd-${version}" "initramfs-${version}.img" \
+@@ -217,6 +220,7 @@ while [ "x$list" != "x" ] ; do
+ "initramfs-${version}.img" "initramfs-${alt_version}.img.old" \
"initrd.img-${alt_version}" "initrd-${alt_version}.img" \
"initrd-${alt_version}" "initramfs-${alt_version}.img" \
+ "initramfs-${version}" \
@@ -45,7 +50,7 @@ index 4532266..42e0248 100644
"initramfs-genkernel-${alt_version}" \
"initramfs-genkernel-${GENKERNEL_ARCH}-${version}" \
diff --git a/util/grub.d/20_linux_xen.in b/util/grub.d/20_linux_xen.in
-index 96179ea..6c4c411 100644
+index 8656bb453..69c76a820 100644
--- a/util/grub.d/20_linux_xen.in
+++ b/util/grub.d/20_linux_xen.in
@@ -29,9 +29,9 @@ export TEXTDOMAINDIR="@localedir@"
@@ -60,11 +65,14 @@ index 96179ea..6c4c411 100644
CLASS="--class $(echo ${GRUB_DISTRIBUTOR} | tr 'A-Z' 'a-z' | cut -d' ' -f1|LC_ALL=C sed 's,[^[:alnum:]_],_,g') ${CLASS}"
fi
-@@ -256,6 +256,7 @@ while [ "x${xen_list}" != "x" ] ; do
- "initrd-${version}" "initramfs-${version}.img" \
+@@ -286,6 +286,7 @@ while [ "x${xen_list}" != "x" ] ; do
+ "initramfs-${version}.img" "initramfs-${alt_version}.img.old" \
"initrd.img-${alt_version}" "initrd-${alt_version}.img" \
"initrd-${alt_version}" "initramfs-${alt_version}.img" \
+ "initramfs-${version}" \
"initramfs-genkernel-${version}" \
"initramfs-genkernel-${alt_version}" \
"initramfs-genkernel-${GENKERNEL_ARCH}-${version}" \
+--
+2.39.2
+
diff --git a/main/grub/lang-C.UTF-8.patch b/main/grub/0022-templates-fix-lang-locale-detection.patch
index 0b74654bcbc..79696e0820f 100644
--- a/main/grub/lang-C.UTF-8.patch
+++ b/main/grub/0022-templates-fix-lang-locale-detection.patch
@@ -1,5 +1,9 @@
+5ba06ad13292c725c5f4915121130bd5837e60c0 templates: fix lang/locale detection
+ util/grub.d/00_header.in | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
diff --git a/util/grub.d/00_header.in b/util/grub.d/00_header.in
-index 93a9023..130abd4 100644
+index 93a90233e..130abd429 100644
--- a/util/grub.d/00_header.in
+++ b/util/grub.d/00_header.in
@@ -191,7 +191,7 @@ EOF
@@ -11,3 +15,6 @@ index 93a9023..130abd4 100644
cat << EOF
set locale_dir=\$prefix/locale
set lang=${grub_lang}
+--
+2.39.2
+
diff --git a/main/grub/fix-gcc-no-pie-specs.patch b/main/grub/0023-build-force-no-pie.patch
index 273c9dbe39f..cc14a3e200c 100644
--- a/main/grub/fix-gcc-no-pie-specs.patch
+++ b/main/grub/0023-build-force-no-pie.patch
@@ -1,6 +1,12 @@
---- ./configure.ac.orig
-+++ ./configure.ac
-@@ -1100,7 +1100,7 @@
+8826c39fdbf7988c73ae42846a8cf0cfbd81fbad build: force -no-pie
+ configure.ac | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/configure.ac b/configure.ac
+index 9c5fa618d..dffdaa9e7 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -1190,7 +1190,7 @@ if test x"$efiemu_excuse" = x ; then
if test x"$grub_cv_target_cc_efiemu64_link_format" = xunknown; then
efiemu_excuse="no suitable link format for efiemu64 found"
else
@@ -9,3 +15,6 @@
fi
fi
if test x"$enable_efiemu" = xyes && test x"$efiemu_excuse" != x ; then
+--
+2.39.2
+
diff --git a/main/grub/APKBUILD b/main/grub/APKBUILD
index 81031c7eb01..74d4c972cf7 100644
--- a/main/grub/APKBUILD
+++ b/main/grub/APKBUILD
@@ -2,7 +2,7 @@
# Maintainer: Timo Teräs <timo.teras@iki.fi>
pkgname=grub
pkgver=2.06
-pkgrel=8
+pkgrel=9
pkgdesc="Bootloader with support for Linux, Multiboot and more"
url="https://www.gnu.org/software/grub/"
arch="all !s390x"
@@ -38,24 +38,32 @@ for f in $flavors; do
done
source="https://ftp.gnu.org/gnu/grub/grub-$pkgver.tar.xz
- fix-gcc-no-pie-specs.patch
grub-xen-host_grub.cfg
- alpine-mkconfig.patch
- lang-C.UTF-8.patch
- 0001-loader-drop-argv-argument-in-grub_initrd_load.patch
- 0002-efi-add-definition-of-LoadFile2-protocol.patch
- 0003-efi-implemented-LoadFile2-initrd-loading-protocol-fo.patch
- 0004-linux-ignore-FDT-unless-we-need-to-modify-it.patch
- 0005-loader-Move-arm64-linux-loader-to-common-code.patch
- 0006-RISC-V-Update-image-header.patch
- 0007-RISC-V-Use-common-linux-loader.patch
- 0008-fix-build-error-in-binutils-2.36.patch
- 0009-fix-kernel-version-detection.patch
- 0010-riscv-binutils-2.38.patch
- 0011-mkconfig-ignore-apk-new-files.patch
- 0012-remove-udevadm-usage.patch
- 0013-prevent-vgs-warnings.patch
- 0014-fix-encrypted-zfs.patch
+
+ 0001-osdep-Introduce-include-grub-osdep-major.h-and-use-i.patch
+ 0002-osdep-linux-hostdisk-Use-stat-instead-of-udevadm-for.patch
+ 0003-build-Fix-build-error-with-binutils-2.36.patch
+ 0004-configure-Fix-misspelled-variable-BUILD_LDFAGS-BUILD.patch
+ 0005-RISC-V-Adjust-march-flags-for-binutils-2.38.patch
+ 0006-templates-Improve-initramfs-detection.patch
+ 0007-loader-arm64-linux-Remove-magic-number-header-field-.patch
+ 0008-loader-Drop-argv-argument-in-grub_initrd_load.patch
+ 0009-efi-Move-MS-DOS-stub-out-of-generic-PE-header-defini.patch
+ 0010-arm-linux-Unify-ARM-arm64-vs-Xen-PE-COFF-header-hand.patch
+ 0011-loader-arm64-linux-Account-for-COFF-headers-appearin.patch
+ 0012-arm64-efi-linux-Implement-LoadFile2-initrd-loading-p.patch
+ 0013-arm64-efi-linux-Ignore-FDT-unless-we-need-to-modify-.patch
+
+ 0014-loader-Move-arm64-linux-loader-to-common-code.patch
+ 0015-RISC-V-Update-image-header.patch
+ 0016-RISC-V-Use-common-linux-loader.patch
+ 0017-Fix-grub-mkconfig-detection-of-linux-edge-virt.patch
+ 0018-ensure-grub-mkconfig-ignores-.apk-new-files.patch
+ 0019-prevent-harmless-LVM-warnings-from-grub-probe.patch
+ 0020-Handle-encrypted-zfs-root-partition.patch
+ 0021-Alpine-Linux-fixes-for-menu.patch
+ 0022-templates-fix-lang-locale-detection.patch
+ 0023-build-force-no-pie.patch
"
# secfixes:
@@ -267,22 +275,28 @@ bashcomp() {
sha512sums="
4f11c648f3078567e53fc0c74d5026fdc6da4be27d188975e79d9a4df817ade0fe5ad2ddd694238a07edc45adfa02943d83c57767dd51548102b375e529e8efe grub-2.06.tar.xz
-f2a7d9ab6c445f4e402e790db56378cecd6631b5c367451aa6ce5c01cd95b95c83c3dd24d6d4b857f8f42601eba82c855607513eb6ce5b2af6bd6c71f046e288 fix-gcc-no-pie-specs.patch
4e7394e0fff6772c89683039ccf81099ebbfe4f498e6df408977a1488fd59389b6e19afdbf0860ec271e2b2aea0df7216243dcc8235d1ca3af0e7f4d0a9d60a4 grub-xen-host_grub.cfg
-84d9694af384336c0846faad968a63b154e2bd957671fa7c0163c36e20fd086a8d5b67ddf5eb983a11a69f65dac52668d0f51537e7cfe9a1ea9bca7aba91f20b alpine-mkconfig.patch
-f23702741f2a37c83d0cbf16a000a6229dfd433cd583f3254d523ce35b3668c1db2d8a704a75013e74655ec4f9da5db6b630aa92e3ca5cc47df44cc9e41d1806 lang-C.UTF-8.patch
-c0ea8ef9a3d4e511fae97a4b90dc6f407c5b0a81c922924992f3eccd49fad0886f2e06ff21731cc59d42a6ac28272eb859a7ee9f14642ae1ad705f2cd1da1956 0001-loader-drop-argv-argument-in-grub_initrd_load.patch
-708c3e8ca60638b7961aac64fe1eecb21ef9db844b4a21c2d36303c7fcd71173ba13dc0df3c8ae09b4a0a6a4a5b7fb3c41736a9bf6d1ef367c73dcf5bdf17668 0002-efi-add-definition-of-LoadFile2-protocol.patch
-aa2fbabeab2e8f517128f0d81d3c76eba18b24518b616d4574ffaaec7d4765e02b5b118caf04da1e225342a66700f2774c6a04c1ebfd32747499eb3cbc9b72ea 0003-efi-implemented-LoadFile2-initrd-loading-protocol-fo.patch
-6616373b6c94f48dd8ee0636973451a7cf492ea8dfc854b9c250bcc291d5c3a9efae51ad9d37b7298dc8e6f22041109b4ad8e82cf75c9514b5dfaa78a02d9ce1 0004-linux-ignore-FDT-unless-we-need-to-modify-it.patch
-74b2bf8e9da604c5ca60ed13e389e48ceb4eeea1669b8ac720cdc452a4450676fe4bb961a63d31603bcdc9fe15ab6a8cb74b9ff97b6d7d85f1aaba24b1e9e244 0005-loader-Move-arm64-linux-loader-to-common-code.patch
-4901c964278ab8a46901b905efef4562aa4942d6c37be052db9536d4779ecea6a0cf68fcc97fe6ef2b39c54cd598d4f8351cf3e27c3dacff888549bdc35deee3 0006-RISC-V-Update-image-header.patch
-721c9d7aefd9d9fdd4fe92c229122c3311e75266a9419a12f5f77536099070a232b6c4ff3c33ab5a2cb6f7f917ae0d6510b09045d2f035f87c65b4dd7f09d3ee 0007-RISC-V-Use-common-linux-loader.patch
-8c35663ef72683bd23c18e75134a0ddb1bb9a7c053ed87691e2ac5c9765fdf802761a6ad54f8bdc7999679d9cc5ebea9c01f1c0f615ac90505f7a398129d157b 0008-fix-build-error-in-binutils-2.36.patch
-d4432a36286f0ad7d3527d34e20daf9fbef24d6037171582ae3ccdd51668ffe422b87d984f107a9b4dcf019b89ac76dd322d64e42bbfa64bb6789d3d897fc1f2 0009-fix-kernel-version-detection.patch
-4b8b5eeeb45dd9fddc9af9b6e694644470672b35af33cd11f1578f35503b08662c51f27c10bffeb96a51de0a879c741c0d22600410147eb20505efe1a3b50b54 0010-riscv-binutils-2.38.patch
-229fe710de9fb106e08457a5a19dd3cc1746389ff1cdd95721b092913c51550fc8ad05141a23fc396a9e8dbbcec909920eda5f3eed339af9938774feb9e6c7bc 0011-mkconfig-ignore-apk-new-files.patch
-c6011ece89e55d92e351bdab3eae180d75fcde642865934800641d42969febebd3a29a68941a10ef42a0bdeae0069432f2bb31e42fa651263cdedc1b964d5b33 0012-remove-udevadm-usage.patch
-979d02731f2ae1769aa80fc86fe5fd6e1f872a9d614491ca166d73151a0c9156c4636b986aed26d705f0dbe3ef6ad4d8ff623eddb190266c361aa43ebb563315 0013-prevent-vgs-warnings.patch
-3ce38e8df3ff8dc7e6a0ad513535305aaff79f20601755cc6e2e667f9773d0c26f25c90966aa10498a332daf083a9813364400e83387068f32107433a6c97171 0014-fix-encrypted-zfs.patch
+377ecb3203bc19c792c3299cec5e678a8765b552a020e0f8cf29f881a9ed936fd00fb1eddde835daf98d9450078f5ab3a0236b6a6a8cd1ffc204e80739c7dc27 0001-osdep-Introduce-include-grub-osdep-major.h-and-use-i.patch
+73dfe930925554cd750b37cb386e98f9b9ae0ccfde7d6edfda201e7a723173314523123fbd1aedaa83cf3649fc28550649a21709705b3a62b5d90914f58587c6 0002-osdep-linux-hostdisk-Use-stat-instead-of-udevadm-for.patch
+b054e0fc91ff81980eebad07d1bafab6b5d11c48f544ef389a94e1da14a89aaed88ac1d0086ffc64d56f5b7bd5d9486bbf8f7c0fbba75bd34047ca677ed4ddf8 0003-build-Fix-build-error-with-binutils-2.36.patch
+24ad940e33be72b75577d53017052b074f72a275804f8572a15ca0301fd742ce001459e8eee5d9ee90824837495d04060e494d414f241d9053931d40dafb15b9 0004-configure-Fix-misspelled-variable-BUILD_LDFAGS-BUILD.patch
+91c52255be2668a2a16dba0ab6a89a2fe6c3b0cc71b20577feaadafeb7dd7f6274f4c2e20ed9c836b22cc88e46cf5528780493c73a5c9b865134b2529a20e45a 0005-RISC-V-Adjust-march-flags-for-binutils-2.38.patch
+ad17a2af8fb73d23a1b4dc943bdcb6bbbfb02387f2fa3e4c05302ee5920d3c035b4c68004887d9f5997f07cea650c70b67e1f96442b32f62173b6f1722805bfb 0006-templates-Improve-initramfs-detection.patch
+c0d7b9bb8876988c193c62d0dac05ddc9880c67d737551e6e169de30c5fd86060fa6c039e9959af2abbc55796aa7b5320bb28d1634c9a1238c2d61068acb5383 0007-loader-arm64-linux-Remove-magic-number-header-field-.patch
+a8cb230c13e8e53f3a2b87f791350b1bc3e244e6d98d18297c5f71ba3b0c8e9c1cfdd288fdcdfd11119df676dbf16cb45b2dd4157474bf92cb42a176cbcb442e 0008-loader-Drop-argv-argument-in-grub_initrd_load.patch
+4529b9808f5f496bbb2dde6aa3964a1545f49ca0d1c139ba60d135fc46dd464df67ac8e4572adfcbddb45dc8adf25efaa72ffefbaaaa45ba5df90e4da1d35e1c 0009-efi-Move-MS-DOS-stub-out-of-generic-PE-header-defini.patch
+d2a5ec2a7d43b9be2af6194656be33a2fef0ffccacb03aec6f7386eaa623f98008922f943b77ec4941e9bcbc6793a4b95758e4e973c7341ae0224d6212e7b4e0 0010-arm-linux-Unify-ARM-arm64-vs-Xen-PE-COFF-header-hand.patch
+ce80c16b8afac7dadfd0c16498466aa5c536663cf9ac98ad2aaf069137dcab28b6806609ff24285a33da70c3a993bcb70c51f1ad84b333c496c1ae9f3969eede 0011-loader-arm64-linux-Account-for-COFF-headers-appearin.patch
+2f4f29a9ca0148f741b4f8540e6642d6cc51bb5ec3fa1510aef3730ad3a923698b8054c5590e8c96edde2a72f69e92de9931a6d14a8f19d5f69b87dd30011f33 0012-arm64-efi-linux-Implement-LoadFile2-initrd-loading-p.patch
+8056810d6b2a39e476b6ffd47617ef208c415d37358a1fa1a8642a18af4ffaa8ada014bf87cbf2411e12461de00827faeedb06a797469c590c68d6d219824548 0013-arm64-efi-linux-Ignore-FDT-unless-we-need-to-modify-.patch
+3ca9c1595e70e83e26a13aa34dc94d753c95fefc399b1383f190045e1618756df5adcb94eda6b37c149bcc5cb967ee5c71d637144910f843df208578fbccee69 0014-loader-Move-arm64-linux-loader-to-common-code.patch
+b69a24bf6d19fc262108d6064555754c8662ba1b8e4f68717419acafc18c5e04117c01bd40da3a724fbbc203ee423ee8440b5fc4f5b82e3e5f1529be82dc2e1c 0015-RISC-V-Update-image-header.patch
+3ba2bc9da34638f650f28705e4c89131f6d80aef66ed7c3d3e017790b648ae38b94264c069fc20f94fbb9b7e595b70510decb76bedbe659ddfbb11c86350d93f 0016-RISC-V-Use-common-linux-loader.patch
+6a631ba877542f2ba0837cc3f9bfcc8192dc735ec1c4185fd6c0e2a0246c08a3355665851335619b5ed136ac4c81f018635e833bbfe6c6f7e5a0f39940dc67c5 0017-Fix-grub-mkconfig-detection-of-linux-edge-virt.patch
+97719bfd538b8b328a1b2a975bea4c836cea2b2c391d24f4ec66a4626c6ae2aecd4d5a343061d08174299db8556f07d6d0353485f7c2205f8d960ea2ea50e90e 0018-ensure-grub-mkconfig-ignores-.apk-new-files.patch
+334e4559eb63ba3861b35d9502524dc6e6faa6af56c54554960854c293f9c524cddbb778f9bd7d0bd4f4e4ce8bfa5b9b0087445c2174b733c95640e44df38e6c 0019-prevent-harmless-LVM-warnings-from-grub-probe.patch
+333231df2394a9257352b51712f9dd386193d6e52d591ad8456e54b4fb585e425ceb62843928d4e5e82dc17debe31eb7dc0ccca0cec7352303c718f58987e1ec 0020-Handle-encrypted-zfs-root-partition.patch
+483d3aae4e3f943b203823be15fa225e943a7fc077f4c4cc59114fd21e16b237a2afd4499e7b6b373618c2551da1ed43c9ecddf9ec09103770d8726ad2b20241 0021-Alpine-Linux-fixes-for-menu.patch
+d4e311ed2a849d9424eb215b55e217e7c0db80b54c7dc67679eb1ec81892e4dff77d4e837abbd17117c2ae6378a6bd06b0d57d2b4856d4045feafe1be43c2067 0022-templates-fix-lang-locale-detection.patch
+552a0034b4f721d56b3ad7eb23b47b278690c219ba1a12fbf1f82eb88b03132c0b73fe11934f7ab26e7e2c819f1c20f06422ae2df26dbeaec8f0eaa3dfd4f03d 0023-build-force-no-pie.patch
"