guix-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

01/02: gnu: linux: Move customization procedures near the top.


From: guix-commits
Subject: 01/02: gnu: linux: Move customization procedures near the top.
Date: Wed, 7 Dec 2022 09:27:12 -0500 (EST)

apteryx pushed a commit to branch master
in repository guix.

commit 1e05b4a7fd862f7abafb745d52d89e0f20f0c1ba
Author: Maxim Cournoyer <maxim.cournoyer@gmail.com>
AuthorDate: Wed Dec 7 00:33:46 2022 -0500

    gnu: linux: Move customization procedures near the top.
    
    This makes it possible to use them to define Linux kernel variants in the 
same
    file.
    
    * gnu/packages/linux.scm (customize-linux), make-defconfig): Move near the 
top
    of the module.
---
 gnu/packages/linux.scm | 211 +++++++++++++++++++++++++------------------------
 1 file changed, 106 insertions(+), 105 deletions(-)

diff --git a/gnu/packages/linux.scm b/gnu/packages/linux.scm
index 18e9016806..8d86ec67e1 100644
--- a/gnu/packages/linux.scm
+++ b/gnu/packages/linux.scm
@@ -195,6 +195,112 @@
   #:export (customize-linux
             make-defconfig))
 
+
+
+;;;
+;;; Linux kernel customization functions.
+;;;
+
+(define* (customize-linux #:key name
+                          (linux linux-libre)
+                          source
+                          defconfig
+                          (configs "")
+                          extra-version)
+  "Make a customized Linux package NAME derived from the LINUX package.
+
+If NAME is not given, then it defaults to the same name as the LINUX package.
+
+Unless SOURCE is given the source of LINUX is used.
+
+A DEFCONFIG file to be used can be given as an origin, as a file-like object
+(file-append, local-file etc.), or as a string with the name of a defconfig 
file
+available in the Linux sources.  If DEFCONFIG is not given, then a defconfig
+file will be saved from the LINUX package configuration.
+
+Additional CONFIGS will be used to modify the given or saved defconfig, which
+will finally be used to build Linux.
+
+CONFIGS can be a list of strings, with one configuration per line.  The usual
+defconfig syntax has to be used, but there is a special extension to ease the
+removal of configurations.  Comment lines are supported as well.
+
+Here is an example:
+
+  '(;; This string defines the version tail in 'uname -r'.
+    \"CONFIG_LOCALVERSION=\\\"-handcrafted\\\"
+    ;; This '# CONFIG_... is not set' syntax has to match exactly!
+    \"# CONFIG_BOOT_CONFIG is not set\"
+    \"CONFIG_NFS_SWAP=y\"
+    ;; This is a multiline configuration:
+    \"CONFIG_E1000=y
+# This is a comment, below follows an extension to unset a configuration:
+CONFIG_CMDLINE_EXTEND\")
+
+A string of configurations instead of a list of configuration strings is also
+possible.
+
+EXTRA-VERSION can be a string overwriting the EXTRAVERSION setting of the LINUX
+package, after being prepended by a hyphen.  It will be visible in the output
+of 'uname -r' behind the Linux version numbers."
+  (package
+    (inherit linux)
+    (name (or name (package-name linux)))
+    (source (or source (package-source linux)))
+    (arguments
+     (substitute-keyword-arguments
+         (package-arguments linux)
+       ((#:imported-modules imported-modules %gnu-build-system-modules)
+        `((guix build kconfig) ,@imported-modules))
+       ((#:modules modules)
+        `((guix build kconfig) ,@modules))
+       ((#:phases phases)
+        #~(modify-phases #$phases
+            (replace 'configure
+              (lambda* (#:key inputs #:allow-other-keys #:rest arguments)
+                (setenv "EXTRAVERSION"
+                        #$(and extra-version
+                               (not (string-null? extra-version))
+                               (string-append "-" extra-version)))
+                (let* ((configs
+                        (string-append "arch/" #$(linux-srcarch) "/configs/"))
+                       (guix_defconfig
+                        (string-append configs "guix_defconfig")))
+                  #$(cond
+                     ((not defconfig)
+                      #~(begin
+                          ;; Call the original 'configure phase.
+                          (apply (assoc-ref #$phases 'configure) arguments)
+                          ;; Save a defconfig file.
+                          (invoke "make" "savedefconfig")
+                          ;; Move the saved defconfig to the proper location.
+                          (rename-file "defconfig"
+                                       guix_defconfig)))
+                     ((string? defconfig)
+                      ;; Use another existing defconfig from the Linux sources.
+                      #~(rename-file (string-append configs #$defconfig)
+                                     guix_defconfig))
+                     (else
+                      ;; Copy the defconfig input to the proper location.
+                      #~(copy-file (assoc-ref inputs "guix_defconfig")
+                                   guix_defconfig)))
+                  (chmod guix_defconfig #o644)
+                  (modify-defconfig guix_defconfig '#$configs)
+                  (invoke "make" "guix_defconfig")
+                  (verify-config ".config" guix_defconfig))))))))
+    (native-inputs
+     (append (if (or (not defconfig)
+                     (string? defconfig))
+                 '()
+                 ;; The defconfig should be an origin or file-like object.
+                 `(("guix_defconfig" ,defconfig)))
+             (package-native-inputs linux)))))
+
+(define (make-defconfig uri sha256-as-base32)
+  (origin (method url-fetch)
+          (uri uri)
+          (sha256 (base32 sha256-as-base32))))
+
 (define (linux-srcarch)
   "Return the linux SRCARCH name, which is set in the toplevel Makefile of
 Linux and denotes the architecture-specific directory name below arch/ in its
@@ -1265,111 +1371,6 @@ Linux-Libre, as an Info manual.  To consult it, run 
@samp{info linux}.")))
                 (prepend cpio))))))
 
 
-;;;
-;;; Linux kernel customization functions.
-;;;
-
-(define* (customize-linux #:key name
-                          (linux linux-libre)
-                          source
-                          defconfig
-                          (configs "")
-                          extra-version)
-  "Make a customized Linux package NAME derived from the LINUX package.
-
-If NAME is not given, then it defaults to the same name as the LINUX package.
-
-Unless SOURCE is given the source of LINUX is used.
-
-A DEFCONFIG file to be used can be given as an origin, as a file-like object
-(file-append, local-file etc.), or as a string with the name of a defconfig 
file
-available in the Linux sources.  If DEFCONFIG is not given, then a defconfig
-file will be saved from the LINUX package configuration.
-
-Additional CONFIGS will be used to modify the given or saved defconfig, which
-will finally be used to build Linux.
-
-CONFIGS can be a list of strings, with one configuration per line.  The usual
-defconfig syntax has to be used, but there is a special extension to ease the
-removal of configurations.  Comment lines are supported as well.
-
-Here is an example:
-
-  '(;; This string defines the version tail in 'uname -r'.
-    \"CONFIG_LOCALVERSION=\\\"-handcrafted\\\"
-    ;; This '# CONFIG_... is not set' syntax has to match exactly!
-    \"# CONFIG_BOOT_CONFIG is not set\"
-    \"CONFIG_NFS_SWAP=y\"
-    ;; This is a multiline configuration:
-    \"CONFIG_E1000=y
-# This is a comment, below follows an extension to unset a configuration:
-CONFIG_CMDLINE_EXTEND\")
-
-A string of configurations instead of a list of configuration strings is also
-possible.
-
-EXTRA-VERSION can be a string overwriting the EXTRAVERSION setting of the LINUX
-package, after being prepended by a hyphen.  It will be visible in the output
-of 'uname -r' behind the Linux version numbers."
-  (package
-    (inherit linux)
-    (name (or name (package-name linux)))
-    (source (or source (package-source linux)))
-    (arguments
-     (substitute-keyword-arguments
-         (package-arguments linux)
-       ((#:imported-modules imported-modules %gnu-build-system-modules)
-        `((guix build kconfig) ,@imported-modules))
-       ((#:modules modules)
-        `((guix build kconfig) ,@modules))
-       ((#:phases phases)
-        #~(modify-phases #$phases
-            (replace 'configure
-              (lambda* (#:key inputs #:allow-other-keys #:rest arguments)
-                (setenv "EXTRAVERSION"
-                        #$(and extra-version
-                               (not (string-null? extra-version))
-                               (string-append "-" extra-version)))
-                (let* ((configs
-                        (string-append "arch/" #$(linux-srcarch) "/configs/"))
-                       (guix_defconfig
-                        (string-append configs "guix_defconfig")))
-                  #$(cond
-                     ((not defconfig)
-                      #~(begin
-                          ;; Call the original 'configure phase.
-                          (apply (assoc-ref #$phases 'configure) arguments)
-                          ;; Save a defconfig file.
-                          (invoke "make" "savedefconfig")
-                          ;; Move the saved defconfig to the proper location.
-                          (rename-file "defconfig"
-                                       guix_defconfig)))
-                     ((string? defconfig)
-                      ;; Use another existing defconfig from the Linux sources.
-                      #~(rename-file (string-append configs #$defconfig)
-                                     guix_defconfig))
-                     (else
-                      ;; Copy the defconfig input to the proper location.
-                      #~(copy-file (assoc-ref inputs "guix_defconfig")
-                                   guix_defconfig)))
-                  (chmod guix_defconfig #o644)
-                  (modify-defconfig guix_defconfig '#$configs)
-                  (invoke "make" "guix_defconfig")
-                  (verify-config ".config" guix_defconfig))))))))
-    (native-inputs
-     (append (if (or (not defconfig)
-                     (string? defconfig))
-                 '()
-                 ;; The defconfig should be an origin or file-like object.
-                 `(("guix_defconfig" ,defconfig)))
-             (package-native-inputs linux)))))
-
-(define (make-defconfig uri sha256-as-base32)
-  (origin (method url-fetch)
-          (uri uri)
-          (sha256 (base32 sha256-as-base32))))
-
-
 ;;;
 ;;; Linux kernel modules.
 ;;;



reply via email to

[Prev in Thread] Current Thread [Next in Thread]