Subject: [bug#75827] [PATCH] gnu: Improve hackability of the Linux kernel

From: Stefan <[email-masked]>
Date: Sat, 25 Jan 2025 15:10:47 +0100

Collect versions and hashes of Linux origins centrally in the public
function upstream-linux-source.  The result of this function is usable for
the #:source argument of the customize-linux function.

gnu/packages/linux.scm (%upstream-linux-source): Rename function to
upstream-linux-source and export it.
(upstream-linux-source)[version, hash]: Make arguments optional, set the
default value of version to "6.12.10".  Add a table of versions and hashes
to return a Linux kernel origin only based on the version, if no hash is
given but internally known.
(make-linux-libre-source)[upstream-source]: Make argument optional and set
its default to (upstream-linux-source version).
(linux-libre-6.12-pristine-source, linux-libre-6.6-pristine-source,
linux-libre-6.1-pristine-source, linux-libre-5.15-pristine-source,
linux-libre-5.10-pristine-source, linux-libre-5.4-pristine-source): Remove
hashes for origins and invoke make-linux-libre-source with the default
value for its upstream-source argument.
(default-extra-linux-options): Remove duplicate of CONFIG_CGROUP_FREEZER.

Change-Id: I9cba6686b83d21368814793fcdb6cc49f27b239e
---
  gnu/packages/linux.scm | 63 +++++++++++++++++-------------------------
  1 file changed, 26 insertions(+), 37 deletions(-)

diff --git a/gnu/packages/linux.scm b/gnu/packages/linux.scm
index 77a53e4805..3d204f3109 100644
--- a/gnu/packages/linux.scm
+++ b/gnu/packages/linux.scm
@@ -69,7 +69,7 @@
  ;;; Copyright © 2022, 2023 Denis 'GNUtoo' Carikli <[email-masked]>
  ;;; Copyright © 2022 Hunter Jozwiak <[email-masked]>
  ;;; Copyright © 2022 Hilton Chain <[email-masked]>
-;;; Copyright © 2022 Stefan <[email-masked]>
+;;; Copyright © 2022, 2025 Stefan <[email-masked]>
  ;;; Copyright © 2022, 2023 Demis Balbach <[email-masked]>
  ;;; Copyright © 2023 Bruno Victal <[email-masked]>
  ;;; Copyright © 2023 Yovan Naumovski <[email-masked]>
@@ -228,6 +228,7 @@ (define-module (gnu packages linux)
    #:use-module (srfi srfi-2)
    #:use-module (srfi srfi-26)
    #:use-module (ice-9 match)
+  #:use-module (ice-9 optargs)
    #:use-module (ice-9 regex)
    #:export (customize-linux
              make-defconfig))
