aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPA4WDH2021-08-25 12:02:32 +0200
committerPA4WDH2021-08-25 12:02:32 +0200
commit38be1b3221b1e85cac1af8a67c733752265425d7 (patch)
tree62805f905167039e00378ede54f5dd41203bc577
parentAdd patch to sys-boot/u-boot-2021.07 to make it work (diff)
downloadunmatched-patchwork-38be1b3221b1e85cac1af8a67c733752265425d7.tar.gz
unmatched-patchwork-38be1b3221b1e85cac1af8a67c733752265425d7.tar.bz2
unmatched-patchwork-38be1b3221b1e85cac1af8a67c733752265425d7.zip
Add sys-boot/grub-2.06-r1
-rw-r--r--sys-boot/grub/Manifest11
-rw-r--r--sys-boot/grub/files/grub-2.06-001-loader-drop-argv-in-grub_initrd_load.patch173
-rw-r--r--sys-boot/grub/files/grub-2.06-002-efi-add-definition-of-loadfile2-protocol.patch58
-rw-r--r--sys-boot/grub/files/grub-2.06-003-efi-implemented-loadfile2-initrd-loading.patch180
-rw-r--r--sys-boot/grub/files/grub-2.06-004-linux-ignore-fdt-unless-we-need-to-modify-it.patch77
-rw-r--r--sys-boot/grub/files/grub-2.06-005-loader-move-arm64-linux-loader.patch73
-rw-r--r--sys-boot/grub/files/grub-2.06-006-riscv-update-image-header.patch81
-rw-r--r--sys-boot/grub/files/grub-2.06-007-riscv-use-common-linux-loader.patch117
-rw-r--r--sys-boot/grub/files/grub-2.06-010-efi-device-tree-fixup-protocol.patch135
-rw-r--r--sys-boot/grub/files/grub-2.06-011-support-loading-device-trees.patch73
-rw-r--r--sys-boot/grub/files/grub-2.06-012-move-load-fdt.patch21
-rw-r--r--sys-boot/grub/grub-2.06-r1.ebuild315
12 files changed, 1314 insertions, 0 deletions
diff --git a/sys-boot/grub/Manifest b/sys-boot/grub/Manifest
index f61a2e5..31c1dee 100644
--- a/sys-boot/grub/Manifest
+++ b/sys-boot/grub/Manifest
@@ -1,5 +1,15 @@
AUX gfxpayload.patch 1118 BLAKE2B 4104fc696535b1c3feba5876bccc64f9b2e52319ee992c59e7f17b8310cc9addf7545630fff78c73ca3f4b0dcd44e1bf69f4df5264d6f58777f7e5aeae93cbcb SHA512 00324825c369902a0383b792cd21e161853eadccbdc5abe2420f2d443bf6a74f72be6c15243107b936acd38c3547387c3771dc2cb566003c4c754c9260b4aa00
AUX grub-2.02_beta2-KERNEL_GLOBS.patch 2121 BLAKE2B 398195f59537d40a4f61eadf5be974b8f9eb56a4eb07b798f0dc18e29588b3a9f8daa8d6e64980a835ec1960fab60b8c96d6552ef2920fe6604170abf7d5e7da SHA512 f85bc538ae647c46efbe07d7b87acf49daa7b07e9752af3aa3f77019f48ea24cd1b6a095a6f9c19d50128701753f453c531b9b068e11ee22a259f3fdf8ac205e
+AUX grub-2.06-001-loader-drop-argv-in-grub_initrd_load.patch 6675 BLAKE2B 98940b99fefe4980d5fb21248fb41a62c8755ee827b3adbc9fa73d946dbbb9a8aad801fba1fb0f25b2c58e3321933ef309a183c42a688bfa03b8afced974de1b SHA512 8912e90251cc47b35a2a0b91eba6e0f80b543d4f62c26d9ff1d7fd5c1d910eaa564d941088a628cb52e86acf1d90eaab0f8e696cc6d6dd2121750defb6e63fb4
+AUX grub-2.06-002-efi-add-definition-of-loadfile2-protocol.patch 2166 BLAKE2B 6efa48b8b7251395ebb8e18abc2e59db7c69a85b97d5e564c6deb71a0c1c220b29a760dfef2428d4f5904968535e533f74c8193b183f478ee4ea20908882c013 SHA512 52e33c0984a3cc148ca83f6fe3d0d288747e62ff1f462fb6ff5227d78dcc6f31525f03d4e8e6a5b36c7532609e0f302879f5c9614937bc3d9904e282f80866ba
+AUX grub-2.06-003-efi-implemented-loadfile2-initrd-loading.patch 6016 BLAKE2B ef30a96d5de6995bb6a2dc48548abb245548b83c3d27c5901e072b0600a44ce3a23fc7e83bb5d1f22588acc6565cc2a6a5ce441ceebada848b5e4d1d086f45c2 SHA512 45f96c552237e78b70594d436bebc946611d63c9c6d1aca5a5c60148b12cde34689f1ae502fd1ba197e960dab188cd9cde9e376f7777773dc72523981e935a06
+AUX grub-2.06-004-linux-ignore-fdt-unless-we-need-to-modify-it.patch 2506 BLAKE2B 632f82fc1c9d7e9f194d23e6ae1ade47bbfcc02a115637e3aca6e257e208782dd71bbdd196839e0f17888de78cbb27d71ed75b87a58fe0d87d08e402a0cca257 SHA512 65bbe8d5b60d10b5faaca424e1e966ea3de7fde5265e478b3281427351e52acc34a8c8902149e3d69b82dd7780fd3a231a44747a28cd2eed6156741eb15ec6a8
+AUX grub-2.06-005-loader-move-arm64-linux-loader.patch 2797 BLAKE2B bc83f82a465ac7dee69a36d93c56e07c3a37dee46d09b3317cfa425d5ec62b795e5b2cd2449e7fc439e71436edfcf5b441550f15b80f0bd11095c69cd0300909 SHA512 f3191baca59e9903aaf84dbe470f8b1ee371c0ac976c84840919cf06629f121b9b67ded950e9e70a74b9ca01e0d88728888877d29521ee066f8bcbfb1ac43234
+AUX grub-2.06-006-riscv-update-image-header.patch 3192 BLAKE2B 57004beca8a54bc070c8ce52e9acd5583d288b406909a679544c0ebe8c697ccfdf41e040a24585b04c2cfe234f7e48d6c0296beeaf399dabfed05aacf7cbdb52 SHA512 d0c4d09c1f06d14d2df0dfb44f4c0dc6f8bd57be08e1e25632bc80001f590a65511792e2b2a87c9528150174669a8c81969db24f2472be0351a833327d884a3b
+AUX grub-2.06-007-riscv-use-common-linux-loader.patch 3901 BLAKE2B 109808cf3fb7dba758805b04fcc7babcea5634a936a44351f068b620a59bfa8f228201d898c74a69d1885d6722df80af0573f1630a0a4d6f2aa16760aa5cf855 SHA512 2f181d30b4684af32438e9630982c1de0993cf81a1e17615fb0802d83331d43ee4928d4cf53f24c1b8349cc09127ee9966cc73b2d24391989478c5c06b1caddc
+AUX grub-2.06-010-efi-device-tree-fixup-protocol.patch 4260 BLAKE2B cc63a8c25dc649e6fb06b3f9b736d06a6cbe5bf715e7760443748fb289212c459fa2cc61752daaac8f626d845d570ec578d8a4deaba396083ca39b0406ae92a2 SHA512 9dbae1a8a7d7f71cf31124101c57a921392ea9b0de7cfd8e27366cfdc781a38eb1b55a6adbfb63abeedbe79bd27a6d0efb2bdcde3973d13ca962aded23b7af62
+AUX grub-2.06-011-support-loading-device-trees.patch 2416 BLAKE2B 73427de0c99cfdaa203127cc39e4192ec560541320d2f391594e6099f5f978ec53633d979e2041eae80603ff3dbbc3737ea88c207e9dddd46973e6bfb1d8c540 SHA512 1a9751934191c4ec05e70dfd6bc5698484dc9fb34d1bc1cdd1d18fd7db4baccd867741015680af9eb024c6b13a5ab830e8f16d3cd6c352782fe6f7c3f43450a4
+AUX grub-2.06-012-move-load-fdt.patch 547 BLAKE2B 65333fb25aae5572f5677a837b5b7a78f607b6edc4a6690ef7523bfa65d448f7db869920513e81a1de260524aa913d4282d3b1ef632e68a2747edbc79f0580ee SHA512 ab73499ec00952ba53dbb82add56d70e578dcc2c38880a91d85a9d4f7139cecfd54385668a7468aaf91b754d87fad2f28c168fb52dd4c09ae6800cd05358d2e7
AUX grub-2.06-add-boot-hartid-to-fdt.patch 995 BLAKE2B 86ab277819eeab08d552e1d5300f8f5e798823e56e66d8dd39ae442b3b4777a22d155dd85f9b38778a644c7f52b61f673b6c856c66492da412d2ee2587125484 SHA512 5d334050165dd648bd3547ede9cc62380f75a5d9625a4282972a4e71e34e14d72cf6acb363c513942375c84c79a48acd6331bbcbc56f4999a339e29391fbb5ae
AUX grub-2.06-linux-riscv.patch 12599 BLAKE2B bfbb85e8824586d1a13d142020d591e0e103c77c193ef7a82e1770b3ffcd23f6daec9729a9d1cb579d5dcaeb6be40f23682fdab8e2e5c7067b382362faee2c36 SHA512 5f964e98caff6c57fc4ac7d57bbd86c8cc1ab35ca25c58a1e8c7a2db232b7b1470b6fe8a6a372c62fc3bfe939ce64c75027ed4b3d3d4db141b73a709557275c1
AUX grub-2.06-magic-number.patch 1826 BLAKE2B 83dc3e86b2ae3d96d3459641fda67b47178688410cacdc54ee79ccbab129cabfd1aa087ff1afc6fcdb607c1e183a7b55d54f5c0d5cbca951178129c50b26bb35 SHA512 44e03d1cbef8ca7128c4a91647d1095453f5f9c9aa9329f20bb5af178a766c6ed22b4c2ea3e515bac7b0c977f8248401590a6e76561d86146729c9cc1d931700
@@ -8,5 +18,6 @@ AUX grub.default-3 2528 BLAKE2B c32de43644eca5fae8d8d727ff443600917a93e015f8a83d
DIST dejavu-sans-ttf-2.37.zip 417746 BLAKE2B c8904f3cd5a49370a7dc10e456684c88aeae998a99090bf4d0a5baa4f36cc8fb8f70586cf6d610a5ffeee97261d28c80f55bbe9dcfc3ed796d5c2d60e79adb58 SHA512 ede5899daa1984c5aa8cacb1c850eb53f189dddef3d9bb78bf9774d8976b7c0d6eb0bcf86237cd7d11f5b36cf5b5058d42cd94d3bd76f2bd0931c7ceb1271fae
DIST grub-2.06.tar.xz 6581924 BLAKE2B 2a40b9b03d7bb3b9e7b1309ab274d686f01b3c42e7035ebc6e5a0e59a59c3b7362ba518341664b314cb0dbc8222bb10ea05ce09f08ce9d58a293207cb909e417 SHA512 4f11c648f3078567e53fc0c74d5026fdc6da4be27d188975e79d9a4df817ade0fe5ad2ddd694238a07edc45adfa02943d83c57767dd51548102b375e529e8efe
DIST unifont-12.1.02.pcf.gz 1335424 BLAKE2B 97080312468e3f3c8aa6f49cef08f5622641e8c9c035f3ede1e09d8d98de4e78d3b23c8aba2e8070eb46cbebd2d55e8568e467d7f15f35aa8fc8db792b7e5f14 SHA512 b280b2db7cf5f480b0668c331130dede2c0cc87d5e02e44566b77787113d0f6604d0105522858288f2ac6b8e77df7a2d9878725013a6c778dc5bfb183156e2f0
+EBUILD grub-2.06-r1.ebuild 8088 BLAKE2B e097c58fd5a8df8e1859131f69c90209ad3c1268608f418ebf3e725f74978bf0e465d92afc0ac985c29d009e23507b467931d135d8d1c0ca3fe5439021263963 SHA512 520e926cf09b1cf4a82509ebfa204df623156bf68436da6a72c13677337bde0702f4b2ea851f7691f2ef3f4f5b5373ebfe55b0edd18c3361115b106a6ad1a650
EBUILD grub-2.06.ebuild 7548 BLAKE2B d8c7ba5110cd4b8483a80255e80f3d61c99d8ced45c862ac319c5b5196b3cc2f7d7a4b9eeae378d6c1da01863dec3a7e86ed092559db9c7f47ac46b6be515599 SHA512 aabf4dc758ed3a0fb07f57eede1130f9e48e92c20cfb1992e629c2b4bca0e8e446b28deb7c74f4230b74bbf6240a6e027955133126c9592158afed9ae17e8506
MISC metadata.xml 985 BLAKE2B 36f108b5d3441f8576609c77ab3547c60ac2c508b55472bd0ec0e3af8d0fa018d305d7267c0e2e84c8526affced9ed5ce51738b9fcf05b31ac36c1b4d5c2702a SHA512 bd28dd88d4eb76a32cfa757eb5bf7641d033f670280ab7230b72a66b1bd8fd65c777473b1d7f81257004a215fe5a858a79a6a912e0ceaecd586867e9a76f6b4e
diff --git a/sys-boot/grub/files/grub-2.06-001-loader-drop-argv-in-grub_initrd_load.patch b/sys-boot/grub/files/grub-2.06-001-loader-drop-argv-in-grub_initrd_load.patch
new file mode 100644
index 0000000..66d91dd
--- /dev/null
+++ b/sys-boot/grub/files/grub-2.06-001-loader-drop-argv-in-grub_initrd_load.patch
@@ -0,0 +1,173 @@
+
+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>
+---
+ grub-core/loader/arm/linux.c | 2 +-
+ grub-core/loader/arm64/linux.c | 2 +-
+ grub-core/loader/i386/linux.c | 2 +-
+ grub-core/loader/i386/pc/linux.c | 2 +-
+ grub-core/loader/i386/xen.c | 3 +--
+ grub-core/loader/ia64/efi/linux.c | 2 +-
+ grub-core/loader/linux.c | 4 ++--
+ grub-core/loader/mips/linux.c | 2 +-
+ grub-core/loader/powerpc/ieee1275/linux.c | 2 +-
+ grub-core/loader/sparc64/ieee1275/linux.c | 2 +-
+ include/grub/linux.h | 2 +-
+ 11 files changed, 12 insertions(+), 13 deletions(-)
+
+diff --git a/grub-core/loader/arm/linux.c b/grub-core/loader/arm/linux.c
+index ed23dc71e..1f7ab7578 100644
+--- a/grub-core/loader/arm/linux.c
++++ b/grub-core/loader/arm/linux.c
+@@ -422,7 +422,7 @@ grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)),
+ grub_dprintf ("loader", "Loading initrd to 0x%08x\n",
+ (grub_addr_t) initrd_start);
+
+- if (grub_initrd_load (&initrd_ctx, argv, (void *) initrd_start))
++ if (grub_initrd_load (&initrd_ctx, (void *) initrd_start))
+ goto fail;
+
+ 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
+--- 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)),
+ goto fail;
+ }
+
+- if (grub_initrd_load (&initrd_ctx, argv, initrd_mem))
++ if (grub_initrd_load (&initrd_ctx, initrd_mem))
+ goto fail;
+
+ initrd_start = (grub_addr_t) initrd_mem;
+diff --git a/grub-core/loader/i386/linux.c b/grub-core/loader/i386/linux.c
+index 9f74a96b1..f30a1586a 100644
+--- a/grub-core/loader/i386/linux.c
++++ b/grub-core/loader/i386/linux.c
+@@ -1107,7 +1107,7 @@ grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)),
+ initrd_mem_target = get_physical_target_address (ch);
+ }
+
+- if (grub_initrd_load (&initrd_ctx, argv, initrd_mem))
++ if (grub_initrd_load (&initrd_ctx, initrd_mem))
+ goto fail;
+
+ grub_dprintf ("linux", "Initrd, addr=0x%x, size=0x%x\n",
+diff --git a/grub-core/loader/i386/pc/linux.c b/grub-core/loader/i386/pc/linux.c
+index 2a2995201..efeeeb206 100644
+--- a/grub-core/loader/i386/pc/linux.c
++++ b/grub-core/loader/i386/pc/linux.c
+@@ -462,7 +462,7 @@ grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)),
+ initrd_addr = get_physical_target_address (ch);
+ }
+
+- if (grub_initrd_load (&initrd_ctx, argv, initrd_chunk))
++ if (grub_initrd_load (&initrd_ctx, initrd_chunk))
+ goto fail;
+
+ lh->ramdisk_image = initrd_addr;
+diff --git a/grub-core/loader/i386/xen.c b/grub-core/loader/i386/xen.c
+index cd24874ca..3b856e842 100644
+--- a/grub-core/loader/i386/xen.c
++++ b/grub-core/loader/i386/xen.c
+@@ -809,8 +809,7 @@ grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)),
+ if (err)
+ goto fail;
+
+- if (grub_initrd_load (&initrd_ctx, argv,
+- get_virtual_current_address (ch)))
++ if (grub_initrd_load (&initrd_ctx, get_virtual_current_address (ch)))
+ goto fail;
+ }
+
+diff --git a/grub-core/loader/ia64/efi/linux.c b/grub-core/loader/ia64/efi/linux.c
+index 7987fd1ba..8873b7a55 100644
+--- a/grub-core/loader/ia64/efi/linux.c
++++ b/grub-core/loader/ia64/efi/linux.c
+@@ -563,7 +563,7 @@ grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)),
+ grub_dprintf ("linux", "[addr=0x%lx, size=0x%lx]\n",
+ (grub_uint64_t) initrd_mem, initrd_size);
+
+- if (grub_initrd_load (&initrd_ctx, argv, initrd_mem))
++ if (grub_initrd_load (&initrd_ctx, initrd_mem))
+ goto fail;
+ fail:
+ grub_initrd_close (&initrd_ctx);
+diff --git a/grub-core/loader/linux.c b/grub-core/loader/linux.c
+index 3fe390f17..d19df670e 100644
+--- a/grub-core/loader/linux.c
++++ b/grub-core/loader/linux.c
+@@ -271,7 +271,7 @@ grub_initrd_close (struct grub_linux_initrd_context *initrd_ctx)
+
+ grub_err_t
+ grub_initrd_load (struct grub_linux_initrd_context *initrd_ctx,
+- char *argv[], void *target)
++ void *target)
+ {
+ grub_uint8_t *ptr = target;
+ int i;
+@@ -317,7 +317,7 @@ grub_initrd_load (struct grub_linux_initrd_context *initrd_ctx,
+ {
+ if (!grub_errno)
+ grub_error (GRUB_ERR_FILE_READ_ERROR, N_("premature end of file %s"),
+- argv[i]);
++ initrd_ctx->components[i].file->name);
+ grub_initrd_close (initrd_ctx);
+ return grub_errno;
+ }
+diff --git a/grub-core/loader/mips/linux.c b/grub-core/loader/mips/linux.c
+index e4ed95921..94594721d 100644
+--- a/grub-core/loader/mips/linux.c
++++ b/grub-core/loader/mips/linux.c
+@@ -452,7 +452,7 @@ grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)),
+ initrd_dest = get_physical_target_address (ch) | 0x80000000;
+ }
+
+- if (grub_initrd_load (&initrd_ctx, argv, initrd_src))
++ if (grub_initrd_load (&initrd_ctx, initrd_src))
+ goto fail;
+
+ #ifdef GRUB_MACHINE_MIPS_QEMU_MIPS
+diff --git a/grub-core/loader/powerpc/ieee1275/linux.c b/grub-core/loader/powerpc/ieee1275/linux.c
+index 818b2a86d..a51e7a786 100644
+--- a/grub-core/loader/powerpc/ieee1275/linux.c
++++ b/grub-core/loader/powerpc/ieee1275/linux.c
+@@ -363,7 +363,7 @@ grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)),
+
+ grub_dprintf ("loader", "Loading initrd at 0x%x, size 0x%x\n", addr, size);
+
+- if (grub_initrd_load (&initrd_ctx, argv, (void *) addr))
++ if (grub_initrd_load (&initrd_ctx, (void *) addr))
+ goto fail;
+
+ initrd_addr = addr;
+diff --git a/grub-core/loader/sparc64/ieee1275/linux.c b/grub-core/loader/sparc64/ieee1275/linux.c
+index bb47ee0cc..ac2206f3c 100644
+--- a/grub-core/loader/sparc64/ieee1275/linux.c
++++ b/grub-core/loader/sparc64/ieee1275/linux.c
+@@ -413,7 +413,7 @@ grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)),
+ grub_dprintf ("loader", "Loading initrd at vaddr 0x%lx, paddr 0x%lx, size 0x%lx\n",
+ addr, paddr, size);
+
+- if (grub_initrd_load (&initrd_ctx, argv, (void *) addr))
++ if (grub_initrd_load (&initrd_ctx, (void *) addr))
+ goto fail;
+
+ initrd_addr = addr;
+diff --git a/include/grub/linux.h b/include/grub/linux.h
+index 594a3f307..a96ac2048 100644
+--- a/include/grub/linux.h
++++ b/include/grub/linux.h
+@@ -21,4 +21,4 @@ grub_initrd_close (struct grub_linux_initrd_context *initrd_ctx);
+
+ grub_err_t
+ grub_initrd_load (struct grub_linux_initrd_context *initrd_ctx,
+- char *argv[], void *target);
++ void *target);
+--
+2.29.3
diff --git a/sys-boot/grub/files/grub-2.06-002-efi-add-definition-of-loadfile2-protocol.patch b/sys-boot/grub/files/grub-2.06-002-efi-add-definition-of-loadfile2-protocol.patch
new file mode 100644
index 0000000..35777b5
--- /dev/null
+++ b/sys-boot/grub/files/grub-2.06-002-efi-add-definition-of-loadfile2-protocol.patch
@@ -0,0 +1,58 @@
+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.29.3
diff --git a/sys-boot/grub/files/grub-2.06-003-efi-implemented-loadfile2-initrd-loading.patch b/sys-boot/grub/files/grub-2.06-003-efi-implemented-loadfile2-initrd-loading.patch
new file mode 100644
index 0000000..65fdf2e
--- /dev/null
+++ b/sys-boot/grub/files/grub-2.06-003-efi-implemented-loadfile2-initrd-loading.patch
@@ -0,0 +1,180 @@
+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.29.3
diff --git a/sys-boot/grub/files/grub-2.06-004-linux-ignore-fdt-unless-we-need-to-modify-it.patch b/sys-boot/grub/files/grub-2.06-004-linux-ignore-fdt-unless-we-need-to-modify-it.patch
new file mode 100644
index 0000000..0655fab
--- /dev/null
+++ b/sys-boot/grub/files/grub-2.06-004-linux-ignore-fdt-unless-we-need-to-modify-it.patch
@@ -0,0 +1,77 @@
+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>
+---
+ 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
+--- a/grub-core/loader/arm64/linux.c
++++ b/grub-core/loader/arm64/linux.c
+@@ -95,21 +95,21 @@ finalize_params_linux (void)
+
+ void *fdt;
+
+- fdt = grub_fdt_load (GRUB_EFI_LINUX_FDT_EXTRA_SPACE);
++ /* Set initrd info */
++ if (initrd_start && initrd_end > initrd_start)
++ {
++ fdt = grub_fdt_load (GRUB_EFI_LINUX_FDT_EXTRA_SPACE);
+
+- if (!fdt)
+- goto failure;
++ if (!fdt)
++ 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");
+
+- if (node < 1)
+- goto failure;
++ if (node < 1)
++ goto failure;
+
+- /* Set initrd info */
+- if (initrd_start && initrd_end > initrd_start)
+- {
+ grub_dprintf ("linux", "Initrd @ %p-%p\n",
+ (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
+--- 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)
++ 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);
+ 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);
+ return GRUB_ERR_NONE;
+ }
+
+--
+2.29.3
diff --git a/sys-boot/grub/files/grub-2.06-005-loader-move-arm64-linux-loader.patch b/sys-boot/grub/files/grub-2.06-005-loader-move-arm64-linux-loader.patch
new file mode 100644
index 0000000..4a98b44
--- /dev/null
+++ b/sys-boot/grub/files/grub-2.06-005-loader-move-arm64-linux-loader.patch
@@ -0,0 +1,73 @@
+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>
+---
+ grub-core/Makefile.core.def | 4 ++--
+ grub-core/loader/{arm64 => efi}/linux.c | 2 +-
+ 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%)
+
+diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def
+index 8022e1c0a..b36cf663a 100644
+--- a/grub-core/Makefile.core.def
++++ b/grub-core/Makefile.core.def
+@@ -1806,9 +1806,9 @@ module = {
+ sparc64_ieee1275 = loader/sparc64/ieee1275/linux.c;
+ ia64_efi = loader/ia64/efi/linux.c;
+ arm_coreboot = loader/arm/linux.c;
+- arm_efi = loader/arm64/linux.c;
++ arm_efi = loader/efi/linux.c;
+ arm_uboot = loader/arm/linux.c;
+- arm64 = loader/arm64/linux.c;
++ arm64 = loader/efi/linux.c;
+ riscv32 = loader/riscv/linux.c;
+ 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%
+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
+--- a/include/grub/arm/linux.h
++++ b/include/grub/arm/linux.h
+@@ -35,7 +35,7 @@ struct linux_arm_kernel_header {
+ };
+
+ #if defined(__arm__)
+-# define GRUB_LINUX_ARMXX_MAGIC_SIGNATURE GRUB_LINUX_ARM_MAGIC_SIGNATURE
++# define GRUB_LINUX_ARCH_MAGIC_SIGNATURE GRUB_LINUX_ARM_MAGIC_SIGNATURE
+ # define linux_arch_kernel_header linux_arm_kernel_header
+ #endif
+
+diff --git a/include/grub/arm64/linux.h b/include/grub/arm64/linux.h
+index 7e22b4ab6..effd870ef 100644
+--- a/include/grub/arm64/linux.h
++++ b/include/grub/arm64/linux.h
+@@ -39,7 +39,7 @@ struct linux_arm64_kernel_header
+ };
+
+ #if defined(__aarch64__)
+-# define GRUB_LINUX_ARMXX_MAGIC_SIGNATURE GRUB_LINUX_ARM64_MAGIC_SIGNATURE
++# define GRUB_LINUX_ARCH_MAGIC_SIGNATURE GRUB_LINUX_ARM64_MAGIC_SIGNATURE
+ # define linux_arch_kernel_header linux_arm64_kernel_header
+ #endif
+
+--
+2.29.3
diff --git a/sys-boot/grub/files/grub-2.06-006-riscv-update-image-header.patch b/sys-boot/grub/files/grub-2.06-006-riscv-update-image-header.patch
new file mode 100644
index 0000000..5ebd4f2
--- /dev/null
+++ b/sys-boot/grub/files/grub-2.06-006-riscv-update-image-header.patch
@@ -0,0 +1,81 @@
+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>
+---
+ include/grub/riscv32/linux.h | 15 ++++++++-------
+ include/grub/riscv64/linux.h | 15 ++++++++-------
+ 2 files changed, 16 insertions(+), 14 deletions(-)
+
+diff --git a/include/grub/riscv32/linux.h b/include/grub/riscv32/linux.h
+index 512b777c8..de0dbdcd1 100644
+--- a/include/grub/riscv32/linux.h
++++ b/include/grub/riscv32/linux.h
+@@ -19,20 +19,21 @@
+ #ifndef GRUB_RISCV32_LINUX_HEADER
+ #define GRUB_RISCV32_LINUX_HEADER 1
+
+-#define GRUB_LINUX_RISCV_MAGIC_SIGNATURE 0x52534356 /* 'RSCV' */
++#define GRUB_LINUX_RISCV_MAGIC_SIGNATURE 0x05435352 /* 'RSC\0x5' */
+
+-/* From linux/Documentation/riscv/booting.txt */
++/* From linux/Documentation/riscv/boot-image-header.rst */
+ struct linux_riscv_kernel_header
+ {
+ grub_uint32_t code0; /* Executable code */
+ grub_uint32_t code1; /* Executable code */
+- grub_uint64_t text_offset; /* Image load offset */
+- grub_uint64_t res0; /* reserved */
+- grub_uint64_t res1; /* reserved */
++ grub_uint64_t text_offset; /* Image load offset, little endian */
++ grub_uint64_t image_size; /* Effective Image size, little endian */
++ grub_uint64_t flags; /* kernel flags, little endian */
++ grub_uint32_t version; /* Version of this header */
++ grub_uint32_t res1; /* reserved */
+ grub_uint64_t res2; /* reserved */
+ grub_uint64_t res3; /* reserved */
+- grub_uint64_t res4; /* reserved */
+- grub_uint32_t magic; /* Magic number, little endian, "RSCV" */
++ grub_uint32_t magic; /* Magic number, little endian, "RSC\x05" */
+ grub_uint32_t hdr_offset; /* Offset of PE/COFF header */
+ };
+
+diff --git a/include/grub/riscv64/linux.h b/include/grub/riscv64/linux.h
+index 3630c30fb..7c28bc922 100644
+--- a/include/grub/riscv64/linux.h
++++ b/include/grub/riscv64/linux.h
+@@ -19,22 +19,23 @@
+ #ifndef GRUB_RISCV64_LINUX_HEADER
+ #define GRUB_RISCV64_LINUX_HEADER 1
+
+-#define GRUB_LINUX_RISCV_MAGIC_SIGNATURE 0x52534356 /* 'RSCV' */
++#define GRUB_LINUX_RISCV_MAGIC_SIGNATURE 0x05435352 /* 'RSC\0x5' */
+
+ #define GRUB_EFI_PE_MAGIC 0x5A4D
+
+-/* From linux/Documentation/riscv/booting.txt */
++/* From linux/Documentation/riscv/boot-image-header.rst */
+ struct linux_riscv_kernel_header
+ {
+ grub_uint32_t code0; /* Executable code */
+ grub_uint32_t code1; /* Executable code */
+- grub_uint64_t text_offset; /* Image load offset */
+- grub_uint64_t res0; /* reserved */
+- grub_uint64_t res1; /* reserved */
++ grub_uint64_t text_offset; /* Image load offset, little endian */
++ grub_uint64_t image_size; /* Effective Image size, little endian */
++ grub_uint64_t flags; /* kernel flags, little endian */
++ grub_uint32_t version; /* Version of this header */
++ grub_uint32_t res1; /* reserved */
+ grub_uint64_t res2; /* reserved */
+ grub_uint64_t res3; /* reserved */
+- grub_uint64_t res4; /* reserved */
+- grub_uint32_t magic; /* Magic number, little endian, "RSCV" */
++ grub_uint32_t magic; /* Magic number, little endian, "RSC\x05" */
+ grub_uint32_t hdr_offset; /* Offset of PE/COFF header */
+ };
+
+--
+2.29.3
diff --git a/sys-boot/grub/files/grub-2.06-007-riscv-use-common-linux-loader.patch b/sys-boot/grub/files/grub-2.06-007-riscv-use-common-linux-loader.patch
new file mode 100644
index 0000000..525d3a9
--- /dev/null
+++ b/sys-boot/grub/files/grub-2.06-007-riscv-use-common-linux-loader.patch
@@ -0,0 +1,117 @@
+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>
+---
+ grub-core/Makefile.core.def | 4 +--
+ grub-core/loader/riscv/linux.c | 59 ----------------------------------
+ include/grub/riscv32/linux.h | 1 +
+ include/grub/riscv64/linux.h | 1 +
+ 4 files changed, 4 insertions(+), 61 deletions(-)
+ delete mode 100644 grub-core/loader/riscv/linux.c
+
+diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def
+index b36cf663a..0536575bc 100644
+--- a/grub-core/Makefile.core.def
++++ b/grub-core/Makefile.core.def
+@@ -1809,8 +1809,8 @@ module = {
+ arm_efi = loader/efi/linux.c;
+ arm_uboot = loader/arm/linux.c;
+ arm64 = loader/efi/linux.c;
+- riscv32 = loader/riscv/linux.c;
+- riscv64 = loader/riscv/linux.c;
++ riscv32 = loader/efi/linux.c;
++ riscv64 = loader/efi/linux.c;
+ common = loader/linux.c;
+ common = lib/cmdline.c;
+ enable = noemu;
+diff --git a/grub-core/loader/riscv/linux.c b/grub-core/loader/riscv/linux.c
+deleted file mode 100644
+index d17c488e1..000000000
+--- a/grub-core/loader/riscv/linux.c
++++ /dev/null
+@@ -1,59 +0,0 @@
+-/*
+- * GRUB -- GRand Unified Bootloader
+- * Copyright (C) 2018 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/>.
+- */
+-
+-#include <grub/command.h>
+-#include <grub/dl.h>
+-#include <grub/lib/cmdline.h>
+-
+-GRUB_MOD_LICENSE ("GPLv3+");
+-
+-static grub_err_t
+-grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)),
+- int argc __attribute__ ((unused)),
+- char *argv[] __attribute__ ((unused)))
+-{
+- grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET, N_("Linux not supported yet"));
+-
+- return grub_errno;
+-}
+-
+-static grub_err_t
+-grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)),
+- int argc __attribute__ ((unused)),
+- char *argv[] __attribute__ ((unused)))
+-{
+- grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET, N_("Linux not supported yet"));
+-
+- return grub_errno;
+-}
+-
+-static grub_command_t cmd_linux, cmd_initrd;
+-
+-GRUB_MOD_INIT (linux)
+-{
+- cmd_linux = grub_register_command ("linux", grub_cmd_linux, 0,
+- N_("Load Linux."));
+- cmd_initrd = grub_register_command ("initrd", grub_cmd_initrd, 0,
+- N_("Load initrd."));
+-}
+-
+-GRUB_MOD_FINI (linux)
+-{
+- grub_unregister_command (cmd_linux);
+- grub_unregister_command (cmd_initrd);
+-}
+diff --git a/include/grub/riscv32/linux.h b/include/grub/riscv32/linux.h
+index de0dbdcd1..706c69087 100644
+--- a/include/grub/riscv32/linux.h
++++ b/include/grub/riscv32/linux.h
+@@ -38,5 +38,6 @@ struct linux_riscv_kernel_header
+ };
+
+ #define linux_arch_kernel_header linux_riscv_kernel_header
++# define GRUB_LINUX_ARCH_MAGIC_SIGNATURE GRUB_LINUX_RISCV_MAGIC_SIGNATURE
+
+ #endif /* ! GRUB_RISCV32_LINUX_HEADER */
+diff --git a/include/grub/riscv64/linux.h b/include/grub/riscv64/linux.h
+index 7c28bc922..88d5df781 100644
+--- a/include/grub/riscv64/linux.h
++++ b/include/grub/riscv64/linux.h
+@@ -40,5 +40,6 @@ struct linux_riscv_kernel_header
+ };
+
+ #define linux_arch_kernel_header linux_riscv_kernel_header
++# define GRUB_LINUX_ARCH_MAGIC_SIGNATURE GRUB_LINUX_RISCV_MAGIC_SIGNATURE
+
+ #endif /* ! GRUB_RISCV64_LINUX_HEADER */
+--
+2.29.3
diff --git a/sys-boot/grub/files/grub-2.06-010-efi-device-tree-fixup-protocol.patch b/sys-boot/grub/files/grub-2.06-010-efi-device-tree-fixup-protocol.patch
new file mode 100644
index 0000000..ee7c122
--- /dev/null
+++ b/sys-boot/grub/files/grub-2.06-010-efi-device-tree-fixup-protocol.patch
@@ -0,0 +1,135 @@
+Device-trees are used to convey information about hardware to the operating
+system. Some of the properties are only known at boot time. (One example of
+such a property is the number of the boot hart on RISC-V systems.) Therefore
+the firmware applies fix-ups to the original device-tree. Some nodes and
+properties are added or altered.
+
+When using GRUB's device-tree command the same fix-ups have to be applied.
+The EFI Device Tree Fixup Protocol allows to pass the loaded device tree
+to the firmware for this purpose.
+
+The protocol can
+
+* add nodes and update properties
+* reserve memory according to the /reserved-memory node and the memory
+ reservation block
+* install the device-tree as configuration table
+
+With the patch GRUB checks if the protocol is installed and invokes it if
+available.
+
+Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
+---
+ grub-core/loader/efi/fdt.c | 35 ++++++++++++++++++++++++++++++++++-
+ include/grub/efi/api.h | 22 ++++++++++++++++++++++
+ 2 files changed, 56 insertions(+), 1 deletion(-)
+
+diff --git a/grub-core/loader/efi/fdt.c b/grub-core/loader/efi/fdt.c
+index 57ee81686..58e95eb05 100644
+--- a/grub-core/loader/efi/fdt.c
++++ b/grub-core/loader/efi/fdt.c
+@@ -29,6 +29,7 @@
+
+ static void *loaded_fdt;
+ static void *fdt;
++static grub_efi_guid_t dt_fixup_guid = GRUB_EFI_DT_FIXUP_PROTOCOL_GUID;
+
+ #define FDT_ADDR_CELLS_STRING "#address-cells"
+ #define FDT_SIZE_CELLS_STRING "#size-cells"
+@@ -36,6 +37,38 @@ static void *fdt;
+ sizeof (FDT_ADDR_CELLS_STRING) + \
+ sizeof (FDT_SIZE_CELLS_STRING))
+
++static void *grub_fdt_fixup (void)
++{
++ grub_efi_dt_fixup_t *dt_fixup_prot;
++ grub_efi_uintn_t size = 0;
++ grub_efi_status_t status;
++ void *fixup_fdt;
++
++ dt_fixup_prot = grub_efi_locate_protocol (&dt_fixup_guid, 0);
++ if (! dt_fixup_prot)
++ return loaded_fdt;
++
++ grub_dprintf ("linux", "EFI_DT_FIXUP_PROTOCOL available\n");
++
++ status = efi_call_4 (dt_fixup_prot->fixup, dt_fixup_prot, loaded_fdt, &size,
++ GRUB_EFI_DT_APPLY_FIXUPS | GRUB_EFI_DT_RESERVE_MEMORY);
++ if (status != GRUB_EFI_BUFFER_TOO_SMALL)
++ return loaded_fdt;
++
++ fixup_fdt = grub_realloc (loaded_fdt, size);
++ if (!fixup_fdt)
++ return loaded_fdt;
++ loaded_fdt = fixup_fdt;
++
++ status = efi_call_4 (dt_fixup_prot->fixup, dt_fixup_prot, loaded_fdt, &size,
++ GRUB_EFI_DT_APPLY_FIXUPS | GRUB_EFI_DT_RESERVE_MEMORY);
++
++ if (status == GRUB_EFI_SUCCESS)
++ grub_dprintf ("linux", "Device tree fixed up via EFI_DT_FIXUP_PROTOCOL\n");
++
++ return loaded_fdt;
++}
++
+ void *
+ grub_fdt_load (grub_size_t additional_size)
+ {
+@@ -49,7 +82,7 @@ grub_fdt_load (grub_size_t additional_size)
+ }
+
+ if (loaded_fdt)
+- raw_fdt = loaded_fdt;
++ raw_fdt = grub_fdt_fixup();
+ else
+ raw_fdt = grub_efi_get_firmware_fdt();
+
+diff --git a/include/grub/efi/api.h b/include/grub/efi/api.h
+index 34109861a..8101df0df 100644
+--- a/include/grub/efi/api.h
++++ b/include/grub/efi/api.h
+@@ -334,6 +334,11 @@
+ { 0x83, 0x0b, 0xd9, 0x15, 0x2c, 0x69, 0xaa, 0xe0 } \
+ }
+
++#define GRUB_EFI_DT_FIXUP_PROTOCOL_GUID \
++ { 0xe617d64c, 0xfe08, 0x46da, \
++ { 0xf4, 0xdc, 0xbb, 0xd5, 0x87, 0x0c, 0x73, 0x00 } \
++ }
++
+ #define GRUB_EFI_VENDOR_APPLE_GUID \
+ { 0x2B0585EB, 0xD8B8, 0x49A9, \
+ { 0x8B, 0x8C, 0xE2, 0x1B, 0x01, 0xAE, 0xF2, 0xB7 } \
+@@ -1641,6 +1646,13 @@ enum
+ GRUB_EFI_SIMPLE_NETWORK_RECEIVE_PROMISCUOUS_MULTICAST = 0x10,
+ };
+
++enum
++ {
++ GRUB_EFI_DT_APPLY_FIXUPS = 0x01,
++ GRUB_EFI_DT_RESERVE_MEMORY = 0x02,
++ GRUB_EFI_EFI_DT_INSTALL_TABLE = 0x04,
++ };
++
+ struct grub_efi_simple_network
+ {
+ grub_uint64_t revision;
+@@ -1704,6 +1716,16 @@ struct grub_efi_block_io
+ };
+ typedef struct grub_efi_block_io grub_efi_block_io_t;
+
++struct grub_efi_dt_fixup
++{
++ grub_efi_uint64_t revision;
++ grub_efi_status_t (*fixup) (struct grub_efi_dt_fixup *this,
++ void *fdt,
++ grub_efi_uintn_t *buffer_size,
++ grub_uint32_t flags);
++};
++typedef struct grub_efi_dt_fixup grub_efi_dt_fixup_t;
++
+ struct grub_efi_shim_lock_protocol
+ {
+ grub_efi_status_t (*verify) (void *buffer, grub_uint32_t size);
+--
+2.30.0
diff --git a/sys-boot/grub/files/grub-2.06-011-support-loading-device-trees.patch b/sys-boot/grub/files/grub-2.06-011-support-loading-device-trees.patch
new file mode 100644
index 0000000..f892376
--- /dev/null
+++ b/sys-boot/grub/files/grub-2.06-011-support-loading-device-trees.patch
@@ -0,0 +1,73 @@
+diff --git a/docs/grub.texi b/docs/grub.texi
+index eeac9b2ce..64cf95e6f 100644
+--- a/docs/grub.texi
++++ b/docs/grub.texi
+@@ -1560,6 +1560,12 @@ This option may be set to a list of GRUB module names separated by spaces.
+ Each module will be loaded as early as possible, at the start of
+ @file{grub.cfg}.
+
++@item GRUB_LOAD_DEVICE_TREE
++If this option is set to @samp{true}, a devicetree command will be added
++to the Linux menu entries in @file{grub.cfg}. Device-trees require fix-ups
++by the firmware. You should use this option only if your firmware supports
++the EFI Device Tree Fixup Protocol.
++
+ @end table
+
+ The following options are still accepted for compatibility with existing
+diff --git a/util/grub-mkconfig.in b/util/grub-mkconfig.in
+index d3e879b8e..3d7fd54f3 100644
+--- a/util/grub-mkconfig.in
++++ b/util/grub-mkconfig.in
+@@ -230,6 +230,7 @@ export GRUB_DEFAULT \
+ GRUB_CMDLINE_GNUMACH \
+ GRUB_EARLY_INITRD_LINUX_CUSTOM \
+ GRUB_EARLY_INITRD_LINUX_STOCK \
++ GRUB_LOAD_DEVICETREE \
+ GRUB_TERMINAL_INPUT \
+ GRUB_TERMINAL_OUTPUT \
+ GRUB_SERIAL_COMMAND \
+diff --git a/util/grub.d/10_linux.in b/util/grub.d/10_linux.in
+index e8b01c0d0..15bc26ba8 100644
+--- a/util/grub.d/10_linux.in
++++ b/util/grub.d/10_linux.in
+@@ -143,6 +143,15 @@ linux_entry ()
+ echo '$(echo "$message" | grub_quote)'
+ linux ${rel_dirname}/${basename} root=${linux_root_device_thisversion} ro ${args}
+ EOF
++ if [ "x${GRUB_LOAD_DEVICETREE}" = "xtrue" ]; then
++ if test -n "${dtb}" ; then
++ message="$(gettext_printf "Loading device tree ...")"
++ sed "s/^/$submenu_indentation/" << EOF
++ echo '$(echo "$message" | grub_quote)'
++ devicetree ${rel_dirname}/${dtb}
++EOF
++ fi
++ fi
+ if test -n "${initrd}" ; then
+ # TRANSLATORS: ramdisk isn't identifier. Should be translated.
+ message="$(gettext_printf "Loading initial ramdisk ...")"
+@@ -244,6 +253,20 @@ while [ "x$list" != "x" ] ; do
+ fi
+ done
+
++ if [ "x${GRUB_LOAD_DEVICETREE}" = "xtrue" ]; then
++ dtb=
++ for i in "dtb-${version}" "dtb" ; do
++ if test -e "${dirname}/${i}" ; then
++ dtb="${i}"
++ break
++ fi
++ done
++
++ if test -n "${dtb}" ; then
++ gettext_printf "Found dtb: %s\n" "${dirname}/${dtb}" >&2
++ fi
++ fi
++
+ initramfs=
+ if test -n "${config}" ; then
+ initramfs=`grep CONFIG_INITRAMFS_SOURCE= "${config}" | cut -f2 -d= | tr
+-d \"`
+--
+2.30.0
diff --git a/sys-boot/grub/files/grub-2.06-012-move-load-fdt.patch b/sys-boot/grub/files/grub-2.06-012-move-load-fdt.patch
new file mode 100644
index 0000000..b348225
--- /dev/null
+++ b/sys-boot/grub/files/grub-2.06-012-move-load-fdt.patch
@@ -0,0 +1,21 @@
+--- grub-2.06/grub-core/loader/efi/linux.c 2021-08-25 11:30:12.186661512 +0200
++++ grub-2.06-mod/grub-core/loader/efi/linux.c 2021-08-25 11:25:50.337761208 +0200
+@@ -95,13 +95,14 @@
+
+ void *fdt;
+
++ fdt = grub_fdt_load (GRUB_EFI_LINUX_FDT_EXTRA_SPACE);
++
++ if (!fdt)
++ goto failure;
++
+ /* Set initrd info */
+ if (initrd_start && initrd_end > initrd_start)
+ {
+- fdt = grub_fdt_load (GRUB_EFI_LINUX_FDT_EXTRA_SPACE);
+-
+- if (!fdt)
+- goto failure;
+
+ node = grub_fdt_find_subnode (fdt, 0, "chosen");
+ if (node < 0)
diff --git a/sys-boot/grub/grub-2.06-r1.ebuild b/sys-boot/grub/grub-2.06-r1.ebuild
new file mode 100644
index 0000000..bf8e7c0
--- /dev/null
+++ b/sys-boot/grub/grub-2.06-r1.ebuild
@@ -0,0 +1,315 @@
+# Copyright 1999-2021 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=7
+
+if [[ ${PV} == 9999 ]]; then
+ GRUB_AUTORECONF=1
+ GRUB_BOOTSTRAP=1
+fi
+GRUB_AUTOGEN=1
+GRUB_AUTORECONF=1
+
+PYTHON_COMPAT=( python{2_7,3_{6,7,8,9}} )
+WANT_LIBTOOL=none
+
+if [[ -n ${GRUB_AUTOGEN} || -n ${GRUB_BOOTSTRAP} ]]; then
+ inherit python-any-r1
+fi
+
+if [[ -n ${GRUB_AUTORECONF} ]]; then
+ inherit autotools
+fi
+
+inherit bash-completion-r1 flag-o-matic multibuild optfeature pax-utils toolchain-funcs
+
+if [[ ${PV} != 9999 ]]; then
+ if [[ ${PV} == *_alpha* || ${PV} == *_beta* || ${PV} == *_rc* ]]; then
+ # The quote style is to work with <=bash-4.2 and >=bash-4.3 #503860
+ MY_P=${P/_/'~'}
+ SRC_URI="https://alpha.gnu.org/gnu/${PN}/${MY_P}.tar.xz"
+ S=${WORKDIR}/${MY_P}
+ else
+ SRC_URI="mirror://gnu/${PN}/${P}.tar.xz"
+ S=${WORKDIR}/${P%_*}
+ fi
+ KEYWORDS="~amd64 ~arm ~arm64 ~ia64 ~ppc ~ppc64 ~sparc ~x86"
+else
+ inherit git-r3
+ EGIT_REPO_URI="https://git.savannah.gnu.org/git/grub.git"
+fi
+
+PATCHES=(
+ "${FILESDIR}"/gfxpayload.patch
+ "${FILESDIR}"/grub-2.02_beta2-KERNEL_GLOBS.patch
+ "${FILESDIR}"/grub-2.06-test-words.patch
+ "${FILESDIR}/"grub-2.06-001-loader-drop-argv-in-grub_initrd_load.patch
+ "${FILESDIR}"/grub-2.06-002-efi-add-definition-of-loadfile2-protocol.patch
+ "${FILESDIR}"/grub-2.06-003-efi-implemented-loadfile2-initrd-loading.patch
+ "${FILESDIR}"/grub-2.06-004-linux-ignore-fdt-unless-we-need-to-modify-it.patch
+ "${FILESDIR}"/grub-2.06-005-loader-move-arm64-linux-loader.patch
+ "${FILESDIR}"/grub-2.06-006-riscv-update-image-header.patch
+ "${FILESDIR}"/grub-2.06-007-riscv-use-common-linux-loader.patch
+ "${FILESDIR}"/grub-2.06-010-efi-device-tree-fixup-protocol.patch
+ "${FILESDIR}"/grub-2.06-011-support-loading-device-trees.patch
+ "${FILESDIR}"/grub-2.06-012-move-load-fdt.patch
+)
+
+
+DEJAVU=dejavu-sans-ttf-2.37
+UNIFONT=unifont-12.1.02
+SRC_URI+=" fonts? ( mirror://gnu/unifont/${UNIFONT}/${UNIFONT}.pcf.gz )
+ themes? ( mirror://sourceforge/dejavu/${DEJAVU}.zip )"
+
+DESCRIPTION="GNU GRUB boot loader"
+HOMEPAGE="https://www.gnu.org/software/grub/"
+
+# Includes licenses for dejavu and unifont
+LICENSE="GPL-3+ BSD MIT fonts? ( GPL-2-with-font-exception ) themes? ( CC-BY-SA-3.0 BitstreamVera )"
+SLOT="2/${PVR}"
+IUSE="device-mapper doc efiemu +fonts mount nls sdl test +themes truetype libzfs"
+
+GRUB_ALL_PLATFORMS=( coreboot efi-32 efi-64 emu ieee1275 loongson multiboot qemu qemu-mips pc uboot xen xen-32 xen-pvh efi )
+IUSE+=" ${GRUB_ALL_PLATFORMS[@]/#/grub_platforms_}"
+
+REQUIRED_USE="
+ grub_platforms_coreboot? ( fonts )
+ grub_platforms_qemu? ( fonts )
+ grub_platforms_ieee1275? ( fonts )
+ grub_platforms_loongson? ( fonts )
+"
+
+BDEPEND="
+ ${PYTHON_DEPS}
+ app-misc/pax-utils
+ sys-devel/flex
+ sys-devel/bison
+ sys-apps/help2man
+ sys-apps/texinfo
+ fonts? (
+ media-libs/freetype:2
+ virtual/pkgconfig
+ )
+ test? (
+ app-admin/genromfs
+ app-arch/cpio
+ app-arch/lzop
+ app-emulation/qemu
+ dev-libs/libisoburn
+ sys-apps/miscfiles
+ sys-block/parted
+ sys-fs/squashfs-tools
+ )
+ themes? (
+ app-arch/unzip
+ media-libs/freetype:2
+ virtual/pkgconfig
+ )
+ truetype? ( virtual/pkgconfig )
+"
+DEPEND="
+ app-arch/xz-utils
+ >=sys-libs/ncurses-5.2-r5:0=
+ grub_platforms_emu? (
+ sdl? ( media-libs/libsdl )
+ )
+ device-mapper? ( >=sys-fs/lvm2-2.02.45 )
+ libzfs? ( sys-fs/zfs:= )
+ mount? ( sys-fs/fuse:0 )
+ truetype? ( media-libs/freetype:2= )
+ ppc? ( >=sys-apps/ibm-powerpc-utils-1.3.5 )
+ ppc64? ( >=sys-apps/ibm-powerpc-utils-1.3.5 )
+"
+RDEPEND="${DEPEND}
+ kernel_linux? (
+ grub_platforms_efi-32? ( sys-boot/efibootmgr )
+ grub_platforms_efi-64? ( sys-boot/efibootmgr )
+ )
+ !sys-boot/grub:0
+ nls? ( sys-devel/gettext )
+"
+
+RESTRICT="!test? ( test )"
+
+QA_EXECSTACK="usr/bin/grub-emu* usr/lib/grub/*"
+QA_PRESTRIPPED="usr/lib/grub/.*"
+QA_MULTILIB_PATHS="usr/lib/grub/.*"
+QA_WX_LOAD="usr/lib/grub/*"
+
+pkg_setup() {
+ :
+}
+
+src_unpack() {
+ if [[ ${PV} == 9999 ]]; then
+ git-r3_src_unpack
+ pushd "${P}" >/dev/null || die
+ local GNULIB_URI="https://git.savannah.gnu.org/git/gnulib.git"
+ local GNULIB_REVISION=$(source bootstrap.conf >/dev/null; echo "${GNULIB_REVISION}")
+ git-r3_fetch "${GNULIB_URI}" "${GNULIB_REVISION}"
+ git-r3_checkout "${GNULIB_URI}" gnulib
+ popd >/dev/null || die
+ fi
+ default
+}
+
+src_prepare() {
+ default
+
+ sed -i -e /autoreconf/d autogen.sh || die
+
+ if [[ -n ${GRUB_AUTOGEN} || -n ${GRUB_BOOTSTRAP} ]]; then
+ python_setup
+ else
+ export PYTHON=true
+ fi
+
+ if [[ -n ${GRUB_BOOTSTRAP} ]]; then
+ eautopoint --force
+ AUTOPOINT=: AUTORECONF=: ./bootstrap || die
+ elif [[ -n ${GRUB_AUTOGEN} ]]; then
+ ./autogen.sh || die
+ fi
+
+ if [[ -n ${GRUB_AUTORECONF} ]]; then
+ eautoreconf
+ fi
+}
+
+grub_do() {
+ multibuild_foreach_variant run_in_build_dir "$@"
+}
+
+grub_do_once() {
+ multibuild_for_best_variant run_in_build_dir "$@"
+}
+
+grub_configure() {
+ local platform
+
+ case ${MULTIBUILD_VARIANT} in
+ efi*) platform=efi ;;
+ xen-pvh) platform=xen_pvh ;;
+ xen*) platform=xen ;;
+ guessed) ;;
+ *) platform=${MULTIBUILD_VARIANT} ;;
+ esac
+
+ case ${MULTIBUILD_VARIANT} in
+ *-32)
+ if [[ ${CTARGET:-${CHOST}} == x86_64* ]]; then
+ local CTARGET=i386
+ fi ;;
+ *-64)
+ if [[ ${CTARGET:-${CHOST}} == i?86* ]]; then
+ local CTARGET=x86_64
+ local -x TARGET_CFLAGS="-Os -march=x86-64 ${TARGET_CFLAGS}"
+ local -x TARGET_CPPFLAGS="-march=x86-64 ${TARGET_CPPFLAGS}"
+ fi ;;
+ esac
+
+ local myeconfargs=(
+ --disable-werror
+ --program-prefix=
+ --libdir="${EPREFIX}"/usr/lib
+ $(use_enable device-mapper)
+ $(use_enable mount grub-mount)
+ $(use_enable nls)
+ $(use_enable themes grub-themes)
+ $(use_enable truetype grub-mkfont)
+ $(use_enable libzfs)
+ $(use_enable sdl grub-emu-sdl)
+ ${platform:+--with-platform=}${platform}
+
+ # Let configure detect this where supported
+ $(usex efiemu '' '--disable-efiemu')
+ )
+
+ if use fonts; then
+ ln -rs "${WORKDIR}/${UNIFONT}.pcf" unifont.pcf || die
+ fi
+
+ if use themes; then
+ ln -rs "${WORKDIR}/${DEJAVU}/ttf/DejaVuSans.ttf" DejaVuSans.ttf || die
+ fi
+
+ local ECONF_SOURCE="${S}"
+ econf "${myeconfargs[@]}"
+}
+
+src_configure() {
+ # Bug 508758.
+ replace-flags -O3 -O2
+
+ # We don't want to leak flags onto boot code.
+ export HOST_CCASFLAGS=${CCASFLAGS}
+ export HOST_CFLAGS=${CFLAGS}
+ export HOST_CPPFLAGS=${CPPFLAGS}
+ export HOST_LDFLAGS=${LDFLAGS}
+ unset CCASFLAGS CFLAGS CPPFLAGS LDFLAGS
+
+ tc-ld-disable-gold #439082 #466536 #526348
+ export TARGET_LDFLAGS="${TARGET_LDFLAGS} ${LDFLAGS}"
+ unset LDFLAGS
+
+ tc-export CC NM OBJCOPY RANLIB STRIP
+ tc-export BUILD_CC BUILD_PKG_CONFIG
+
+ MULTIBUILD_VARIANTS=()
+ local p
+ for p in "${GRUB_ALL_PLATFORMS[@]}"; do
+ use "grub_platforms_${p}" && MULTIBUILD_VARIANTS+=( "${p}" )
+ done
+ [[ ${#MULTIBUILD_VARIANTS[@]} -eq 0 ]] && MULTIBUILD_VARIANTS=( guessed )
+ grub_do grub_configure
+}
+
+src_compile() {
+ # Sandbox bug 404013.
+ use libzfs && addpredict /etc/dfs:/dev/zfs
+
+ grub_do emake
+
+ use doc && grub_do_once emake -C docs html
+}
+
+src_test() {
+ # The qemu dependency is a bit complex.
+ # You will need to adjust QEMU_SOFTMMU_TARGETS to match the cpu/platform.
+ grub_do emake check
+}
+
+src_install() {
+ grub_do emake install DESTDIR="${D}" bashcompletiondir="$(get_bashcompdir)"
+ use doc && grub_do_once emake -C docs install-html DESTDIR="${D}"
+
+ einstalldocs
+
+ insinto /etc/default
+ newins "${FILESDIR}"/grub.default-3 grub
+
+ # https://bugs.gentoo.org/231935
+ dostrip -x /usr/lib/grub
+}
+
+pkg_postinst() {
+ elog "For information on how to configure GRUB2 please refer to the guide:"
+ elog " https://wiki.gentoo.org/wiki/GRUB2_Quick_Start"
+
+ if has_version 'sys-boot/grub:0'; then
+ elog "A migration guide for GRUB Legacy users is available:"
+ elog " https://wiki.gentoo.org/wiki/GRUB2_Migration"
+ fi
+
+ if [[ -z ${REPLACING_VERSIONS} ]]; then
+ elog
+ optfeature "detecting other operating systems (grub-mkconfig)" sys-boot/os-prober
+ optfeature "creating rescue media (grub-mkrescue)" dev-libs/libisoburn
+ optfeature "enabling RAID device detection" sys-fs/mdadm
+ fi
+
+ if has_version sys-boot/os-prober; then
+ ewarn "Due to security concerns, os-prober is disabled by default."
+ ewarn "Set GRUB_DISABLE_OS_PROBER=false in /etc/default/grub to enable it."
+ fi
+}