commit:     7cea90df5543b29b629b40e12235e3cc864bc698
Author:     Viorel Munteanu <ceamac <AT> gentoo <DOT> org>
AuthorDate: Thu Jul 25 07:06:48 2024 +0000
Commit:     Viorel Munteanu <ceamac <AT> gentoo <DOT> org>
CommitDate: Thu Jul 25 07:09:45 2024 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=7cea90df

sys-boot/refind: add fix for gnu-efi 3.0.18

Closes: https://bugs.gentoo.org/934474
Closes: https://bugs.gentoo.org/934320
Signed-off-by: Viorel Munteanu <ceamac <AT> gentoo.org>

 .../files/refind-0.14.2-fix-gnu-efi-3.0.18.patch   | 77 ++++++++++++++++++++++
 ...efind-0.14.2.ebuild => refind-0.14.2-r1.ebuild} | 25 ++-----
 2 files changed, 82 insertions(+), 20 deletions(-)

diff --git a/sys-boot/refind/files/refind-0.14.2-fix-gnu-efi-3.0.18.patch 
b/sys-boot/refind/files/refind-0.14.2-fix-gnu-efi-3.0.18.patch
new file mode 100644
index 000000000000..b5d9d2692883
--- /dev/null
+++ b/sys-boot/refind/files/refind-0.14.2-fix-gnu-efi-3.0.18.patch
@@ -0,0 +1,77 @@
+The same commit from gnu-efi that changed CopyMem in a way that broke refind 
also changed SetMem.
+This patch attempts to fix it in the same way upstream fixed CopyMem.
+
+The commit: 
https://sourceforge.net/p/gnu-efi/code/ci/deb8a7f267d96299b9aa41300539f617db54c2a9/
+The bug: https://bugs.gentoo.org/934474
+
+--- a/gptsync/gptsync.c
++++ b/gptsync/gptsync.c
+@@ -164,7 +164,7 @@ static UINTN write_mbr(VOID)
+     }
+     if (!have_bootcode) {
+         // no boot code found in the MBR, add the syslinux MBR code
+-        SetMem(sector, MBR_BOOTCODE_SIZE, 0);
++        refit_call3_wrapper(gBS->SetMem, sector, MBR_BOOTCODE_SIZE, 0);
+         refit_call3_wrapper(gBS->CopyMem, sector, syslinux_mbr, 
SYSLINUX_MBR_SIZE);
+     }
+ 
+--- a/libeg/lodepng_xtra.c
++++ b/libeg/lodepng_xtra.c
+@@ -87,7 +87,7 @@ int MyStrlen(const char *InString) {
+ } // int MyStrlen()
+ 
+ VOID *MyMemSet(VOID *s, int c, size_t n) {
+-    SetMem(s, c, n);
++    MySetMem(s, c, n);
+     return s;
+ }
+ 
+--- a/refind/config.c
++++ b/refind/config.c
+@@ -667,7 +667,7 @@ VOID ReadConfig(CHAR16 *FileName)
+             HandleStrings(TokenList, TokenCount, &(GlobalConfig.DriverDirs));
+ 
+         } else if (MyStriCmp(TokenList[0], L"showtools")) {
+-            SetMem(GlobalConfig.ShowTools, NUM_TOOLS * sizeof(UINTN), 0);
++            MySetMem(GlobalConfig.ShowTools, NUM_TOOLS * sizeof(UINTN), 0);
+             GlobalConfig.HiddenTags = FALSE;
+             for (i = 1; (i < TokenCount) && (i < NUM_TOOLS); i++) {
+                 FlagName = TokenList[i];
+--- a/refind/launch_legacy.c
++++ b/refind/launch_legacy.c
+@@ -114,7 +114,7 @@ static EFI_STATUS ActivateMbrPartition(IN EFI_BLOCK_IO 
*BlockIO, IN UINTN Partit
+     }
+     if (!HaveBootCode) {
+         // no boot code found in the MBR, add the syslinux MBR code
+-        SetMem(SectorBuffer, MBR_BOOTCODE_SIZE, 0);
++        MySetMem(SectorBuffer, MBR_BOOTCODE_SIZE, 0);
+         MyCopyMem(SectorBuffer, syslinux_mbr, SYSLINUX_MBR_SIZE);
+     }
+ 
+--- a/refind/lib.c
++++ b/refind/lib.c
+@@ -651,7 +651,7 @@ static VOID SetFilesystemData(IN UINT8 *Buffer, IN UINTN 
BufferSize, IN OUT REFI
+ 
+     LOG(2, LOG_LINE_NORMAL, L"Identifying filesystem types....");
+     if ((Buffer != NULL) && (Volume != NULL)) {
+-        SetMem(&(Volume->VolUuid), sizeof(EFI_GUID), 0);
++        MySetMem(&(Volume->VolUuid), sizeof(EFI_GUID), 0);
+         Volume->FSType = FS_TYPE_UNKNOWN;
+ 
+         if (BufferSize >= (1024 + 100)) {
+--- a/refind/lib.h
++++ b/refind/lib.h
+@@ -133,10 +133,13 @@ VOID MyFreePool(IN OUT VOID *Pointer);
+ 
+ // When using GNU-EFI, call the EFI's built-in gBS->CopyMem() function, 
because
+ // GNU-EFI 3.0.18 changed its CopyMem() definition in a way that broke rEFInd.
++// Same for SetMem
+ #ifdef __MAKEWITH_GNUEFI
+ #define MyCopyMem(Dest, Src, len) refit_call3_wrapper(gBS->CopyMem, Dest, 
Src, len)
++#define MySetMem(Dest, Src, len) refit_call3_wrapper(gBS->SetMem, Dest, Src, 
len)
+ #else
+ #define MyCopyMem(Dest, Src, len) CopyMem(Dest, Src, len)
++#define MySetMem(Dest, Src, len) SetMem(Dest, Src, len)
+ #endif
+ 
+ BOOLEAN EjectMedia(VOID);

diff --git a/sys-boot/refind/refind-0.14.2.ebuild 
b/sys-boot/refind/refind-0.14.2-r1.ebuild
similarity index 87%
rename from sys-boot/refind/refind-0.14.2.ebuild
rename to sys-boot/refind/refind-0.14.2-r1.ebuild
index f280380cf1c4..d3866389c5cb 100644
--- a/sys-boot/refind/refind-0.14.2.ebuild
+++ b/sys-boot/refind/refind-0.14.2-r1.ebuild
@@ -11,8 +11,7 @@ 
SRC_URI="https://downloads.sourceforge.net/project/${PN}/${PV}/${PN}-src-${PV}.t
 
 LICENSE="BSD CC-BY-SA-3.0 CC-BY-SA-4.0 FDL-1.3 GPL-2+ GPL-3+ LGPL-3+"
 SLOT="0"
-# Unkeyworded for now because of bug #934474
-#KEYWORDS="~amd64 ~x86"
+KEYWORDS="~amd64 ~x86"
 FS_USE="btrfs +ext2 +ext4 hfs +iso9660 ntfs reiserfs"
 IUSE="${FS_USE} doc"
 
@@ -23,7 +22,10 @@ BDEPEND="sys-devel/binutils"
 
 DOCS=( README.txt NEWS.txt )
 
-PATCHES=( "${FILESDIR}"/${PN}-0.14.0.2-clang.patch )
+PATCHES=(
+       "${FILESDIR}"/${PN}-0.14.0.2-clang.patch
+       "${FILESDIR}"/${P}-fix-gnu-efi-3.0.18.patch
+)
 
 checktools() {
        if [[ ${MERGE_TYPE} != "binary" ]]; then
@@ -42,28 +44,11 @@ checktools() {
        fi
 }
 
-check-gnu-efi() {
-       if [[ ${MERGE_TYPE} != "binary" ]]; then
-               local efi=sys-boot/gnu-efi
-
-               local broken=3.0.18-r1
-               has_version -d "=${efi}-${broken}" && die "This version of 
refind does not boot if compiled with =${efi}-${broken}"
-
-               broken=3.0.18
-               if has_version -d ">=${efi}-${broken}"; then
-                       ewarn "This version of refind does not display jpegs 
correctly if compiled with >=${efi}-${broken} (bug #934474)"
-               fi
-       fi
-}
-
 pkg_pretend() {
-       check-gnu-efi
        checktools
 }
 
 pkg_setup() {
-       check-gnu-efi
-
        if use x86; then
                export EFIARCH=ia32
                export BUILDARCH=ia32

Reply via email to