@@ -385,9 +386,11 @@ (define (linux-libre-deblob-scripts version gnu-revision
  ;; XXXX: Workaround 'snippet' limitations
  (define computed-origin-method (@@ (guix packages) computed-origin-method))
  
-(define (make-linux-libre-source version
-                                 upstream-source
-                                 deblob-scripts)
+(define* (make-linux-libre-source version
+                                  deblob-scripts
+                                  #:optional
+                                  (upstream-source
+                                   (upstream-linux-source version)))
    "Return a 'computed' origin that generates a Linux-libre tarball from the
  corresponding UPSTREAM-SOURCE (an origin), using the given DEBLOB-SCRIPTS."
    (match deblob-scripts
@@ -503,13 +506,24 @@ (define (linux-libre-urls version gnu-revision)
           "mirror://gnu/linux-libre/" version "-" gnu-revision "/linux-libre-"
           version "-" gnu-revision ".tar.xz")))
  
-(define (%upstream-linux-source version hash)
+(define*-public (upstream-linux-source #:optional (version "6.12.10") hash)
    (origin
      (method url-fetch)
      (uri (string-append "mirror://kernel.org"
                          "/linux/kernel/v" (version-major version) ".x/"
                          "linux-" version ".tar.xz"))
-    (sha256 hash)))
+    (sha256
+     (or hash
+         (base32
+          (match version
+            ("6.12.10"  "15xjjn8ff7g9q0ljr2g8k098ppxnpvxlgv22rdrplls8sxg6wlaa")
+            ("6.6.72"   "0fggpba886340xi8gkxc6hmzplcm69nliddql3d6hn8djcafbfgy")
+            ("6.1.125"  "0g0b23dm8kzijh9j1g4rv7b3r2lzz53g26xmz4zgchkybxfkbwnr")
+            ("5.15.176" "1cfk55469swywnf4r6pl7b3njxws8w3np81r99f0wnlaihrbajm8")
+            ("5.10.233" "0lkz2g8r032f027j3gih3f7crx991mrpng9qgqc5k4cc1wl5g7i3")
+            ("5.4.289"  "043dl195h06hs3zdjd6j1m1zgvmky3s0plrpma75zqf8ab05yghy")
+            (_ (error
+                (format #f "unknown hash for linux version ~a" version)))))))))
  
  ;; The current "stable" kernels. That is, the most recently released major
  ;; versions that are still supported upstream.
@@ -523,11 +537,7 @@ (define deblob-scripts-6.12
     (base32 "0i24k4zc6x5lvif12ba53c6cd5ydiah9j32ly2wpl88424ld389h")
     (base32 "0jwnb1pd8ayfkck3sw3jjlsg7gayig0ymiay53mg7qchhycih8xs")))
  (define-public linux-libre-6.12-pristine-source
-  (let ((version linux-libre-6.12-version)
-        (hash (base32 "15xjjn8ff7g9q0ljr2g8k098ppxnpvxlgv22rdrplls8sxg6wlaa")))
-   (make-linux-libre-source version
-                            (%upstream-linux-source version hash)
-                            deblob-scripts-6.12)))
+  (make-linux-libre-source linux-libre-6.12-version deblob-scripts-6.12))
  
  ;; The "longterm" kernels — the older releases with long-term upstream support.
  ;; Here are the support timelines:
@@ -542,11 +552,7 @@ (define deblob-scripts-6.6
     (base32 "1a28pdl645bj4d8gac71dmwmll6a2kgd3k7gkpfvi94yqkzd9r2z")
     (base32 "1gqha26cxijizyhg6k5397bc9pn54wxz01d4gb7j2xx22rkxjwhb")))
  (define-public linux-libre-6.6-pristine-source
-  (let ((version linux-libre-6.6-version)
-        (hash (base32 "0fggpba886340xi8gkxc6hmzplcm69nliddql3d6hn8djcafbfgy")))
-   (make-linux-libre-source version
-                            (%upstream-linux-source version hash)
-                            deblob-scripts-6.6)))
+  (make-linux-libre-source linux-libre-6.6-version deblob-scripts-6.6))
  
  (define-public linux-libre-6.1-version "6.1.125")
  (define-public linux-libre-6.1-gnu-revision "gnu")
@@ -557,11 +563,7 @@ (define deblob-scripts-6.1
     (base32 "1sf80f2i4vf888xjcn84ymn4w5ynn30ib9033zwmv7f09yvfhapy")
     (base32 "060pbbvk3c1r9v6fz1qm5f0hjb29wi67lg7an0nwl6bpjsk5ci52")))
  (define-public linux-libre-6.1-pristine-source
-  (let ((version linux-libre-6.1-version)
-        (hash (base32 "0g0b23dm8kzijh9j1g4rv7b3r2lzz53g26xmz4zgchkybxfkbwnr")))
-   (make-linux-libre-source version
-                            (%upstream-linux-source version hash)
-                            deblob-scripts-6.1)))
+  (make-linux-libre-source linux-libre-6.1-version deblob-scripts-6.1))
  
  (define-public linux-libre-5.15-version "5.15.176")
  (define-public linux-libre-5.15-gnu-revision "gnu")
@@ -572,11 +574,7 @@ (define deblob-scripts-5.15
     (base32 "18ac30kxg2mf2f6gk3p935hzhz2qs110jy4xwk21kblnnkskbxj8")
     (base32 "1pbl08jzqh944z34bz25k2v7igsm3r89jbcg0hba3cvyybkkfc2g")))
  (define-public linux-libre-5.15-pristine-source
-  (let ((version linux-libre-5.15-version)
-        (hash (base32 "1cfk55469swywnf4r6pl7b3njxws8w3np81r99f0wnlaihrbajm8")))
-   (make-linux-libre-source version
-                            (%upstream-linux-source version hash)
-                            deblob-scripts-5.15)))
+  (make-linux-libre-source linux-libre-5.15-version deblob-scripts-5.15))
  
  (define-public linux-libre-5.10-version "5.10.233")
  (define-public linux-libre-5.10-gnu-revision "gnu1")
@@ -587,11 +585,7 @@ (define deblob-scripts-5.10
     (base32 "1b33rkn32b923025iiz4xzxiy8y5ii9j5qk4021mg575890rl4ch")
     (base32 "14jdl5rk3w7h97svl6j6ngbywj5qixmpv6ifhqkzjxpp07xngvs4")))
  (define-public linux-libre-5.10-pristine-source
-  (let ((version linux-libre-5.10-version)
-        (hash (base32 "0lkz2g8r032f027j3gih3f7crx991mrpng9qgqc5k4cc1wl5g7i3")))
-   (make-linux-libre-source version
-                            (%upstream-linux-source version hash)
-                            deblob-scripts-5.10)))
+  (make-linux-libre-source linux-libre-5.10-version deblob-scripts-5.10))
  
  (define-public linux-libre-5.4-version "5.4.289")
  (define-public linux-libre-5.4-gnu-revision "gnu1")
@@ -602,11 +596,7 @@ (define deblob-scripts-5.4
     (base32 "0xg5cz82k2cb0ikxvwv1hp5c3h377jkb5sd6aszvsk7hnabhk62v")
     (base32 "1q1wcslpwpwsnwzbddjdc0qv2h89492skyw2zsjyb4rpz41s66mg")))
  (define-public linux-libre-5.4-pristine-source
-  (let ((version linux-libre-5.4-version)
-        (hash (base32 "043dl195h06hs3zdjd6j1m1zgvmky3s0plrpma75zqf8ab05yghy")))
-   (make-linux-libre-source version
-                            (%upstream-linux-source version hash)
-                            deblob-scripts-5.4)))
+  (make-linux-libre-source linux-libre-5.4-version deblob-scripts-5.4))
  
  (define %boot-logo-patch
    ;; Linux-Libre boot logo featuring Freedo and a gnu.
@@ -862,7 +852,6 @@ (define (default-extra-linux-options version)
      ("CONFIG_CGROUP_WRITEBACK" . #t)
      ("CONFIG_CGROUP_SCHED" . #t)
      ("CONFIG_CGROUP_PIDS" . #t)
-    ("CONFIG_CGROUP_FREEZER" . #t)
      ("CONFIG_CGROUP_DEVICE" . #t)
      ("CONFIG_CGROUP_CPUACCT" . #t)
      ("CONFIG_CGROUP_PERF" . #t)

base-commit: d1e3c41abdda9f8e9f1283376feb853670393793
-- 
2.47.1