summaryrefslogtreecommitdiff
path: root/gnu/packages/linux.scm
diff options
context:
space:
mode:
authorSergio Pastor Pérez <sergio.pastorperez@gmail.com>2026-07-08 14:57:43 +0200
committerVagrant Cascadian <vagrant@debian.org>2026-08-27 00:05:01 -0700
commit38a7797012907bc8e0ec5f6d4e76aede9666e38a (patch)
tree9e5df31a5649ad93089a14db07e8a8961a153e4d /gnu/packages/linux.scm
parentc63b4007bc230d7eb88c3f87fa6434f801b25279 (diff)
gnu: linux: Generalize Linux source building.
* gnu/packages/linux.scm (make-linux-libre-source, make-linux-libre) (make-linux-libre*): Adjust to use generic Linux source prodecures. (make-linux-source, make-linux*): New procedure.
Diffstat (limited to 'gnu/packages/linux.scm')
-rw-r--r--gnu/packages/linux.scm309
1 files changed, 194 insertions, 115 deletions
diff --git a/gnu/packages/linux.scm b/gnu/packages/linux.scm
index f63e89a7f81..6965528ab7a 100644
--- a/gnu/packages/linux.scm
+++ b/gnu/packages/linux.scm
@@ -416,90 +416,148 @@ corresponding UPSTREAM-SOURCE (an origin), using the given DEBLOB-SCRIPTS."
416 ;; different version (major+minor) of Linux, even if no errors 416 ;; different version (major+minor) of Linux, even if no errors
417 ;; are signaled during execution. 417 ;; are signaled during execution.
418 (error "deblob major+minor version mismatch")) 418 (error "deblob major+minor version mismatch"))
419 (define unchecked-source
420 (make-linux-source
421 version upstream-source
422 (delay
423 (with-imported-modules '((guix build utils))
424 #~(begin
425 (use-modules (guix build utils))
426
427 (mkdir "/tmp/bin")
428 (set-path-environment-variable
429 "PATH" '("bin")
430 (list "/tmp"
431 #+(canonical-package bash)
432 #+(canonical-package coreutils)
433 #+(canonical-package diffutils)
434 #+(canonical-package findutils)
435 #+(canonical-package patch)
436 #+(canonical-package xz)
437 #+(canonical-package sed)
438 #+(canonical-package grep)
439 #+(canonical-package bzip2)
440 #+(canonical-package gzip)
441 #+(canonical-package tar)
442 #+(canonical-package gawk)
443 #+python-wrapper))
444
445 (with-directory-excursion "/tmp/bin"
446 (copy-file #+deblob "deblob")
447 (chmod "deblob" #o755)
448 (substitute* "deblob"
449 (("/bin/sh") (which "sh")))
450
451 (copy-file #+deblob-check "deblob-check")
452 (chmod "deblob-check" #o755)
453 (substitute* "deblob-check"
454 (("/bin/sh") (which "sh"))
455 (("/bin/sed") (which "sed"))
456 (("/usr/bin/python") (which "python"))))
457
458 (format #t "Running deblob script...~%")
459 (invoke "/tmp/bin/deblob"))))))
419 (origin 460 (origin
420 (method computed-origin-method) 461 (method computed-origin-method)
421 (file-name (string-append "linux-libre-" version "-guix.tar.xz")) 462 (file-name (string-append "linux-" version "-guix.tar.xz"))
422 (sha256 #f) 463 (sha256 #f)
423 (uri 464 (uri
424 (delay 465 (delay
425 (with-imported-modules '((guix build utils)) 466 (with-imported-modules '((guix build utils))
426 #~(begin 467 #~(begin
427 (use-modules (guix build utils) 468 (use-modules (guix build utils))
428 (srfi srfi-1) 469
429 (ice-9 match) 470 (mkdir "/tmp/bin")
430 (ice-9 ftw)) 471 (set-path-environment-variable
431 472 "PATH" '("bin")
432 (setvbuf (current-output-port) 'line) 473 (list "/tmp"
433 474 #+(canonical-package bash)
434 (let ((dir (string-append "linux-" #$version))) 475 #+(canonical-package coreutils)
435 476 #+(canonical-package diffutils)
436 (mkdir "/tmp/bin") 477 #+(canonical-package findutils)
437 (set-path-environment-variable 478 #+(canonical-package patch)
438 "PATH" '("bin") 479 #+(canonical-package xz)
439 (list "/tmp" 480 #+(canonical-package sed)
440 #+(canonical-package bash) 481 #+(canonical-package grep)
441 #+(canonical-package coreutils) 482 #+(canonical-package bzip2)
442 #+(canonical-package diffutils) 483 #+(canonical-package gzip)
443 #+(canonical-package findutils) 484 #+(canonical-package tar)
444 #+(canonical-package patch) 485 #+(canonical-package gawk)
445 #+(canonical-package xz) 486 #+python-wrapper))
446 #+(canonical-package sed) 487
447 #+(canonical-package grep) 488 (with-directory-excursion "/tmp/bin"
448 #+(canonical-package bzip2) 489 (copy-file #+deblob-check "deblob-check")
449 #+(canonical-package gzip) 490 (chmod "deblob-check" #o755)
450 #+(canonical-package tar) 491 (substitute* "deblob-check"
451 #+(canonical-package gawk) 492 (("/bin/sh") (which "sh"))
452 #+python-wrapper)) 493 (("/bin/sed") (which "sed"))
453 494 (("/usr/bin/python") (which "python"))))
454 (with-directory-excursion "/tmp/bin" 495
455 496 (copy-file #$unchecked-source #$output)
456 (copy-file #+deblob "deblob") 497
457 (chmod "deblob" #o755) 498 (format #t "~%Scanning the generated tarball for blobs...~%")
458 (substitute* "deblob" 499 (invoke "/tmp/bin/deblob-check" "--use-awk" "--list-blobs"
459 (("/bin/sh") (which "sh"))) 500 #$output)))))))))
460 501
461 (copy-file #+deblob-check "deblob-check") 502(define (make-linux-source version upstream-source transformation)
462 (chmod "deblob-check" #o755) 503 "Return a 'computed' origin that generates a modified Linux tarball from the
463 (substitute* "deblob-check" 504corresponding UPSTREAM-SOURCE (an origin), using the given TRANSFORMATION (a
464 (("/bin/sh") (which "sh")) 505GEXP)."
465 (("/bin/sed") (which "sed")) 506 (origin
466 (("/usr/bin/python") (which "python")))) 507 (method computed-origin-method)
467 508 (file-name (string-append "linux-" version "-guix.tar.xz"))
468 (if (file-is-directory? #+upstream-source) 509 (sha256 #f)
469 (begin 510 (uri
470 (format #t "Copying upstream linux source...~%") 511 (delay
471 (invoke "cp" "--archive" #+upstream-source dir) 512 (with-imported-modules '((guix build utils))
472 (invoke "chmod" "--recursive" "u+w" dir)) 513 ;; NOTE: it's very important not to introduce local symbols inside
473 (begin 514 ;; the gexp as they will shadow symbols used in TRANSFORMATION.
474 (format #t "Unpacking upstream linux tarball...~%") 515 (let ((dir (string-append "linux-" version))
475 (invoke "tar" "xf" #$upstream-source) 516 (cp (file-append (canonical-package coreutils) "/bin/cp"))
476 (match (scandir "." 517 (tar (file-append (canonical-package tar) "/bin/tar"))
477 (lambda (name) 518 (change-mode (file-append (canonical-package coreutils) "/bin/chmod")))
478 (and (not (member name '("." ".."))) 519 #~(begin
479 (file-is-directory? name)))) 520 (use-modules (guix build utils)
480 ((unpacked-dir) 521 (srfi srfi-1)
481 (unless (string=? dir unpacked-dir) 522 (ice-9 match)
482 (rename-file unpacked-dir dir))) 523 (ice-9 ftw))
483 (dirs 524
484 (error "multiple directories found" dirs))))) 525 ;; Required for tar gz decompression.
485 526 (setenv "PATH" #+(file-append (canonical-package xz) "/bin"))
486 (with-directory-excursion dir 527
487 (format #t "Running deblob script...~%") 528 (if (file-is-directory? #+upstream-source)
488 (invoke "/tmp/bin/deblob")) 529 (begin
489 530 (format #t "Copying upstream Linux source...~%")
490 (format #t "~%Packing new Linux-libre tarball...~%") 531 (copy-recursively #+upstream-source #$dir)
491 (invoke "tar" "cvfa" #$output 532 (for-each (cut make-file-writable <>)
492 ;; Avoid non-determinism in the archive. 533 (find-files #$dir)))
493 "--mtime=@0" 534 (begin
494 "--owner=root:0" 535 (format #t "Unpacking upstream Linux tarball...~%")
495 "--group=root:0" 536 (invoke #+tar "xf" #$upstream-source)
496 "--sort=name" 537 (match (scandir "."
497 "--hard-dereference" 538 (lambda (name)
498 dir) 539 (and (not (member name '("." "..")))
499 540 (file-is-directory? name))))
500 (format #t "~%Scanning the generated tarball for blobs...~%") 541 ((unpacked-dir)
501 (invoke "/tmp/bin/deblob-check" "--use-awk" "--list-blobs" 542 (unless (string=? #$dir unpacked-dir)
502 #$output)))))))))) 543 (rename-file unpacked-dir #$dir)))
544 (dirs
545 (error "multiple directories found" dirs)))))
546
547 (with-directory-excursion #$dir
548 #$(if (promise? transformation)
549 (force transformation)
550 transformation))
551
552 (format #t "~%Packing new Linux tarball...~%")
553 (invoke #+tar "cvfa" #$output
554 ;; Avoid non-determinism in the archive.
555 "--mtime=@0"
556 "--owner=root:0"
557 "--group=root:0"
558 "--sort=name"
559 "--hard-dereference"
560 #$dir))))))))
503 561
504 562
505;;; 563;;;
@@ -989,46 +1047,18 @@ ARCH and optionally VARIANT, or #f if there is no such configuration."
989 (and (version>=? version "5.10") 1047 (and (version>=? version "5.10")
990 (not (version>=? version "6.2")))) ;patch applied upstream 1048 (not (version>=? version "6.2")))) ;patch applied upstream
991 1049
992 1050(define* (make-linux* version source supported-systems
993(define* (make-linux-libre version gnu-revision hash-string supported-systems 1051 #:key
994 #:key 1052 (extra-version #f)
995 (extra-version #f) 1053 ;; A function that takes an arch and a variant.
996 ;; A function that takes an arch and a variant, and 1054 ;; See kernel-config for an example.
997 ;; return a file-like object. See kernel-config 1055 (configuration-file #f)
998 ;; for an example. 1056 (defconfig "defconfig")
999 (configuration-file #f) 1057 (extra-options (default-extra-linux-options version)))
1000 (defconfig "defconfig")
1001 (extra-options (default-extra-linux-options version))
1002 (patches
1003 `(,%boot-logo-patch
1004 ,@(if (apply-infodoc-patch? version)
1005 (list (search-patch
1006 "linux-libre-infodocs-target.patch"))
1007 '()))))
1008 (make-linux-libre* version gnu-revision
1009 (origin
1010 (method url-fetch)
1011 (uri (linux-libre-urls version gnu-revision))
1012 (sha256 (base32 hash-string))
1013 (patches patches))
1014 supported-systems
1015 #:extra-version extra-version
1016 #:configuration-file configuration-file
1017 #:defconfig defconfig
1018 #:extra-options extra-options))
1019
1020(define* (make-linux-libre* version gnu-revision source supported-systems
1021 #:key
1022 (extra-version #f)
1023 ;; A function that takes an arch and a variant.
1024 ;; See kernel-config for an example.
1025 (configuration-file #f)
1026 (defconfig "defconfig")
1027 (extra-options (default-extra-linux-options version)))
1028 (package 1058 (package
1029 (name (if extra-version 1059 (name (if extra-version
1030 (string-append "linux-libre-" extra-version) 1060 (string-append "linux-" extra-version)
1031 "linux-libre")) 1061 "linux"))
1032 (version version) 1062 (version version)
1033 (source source) 1063 (source source)
1034 (supported-systems supported-systems) 1064 (supported-systems supported-systems)
@@ -1178,6 +1208,55 @@ ARCH and optionally VARIANT, or #f if there is no such configuration."
1178 zlib 1208 zlib
1179 ;; For Zstd compression of kernel modules. 1209 ;; For Zstd compression of kernel modules.
1180 zstd)) 1210 zstd))
1211 (home-page #f)
1212 (synopsis #f)
1213 (description #f)
1214 (license #f)))
1215
1216(define* (make-linux-libre version gnu-revision hash-string supported-systems
1217 #:key
1218 (extra-version #f)
1219 ;; A function that takes an arch and a variant, and
1220 ;; return a file-like object. See kernel-config
1221 ;; for an example.
1222 (configuration-file #f)
1223 (defconfig "defconfig")
1224 (extra-options (default-extra-linux-options version))
1225 (patches
1226 `(,%boot-logo-patch
1227 ,@(if (apply-infodoc-patch? version)
1228 (list (search-patch
1229 "linux-libre-infodocs-target.patch"))
1230 '()))))
1231 (make-linux-libre* version gnu-revision
1232 (origin
1233 (method url-fetch)
1234 (uri (linux-libre-urls version gnu-revision))
1235 (sha256 (base32 hash-string))
1236 (patches patches))
1237 supported-systems
1238 #:extra-version extra-version
1239 #:configuration-file configuration-file
1240 #:defconfig defconfig
1241 #:extra-options extra-options))
1242
1243(define* (make-linux-libre* version gnu-revision source supported-systems
1244 #:key
1245 (extra-version #f)
1246 ;; A function that takes an arch and a variant.
1247 ;; See kernel-config for an example.
1248 (configuration-file #f)
1249 (defconfig "defconfig")
1250 (extra-options (default-extra-linux-options version)))
1251 (package
1252 (inherit (make-linux* version source supported-systems
1253 #:extra-version extra-version
1254 #:configuration-file configuration-file
1255 #:defconfig defconfig
1256 #:extra-options extra-options))
1257 (name (if extra-version
1258 (string-append "linux-libre-" extra-version)
1259 "linux-libre"))
1181 (home-page "https://www.gnu.org/software/linux-libre/") 1260 (home-page "https://www.gnu.org/software/linux-libre/")
1182 (synopsis "100% free redistribution of a cleaned Linux kernel") 1261 (synopsis "100% free redistribution of a cleaned Linux kernel")
1183 (description "GNU Linux-Libre is a free (as in freedom) variant of the 1262 (description "GNU Linux-Libre is a free (as in freedom) variant of the