gnu: make-linux-libre*: Remove input labels.

This restores commit dfc6957a5a, with an
additional fix to the kernel-config procedure so that it returns #f when no
configuration exists for the architecture requested, as reported by Pierre
Langlois (thanks!).

* gnu/packages/linux.scm (kernel-config): Make the return value a gexp, using
local-file, while preserving the #f return value in case of no matching config
file found.  Adjust doc.
(make-linux-libre*): Adjust doc.
[native-inputs]: Remove input labels.  Rewrite config input to be directly
expanded...
[phases] <configure>: ... here.  Re-flow comments.  Remove extraneous INPUTS
argument.
<install>: Likewise.
This commit is contained in:
Maxim Cournoyer 2023-01-13 15:38:36 -05:00
parent 0f85081ed1
commit 4913ac7491
No known key found for this signature in database
GPG key ID: 1260E46482E63562

View file

@ -782,12 +782,13 @@ (define-public linux-libre-headers linux-libre-headers-5.10.35)
;;; ;;;
(define* (kernel-config arch #:key variant) (define* (kernel-config arch #:key variant)
"Return the absolute file name of the Linux-Libre build configuration file "Return a file-like object of the Linux-Libre build configuration file for
for ARCH and optionally VARIANT, or #f if there is no such configuration." ARCH and optionally VARIANT, or #f if there is no such configuration."
(let* ((name (string-append (if variant (string-append variant "-") "") (let* ((name (string-append (if variant (string-append variant "-") "")
(if (string=? "i386" arch) "i686" arch) ".conf")) (if (string=? "i386" arch) "i686" arch) ".conf"))
(file (string-append "linux-libre/" name))) (file (string-append "linux-libre/" name))
(search-auxiliary-file file))) (config (search-auxiliary-file file)))
(and config (local-file config))))
(define %default-extra-linux-options (define %default-extra-linux-options
`(;; Make the kernel config available at /proc/config.gz `(;; Make the kernel config available at /proc/config.gz
@ -895,8 +896,9 @@ (define (doc-supported? version)
(define* (make-linux-libre version gnu-revision hash-string supported-systems (define* (make-linux-libre version gnu-revision hash-string supported-systems
#:key #:key
(extra-version #f) (extra-version #f)
;; A function that takes an arch and a variant. ;; A function that takes an arch and a variant, and
;; See kernel-config for an example. ;; return a file-like object. See kernel-config
;; for an example.
(configuration-file #f) (configuration-file #f)
(defconfig "defconfig") (defconfig "defconfig")
(extra-options %default-extra-linux-options) (extra-options %default-extra-linux-options)
@ -980,8 +982,20 @@ (define* (make-linux-libre* version gnu-revision source supported-systems
#$(and extra-version #$(and extra-version
(string-append "-" extra-version))))) (string-append "-" extra-version)))))
(replace 'configure (replace 'configure
(lambda* (#:key inputs #:allow-other-keys) (lambda _
(let ((config (assoc-ref inputs "kconfig"))) (let ((config
#$(match (let ((arch (platform-linux-architecture
(lookup-platform-by-target-or-system
(or (%current-target-system)
(%current-system))))))
(and configuration-file arch
(configuration-file
arch
#:variant (version-major+minor version))))
(#f ;no config for this platform
#f)
((? file-like? config)
config))))
;; Use a custom kernel configuration file or a default ;; Use a custom kernel configuration file or a default
;; configuration file. ;; configuration file.
(if config (if config
@ -989,15 +1003,15 @@ (define* (make-linux-libre* version gnu-revision source supported-systems
(copy-file config ".config") (copy-file config ".config")
(chmod ".config" #o666)) (chmod ".config" #o666))
(invoke "make" #$defconfig)) (invoke "make" #$defconfig))
;; Appending works even when the option wasn't in the ;; Appending works even when the option wasn't in the file.
;; file. The last one prevails if duplicated. ;; The last one prevails if duplicated.
(let ((port (open-file ".config" "a")) (let ((port (open-file ".config" "a"))
(extra-configuration #$(config->string extra-options))) (extra-configuration #$(config->string extra-options)))
(display extra-configuration port) (display extra-configuration port)
(close-port port)) (close-port port))
(invoke "make" "oldconfig")))) (invoke "make" "oldconfig"))))
(replace 'install (replace 'install
(lambda* (#:key inputs #:allow-other-keys) (lambda _
(let ((moddir (string-append #$output "/lib/modules")) (let ((moddir (string-append #$output "/lib/modules"))
(dtbdir (string-append #$output "/lib/dtbs"))) (dtbdir (string-append #$output "/lib/dtbs")))
;; Install kernel image, kernel configuration and link map. ;; Install kernel image, kernel configuration and link map.
@ -1012,11 +1026,11 @@ (define* (make-linux-libre* version gnu-revision source supported-systems
;; Install kernel modules ;; Install kernel modules
(mkdir-p moddir) (mkdir-p moddir)
(invoke "make" (invoke "make"
;; Disable depmod because the Guix system's ;; Disable depmod because the Guix system's module
;; module directory is an union of potentially ;; directory is an union of potentially multiple
;; multiple packages. It is not possible to use ;; packages. It is not possible to use depmod to
;; depmod to usefully calculate a dependency ;; usefully calculate a dependency graph while
;; graph while building only one of them. ;; building only one of them.
"DEPMOD=true" "DEPMOD=true"
(string-append "MODULE_DIR=" moddir) (string-append "MODULE_DIR=" moddir)
(string-append "INSTALL_PATH=" #$output) (string-append "INSTALL_PATH=" #$output)
@ -1029,8 +1043,8 @@ (define* (make-linux-libre* version gnu-revision source supported-systems
(version (match versions (version (match versions
((x) x)))) ((x) x))))
;; There are symlinks to the build and source directory. ;; There are symlinks to the build and source directory.
;; Both will point to target /tmp/guix-build* and thus ;; Both will point to target /tmp/guix-build* and thus not
;; not be useful in a profile. Delete the symlinks. ;; be useful in a profile. Delete the symlinks.
(false-if-file-not-found (false-if-file-not-found
(delete-file (delete-file
(string-append moddir "/" version "/build"))) (string-append moddir "/" version "/build")))
@ -1038,29 +1052,16 @@ (define* (make-linux-libre* version gnu-revision source supported-systems
(delete-file (delete-file
(string-append moddir "/" version "/source")))))))))) (string-append moddir "/" version "/source"))))))))))
(native-inputs (native-inputs
`(("perl" ,perl) (list perl
("bc" ,bc) bc
("openssl" ,openssl) openssl
("elfutils" ,elfutils) ;needed to enable CONFIG_STACK_VALIDATION elfutils ;needed to enable CONFIG_STACK_VALIDATION
("flex" ,flex) flex
("bison" ,bison) bison
;; These are needed to compile the GCC plugins.
;; These are needed to compile the GCC plugins. gmp
("gmp" ,gmp) mpfr
("mpfr" ,mpfr) mpc))
("mpc" ,mpc)
,@(match (let ((arch (platform-linux-architecture
(lookup-platform-by-target-or-system
(or (%current-target-system)
(%current-system))))))
(and configuration-file arch
(configuration-file
arch
#:variant (version-major+minor version))))
(#f ;no config for this platform
'())
((? string? config)
`(("kconfig" ,config))))))
(home-page "https://www.gnu.org/software/linux-libre/") (home-page "https://www.gnu.org/software/linux-libre/")
(synopsis "100% free redistribution of a cleaned Linux kernel") (synopsis "100% free redistribution of a cleaned Linux kernel")
(description "GNU Linux-Libre is a free (as in freedom) variant of the (description "GNU Linux-Libre is a free (as in freedom) variant of the