From patchwork Sun Aug 28 13:18:41 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Hartmut Goebel X-Patchwork-Id: 42037 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 B2FFD27BBEA; Sun, 28 Aug 2022 14:21:26 +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.9 required=5.0 tests=BAYES_00,MAILING_LIST_MULTI, SPF_HELO_PASS 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 CD14527BBE9 for ; Sun, 28 Aug 2022 14:21:25 +0100 (BST) Received: from localhost ([::1]:48458 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oSIE9-0005Zu-0e for patchwork@mira.cbaines.net; Sun, 28 Aug 2022 09:21:25 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59416) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oSICv-0002z2-Sk for guix-patches@gnu.org; Sun, 28 Aug 2022 09:20:10 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:39844) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oSICv-0002g9-Jd for guix-patches@gnu.org; Sun, 28 Aug 2022 09:20:09 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1oSICv-0006zD-Fc for guix-patches@gnu.org; Sun, 28 Aug 2022 09:20:09 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#57460] [PATCH 15/20] refresh: Allow updating to a specific version (script) Resent-From: Hartmut Goebel Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Sun, 28 Aug 2022 13:20:09 +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: 57460@debbugs.gnu.org Received: via spool by 57460-submit@debbugs.gnu.org id=B57460.166169278126688 (code B ref 57460); Sun, 28 Aug 2022 13:20:09 +0000 Received: (at 57460) by debbugs.gnu.org; 28 Aug 2022 13:19:41 +0000 Received: from localhost ([127.0.0.1]:57804 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oSICS-0006wG-S5 for submit@debbugs.gnu.org; Sun, 28 Aug 2022 09:19:41 -0400 Received: from mout.kundenserver.de ([212.227.126.134]:57489) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oSICH-0006un-O1 for 57460@debbugs.gnu.org; Sun, 28 Aug 2022 09:19:30 -0400 Received: from hermia.goebel-consult.de ([46.87.137.46]) by mrelayeu.kundenserver.de (mreue009 [212.227.15.167]) with ESMTPSA (Nemesis) id 1M6URd-1oUDzx0YMz-006w7C for <57460@debbugs.gnu.org>; Sun, 28 Aug 2022 15:19:24 +0200 Received: from lenashee.fritz.box (lenashee.goebel-consult.de [192.168.110.2]) by hermia.goebel-consult.de (Postfix) with ESMTP id 4E3C165A4A; Sun, 28 Aug 2022 15:18:56 +0200 (CEST) From: Hartmut Goebel Date: Sun, 28 Aug 2022 15:18:41 +0200 Message-Id: X-Mailer: git-send-email 2.30.4 In-Reply-To: References: MIME-Version: 1.0 X-Provags-ID: V03:K1:vSysZ/IaTQn65cJm9u1e7IYJqjCu+VSqdIVVXOSsNCRRWPT8f3A pLyRoibU6Y+vSI5yalEBbSUSWOO/PLe+6TdZOJu09IOslQamB6CZAybGfYXqZ6Reet/GmiH WV7F/40iMHYrTEaUyvATMg5Zi6gs+YzOHTrbQwAdMH2GXrr1QnI5grhAyMEDtecS/7pK+NI ymA4LNRorf6PvhoKYAcPA== X-UI-Out-Filterresults: notjunk:1;V03:K0:BgrqSDvho7E=:LJGLuGO+kSezOu8jdjGxM4 E9P5jlPhsLAWkUiD7j4u75/RLqh+EBPtuMIYT0JX0baK79CvZlbsYPwPP8W4lsQvlfhEJSE2t JW9Fw9HhnqMd5nZ6FUpuXVU4MRz7pe3I71F2qF+MmAoTUs0xLkyvrkwfs9kqCLkHxq9MDWBBD Qb5CTA1s//Z4rF7I4O98vdLJS4YzR3ckAusDNiOCPHpWscnrO6IKY3Tle5ST5U835pIQOLlLE nVGJpjb9Yk9HmGw1CdO+Ht9sl+V7JG+xBbYhkBp1FiPXOQG0lGsCY5faqCV2XJg7pSXKvCsdk upm9OsSmP7O5rj2D4M38qzZHFSFXVmiN8LdKcaBBpdhsp9Hl0iPVq7qAcf4UHcU3PlJsQMWJ/ zVlZzRDBnuBvOyOKiIStwmbjsw8ERPPSmhypWhWym5bjZpQoyqaNNlpGx/9TPoZvFVmqCV6j8 7iWDAcCZJIAstHi1KvTrNiQGscvzGIlETgjK/8Ok03uogfzwUAxsabwrMUXgGAhj6JkwRdHHw qhhi0lfSPTUMzPML4ZnW1ltNW9cO8fnH7Ya9aBFPQ5Kn2/t5bqi8yUK88L8VUBFFupIrY7SXq 7ClN8p0GIwbB9YkgM4yZo5tsjXhsjJc9JOWrMBY1f28SMugJukz1Oy8dB8qmC2bmPOBv7iEJp IUt7PzdgEFsmevley5SzIy1bYkG8f1C1LlRzBafbnOby+NOKnjTYcBya1tTowd/UVawCvOME7 /IRMDlqvkVMLR4lEnvHdhIKPay6Grswkh+WK/7wtKFUOhEFw5/ZoTWjE4aU= 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" X-getmail-retrieved-from-mailbox: Patches * guix/scripts/refresh.scm(options->packages)[args-packages]: Handle version specification in package name arguments. (update-package): Add keyword-argument 'version' 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 | 40 +++++++++++++++++++++++++++++----------- 1 file changed, 29 insertions(+), 11 deletions(-) diff --git a/guix/scripts/refresh.scm b/guix/scripts/refresh.scm index 14329751f8..441e71a6e4 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. ;;; @@ -224,7 +225,8 @@ update would trigger a complete rebuild." (('argument . spec) ;; Take either the specified version or the ;; latest one. - (specification->package spec)) + (let* ((name version (package-name->name+version spec))) + (list (specification->package name) version))) (('expression . exp) (read/eval-package-expression exp)) (_ #f)) @@ -298,7 +300,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 +309,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 @@ -523,6 +525,18 @@ all are dependent packages: ~{~a~^ ~}~%") (lists (concatenate lists)))) + (define (package-list-without-versions packages) + (map (match-lambda + ((package version) package) + (package package)) + packages)) + + (define (package-list-with-versions packages) + (map (match-lambda + ((package version) (list package version)) + (package (list package #f))) + packages)) + (let* ((opts (parse-options)) (update? (assoc-ref opts 'update?)) (updaters (options->updaters opts)) @@ -540,12 +554,13 @@ all are dependent packages: ~{~a~^ ~}~%") (with-error-handling (with-store store (run-with-store store + (begin (mlet %store-monad ((packages (options->packages opts))) (cond (list-dependent? - (list-dependents packages)) + (list-dependents (package-list-without-versions packages))) (list-transitive? - (list-transitive packages)) + (list-transitive (package-list-without-versions packages))) (update? (parameterize ((%openpgp-key-server (or (assoc-ref opts 'key-server) @@ -558,13 +573,16 @@ 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) + (cut apply + (lambda (package version) + (update-package store package version updaters + #:key-download key-download + #:warn? warn?)) + <>) + (values (package-list-with-versions packages))) (return #t))) (else (for-each (cut check-for-package-update <> updaters #:warn? warn?) - packages) - (return #t))))))))) + (package-list-without-versions packages)) + (return #t))))))))))