From patchwork Mon May 29 14:45:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Ludovic_Court=C3=A8s?= X-Patchwork-Id: 50436 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 3D88F27BBE9; Mon, 29 May 2023 15:48:17 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,SPF_HELO_PASS,URIBL_BLOCKED autolearn=unavailable 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 7414927BBE2 for ; Mon, 29 May 2023 15:48:16 +0100 (BST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q3e9f-0002Ol-Np; Mon, 29 May 2023 10:47:27 -0400 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 1q3e9O-00028T-H2 for guix-patches@gnu.org; Mon, 29 May 2023 10:47:12 -0400 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 1q3e9O-00035Y-8D; Mon, 29 May 2023 10:47:10 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1q3e9N-0001Ql-0O; Mon, 29 May 2023 10:47:09 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#63571] [PATCH v2 18/19] upstream: Honor package properties for ignored and extra inputs. Resent-From: Ludovic =?utf-8?q?Court=C3=A8s?= Original-Sender: "Debbugs-submit" Resent-CC: mail@cbaines.net, dev@jpoiret.xyz, ludo@gnu.org, othacehe@gnu.org, rekado@elephly.net, zimon.toutoune@gmail.com, me@tobias.gr, guix-patches@gnu.org Resent-Date: Mon, 29 May 2023 14:47:08 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 63571 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 63571@debbugs.gnu.org Cc: Ludovic =?utf-8?q?Court=C3=A8s?= , Christopher Baines , Josselin Poiret , Ludovic =?utf-8?q?Court=C3=A8s?= , Mathieu Othacehe , Ricardo Wurmus , Simon Tournier , Tobias Geerinckx-Rice X-Debbugs-Original-Xcc: Christopher Baines , Josselin Poiret , Ludovic =?utf-8?q?Court=C3=A8s?= , Mathieu Othacehe , Ricardo Wurmus , Simon Tournier , Tobias Geerinckx-Rice Received: via spool by 63571-submit@debbugs.gnu.org id=B63571.16853716185343 (code B ref 63571); Mon, 29 May 2023 14:47:08 +0000 Received: (at 63571) by debbugs.gnu.org; 29 May 2023 14:46:58 +0000 Received: from localhost ([127.0.0.1]:58797 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1q3e9B-0001Ny-8o for submit@debbugs.gnu.org; Mon, 29 May 2023 10:46:57 -0400 Received: from eggs.gnu.org ([209.51.188.92]:44098) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1q3e8J-0001Jq-Pb for 63571@debbugs.gnu.org; Mon, 29 May 2023 10:46:04 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q3e8E-0002gr-IT; Mon, 29 May 2023 10:45:58 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:References:In-Reply-To:Date:Subject:To: From; bh=xHJkI/EXECaO6ZFnNjXQdPtLzxbH/PfUAYOl/Ajh9mw=; b=AVysLTdlba+/hwPM2QuG GQTcc1WCnzVrFFryjTn86LE0DhQK3SeS+hd+WWrLPUEvsyj43v81/tf/MTvRhxXdcKJGvatiy5Ppm l2ALUdM20e/NFxvcalPK7p/bwmXI5EMpnz09naQXDRWyw0LYXfNwHlfRBZBavE/NqALpaQUzyUQIS 9Mzv9pLGE1+LB8W0cl2qMw48KlVpaB/NkDu73GjscGPuOMUj9GUc1PbpjWdA/ZZIlNSwliJDdlbyR AP3Bp9SIPioN7KdYBwf127EtiyqZOS5Sfm9w5GzLEfRnRrqVhfmRX8SETKNyINGZfrUWEdkTDTrLb jpZeCKLLmbRlAg==; Received: from 91-160-117-201.subs.proxad.net ([91.160.117.201] helo=gnu.org) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q3e8E-00044B-5I; Mon, 29 May 2023 10:45:58 -0400 From: Ludovic =?utf-8?q?Court=C3=A8s?= Date: Mon, 29 May 2023 16:45:29 +0200 Message-Id: <04e9c2249a49f86a49b5af638ceecb8379fd9a37.1685371175.git.ludo@gnu.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <87y1l7fb9j.fsf@gnu.org> References: <87y1l7fb9j.fsf@gnu.org> 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 * guix/upstream.scm (update-package-inputs)[filtered-inputs] [regular-inputs, native-inputs, propagated-inputs]: New procedures. Use them in 'update-field' calls. * tests/guix-refresh.sh (GUIX_TEST_UPDATER_TARGETS): Add "libreoffice" to the dependencies of "the-test-package". Add 'updater-ignored-inputs' property to "the-test-package". * doc/guix.texi (Invoking guix refresh): Document it. --- doc/guix.texi | 30 ++++++++++++++++++++++++++++++ guix/upstream.scm | 39 ++++++++++++++++++++++++++++++++++++--- tests/guix-refresh.sh | 5 +++-- 3 files changed, 69 insertions(+), 5 deletions(-) diff --git a/doc/guix.texi b/doc/guix.texi index c54a72bfaa..33528e997e 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -14358,6 +14358,36 @@ Invoking guix refresh @xref{Creating a Channel}, on how to create a channel. +This command updates the version and source code hash of the package. +Depending on the updater being used, it can also update the various +@samp{inputs} fields of the package. In some cases, the updater might +get inputs wrong---it might not know about an extra input that's +necessary, or it might add an input that should be avoided. + +@cindex @code{updater-extra-inputs}, package property +@cindex @code{updater-ignored-inputs}, package property +To address that, packagers can add properties stating inputs that should +be added to those found by the updater or inputs that should be ignored: +the @code{updater-extra-inputs} and @code{updater-ignored-inputs} +properties pertain to ``regular'' inputs, and there are equivalent +properties for @samp{native} and @samp{propagated} inputs. In the +example below, we tell the updater that we need @samp{openmpi} as an +additional input: + +@lisp +(define-public python-mpi4py + (package + (name "python-mpi4py") + ;; @dots{} + (inputs (list openmpi)) + (properties + '((updater-extra-inputs . ("openmpi")))))) +@end lisp + +That way, @command{guix refresh -u python-mpi4py} will leave the +@samp{openmpi} input, even if it is not among the inputs it would +normally add. + @item --select=[@var{subset}] @itemx -s @var{subset} Select all the packages in @var{subset}, one of @code{core}, @code{non-core} diff --git a/guix/upstream.scm b/guix/upstream.scm index 53e473715c..33248d645c 100644 --- a/guix/upstream.scm +++ b/guix/upstream.scm @@ -557,11 +557,44 @@ (define (update-package-inputs package source) (G_ "~a: expected '~a' value: ~s~%") (package-name package) field new)))) + (define (filtered-inputs source-inputs extra-property ignore-property) + ;; Return a procedure that behaves like SOURCE-INPUTS but additionally + ;; honors EXTRA-PROPERTY and IGNORE-PROPERTY from PACKAGE. + (lambda (source) + (let* ((inputs (source-inputs source)) + (properties (package-properties package)) + (ignore (or (assoc-ref properties ignore-property) '())) + (extra (or (assoc-ref properties extra-property) '()))) + (append (if (null? ignore) + inputs + (remove (lambda (input) + (member (upstream-input-downstream-name input) + ignore)) + inputs)) + (map (lambda (name) + (upstream-input + (name name) + (downstream-name name))) + extra))))) + + (define regular-inputs + (filtered-inputs upstream-source-regular-inputs + 'updater-extra-inputs + 'updater-ignored-inputs)) + (define native-inputs + (filtered-inputs upstream-source-native-inputs + 'updater-extra-native-inputs + 'updater-ignored-native-inputs)) + (define propagated-inputs + (filtered-inputs upstream-source-propagated-inputs + 'updater-extra-propagated-inputs + 'updater-ignored-propagated-inputs)) + (for-each update-field '(inputs native-inputs propagated-inputs) - (list upstream-source-regular-inputs - upstream-source-native-inputs - upstream-source-propagated-inputs) + (list regular-inputs + native-inputs + propagated-inputs) (list package-inputs package-native-inputs package-propagated-inputs))) diff --git a/tests/guix-refresh.sh b/tests/guix-refresh.sh index 9d7a57a36e..51d34c4b51 100644 --- a/tests/guix-refresh.sh +++ b/tests/guix-refresh.sh @@ -35,7 +35,7 @@ GUIX_TEST_UPDATER_TARGETS=' ("libreoffice" "" (("1.0" "file:///dev/null"))) ("idutils" "" (("'$idutils_version'" "file:///dev/null"))) ("the-test-package" "" (("5.5" "file://'$PWD/$module_dir'/source" - ("grep" "sed")))))' + ("grep" "sed" "libreoffice")))))' # No newer version available. guix refresh -t test idutils # XXX: should return non-zero? @@ -93,7 +93,8 @@ cat > "$module_dir/sample.scm"<