From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp10.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id cDSpJfY1mWMDOAEAbAwnHQ (envelope-from ) for ; Wed, 14 Dec 2022 03:33:26 +0100 Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp10.migadu.com with LMTPS id iNXSJPY1mWOZdQEAG6o9tA (envelope-from ) for ; Wed, 14 Dec 2022 03:33:26 +0100 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 12D6241F48 for ; Wed, 14 Dec 2022 03:33:26 +0100 (CET) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p5HZw-0000ky-Dw; Tue, 13 Dec 2022 21:33:04 -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 1p5HZv-0000kP-1W for guix-patches@gnu.org; Tue, 13 Dec 2022 21:33: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 1p5HZu-0005gA-Px for guix-patches@gnu.org; Tue, 13 Dec 2022 21:33:02 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1p5HZu-0000YD-Be for guix-patches@gnu.org; Tue, 13 Dec 2022 21:33:02 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#59761] [PATCH v3 1/4] gnu: make-u-boot-package: Add a u-boot argument. References: <20221202052903.10475-1-maxim.cournoyer@gmail.com> In-Reply-To: <20221202052903.10475-1-maxim.cournoyer@gmail.com> Resent-From: Maxim Cournoyer Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Wed, 14 Dec 2022 02:33:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 59761 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 59761@debbugs.gnu.org Cc: Maxim Cournoyer Received: via spool by 59761-submit@debbugs.gnu.org id=B59761.16709851692079 (code B ref 59761); Wed, 14 Dec 2022 02:33:02 +0000 Received: (at 59761) by debbugs.gnu.org; 14 Dec 2022 02:32:49 +0000 Received: from localhost ([127.0.0.1]:36083 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p5HZg-0000XO-S1 for submit@debbugs.gnu.org; Tue, 13 Dec 2022 21:32:49 -0500 Received: from mail-qv1-f45.google.com ([209.85.219.45]:36591) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p5HZe-0000XG-Cl for 59761@debbugs.gnu.org; Tue, 13 Dec 2022 21:32:47 -0500 Received: by mail-qv1-f45.google.com with SMTP id o12so11704887qvn.3 for <59761@debbugs.gnu.org>; Tue, 13 Dec 2022 18:32:46 -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=zrI7rxcEpuhWCZphGgSxrEJ/JD7w9u9yMT5MEzKYawo=; b=Mkv9YcWVSReCp0CocVgvsY8fJiSbj36N7X+YVHnHXGAhkYEkIKBLk+kkqBulUzR5f0 i8wtUPYHfdxC6HCwjxFK1GSqxEq0q3G+hWHwaMEtarlUkMWo9weawigI6q1E1cYab5aV JnVQa9ipqQwTAhV1jbIn9ZKQIaKgaMSM1FYvIffE1pnnShGx3wXpeg2YMbsVIatU299h UOERA8Mux5b+G3ibhE1kDSrrS4eVeF9jVMnoCMazMC1c34qnpWk+XML/fgK/3++BMys6 m7FqpcPFWRTX/aoqg4+3C8UvXJt70OONi/VYdBNvUGbFMLCsESpF2NlNc0BwXfTLVM2a dozg== 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=zrI7rxcEpuhWCZphGgSxrEJ/JD7w9u9yMT5MEzKYawo=; b=57ywYaPwnWFCeRdOt+L0B8Sun9mw/BC5Jr+WZhWr7RU79A9pzndCB9DRWrTXewjtxh oHvy8J8tW2ss2KU9wqfWGSU8xyotITX1UpDXMqKgJ/joruZr4J0DzmV8vTXboHsRMJA6 KrK1YcjF3Yrjdxwz1RKQ/wrEk37loa4AWo6VtqHAv700YitFyrRHWbTUNPtdS+6YfdhK 8TAQQZogcCDRNumY1AELd0Cjzj+I/jzHzdiHr8v7Yg/vzZfcnMqTV86p7fVSPr1H1vbJ IJRZMck5+fPjOYdQJ31RSGLox36TOGX3C4Br4Y/17T6+OAzbOTZeFVmPEsEKlDvsZIko u9Ww== X-Gm-Message-State: ANoB5pnLEbPfIT1HOj4P0V3WBqwfyyNr0Yfey2MtdfDNeB5uflvr6qJM TJFUH6YYeTJQtef/kDtrpOG4zcP6qsrDdA== X-Google-Smtp-Source: AA0mqf4fUFdb2GMGqPIcZAQ5muHbR09oW+OkrMACT8y4fZjwvrhDwPAYrkpxKKRA+bEVS2hznsGXgw== X-Received: by 2002:ad4:5109:0:b0:4c7:26a4:908e with SMTP id g9-20020ad45109000000b004c726a4908emr30603212qvp.47.1670985160210; Tue, 13 Dec 2022 18:32:40 -0800 (PST) Received: from localhost.localdomain ([2607:fad8:4:3::1006]) by smtp.gmail.com with ESMTPSA id k12-20020a05620a414c00b006e42a8e9f9bsm9191306qko.121.2022.12.13.18.32.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Dec 2022 18:32:39 -0800 (PST) From: Maxim Cournoyer Date: Tue, 13 Dec 2022 21:32:33 -0500 Message-Id: <20221214023236.25345-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-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+larch=yhetil.org@gnu.org Sender: guix-patches-bounces+larch=yhetil.org@gnu.org X-Migadu-Country: US X-Migadu-Flow: FLOW_IN ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1670985206; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:resent-cc: resent-from:resent-sender:resent-message-id:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=zrI7rxcEpuhWCZphGgSxrEJ/JD7w9u9yMT5MEzKYawo=; b=PersD1Zy5Kr1lB19In5HXpLfh1nDnoEwgkayVXLB4r6t5amd3bmeaqOqha4qsiPJGyCB2B XFJzfKfp/UE0vpLH8Sb9nU0Lv5l9ehSNkJUO5zBF19W5Kr+VG1TbGKjQxv7FiQdlCJHUl5 I3C/FHYT+SiQvlmPGnSARkmbc65KX7gn6stNBGU47gw7MoZFU+1p9vnn9KO9C5H8gRLYa3 kTX0cTFJP3RnsC46JK8RQ13i46fVv3t46InGspOHLQgX91YQ0Tf9FOrIiy8z6HiQtg2K5E ipeOfcX89DRp16zrVh1Tr3p761QmpB37aDTtrS64qamFtrjOOBfoqaJVordQpQ== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gmail.com header.s=20210112 header.b=Mkv9YcWV; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org"; dmarc=fail reason="SPF not aligned (relaxed)" header.from=gmail.com (policy=none) ARC-Seal: i=1; s=key1; d=yhetil.org; t=1670985206; a=rsa-sha256; cv=none; b=d2FTE+Y1P2k+cBjzyZSLP/V6nKpHkDqwRU13lKe6FW70IbshZ9Rd/UmvYKMwW4ktg8SEAQ opMjVigmVeAUcSJ2GVRViTmTxuDLxo/ubictYJza4+QD2Lyp/gIluEiFLvYuK5CTfGXpMi 72riVuF5N4sCDYZZJJUoALeLxusTcuff/WErjJxs3kJ2KM/jSb3bBxE6SRB4TwiaEff3d8 SHz9Cpxk8mbJTI0GyONBwElql9ClAob2FwVj4HM3X8rZj7KbbhScIU1tfGy9Hz1+wPFpUR di1t0WpGRAKb8PWR+kYp9nJNkTjVESx8+UTuYyUkG6j11+X1XjLd0y9FuZAC/w== X-Migadu-Spam-Score: 7.23 X-Spam-Score: 7.23 X-Migadu-Queue-Id: 12D6241F48 X-Migadu-Scanner: scn0.migadu.com Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gmail.com header.s=20210112 header.b=Mkv9YcWV; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org"; dmarc=fail reason="SPF not aligned (relaxed)" header.from=gmail.com (policy=none) X-TUID: 9klniNC8/Btq 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")) base-commit: 0ffa501f2b3e83ae56e9c2bd31418439090e869a -- 2.38.1