From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp11.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms9.migadu.com with LMTPS id UPkZJDq7dGQdcAEASxT56A (envelope-from ) for ; Mon, 29 May 2023 16:48:26 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp11.migadu.com with LMTPS id yJtPJDq7dGRd3gAA9RJhRA (envelope-from ) for ; Mon, 29 May 2023 16:48:26 +0200 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 5481F30F2B for ; Mon, 29 May 2023 16:48:26 +0200 (CEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q3e9M-00024C-O8; Mon, 29 May 2023 10:47:08 -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 1q3e9L-00023F-1c for guix-patches@gnu.org; Mon, 29 May 2023 10:47:07 -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 1q3e9K-000348-Pl; Mon, 29 May 2023 10:47:06 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1q3e9I-0001P6-3l; Mon, 29 May 2023 10:47:04 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#63571] [PATCH v2 09/19] upstream: 'update-package-source' edits input fields. 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:04 +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.16853715675212 (code B ref 63571); Mon, 29 May 2023 14:47:04 +0000 Received: (at 63571) by debbugs.gnu.org; 29 May 2023 14:46:07 +0000 Received: from localhost ([127.0.0.1]:58777 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1q3e8M-0001Lt-Mz for submit@debbugs.gnu.org; Mon, 29 May 2023 10:46:07 -0400 Received: from eggs.gnu.org ([209.51.188.92]:45726) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1q3e8C-0001Ic-1c for 63571@debbugs.gnu.org; Mon, 29 May 2023 10:45:57 -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 1q3e86-0002eu-RF; Mon, 29 May 2023 10:45:50 -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=F3GNEaQ52Bbe95iQ3chIe7cdEiUpi8A49X3/1dZynNs=; b=VShcUdyZvc3EDyVkNMVV JykfWsNAb9gSP/kogsFIxJg5se2UmEVwXjtgRIccgWCNjGkdE+FZmiyP4smsTGOBNZmCOvIbLaAJO cnrZpVE3r2iZQx8iplmnLj9C8pc+ZkWXZBE5qDbvAuZ9laVUbacIwhNE4ddikzrWVtym4QYYOqH+o hQC9PJAcKLqn3hznJn/UMiH80Fk93SZ8gQmmrel763Bxo49hvFR8hlcF+lwx7uYDGfdYV4sUO2VTf ojSwXyhYYKTZh4LO0MpRwVQ4L7rK9psCIjiMG/3DBLHpS50bLGigWM61HoyNk5DiHv7n2bCpRr3Bx SFl20xz/kWwVCA==; 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 1q3e86-00044B-Dd; Mon, 29 May 2023 10:45:50 -0400 From: Ludovic =?UTF-8?Q?Court=C3=A8s?= Date: Mon, 29 May 2023 16:45:20 +0200 Message-Id: X-Mailer: git-send-email 2.40.1 In-Reply-To: <87y1l7fb9j.fsf@gnu.org> References: <87y1l7fb9j.fsf@gnu.org> MIME-Version: 1.0 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-Flow: FLOW_IN X-Migadu-Country: US ARC-Seal: i=1; s=key1; d=yhetil.org; t=1685371706; a=rsa-sha256; cv=none; b=OWoa+klR1rxjoRu63Wi/i0FasuQ+morLtDuKCHEMTu7TTdwzg9jw6iqnHKanhhNo8NpFsw JEDy2HlzevkX4I06IG4ae+X/WgHUj6g6v3yz3+aHgzFAtSokfPtoM/MMDyEUuzjLcHrYpa G7V4GKi+tC6bF0w9J29bCflzp8a47518gGSsGu4Rjz7q6GQcNHjt0SzEe74C2PM4vO5E/U lVWgPDc7Y1sZGnOG45zm+vR0auxIKUEMSuMW8jxjQu5RmGktgGKjt7Vtv1TLPgsmwAnzQA 7NpJgyZjXYwmDuAXttllRkhkB0XLK8ZOC5ckAiDoIMBBaYSTaTlQivVbN4+PWw== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gnu.org header.s=fencepost-gnu-org header.b=VShcUdyZ; dmarc=pass (policy=none) header.from=gnu.org; 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" ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1685371706; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: 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=F3GNEaQ52Bbe95iQ3chIe7cdEiUpi8A49X3/1dZynNs=; b=Utwo/9J8fsCFP7/Ymksgd78LlVcmD1JRu6psCbM8v2Uk3WWaiospcXldnYXLvWWPeHfa/k ty8FvM9Ugd7NC+XAo9BeqO9t0H4UhQNlal8CP40amLvDFFX3UIjwjblYo6t/wGkm6LcMpL 1g7zYM9+nP93HKXLpc5Z8tIkk+VyTcY7YZg472S4OwyziZSi5vsJZNnHgp4nMSazWS+hbY NUiD4eDAU6Vo0iY5k43p8ajozCvscdpZJEd0ogXyijabRELnk9v4sqMSUf7AamviZb//fl 0V2UxQbXGH11M0yCaFUh0UKF4GI/MY93JYB6Z2IFDScpu2p9/wavYy8iEBnRoA== X-Migadu-Scanner: scn1.migadu.com Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gnu.org header.s=fencepost-gnu-org header.b=VShcUdyZ; dmarc=pass (policy=none) header.from=gnu.org; 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" X-Migadu-Spam-Score: -1.05 X-Spam-Score: -1.05 X-Migadu-Queue-Id: 5481F30F2B X-TUID: ubGwWSi++bts Previously, 'guix refresh r-ggplot2 -u' and similar commands would print of list of input changes that would have to be made manually. With this change, 'guix refresh -u' takes care of updating input fields automatically. * guix/upstream.scm (update-package-inputs): New procedure. (update-package-source): Call it when 'upstream-source-inputs' returns true. * guix/scripts/refresh.scm (update-package): Remove iteration over the result of 'changed-inputs'. * guix/import/test.scm (available-updates): Add support for input lists. * tests/guix-refresh.sh (GUIX_TEST_UPDATER_TARGETS): Add input list for "the-test-package". Make sure 'guix refresh -u' updates 'inputs' accordingly. * doc/guix.texi (Invoking guix refresh): Mention it. --- doc/guix.texi | 5 ++-- guix/import/test.scm | 13 +++++++++- guix/scripts/refresh.scm | 36 -------------------------- guix/upstream.scm | 56 +++++++++++++++++++++++++++++++++++++--- tests/guix-refresh.sh | 7 +++-- 5 files changed, 72 insertions(+), 45 deletions(-) diff --git a/doc/guix.texi b/doc/guix.texi index b52a40cc38..c54a72bfaa 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -14308,8 +14308,9 @@ Invoking guix refresh @end lisp When passed @option{--update}, it modifies distribution source files to -update the version numbers and source tarball hashes of those package -recipes (@pxref{Defining Packages}). This is achieved by downloading +update the version numbers and source code hashes of those package +definitions, as well as possibly their inputs (@pxref{Defining Packages}). +This is achieved by downloading each package's latest source tarball and its associated OpenPGP signature, authenticating the downloaded tarball against its signature using @command{gpgv}, and finally computing its hash---note that GnuPG must be diff --git a/guix/import/test.scm b/guix/import/test.scm index b1ed0b455d..4bd356bddc 100644 --- a/guix/import/test.scm +++ b/guix/import/test.scm @@ -52,7 +52,18 @@ (define (available-updates package) (upstream-source (package (package-name package)) (version version) - (urls (list url))))) + (urls (list url)))) + ((version url (inputs ...)) + (upstream-source + (package (package-name package)) + (version version) + (urls (list url)) + (inputs + (map (lambda (name) + (upstream-input + (name name) + (downstream-name name))) + inputs))))) updates) result) result)))) diff --git a/guix/scripts/refresh.scm b/guix/scripts/refresh.scm index d838a4aca2..9676271542 100644 --- a/guix/scripts/refresh.scm +++ b/guix/scripts/refresh.scm @@ -369,42 +369,6 @@ (define* (update-package store package version updaters (G_ "~a: updating from version ~a to version ~a...~%") (package-name package) (package-version package) version) - (for-each - (lambda (change) - (define field - (match (upstream-input-change-type change) - ('native 'native-inputs) - ('propagated 'propagated-inputs) - (_ 'inputs))) - - (define name - (package-name package)) - (define loc - (package-field-location package field)) - (define change-name - (upstream-input-change-name change)) - - (match (list (upstream-input-change-action change) - (upstream-input-change-type change)) - (('add 'regular) - (info loc (G_ "~a: consider adding this input: ~a~%") - name change-name)) - (('add 'native) - (info loc (G_ "~a: consider adding this native input: ~a~%") - name change-name)) - (('add 'propagated) - (info loc (G_ "~a: consider adding this propagated input: ~a~%") - name change-name)) - (('remove 'regular) - (info loc (G_ "~a: consider removing this input: ~a~%") - name change-name)) - (('remove 'native) - (info loc (G_ "~a: consider removing this native input: ~a~%") - name change-name)) - (('remove 'propagated) - (info loc (G_ "~a: consider removing this propagated input: ~a~%") - name change-name)))) - (changed-inputs package source)) (let ((hash (file-hash* output))) (update-package-source package source hash))) (warning (G_ "~a: version ~a could not be \ diff --git a/guix/upstream.scm b/guix/upstream.scm index 4ae2d1c8c8..7d9ae70eda 100644 --- a/guix/upstream.scm +++ b/guix/upstream.scm @@ -38,6 +38,7 @@ (define-module (guix upstream) #:use-module (guix hash) #:use-module (guix store) #:use-module ((guix derivations) #:select (built-derivations derivation->output-path)) + #:autoload (guix read-print) (object->string*) #:autoload (gcrypt hash) (port-sha256) #:use-module (guix monads) #:use-module (srfi srfi-1) @@ -583,6 +584,52 @@ (define* (package-update store package (package-name package))) (values #f #f #f)))) +(define (update-package-inputs package source) + "Update the input fields of the definition of PACKAGE according to those +specified in SOURCE, an ." + (define (update-field field source-inputs package-inputs) + (define loc + (package-field-location package field)) + + (define new + (map (compose string->symbol upstream-input-downstream-name) + (source-inputs source))) + + (define old + (match (package-inputs package) + (((labels (? package? packages)) ...) + labels) + (_ + '()))) + + (define unchanged? + (equal? new old)) + + (if (and loc (not unchanged?)) + (edit-expression (location->source-properties + (absolute-location loc)) + (lambda (str) + (object->string* `(list ,@new) + (location-column loc)))) + (unless unchanged? + ;; XXX: Bail out when FIELD isn't already present in the source. + ;; TODO: Add the field if it's missing. + (warning (package-location package) + (G_ "~a: '~a' field not found; leaving it unchanged~%") + (package-name package) field) + (warning (package-location package) + (G_ "~a: expected '~a' value: ~s~%") + (package-name package) field new)))) + + (for-each update-field + '(inputs native-inputs propagated-inputs) + (list upstream-source-regular-inputs + upstream-source-native-inputs + upstream-source-propagated-inputs) + (list package-inputs + package-native-inputs + package-propagated-inputs))) + (define* (update-package-source package source hash) "Modify the source file that defines PACKAGE to refer to SOURCE, an whose tarball has SHA256 HASH (a bytevector). Return the @@ -637,9 +684,7 @@ (define* (update-package-source package source hash) ;; function of the person who uploads the package. Note that ;; package definitions usually concatenate fragments of the URL, ;; which is why we only attempt to replace a subset of the URL. - (let ((properties (location->source-properties - (absolute-location loc))) - (replacements `((,old-version . ,version) + (let ((replacements `((,old-version . ,version) (,old-hash . ,hash) ,@(if (and old-commit new-commit) `((,old-commit . ,new-commit)) @@ -648,8 +693,11 @@ (define* (update-package-source package source hash) `((,(dirname old-url) . ,(dirname new-url))) '())))) - (and (edit-expression properties + (and (edit-expression (location->source-properties + (absolute-location loc)) (cut update-expression <> replacements)) + (or (not (upstream-source-inputs source)) + (update-package-inputs package source)) version)) (begin (warning (G_ "~a: could not locate source file") diff --git a/tests/guix-refresh.sh b/tests/guix-refresh.sh index 691020b031..9d7a57a36e 100644 --- a/tests/guix-refresh.sh +++ b/tests/guix-refresh.sh @@ -34,7 +34,8 @@ GUIX_TEST_UPDATER_TARGETS=' ("1.6.4" "file:///dev/null"))) ("libreoffice" "" (("1.0" "file:///dev/null"))) ("idutils" "" (("'$idutils_version'" "file:///dev/null"))) - ("the-test-package" "" (("5.5" "file://'$PWD/$module_dir'/source"))))' + ("the-test-package" "" (("5.5" "file://'$PWD/$module_dir'/source" + ("grep" "sed")))))' # No newer version available. guix refresh -t test idutils # XXX: should return non-zero? @@ -91,13 +92,15 @@ cat > "$module_dir/sample.scm"<