From patchwork Tue Nov 1 15:58:37 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Hartmut Goebel X-Patchwork-Id: 44235 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 C91D027BBEB; Tue, 1 Nov 2022 17:22:17 +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.9 required=5.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,URIBL_BLOCKED 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 9771427BBE9 for ; Tue, 1 Nov 2022 17:22:16 +0000 (GMT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1optfL-0001ZM-M2; Tue, 01 Nov 2022 11:59:03 -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 1optfK-0001Z3-5A for guix-patches@gnu.org; Tue, 01 Nov 2022 11:59:02 -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 1optfJ-0003ju-Sw for guix-patches@gnu.org; Tue, 01 Nov 2022 11:59:01 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1optfJ-0006CP-Ob for guix-patches@gnu.org; Tue, 01 Nov 2022 11:59:01 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#57460] [PATCH 00/19] Refresh to specific version Resent-From: Hartmut Goebel Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Tue, 01 Nov 2022 15:59:01 +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 To: Ludovic =?utf-8?q?Court=C3=A8s?= Cc: 57460@debbugs.gnu.org Received: via spool by 57460-submit@debbugs.gnu.org id=B57460.166731833623818 (code B ref 57460); Tue, 01 Nov 2022 15:59:01 +0000 Received: (at 57460) by debbugs.gnu.org; 1 Nov 2022 15:58:56 +0000 Received: from localhost ([127.0.0.1]:44043 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1optfD-0006C6-Pm for submit@debbugs.gnu.org; Tue, 01 Nov 2022 11:58:56 -0400 Received: from mout.kundenserver.de ([212.227.17.10]:45667) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1optfB-0006Bs-4s for 57460@debbugs.gnu.org; Tue, 01 Nov 2022 11:58:54 -0400 Received: from hermia.goebel-consult.de ([79.211.181.242]) by mrelayeu.kundenserver.de (mreue106 [212.227.15.183]) with ESMTPSA (Nemesis) id 1McHM2-1pSXrk2Qc0-00ci1F; Tue, 01 Nov 2022 16:58:44 +0100 Received: from [192.168.110.2] (lenashee.goebel-consult.de [192.168.110.2]) by hermia.goebel-consult.de (Postfix) with ESMTP id AB28065AB3; Tue, 1 Nov 2022 16:58:37 +0100 (CET) Message-ID: Date: Tue, 1 Nov 2022 16:58:37 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.4.0 References: <87h70xcdha.fsf_-_@gnu.org> Content-Language: de-DE, en-US From: Hartmut Goebel Organization: crazy-compilers.com In-Reply-To: <87h70xcdha.fsf_-_@gnu.org> X-Provags-ID: V03:K1:3Ms2B6S8nsXWWYDoC9r0TzVjGm75IgkMcN++EF+kYz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enThere: 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: , Sender: "Guix-patches" Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org X-getmail-retrieved-from-mailbox: Patches Hi Ludo, attached please find a new patch addressing this and implementing a record time. (Thanks for the tip, this makes the code muche easier.) From c748a25193d8f9ee29b9d281f542fb1d0d3f4ec1 Mon Sep 17 00:00:00 2001 Message-Id: From: Hartmut Goebel Date: Fri, 24 Jun 2022 20:40:57 +0200 Subject: [PATCH v2] refresh: Allow updating to a specific version. * 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..8333d1783c 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. ;;; @@ -33,6 +34,7 @@ #:use-module (guix utils) #:use-module (guix packages) #:use-module (guix profiles) + #:use-module (guix records) #:use-module (guix upstream) #:use-module (guix graph) #:use-module (guix scripts graph) @@ -181,7 +183,7 @@ specified with `--select'.\n")) (newline) (show-bug-report-information)) -(define (options->packages opts) +(define (options->package-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)) + (specification->package-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* package-spec make-package-spec + package-spec? + (package package-spec-package) ; package + (target package-spec-target)) ; target version + +(define (specification->package-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 (make-package-spec (specification->package spec) #f)) + (idx (make-package-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 ((package-specs (options->package-specs opts))) (cond (list-dependent? - (list-dependents packages)) + (list-dependents (map package-spec-package package-specs))) (list-transitive? - (list-transitive packages)) + (list-transitive (map package-spec-package package-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 (package-spec) + (update-package store + (package-spec-package package-spec) + (package-spec-target package-spec) + updaters + #:key-download key-download + #:warn? warn?)) + package-specs) (return #t))) (else (for-each (cut check-for-package-update <> updaters #:warn? warn?) - packages) + (map package-spec-package package-specs)) (return #t))))))))) -- 2.30.6