From patchwork Mon Jan 2 00:46:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxim Cournoyer X-Patchwork-Id: 45787 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id 824C227BBE9; Mon, 2 Jan 2023 00:47:36 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-3.7 required=5.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FROM,MAILING_LIST_MULTI, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS autolearn=ham autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id 8A25327BBED for ; Mon, 2 Jan 2023 00:47:34 +0000 (GMT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pC8yn-0001r6-KT; Sun, 01 Jan 2023 19:47:05 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pC8yl-0001qV-Ta for guix-patches@gnu.org; Sun, 01 Jan 2023 19:47:03 -0500 Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pC8yl-0004WQ-F6 for guix-patches@gnu.org; Sun, 01 Jan 2023 19:47:03 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pC8yl-0007Gn-9k for guix-patches@gnu.org; Sun, 01 Jan 2023 19:47:03 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#60224] [PATCH v3 01/11] gnu: make-u-boot-package: Add a u-boot argument and use gexps. References: <20221220165038.25114-1-maxim.cournoyer@gmail.com> In-Reply-To: <20221220165038.25114-1-maxim.cournoyer@gmail.com> Resent-From: Maxim Cournoyer Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Mon, 02 Jan 2023 00:47:03 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 60224 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 60224@debbugs.gnu.org Cc: rekado@elephly.net, Maxim Cournoyer Received: via spool by 60224-submit@debbugs.gnu.org id=B60224.167262041827872 (code B ref 60224); Mon, 02 Jan 2023 00:47:03 +0000 Received: (at 60224) by debbugs.gnu.org; 2 Jan 2023 00:46:58 +0000 Received: from localhost ([127.0.0.1]:42060 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pC8yf-0007FG-Kg for submit@debbugs.gnu.org; Sun, 01 Jan 2023 19:46:58 -0500 Received: from mail-qt1-f171.google.com ([209.85.160.171]:42720) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pC8yd-0007Eq-Rw for 60224@debbugs.gnu.org; Sun, 01 Jan 2023 19:46:57 -0500 Received: by mail-qt1-f171.google.com with SMTP id i20so21467545qtw.9 for <60224@debbugs.gnu.org>; Sun, 01 Jan 2023 16:46:55 -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=aoaP4N09+ZK7r2QCQIrxaE8IUHQ+3Y1+30O+DuSUUnc=; b=hmeZt3bLmydvmMs9I2XceyaiRtnnYue43u9Gki4tV+0s926SqswH+oTAgfwpPGGCcp FdaBeZ2MLlhXH/T6yhqGm/l3BDfXiFbyla8+XlKmy3V4sKNAryuddxGcKfiF0N0G1pWB 0IlklhXo95gM7y3GtUjmKneDSq30ElllE41lDRk5192sUlM7AaJtTTgXX7jIM5HhMbPb PA1R9lgGnLcIW8m4rdLUhMFG3XgUx/pj50NfGfneHzzElA0jSpKTI8roGJGY1jMBanR7 vsm8SNkiEPc740tYFZihkjB+bZO2s9aasBS8xh3UCgEUTotPBcGQMgNn/My1CqDXVF2L sf6g== 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=aoaP4N09+ZK7r2QCQIrxaE8IUHQ+3Y1+30O+DuSUUnc=; b=rNf5bZDRmY+clb1T5IHXa7gIXxBSGggmy+u5sFQ5/AE9m+W4+alSeMdJRi+RBKMsNx PQeWAij9eqcBLUiQJ8uzGW2taHTIfxHcOMydAjj57Tm1nT0dfPrn895edpXCqSaCgDpZ vMM2cmLI5/wgySi4i7nFYH9BGTnEd/cib9yw5E1Jdu70IodZSiKQ8biqwANJ5cUH2hXD scpSUbnWdvV8RoHQrO+exmDSF8DzEroNC9oT5J6XCJ508/syhfg1FsmqJEIJt3zl9gFE MrQxwhDROwxF+dc+dWF1Ez5jiIJ14reATvkbR3Dqf8vSTHERmBl67o2xSeeOTOYLdRHj OVGA== X-Gm-Message-State: AFqh2kp4I79txm1U4l7C6BuDyqdlaStmydK3CFag2zG6TkrGA0v3c6YO ltMrJKa8tYjxK953LHdjvWJC7TbiZyl6mQ== X-Google-Smtp-Source: AMrXdXvCuDFfiUdraOsQJ6KtAqOq1w6lFBuvft2lEZ5ypAWRfLcpk1D9d7hH2WyXspge03v0mg4aIA== X-Received: by 2002:a05:622a:230e:b0:3a7:e14e:9579 with SMTP id ck14-20020a05622a230e00b003a7e14e9579mr59941913qtb.29.1672620410022; Sun, 01 Jan 2023 16:46:50 -0800 (PST) Received: from localhost.localdomain (dsl-10-148-224.b2b2c.ca. [72.10.148.224]) by smtp.gmail.com with ESMTPSA id h24-20020ac87458000000b003a7ef7a758dsm16788311qtr.59.2023.01.01.16.46.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 01 Jan 2023 16:46:49 -0800 (PST) From: Maxim Cournoyer Date: Sun, 1 Jan 2023 19:46:26 -0500 Message-Id: <20230102004637.3920-1-maxim.cournoyer@gmail.com> X-Mailer: git-send-email 2.38.1 MIME-Version: 1.0 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org X-getmail-retrieved-from-mailbox: Patches 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. Do not bind OUTPUTS. --- Changes in v3: - No longer bind 'outputs' extraneously in build phases gnu/packages/bootloaders.scm | 181 +++++++++++++++++++---------------- 1 file changed, 97 insertions(+), 84 deletions(-) base-commit: d7a9d72bb02a2a3b1a99183655bf878547116032 diff --git a/gnu/packages/bootloaders.scm b/gnu/packages/bootloaders.scm index e3a63882e9..be460ac715 100644 --- a/gnu/packages/bootloaders.scm +++ b/gnu/packages/bootloaders.scm @@ -855,11 +855,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))))) @@ -874,91 +876,102 @@ (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" - "KBUILD_VERBOSE=1" - ,@(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" + "KBUILD_VERBOSE=1" + #$@(if (not (same-arch?)) + (list (string-append "CROSS_COMPILE=" triplet "-")) + '()) + #$@make-flags)) + ((#:phases phases '%standard-phases) + #~(modify-phases #$phases + (replace 'configure + (lambda* (#:key 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 _ + (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"))