From debbugs-submit-bounces@debbugs.gnu.org Fri Dec 02 00:31:05 2022 Received: (at 59761) by debbugs.gnu.org; 2 Dec 2022 05:31:05 +0000 Received: from localhost ([127.0.0.1]:44249 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p0ydc-0001bR-Up for submit@debbugs.gnu.org; Fri, 02 Dec 2022 00:31:05 -0500 Received: from mail-qv1-f42.google.com ([209.85.219.42]:36718) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p0yda-0001ag-Pi for 59761@debbugs.gnu.org; Fri, 02 Dec 2022 00:31:03 -0500 Received: by mail-qv1-f42.google.com with SMTP id o12so2828832qvn.3 for <59761@debbugs.gnu.org>; Thu, 01 Dec 2022 21:31:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=1dfdspZuYdUMjaTIAUn5aND4YoXvLSrGgAmsUXitrBs=; b=O1vvBs00N3lm1UJGYHIgHlVsvGiH0JiqwNfHUJ2ARZx0vwhUXJOb9k2Z8LXFyn3twA kYW4XAJ+43mUbla5+ODJJN8zlLiKmTDaE3y1E1ilS8q+dcN23rMe3Ffv8tZXqmxegDav xwZI0ijLLr6ATG+VGhg59cQoZT/u582rJk6H5Fw7WViLItlCHwf/jYh1Zt4m1SnbIgXb PkAY1wQI7dHWojsPgWfC9ffhDMmork1GxJsmc6inqh3IpA6h/Y+COXNEbSgYY9ngE1AX UzjeoUtGrZJ2YIinYoqySmO61/2ovwJ5U6YqVGhjPs+6M5zosoicSs792Ep8JwNISe8j GQ+A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=1dfdspZuYdUMjaTIAUn5aND4YoXvLSrGgAmsUXitrBs=; b=qHcM3WIIG1j+Evp3SSDLFFSQitJPR9KifNxo4sdoZoCX8kctDOoXL6qJLl4GEpMCkf T8OHFqEgj32a3USGnZXyHrWIB/awNhssQTIO4bAixzDm8V0fE9Vjby4hAT1P7Udr6dwD H9fWV6BtfO5dEm9eHkPMWfH/j3yOK2J3/DDHUchtaZcAp6Jrhn7eC5408GKgoEa53A2D q1FNofP+vttxdBEGGHQM8wdtu/7iQxzyAaRo9+GEkGvCsM/rKJgvYhFcFh8WNnOMdZyQ sIFDtNGKz5tIfwIeMGavW3dUBaGE6mtV1iNL6uqEkWfvnS5KI7EI9Gm3ORXYsk7HLgU8 yh4Q== X-Gm-Message-State: ANoB5pm5uoaqVCxKFpENkhe9tZQDZ0I27bamZgEYa5usNVybWLcXUg0t BlqCAI1gl5C8gA+THIQbwcBQbCRjoxg= X-Google-Smtp-Source: AA0mqf5tYb4qYLkSX8bCj0krCmd0EN/viUtMpiOwi/ZPmbnG+5ynWPxqdlI9i1dh206ostFtnJM7Cw== X-Received: by 2002:ad4:43eb:0:b0:4c6:90f0:cbe6 with SMTP id f11-20020ad443eb000000b004c690f0cbe6mr44711427qvu.116.1669959057077; Thu, 01 Dec 2022 21:30:57 -0800 (PST) Received: from localhost.localdomain ([2607:fad8:4:3::1001]) by smtp.gmail.com with ESMTPSA id o21-20020a05620a2a1500b006eeb3165554sm5019959qkp.19.2022.12.01.21.30.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Dec 2022 21:30:56 -0800 (PST) From: Maxim Cournoyer To: 59761@debbugs.gnu.org Subject: [PATCH 1/2] gnu: make-u-boot-package: Add a u-boot argument. Date: Fri, 2 Dec 2022 00:30:51 -0500 Message-Id: <20221202053052.10563-1-maxim.cournoyer@gmail.com> X-Mailer: git-send-email 2.38.1 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 59761 Cc: Maxim Cournoyer X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) 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 ;;; Copyright © 2022 Denis 'GNUtoo' Carikli ;;; Copyright © 2021 Stefan +;;; Copyright © 2022 Maxim Cournoyer ;;; ;;; 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")) -- 2.38.1