me
/
guix
Archived
1
0
Fork 0

gnu: make-linux-libre*: Use G-expressions.

* gnu/packages/linux.scm (make-linux-libre*)[arguments]:
Rewrite as G-expressions.
master
Tobias Geerinckx-Rice 2021-12-23 06:39:57 +01:00
parent a01b216508
commit a61633d4ba
No known key found for this signature in database
GPG Key ID: 0DB0FF884F556D79
1 changed files with 91 additions and 87 deletions

View File

@ -807,101 +807,105 @@ for ARCH and optionally VARIANT, or #f if there is no such configuration."
((? string? config) ((? string? config)
`(("kconfig" ,config)))))) `(("kconfig" ,config))))))
(arguments (arguments
`(#:modules ((guix build gnu-build-system) (list #:modules '((guix build gnu-build-system)
(guix build utils) (guix build utils)
(srfi srfi-1) (srfi srfi-1)
(srfi srfi-26) (srfi srfi-26)
(ice-9 ftw) (ice-9 ftw)
(ice-9 match)) (ice-9 match))
#:phases #:phases
(modify-phases %standard-phases #~(modify-phases %standard-phases
(add-after 'unpack 'patch-/bin/pwd (add-after 'unpack 'patch-/bin/pwd
(lambda _ (lambda _
(substitute* (find-files "." "^Makefile(\\.include)?$") (substitute* (find-files "." "^Makefile(\\.include)?$")
(("/bin/pwd") "pwd")))) (("/bin/pwd") "pwd"))))
(replace 'configure (replace 'configure
(lambda* (#:key inputs native-inputs target #:allow-other-keys) (lambda* (#:key inputs target #:allow-other-keys)
;; Avoid introducing timestamps. ;; Avoid introducing timestamps.
(setenv "KCONFIG_NOTIMESTAMP" "1") (setenv "KCONFIG_NOTIMESTAMP" "1")
(setenv "KBUILD_BUILD_TIMESTAMP" (getenv "SOURCE_DATE_EPOCH")) (setenv "KBUILD_BUILD_TIMESTAMP"
(getenv "SOURCE_DATE_EPOCH"))
;; Other variables useful for reproducibility. ;; Other variables useful for reproducibility.
(setenv "KBUILD_BUILD_USER" "guix") (setenv "KBUILD_BUILD_USER" "guix")
(setenv "KBUILD_BUILD_HOST" "guix") (setenv "KBUILD_BUILD_HOST" "guix")
;; Set ARCH and CROSS_COMPILE. ;; Set ARCH and CROSS_COMPILE.
(let ((arch ,(system->linux-architecture (let ((arch #$(system->linux-architecture
(or (%current-target-system) (or (%current-target-system)
(%current-system))))) (%current-system)))))
(setenv "ARCH" arch) (setenv "ARCH" arch)
(format #t "`ARCH' set to `~a'~%" (getenv "ARCH")) (format #t "`ARCH' set to `~a'~%" (getenv "ARCH"))
(when target (when target
(setenv "CROSS_COMPILE" (string-append target "-")) (setenv "CROSS_COMPILE" (string-append target "-"))
(format #t "`CROSS_COMPILE' set to `~a'~%" (format #t "`CROSS_COMPILE' set to `~a'~%"
(getenv "CROSS_COMPILE")))) (getenv "CROSS_COMPILE"))))
(setenv "EXTRAVERSION" ,(and extra-version (setenv "EXTRAVERSION"
(string-append "-" extra-version))) #$(and extra-version
(string-append "-" extra-version)))
(let ((build (assoc-ref %standard-phases 'build)) (let ((build (assoc-ref %standard-phases 'build))
(config (assoc-ref (or native-inputs inputs) "kconfig"))) (config (assoc-ref inputs "kconfig")))
;; 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
(begin (begin
(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. The last one prevails if duplicated. ;; file. 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 native-inputs outputs #:allow-other-keys) (lambda* (#:key inputs native-inputs #:allow-other-keys)
(let* ((out (assoc-ref outputs "out")) (let ((moddir (string-append #$output "/lib/modules"))
(moddir (string-append out "/lib/modules")) (dtbdir (string-append #$output "/lib/dtbs")))
(dtbdir (string-append out "/lib/dtbs"))) ;; Install kernel image, kernel configuration and link map.
;; Install kernel image, kernel configuration and link map. (for-each (lambda (file) (install-file file #$output))
(for-each (lambda (file) (install-file file out)) (find-files "." "^(\\.config|bzImage|zImage|Image|vmlinuz|System\\.map|Module\\.symvers)$"))
(find-files "." "^(\\.config|bzImage|zImage|Image|vmlinuz|System\\.map|Module\\.symvers)$")) ;; Install device tree files
;; Install device tree files (unless (null? (find-files "." "\\.dtb$"))
(unless (null? (find-files "." "\\.dtb$")) (mkdir-p dtbdir)
(mkdir-p dtbdir) (invoke "make" (string-append "INSTALL_DTBS_PATH=" dtbdir)
(invoke "make" (string-append "INSTALL_DTBS_PATH=" dtbdir) "dtbs_install"))
"dtbs_install")) ;; 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 directory ;; module directory is an union of potentially
;; is an union of potentially multiple packages. It is not ;; multiple packages. It is not possible to use
;; possible to use depmod to usefully calculate a dependency ;; depmod to usefully calculate a dependency
;; graph while building only one of those packages. ;; graph while building only one of them.
"DEPMOD=true" "DEPMOD=true"
(string-append "MODULE_DIR=" moddir) (string-append "MODULE_DIR=" moddir)
(string-append "INSTALL_PATH=" out) (string-append "INSTALL_PATH=" #$output)
(string-append "INSTALL_MOD_PATH=" out) (string-append "INSTALL_MOD_PATH=" #$output)
"INSTALL_MOD_STRIP=1" "INSTALL_MOD_STRIP=1"
"modules_install") "modules_install")
(let* ((versions (filter (lambda (name) (let* ((versions (filter (lambda (name)
(not (string-prefix? "." name))) (not (string-prefix? "." name)))
(scandir moddir))) (scandir moddir)))
(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 of which will point to target /tmp/guix-build* ;; Both will point to target /tmp/guix-build* and thus
;; and thus not be useful in a profile. Delete the symlinks. ;; not be useful in a profile. Delete the symlinks.
(false-if-file-not-found (false-if-file-not-found
(delete-file (string-append moddir "/" version "/build"))) (delete-file
(false-if-file-not-found (string-append moddir "/" version "/build")))
(delete-file (string-append moddir "/" version "/source")))))))) (false-if-file-not-found
#:tests? #f)) (delete-file
(string-append moddir "/" version "/source"))))))))
#:tests? #f))
(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 (description