unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
From: Maxim Cournoyer <maxim.cournoyer@gmail.com>
To: 59761@debbugs.gnu.org
Cc: Maxim Cournoyer <maxim.cournoyer@gmail.com>
Subject: [bug#59761] [PATCH v3 1/4] gnu: make-u-boot-package: Add a u-boot argument.
Date: Tue, 13 Dec 2022 21:32:33 -0500	[thread overview]
Message-ID: <20221214023236.25345-1-maxim.cournoyer@gmail.com> (raw)
In-Reply-To: <20221202052903.10475-1-maxim.cournoyer@gmail.com>

And have that u-boot argument used as the complete base of the template, so
that a user can override it.

* gnu/packages/bootloaders.scm (make-u-boot-package): New U-BOOT argument.
Document it.
[native-inputs]: Move the native-inputs of U-BOOT first, so that the
cross compilation tools can be overridden via U-BOOT.
[arguments]: Rewrite using substitute-keyword-arguments, extending rather than
overriding most arguments.  Use gexps.
---
 gnu/packages/bootloaders.scm | 180 +++++++++++++++++++----------------
 1 file changed, 97 insertions(+), 83 deletions(-)

diff --git a/gnu/packages/bootloaders.scm b/gnu/packages/bootloaders.scm
index 8888c51736..7ec9bbb543 100644
--- a/gnu/packages/bootloaders.scm
+++ b/gnu/packages/bootloaders.scm
@@ -17,6 +17,7 @@
 ;;; Copyright © 2021 Brice Waegeneire <brice@waegenei.re>
 ;;; Copyright © 2022 Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
 ;;; Copyright © 2021 Stefan <stefan-guix@vodafonemail.de>
+;;; Copyright © 2022 Maxim Cournoyer <maxim.cournoyer@gmail.com>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -782,11 +783,13 @@ (define*-public (make-u-boot-package board triplet
                                      defconfig
                                      configs
                                      name-suffix
-                                     append-description)
+                                     append-description
+                                     (u-boot u-boot))
   "Return a U-Boot package for BOARD cross-compiled for TRIPLET with the
 optional DEFCONFIG file and optional configuration changes from CONFIGS.
 NAME-SUFFIX is appended to the package name, while APPEND-DESCRIPTION is
-appended to the package description."
+appended to the package description.  U-BOOT can be used when a fork or a
+different version of U-Boot must be used."
   (let ((same-arch? (lambda ()
                       (string=? (%current-system)
                                 (gnu-triplet->nix-system triplet)))))
@@ -801,90 +804,101 @@ (define*-public (make-u-boot-package board triplet
                                       "\n\n" append-description)
                        (package-description u-boot)))
       (native-inputs
-       `(,@(if (not (same-arch?))
+       ;; Note: leave the native u-boot inputs first, so that a user can
+       ;; override the cross-gcc and cross-binutils packages.
+       `(,@(package-native-inputs u-boot)
+         ,@(if (not (same-arch?))
                `(("cross-gcc" ,(cross-gcc triplet))
                  ("cross-binutils" ,(cross-binutils triplet)))
-               `())
-         ,@(package-native-inputs u-boot)))
+               `())))
       (arguments
-       `(#:modules ((ice-9 ftw)
-                    (srfi srfi-1)
-                    (guix build gnu-build-system)
-                    (guix build kconfig)
-                    (guix build utils))
-         #:imported-modules (,@%gnu-build-system-modules
-                             (guix build kconfig))
-         #:test-target "test"
-         #:make-flags
-         (list "HOSTCC=gcc"
-               ,@(if (not (same-arch?))
-                     `((string-append "CROSS_COMPILE=" ,triplet "-"))
-                     '()))
-         #:phases
-         (modify-phases %standard-phases
-           (replace 'configure
-             (lambda* (#:key outputs make-flags #:allow-other-keys)
-               (let* ((config-name (string-append ,board "_defconfig"))
-                      (config-file (string-append "configs/" config-name))
-                      (defconfig ,defconfig)
-                      (configs ',configs))
-                 (when defconfig
-                   ;; Replace the board-specific defconfig with the given one.
-                   (copy-file defconfig config-file))
-                 (if (file-exists? config-file)
-                     (begin
-                       (when configs
-                         (modify-defconfig config-file configs))
-                       (apply invoke "make" `(,@make-flags ,config-name))
-                       (verify-config ".config" config-file))
-                     (begin
-                       (display "invalid board name; valid board names are:"
-                                (current-error-port))
-                       (let ((suffix-len (string-length "_defconfig"))
-                             (entries (scandir "configs")))
-                         (for-each (lambda (file-name)
-                                     (when (string-suffix? "_defconfig" file-name)
-                                       (format (current-error-port)
-                                               "- ~A\n"
-                                               (string-drop-right file-name
-                                                                  suffix-len))))
-                                   (sort entries string-ci<)))
-                       (error "invalid boardname ~s" ,board))))))
-           (add-after 'configure 'disable-tools-libcrypto
-             ;; Disable libcrypto due to GPL and OpenSSL license
-             ;; incompatibilities
-             (lambda _
-               (substitute* ".config"
-                 (("CONFIG_TOOLS_LIBCRYPTO=.*$") "CONFIG_TOOLS_LIBCRYPTO=n"))))
-           (replace 'install
-             (lambda* (#:key outputs #:allow-other-keys)
-               (let* ((out (assoc-ref outputs "out"))
-                      (libexec (string-append out "/libexec"))
-                      (uboot-files (append
-                                    (remove
-                                     ;; Those would not be reproducible
-                                     ;; because of the randomness used
-                                     ;; to produce them.
-                                     ;; It's expected that the user will
-                                     ;; use u-boot-tools to generate them
-                                     ;; instead.
-                                     (lambda (name)
-                                       (string-suffix?
-                                        "sunxi-spl-with-ecc.bin"
-                                        name))
-                                     (find-files "." ".*\\.(bin|efi|img|spl|itb|dtb|rksd)$"))
-                                    (find-files "." "^(MLO|SPL)$"))))
-                 (mkdir-p libexec)
-                 (install-file ".config" libexec)
-                 ;; Useful for "qemu -kernel".
-                 (install-file "u-boot" libexec)
-                 (for-each
-                  (lambda (file)
-                    (let ((target-file (string-append libexec "/" file)))
-                      (mkdir-p (dirname target-file))
-                      (copy-file file target-file)))
-                  uboot-files)
-                 #t)))))))))
+       (substitute-keyword-arguments (package-arguments u-boot)
+         ((#:modules modules '())
+          `((ice-9 ftw)
+            (srfi srfi-1)
+            (guix build gnu-build-system)
+            (guix build kconfig)
+            (guix build utils)
+            ,@modules))
+         ((#:imported-modules imported-modules '())
+          `((guix build kconfig)
+            ,@%gnu-build-system-modules
+            ,@imported-modules))
+         ((#:test-target _ "test")
+          "test")
+         ((#:make-flags make-flags '())
+          #~(list "HOSTCC=gcc"
+                  #$@(if (not (same-arch?))
+                         (list (string-append "CROSS_COMPILE=" triplet "-"))
+                         '())
+                  #$@make-flags))
+         ((#:phases phases '%standard-phases)
+          #~(modify-phases #$phases
+              (replace 'configure
+                (lambda* (#:key outputs make-flags #:allow-other-keys)
+                  (let* ((config-name (string-append #$board "_defconfig"))
+                         (config-file (string-append "configs/" config-name))
+                         (defconfig #$defconfig)
+                         (configs '#$configs))
+                    (when defconfig
+                      ;; Replace the board-specific defconfig with the given
+                      ;; one.
+                      (copy-file defconfig config-file))
+                    (if (file-exists? config-file)
+                        (begin
+                          (when configs
+                            (modify-defconfig config-file configs))
+                          (apply invoke "make" `(,@make-flags ,config-name))
+                          (verify-config ".config" config-file))
+                        (begin
+                          (display "invalid board name; valid board names are:"
+                                   (current-error-port))
+                          (let ((suffix-len (string-length "_defconfig"))
+                                (entries (scandir "configs")))
+                            (for-each (lambda (file-name)
+                                        (when (string-suffix? "_defconfig"
+                                                              file-name)
+                                          (format (current-error-port)
+                                                  "- ~A\n"
+                                                  (string-drop-right
+                                                   file-name suffix-len))))
+                                      (sort entries string-ci<)))
+                          (error "invalid boardname ~s" #$board))))))
+              (add-after 'configure 'disable-tools-libcrypto
+                ;; Disable libcrypto due to GPL and OpenSSL license
+                ;; incompatibilities
+                (lambda _
+                  (substitute* ".config"
+                    (("CONFIG_TOOLS_LIBCRYPTO=.*$")
+                     "CONFIG_TOOLS_LIBCRYPTO=n"))))
+              (replace 'install
+                (lambda* (#:key outputs #:allow-other-keys)
+                  (let ((libexec (string-append #$output "/libexec"))
+                        (uboot-files
+                         (append
+                          (remove
+                           ;; Those would not be reproducible
+                           ;; because of the randomness used to
+                           ;; produce them.  It's expected that the
+                           ;; user will use u-boot-tools to generate
+                           ;; them instead.
+                           (lambda (name)
+                             (string-suffix?
+                              "sunxi-spl-with-ecc.bin"
+                              name))
+                           (find-files "."
+                                       ".*\\.(bin|efi|img|spl|itb|dtb|rksd)$"))
+                          (find-files "." "^(MLO|SPL)$"))))
+                    (mkdir-p libexec)
+                    (install-file ".config" libexec)
+                    ;; Useful for "qemu -kernel".
+                    (install-file "u-boot" libexec)
+                    (for-each
+                     (lambda (file)
+                       (let ((target-file (string-append libexec "/" file)))
+                         (mkdir-p (dirname target-file))
+                         (copy-file file target-file)))
+                     uboot-files)))))))))))
 
 (define-public u-boot-malta
   (make-u-boot-package "malta" "mips64el-linux-gnuabi64"))

base-commit: 0ffa501f2b3e83ae56e9c2bd31418439090e869a
-- 
2.38.1





  parent reply	other threads:[~2022-12-14  2:33 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-02  5:29 [bug#59761] [PATCH 0/2] Add u-boot-ts7970-q-2g-1000mhz-c Maxim Cournoyer
2022-12-02  5:30 ` [bug#59761] [PATCH 1/2] gnu: make-u-boot-package: Add a u-boot argument Maxim Cournoyer
2022-12-02  5:30   ` [bug#59761] [PATCH 2/2] gnu: Add u-boot-ts7970-q-2g-1000mhz-c Maxim Cournoyer
2022-12-07 15:01 ` [bug#59761] [PATCH v2 1/3] gnu: make-u-boot-package: Add a u-boot argument Maxim Cournoyer
2022-12-07 15:02   ` [bug#59761] [PATCH v2 2/3] gnu: make-u-boot-package: Install .imx files Maxim Cournoyer
2022-12-07 15:02   ` [bug#59761] [PATCH v2 3/3] gnu: Add u-boot-ts7970-q-2g-1000mhz-c Maxim Cournoyer
2022-12-14  2:32 ` Maxim Cournoyer [this message]
2022-12-14  2:32   ` [bug#59761] [PATCH v3 2/4] gnu: make-u-boot-package: Install .imx files Maxim Cournoyer
2022-12-14  2:32   ` [bug#59761] [PATCH v3 3/4] gnu: Add u-boot-ts7970-q-2g-1000mhz-c Maxim Cournoyer
2022-12-14  2:32   ` [bug#59761] [PATCH v3 4/4] gnu: Add u-boot-ts7970-q-2g-1000mhz-c-bootloader Maxim Cournoyer
2022-12-20 18:22 ` [bug#59761] [PATCH v4 1/2] gnu: Add u-boot-ts7970-q-2g-1000mhz-c Maxim Cournoyer
2022-12-20 18:22   ` [bug#59761] [PATCH v4 2/2] gnu: Add u-boot-ts7970-q-2g-1000mhz-c-bootloader Maxim Cournoyer
2022-12-29 19:33 ` [bug#59761] [PATCH 0/2] Add u-boot-ts7970-q-2g-1000mhz-c Ricardo Wurmus
2023-01-04  4:17   ` Maxim Cournoyer
2023-01-04  5:34     ` Maxim Cournoyer
2023-01-04  7:35     ` Ricardo Wurmus
2023-01-04 14:46       ` Maxim Cournoyer
2023-01-04  5:32 ` [bug#59761] [PATCH v5 1/2] gnu: " Maxim Cournoyer
2023-01-04  5:32   ` [bug#59761] [PATCH v5 2/2] gnu: Add u-boot-ts7970-q-2g-1000mhz-c-bootloader Maxim Cournoyer
2023-01-19  2:30     ` bug#59761: [PATCH 0/2] Add u-boot-ts7970-q-2g-1000mhz-c Maxim Cournoyer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://guix.gnu.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20221214023236.25345-1-maxim.cournoyer@gmail.com \
    --to=maxim.cournoyer@gmail.com \
    --cc=59761@debbugs.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).