Subject: Re: linux-libre packaging: Learn to apply deblob script "errata" patches

From: Leo Famulari <[email-masked]>
Date: Wed, 17 Jul 2024 20:59:29 -0400

I tested the build of linux-libre 6.10 with the attached patches, and it
failed as dariqq said it would on #guix, because this kernel series
requires an update to the 'dwarves' package. I'm building again with the
dwarves update now.

https://logs.guix.gnu.org/guix/2024-07-17.log#204228

Also, these errata patches will only be required for 6.10, and not
subsequent releases in this series (6.10.1, etc).

We don't often end up including the mainline release in Guix, but rather
the subsequent stable releases, so in this case, it's not really
necessary to add this functionality. Although it would be nice.
From 3659eaef947623d502708441cfd6531acdc0fd90 Mon Sep 17 00:00:00 2001
Message-ID: <[email-masked]>
From: Leo Famulari <[email-masked]>
Date: Wed, 17 Jul 2024 16:05:13 -0400
Subject: [PATCH 1/3] gnu: linux-libre: Add the ability to apply errata patches
 to the deblobbing scripts.

* gnu/packages/linux.scm (linux-libre-deblob-scripts): Accept an optional
parameter DEBLOB-ERRATA-PATCHES.

Change-Id: If3c87f713637428e1cd2eaf5ef962b8005395805
---
 gnu/packages/linux.scm | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/gnu/packages/linux.scm b/gnu/packages/linux.scm
