From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp11.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id 2KLHA2iHoWOcRgAAbAwnHQ (envelope-from ) for ; Tue, 20 Dec 2022 10:59:04 +0100 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp11.migadu.com with LMTPS id aGK5A2iHoWOJXQEA9RJhRA (envelope-from ) for ; Tue, 20 Dec 2022 10:59:04 +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 AF2DD3BF80 for ; Tue, 20 Dec 2022 10:59:03 +0100 (CET) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p7Z2x-0005Cg-Hx; Tue, 20 Dec 2022 04:36:27 -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 1p7Z2Z-0004v2-KL for guix-patches@gnu.org; Tue, 20 Dec 2022 04:36:04 -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 1p7Z2Z-000397-Ae for guix-patches@gnu.org; Tue, 20 Dec 2022 04:36:03 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1p7Z2Z-0003UH-0U for guix-patches@gnu.org; Tue, 20 Dec 2022 04:36:03 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#57460] [PATCH v3 16/18] refresh: Allow updating to a specific version. Resent-From: Hartmut Goebel Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Tue, 20 Dec 2022 09:36:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 57460 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch moreinfo To: 57460@debbugs.gnu.org Received: via spool by 57460-submit@debbugs.gnu.org id=B57460.167152891713339 (code B ref 57460); Tue, 20 Dec 2022 09:36:02 +0000 Received: (at 57460) by debbugs.gnu.org; 20 Dec 2022 09:35:17 +0000 Received: from localhost ([127.0.0.1]:43780 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p7Z1o-0003Sy-80 for submit@debbugs.gnu.org; Tue, 20 Dec 2022 04:35:16 -0500 Received: from mout.kundenserver.de ([212.227.126.130]:33339) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p7Z1i-0003R0-JC for 57460@debbugs.gnu.org; Tue, 20 Dec 2022 04:35:11 -0500 Received: from hermia.goebel-consult.de ([87.176.134.225]) by mrelayeu.kundenserver.de (mreue010 [212.227.15.167]) with ESMTPSA (Nemesis) id 1M9WeC-1pD5LA3lA4-005Xv8 for <57460@debbugs.gnu.org>; Tue, 20 Dec 2022 10:35:04 +0100 Received: from thisbe.goebel-consult.de (hermia.goebel-consult.de [192.168.110.7]) by hermia.goebel-consult.de (Postfix) with ESMTP id 7AF33669AD; Tue, 20 Dec 2022 10:34:24 +0100 (CET) From: Hartmut Goebel Date: Tue, 20 Dec 2022 10:34:21 +0100 Message-Id: <33d5dc74aa743c1588644b861fbe095cd761300d.1671527962.git.h.goebel@crazy-compilers.com> X-Mailer: git-send-email 2.30.6 In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Provags-ID: V03:K1:soyilmYbR6EJzJc3u4HcC7sul2RTBfqem5ryYAUe76CfeZ3Axkx qj13XA+ou0Od7MOtKyG2QwBy4a2ZwTqz9zL4oaKH43RxejZpbXs3qlKRlR+/QG4K/Bw8d6v gpq5EBpA5T1M1G/52Q/q5wf159IU5K1bFNJNS0U4kMaL1Vs4czP+3/FiaMn6REZhKOYW7JA 0OrDlo2skLTXYiOVUoBoQ== UI-OutboundReport: notjunk:1;M01:P0:P3TWMKAk3gU=;4unfG9+y9ELIwrjC7Hrz0x8bEo/ dvPuGJHnvg7aB1fRGMWEDP4cItKziziuEi7z4MZgG6hiIc+1VVsU+DtMLfMnKuMWwh7YI72eI fm51YdmTp7AG87SL/n9pzxPZ8K5nPtLgGqMRnDjbiOtpA704KNjhoby2DPuONsi8RvECSiMKi Oqm4cxxavTceH9nXVJQCrp2VsCQdvzNLkTXsQg8GmvaILDH9v0Wkk5qvuCSWG0/eNxrm0Euyd e12fZ/Ym5jnUGqBKnnQPt26T0dpUZqdQBrkWCEeYcnLnDczojB5Uz698cB7V0Awgodb8G/CKU 4oK2SC/cVeM+t4nC1sGdDjEfNQX4AcdRl5yURr3fD9kHdCRQgjwN24GpUEG5yff2D1aUMjYB1 Ar0YNe5vKk9A6jBRXapSdcQrC1deCKLjgiHSfmqGlkpRh4NO+dkbDcUiN6I6J96Nosx4Gd1UA RJonzgBmFnhK9LoZXLcEHfV9evzNGVZtwa02kWo8tZacurTKWOWQ3BWoz2UeCCkmbysl2vRGc jN45LXw/WMheRkx3W6QwxFdshqc0vv/+TfipaoYDX7s06JaEcv8MzE6dNB3THLfMsgBptc1Ic 9hfnCwGyyjrBBmhkIqcDmFNXbTOHlUO4/n0O6f/k2tHHQv9hBUAV87AdiaBXHafYWTDrbuKdy irtsgrK01DCzWhBMeTRyR2f9/t0MtzNHALbInqU4A/MZoPhNmCmP3TNuV/C6a6o= 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-Authentication-Results: i=1; aspmx1.migadu.com; dkim=none; 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=none ARC-Seal: i=1; s=key1; d=yhetil.org; t=1671530343; a=rsa-sha256; cv=none; b=Ye+Mbiv71fq8VJI3PuoqVvTJB6vu/0gNXwbzlIG8mka04pQFozzWENjx4lf3eBHOvKlen2 QlyfNKLk/H4J9rFmYTdE6xvnTwYEh7+Oe4bHZ6jX63JZq7+bxDFnXwhN/NghbccLL7FNvv ekQeDZBokZxNVGBgA21qhrZHiX2w8Gk8OoVp52JSB9lp9O1gtHYBgSh/eUjQo/f+TSJjuv j4xxreMEpY1Vp/GJmE92JRGUrajs0D7FCyfAydJJNwVNRZ/4dy5IWTEU+irnm8Ay4bOGM8 n4HNQ0hDcI3KaUUzhwAHoqjA3aKoLcw2LF6+E4tqWSj6XhiOOAuCUcSTsTIvFQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1671530343; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to: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; bh=llIVWnuCICtIix7qkdIdAdIH09NTZuMoU1f2KjDRlHM=; b=OeMJ879wNMRU3s6wHcOPcoTCFtrdKINVVBEkpNUzCM5Ppsq3De5YIfjDnwO3tpnnUm5RCK ultzfIqb9rcflp88Jg/M3HPAtQ9/VbeajZOvOb8rxBwjuoUkLFZdHJ5lro8WkZYyN5FlIr aasyuCSAS/fCuU4mO30MRtYCKOIRXXMEbdWON3XAustL3hIHjlTSHEFA/HlwfuIRHrQ+ZU ZQWBWDTx/tYw/kKcvqib8uuqmVaDcBS7Jzqi1aqHbd2YI1JYm8K9nlO8uH9HYEOOGwFCfR F3sbSqzB+45+2SC2lWGr9EcgpDkXcQ6Q+m+TMtD03DDJQjAgPC7px6GkdWaUvw== X-Migadu-Scanner: scn0.migadu.com Authentication-Results: aspmx1.migadu.com; dkim=none; 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=none X-Migadu-Spam-Score: -2.99 X-Spam-Score: -2.99 X-Migadu-Queue-Id: AF2DD3BF80 X-TUID: 8gV2/ov4wxqW * guix/scripts/refresh.scm (options->packages)[args-packages]: Handle version specification in package name arguments. (update-package): Add #:version argument and pass it on to called functions. (guix-refresh): When updating, pass the specified version (if any) to update-package. [package-list-without-versions, package-list-with-versions]: New functions. --- guix/scripts/refresh.scm | 49 ++++++++++++++++++++++++++++++---------- 1 file changed, 37 insertions(+), 12 deletions(-) diff --git a/guix/scripts/refresh.scm b/guix/scripts/refresh.scm index 14329751f8..e0b94ce48d 100644 --- a/guix/scripts/refresh.scm +++ b/guix/scripts/refresh.scm @@ -9,6 +9,7 @@ ;;; Copyright © 2019 Ricardo Wurmus ;;; Copyright © 2020 Simon Tournier ;;; Copyright © 2021 Sarah Morgensen +;;; Copyright © 2022 Hartmut Goebel ;;; ;;; This file is part of GNU Guix. ;;; @@ -46,6 +47,7 @@ #:use-module (ice-9 vlist) #:use-module (ice-9 format) #:use-module (srfi srfi-1) + #:use-module (srfi srfi-9) #:use-module (srfi srfi-26) #:use-module (srfi srfi-37) #:use-module (srfi srfi-71) @@ -181,7 +183,7 @@ specified with `--select'.\n")) (newline) (show-bug-report-information)) -(define (options->packages opts) +(define (options->update-specs opts) "Return the list of packages requested by OPTS, honoring options like '--recursive'." (define core-package? @@ -224,7 +226,7 @@ update would trigger a complete rebuild." (('argument . spec) ;; Take either the specified version or the ;; latest one. - (specification->package spec)) + (update-specification->update-spec spec)) (('expression . exp) (read/eval-package-expression exp)) (_ #f)) @@ -254,6 +256,25 @@ update would trigger a complete rebuild." (with-monad %store-monad (return packages)))) + +;;; +;;; Utilities. +;;; + +(define-record-type + (update-spec package version) + update? + (package update-spec-package) + (version update-spec-version)) + +(define (update-specification->update-spec spec) + "Given SPEC, a package name like \"guile@2.0=2.0.8\", return a +record with two fields: the package to upgrade, and the target version." + (match (string-rindex spec #\=) + (#f (update-spec (specification->package spec) #f)) + (idx (update-spec (specification->package (substring spec 0 idx)) + (substring spec (1+ idx)))))) + ;;; ;;; Updates. @@ -298,7 +319,7 @@ update would trigger a complete rebuild." (G_ "no updater for ~a~%") (package-name package))) -(define* (update-package store package updaters +(define* (update-package store package version updaters #:key (key-download 'interactive) warn?) "Update the source file that defines PACKAGE with the new version. KEY-DOWNLOAD specifies a download policy for missing OpenPGP keys; allowed @@ -307,7 +328,7 @@ warn about packages that have no matching updater." (if (lookup-updater package updaters) (let ((version output source (package-update store package updaters - #:key-download key-download)) + #:key-download key-download #:version version)) (loc (or (package-field-location package 'version) (package-location package)))) (when version @@ -540,12 +561,12 @@ all are dependent packages: ~{~a~^ ~}~%") (with-error-handling (with-store store (run-with-store store - (mlet %store-monad ((packages (options->packages opts))) + (mlet %store-monad ((update-specs (options->update-specs opts))) (cond (list-dependent? - (list-dependents packages)) + (list-dependents (map update-spec-package update-specs))) (list-transitive? - (list-transitive packages)) + (list-transitive (map update-spec-package update-specs))) (update? (parameterize ((%openpgp-key-server (or (assoc-ref opts 'key-server) @@ -558,13 +579,17 @@ all are dependent packages: ~{~a~^ ~}~%") (string-append (config-directory) "/upstream/trustedkeys.kbx")))) (for-each - (cut update-package store <> updaters - #:key-download key-download - #:warn? warn?) - packages) + (lambda (update) + (update-package store + (update-spec-package update) + (update-spec-version update) + updaters + #:key-download key-download + #:warn? warn?)) + update-specs) (return #t))) (else (for-each (cut check-for-package-update <> updaters #:warn? warn?) - packages) + (map update-spec-package update-specs)) (return #t))))))))) -- 2.30.6