index e5aa712df7..0defc03e7a 100644
--- a/gnu/packages/linux.scm
+++ b/gnu/packages/linux.scm
@@ -359,9 +359,11 @@ (define-public (system->defconfig system)
 ;;; Kernel source code deblobbing.
 ;;;
 
-(define (linux-libre-deblob-scripts version gnu-revision
+(define* (linux-libre-deblob-scripts version gnu-revision
                                     deblob-hash
-                                    deblob-check-hash)
+                                    deblob-check-hash
+                                    #:optional
+                                    (deblob-errata-patches '()))
   (list (version-major+minor version)
         (origin
           (method url-fetch)
@@ -370,6 +372,8 @@ (define (linux-libre-deblob-scripts version gnu-revision
                               "deblob-" (version-major+minor version)))
           (file-name (string-append "linux-libre-deblob-"
                                     version "-" gnu-revision))
+          (patches
+            (map search-patch deblob-errata-patches))
           (sha256 deblob-hash))
         (origin
           (method url-fetch)

base-commit: 6cfc88e3be73904fc87443cdd5c7d7961923e848
prerequisite-patch-id: 58efdd6ff2418b91eae89e7964de00b95f83105f
-- 
2.45.2

From 82257a2285ba7a94a21c78bcc52a9241d604f977 Mon Sep 17 00:00:00 2001
Message-ID: <[email-masked]>
In-Reply-To: <[email-masked]>
References: <[email-masked]>
From: Leo Famulari <[email-masked]>
Date: Wed, 17 Jul 2024 16:05:42 -0400
Subject: [PATCH 2/3] gnu: linux-libre 6.10: Add the errata patchset 'gnua'.

The original release of linux-libre 6.10-gnu contained a bug that
prevents compilation. This patch was released as linux-libre
6.10-gnua:

http://www.fsfla.org/pipermail/linux-libre/2024-July/003545.html

* gnu/packages/patches/linux-libre-scripts-6.10-gnu-6.10-gnua.patch: New file.
* gnu/local.mk (dist_patch_DATA): Add it.
* gnu/packages/linux.scm (deblob-scripts-6.10)
Use it.

Change-Id: I3a4f27515f4a0834823cd8af1feae243bdef6943
---
 gnu/local.mk                                  |  1 +
 gnu/packages/linux.scm                        |  3 +-
 ...nux-libre-scripts-6.10-gnu-6.10-gnua.patch | 43 +++++++++++++++++++
 3 files changed, 46 insertions(+), 1 deletion(-)
 create mode 100644 gnu/packages/patches/linux-libre-scripts-6.10-gnu-6.10-gnua.patch

diff --git a/gnu/local.mk b/gnu/local.mk
index 638fb512eb..a7d08eb9ae 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -1685,6 +1685,7 @@ dist_patch_DATA =						\
   %D%/packages/patches/linbox-fix-pkgconfig.patch		\
   %D%/packages/patches/linphone-desktop-without-sdk.patch	\
   %D%/packages/patches/linux-libre-infodocs-target.patch	\
+  %D%/packages/patches/linux-libre-scripts-6.10-gnu-6.10-gnua.patch	\
   %D%/packages/patches/linux-libre-support-for-Pinebook-Pro.patch \
   %D%/packages/patches/linux-pam-no-setfsuid.patch		\
   %D%/packages/patches/linux-pam-unix_chkpwd.patch		\
diff --git a/gnu/packages/linux.scm b/gnu/packages/linux.scm
index 0defc03e7a..bef7803fb9 100644
--- a/gnu/packages/linux.scm
+++ b/gnu/packages/linux.scm
@@ -522,7 +522,8 @@ (define deblob-scripts-6.10
    linux-libre-6.10-version
    linux-libre-6.10-gnu-revision
    (base32 "1q7w3jdd1hjb87h6713r8m8gq4xc81jnhxdrn1w8h2hh1vadvxix")
-   (base32 "00bx8g1ijswi9zypmwqhxsk9fdkzmarxdbdx5h6gpn7z4d1qly3j")))
+   (base32 "00bx8g1ijswi9zypmwqhxsk9fdkzmarxdbdx5h6gpn7z4d1qly3j")
+   '("linux-libre-scripts-6.10-gnu-6.10-gnua.patch")))
 (define-public linux-libre-6.10-pristine-source
   (let ((version linux-libre-6.10-version)
         (hash (base32 "09p2z3z8c3aq6ipqdc58x6s52sy0cmyg6mj4f0g5yk755r19hikp")))
diff --git a/gnu/packages/patches/linux-libre-scripts-6.10-gnu-6.10-gnua.patch b/gnu/packages/patches/linux-libre-scripts-6.10-gnu-6.10-gnua.patch
new file mode 100644
index 0000000000..e96997799a
--- /dev/null
+++ b/gnu/packages/patches/linux-libre-scripts-6.10-gnu-6.10-gnua.patch
@@ -0,0 +1,43 @@
+diff --git scripts/linux-libre-6.10-gnu/deblob-6.10 scripts/linux-libre-6.10-gnu/deblob-6.10
+index b8e39342b47a..ecdb90efcf58 100755
+--- linux-libre-6.10-gnu/linux-libre-deblob-6.10-gnu
++++ linux-libre-6.10-gnu/linux-libre-deblob-6.10-gnu
+@@ -927,7 +927,11 @@ reject_firmware drivers/gpu/drm/i915/display/intel_dmc.c
+ clean_blob drivers/gpu/drm/i915/display/intel_dmc.c
+ reject_firmware drivers/gpu/drm/i915/gt/uc/intel_uc_fw.c
+ clean_sed '/uc_fw->file_selected\.path = blob->path/ i\
+-		else if (blob->path == NONFREE_FIRMWARE)\
++		/* If the compiler unifies string literals, as expected,\
++		   do not bother with strcmp.  */\
++		else if ((char const *)NONFREE_FIRMWARE == (char const *)NONFREE_FIRMWARE\
++			 ? blob->path == (char const *)NONFREE_FIRMWARE\
++			 : !strcmp (blob->path, NONFREE_FIRMWARE))\
+ 			/* Never select an entry we would refuse to load.\
+ 			   If we find nothing, loading is disabled but the card\
+ 			   initialization proceeds as if the user had disabled\
+@@ -937,7 +941,11 @@ clean_sed '/uc_fw->file_selected\.path = blob->path/ i\
+ 
+ ' drivers/gpu/drm/i915/gt/uc/intel_uc_fw.c 'disable non-Free firmware'
+ clean_sed '/Versionless file names must be unique/ i\
+-	    if (fw_blobs[i].blob.path != NONFREE_FIRMWARE)
++		/* If the compiler unifies string literals, as expected,\
++		   do not bother with strcmp.  */\
++		if ((char const *)NONFREE_FIRMWARE == (char const *)NONFREE_FIRMWARE\
++		    ? fw_blobs[i].blob.path != (char const *)NONFREE_FIRMWARE\
++		    : strcmp (fw_blobs[i].blob.path, NONFREE_FIRMWARE))
+ ' drivers/gpu/drm/i915/gt/uc/intel_uc_fw.c 'avoid validation fails'
+ clean_blob drivers/gpu/drm/i915/gt/uc/intel_uc_fw.c
+ clean_blob drivers/gpu/drm/i915/gt/uc/intel_uc_fw.h
+@@ -3294,9 +3302,9 @@ announce SCSI_QLA_FC - "QLogic QLA2XXX Fibre Channel Support"
+ reject_firmware drivers/scsi/qla2xxx/qla_os.c
+ clean_sed '
+ /^config SCSI_QLA_FC$/,/^config /{
+-  /By default, firmware/i\
+-	/*(DEBLOBBED)*/
+-  /By default, firmware/,/linux-firmware tree/d
++  /^	  By default, firmware/i\
++	  /*(DEBLOBBED)*/
++  /^	  By default, firmware/,/linux-firmware tree/d
+ }' drivers/scsi/qla2xxx/Kconfig 'removed firmware notes'
+ clean_blob drivers/scsi/qla2xxx/qla_os.c
+ clean_kconfig drivers/scsi/qla2xxx/Kconfig SCSI_QLA_FC
-- 
2.45.2

From 1942a6c7340ee124313f65602dd218471ddbc193 Mon Sep 17 00:00:00 2001
Message-ID: <[email-masked]>
In-Reply-To: <[email-masked]>
References: <[email-masked]>
From: Leo Famulari <[email-masked]>
Date: Wed, 17 Jul 2024 20:53:39 -0400
Subject: [PATCH 3/3] gnu: dwarves: Update to 1.27.

* gnu/packages/linux.scm (dwarves): Update to 1.27.

Change-Id: Id986fdd240a6619544ff6be93cce00afd9fc31bd
---
 gnu/packages/linux.scm | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/gnu/packages/linux.scm b/gnu/packages/linux.scm
index bef7803fb9..141aaf33f5 100644
--- a/gnu/packages/linux.scm
+++ b/gnu/packages/linux.scm
@@ -2421,7 +2421,7 @@ (define-public dislocker
 (define-public dwarves
   (package
     (name "dwarves")
-    (version "1.26")
+    (version "1.27")
     (source (origin
               (method git-fetch)
               (uri (git-reference
@@ -2430,7 +2430,7 @@ (define-public dwarves
               (file-name (git-file-name name version))
               (sha256
                (base32
-                "0xfq0r3whc3dk922ss8i5vwyfcqhgc95dy27mm69j5niy7i5kzrd"))
+                "0qwc3772az1h3c78pyswawyvyq9spj5s1prj7ckfij9nazp3a007"))
               (patches
                (search-patches "dwarves-threading-reproducibility.patch"))))
     (build-system cmake-build-system)
-- 
2.45.2