GNU bug report logs - #65235
[PATCH] refresh: Add --to-version option.

Previous Next

Package: guix-patches;

Reported by: Maxim Cournoyer <maxim.cournoyer <at> gmail.com>

Date: Fri, 11 Aug 2023 21:46:02 UTC

Severity: normal

Tags: patch

Done: Maxim Cournoyer <maxim.cournoyer <at> gmail.com>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 65235 in the body.
You can then email your comments to 65235 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to guix <at> cbaines.net, dev <at> jpoiret.xyz, ludo <at> gnu.org, othacehe <at> gnu.org, rekado <at> elephly.net, zimon.toutoune <at> gmail.com, me <at> tobias.gr, guix-patches <at> gnu.org:
bug#65235; Package guix-patches. (Fri, 11 Aug 2023 21:46:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Maxim Cournoyer <maxim.cournoyer <at> gmail.com>:
New bug report received and forwarded. Copy sent to guix <at> cbaines.net, dev <at> jpoiret.xyz, ludo <at> gnu.org, othacehe <at> gnu.org, rekado <at> elephly.net, zimon.toutoune <at> gmail.com, me <at> tobias.gr, guix-patches <at> gnu.org. (Fri, 11 Aug 2023 21:46:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Maxim Cournoyer <maxim.cournoyer <at> gmail.com>
To: guix-patches <at> gnu.org,
	maxim.cournoyer <at> gmail.com
Subject: [PATCH] refresh: Add --to-version option.
Date: Fri, 11 Aug 2023 17:45:11 -0400
* guix/scripts/refresh.scm (%options): Register 'to-version' long version.
(update-specification->update-spec): Add a fallback-version argument.
(options->update-specs): Honor to-version option.
* tests/guix-refresh.sh: Test it.
* doc/guix.texi (Invoking guix refresh): Document it.
---
 doc/guix.texi            | 20 ++++++++++++++++++++
 guix/scripts/refresh.scm | 31 +++++++++++++++++++++++--------
 tests/guix-refresh.sh    |  7 +++++++
 3 files changed, 50 insertions(+), 8 deletions(-)

diff --git a/doc/guix.texi b/doc/guix.texi
index 409ca2ad62..ade80dd72a 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -14529,6 +14529,26 @@ Invoking guix refresh
 @dots{}
 @end example
 
+In some specific cases, you may have many packages specified via a
+manifest or a module selection which should all be updated together; for
+these cases, the @option{--to-version} option can be provided to have
+them all refreshed to the same version, as shown in the examples below:
+
+@example
+$ guix refresh qtbase qtdeclarative --to-version=6.5.2
+gnu/packages/qt.scm:1248:13: qtdeclarative would be upgraded from 6.3.2 to 6.5.2
+gnu/packages/qt.scm:584:2: qtbase would be upgraded from 6.3.2 to 6.5.2
+@end example
+
+@example
+$ guix refresh --manifest=qt5-manifest.scm --to-version=5.15.10
+gnu/packages/qt.scm:1173:13: qtxmlpatterns would be upgraded from 5.15.8 to 5.15.10
+gnu/packages/qt.scm:1202:13: qtdeclarative would be upgraded from 5.15.8 to 5.15.10
+gnu/packages/qt.scm:1762:13: qtserialbus would be upgraded from 5.15.8 to 5.15.10
+gnu/packages/qt.scm:2070:13: qtquickcontrols2 would be upgraded from 5.15.8 to 5.15.10
+@dots{}
+@end example
+
 Sometimes the upstream name differs from the package name used in Guix,
 and @command{guix refresh} needs a little help.  Most updaters honor the
 @code{upstream-name} property in package definitions, which can be used
diff --git a/guix/scripts/refresh.scm b/guix/scripts/refresh.scm
index a9241aa20d..54ac7ceea3 100644
--- a/guix/scripts/refresh.scm
+++ b/guix/scripts/refresh.scm
@@ -10,6 +10,7 @@
 ;;; Copyright © 2020 Simon Tournier <zimon.toutoune <at> gmail.com>
 ;;; Copyright © 2021 Sarah Morgensen <iskarian <at> mgsn.dev>
 ;;; Copyright © 2022 Hartmut Goebel <h.goebel <at> crazy-compilers.com>
+;;; Copyright © 2023 Maxim Cournoyer maxim.cournoyer <at> gmail.com>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -106,6 +107,9 @@ (define %options
         (option '(#\m "manifest") #t #f
                 (lambda (opt name arg result)
                   (alist-cons 'manifest arg result)))
+        (option '("to-version") #t #f
+                (lambda (opt name arg result)
+                  (alist-cons 'to-version arg result)))
         (option '(#\e "expression") #t #f
                 (lambda (opt name arg result)
                   (alist-cons 'expression arg result)))
@@ -164,6 +168,9 @@ (define (show-help)
                          'module:(gnu packages guile)'"))
   (display (G_ "
   -m, --manifest=FILE    select all the packages from the manifest in FILE"))
+  (display (G_ "
+      --to-version=VERSION
+                         update the package or packages to VERSION"))
   (display (G_ "
   -t, --type=UPDATER,... restrict to updates from the specified updaters
                          (e.g., 'gnu')"))
@@ -213,17 +220,20 @@ (define-record-type <update-spec>
 (define* (update-spec package #:optional version)
   (%update-spec package version))
 
-(define (update-specification->update-spec spec)
+(define (update-specification->update-spec spec fallback-version)
   "Given SPEC, a package name like \"guile <at> 2.0=2.0.8\", return a <update>
-record with two fields: the package to upgrade, and the target version."
+record with two fields: the package to upgrade, and the target version.  When
+SPEC lacks a version, use FALLBACK-VERSION."
   (match (string-rindex spec #\=)
-    (#f  (update-spec (specification->package spec) #f))
+    (#f  (update-spec (specification->package spec) fallback-version))
     (idx (update-spec (specification->package (substring spec 0 idx))
                       (substring spec (1+ idx))))))
 
 (define (options->update-specs opts)
   "Return the list of <update-spec> records requested by OPTS, honoring
 options like '--recursive'."
+  (define to-version (assoc-ref opts 'to-version))
+
   (define core-package?
     (let* ((input->package (match-lambda
                              ((name (? package? package) _ ...) package)
@@ -263,13 +273,18 @@ (define (options->update-specs opts)
     ;; Update specs explicitly passed as command-line arguments.
     (match (append-map (match-lambda
                          (('argument . spec)
-                          ;; Take either the specified version or the
-                          ;; latest one.
-                          (list (update-specification->update-spec spec)))
+                          ;; Take either the specified version or the latest
+                          ;; one.  The version specified as part of a spec
+                          ;; takes precedence, with the command-line specified
+                          ;; --to-version used as a fallback.
+                          (list (update-specification->update-spec spec
+                                                                   to-version)))
                          (('expression . exp)
-                          (list (update-spec (read/eval-package-expression exp))))
+                          (list (update-spec (read/eval-package-expression exp)
+                                             to-version)))
                          (('manifest . manifest)
-                          (map update-spec (packages-from-manifest manifest)))
+                          (map (cut update-spec <> to-version)
+                               (packages-from-manifest manifest)))
                          (_
                           '()))
                        opts)
diff --git a/tests/guix-refresh.sh b/tests/guix-refresh.sh
index 51d34c4b51..a2be93fce4 100644
--- a/tests/guix-refresh.sh
+++ b/tests/guix-refresh.sh
@@ -109,6 +109,13 @@ case "$(guix refresh -t test guile=2.0.0 2>&1)" in
     *"failed to find"*"2.0.0"*) true;;
     *) false;;
 esac
+
+guix refresh -t test guile --to-version=2.0.0 # XXX: should return non-zero?
+case "$(guix refresh -t test guile --to-version=2.0.0 2>&1)" in
+    *"failed to find"*"2.0.0"*) true;;
+    *) false;;
+esac
+
 for spec in "guile=1.6.4" "guile <at> 3=1.6.4"
 do
     guix refresh -t test "$spec"

base-commit: 77251c5f5af193dcd031dffef744001cfc48f7e5
-- 
2.41.0





Information forwarded to guix-patches <at> gnu.org:
bug#65235; Package guix-patches. (Tue, 15 Aug 2023 10:41:01 GMT) Full text and rfc822 format available.

Message #8 received at 65235 <at> debbugs.gnu.org (full text, mbox):

From: Ludovic Courtès <ludo <at> gnu.org>
To: Maxim Cournoyer <maxim.cournoyer <at> gmail.com>
Cc: Josselin Poiret <dev <at> jpoiret.xyz>,
 Simon Tournier <zimon.toutoune <at> gmail.com>, Mathieu Othacehe <othacehe <at> gnu.org>,
 Tobias Geerinckx-Rice <me <at> tobias.gr>, Ricardo Wurmus <rekado <at> elephly.net>,
 65235 <at> debbugs.gnu.org, Christopher Baines <guix <at> cbaines.net>
Subject: Re: bug#65235: [PATCH] refresh: Add --to-version option.
Date: Tue, 15 Aug 2023 12:39:48 +0200
Hi Maxim,

Maxim Cournoyer <maxim.cournoyer <at> gmail.com> skribis:

> * guix/scripts/refresh.scm (%options): Register 'to-version' long version.
> (update-specification->update-spec): Add a fallback-version argument.
> (options->update-specs): Honor to-version option.
> * tests/guix-refresh.sh: Test it.
> * doc/guix.texi (Invoking guix refresh): Document it.

[...]

> +In some specific cases, you may have many packages specified via a
> +manifest or a module selection which should all be updated together; for
> +these cases, the @option{--to-version} option can be provided to have
> +them all refreshed to the same version, as shown in the examples below:
> +
> +@example
> +$ guix refresh qtbase qtdeclarative --to-version=6.5.2
> +gnu/packages/qt.scm:1248:13: qtdeclarative would be upgraded from 6.3.2 to 6.5.2
> +gnu/packages/qt.scm:584:2: qtbase would be upgraded from 6.3.2 to 6.5.2
> +@end example
> +
> +@example
> +$ guix refresh --manifest=qt5-manifest.scm --to-version=5.15.10
> +gnu/packages/qt.scm:1173:13: qtxmlpatterns would be upgraded from 5.15.8 to 5.15.10
> +gnu/packages/qt.scm:1202:13: qtdeclarative would be upgraded from 5.15.8 to 5.15.10
> +gnu/packages/qt.scm:1762:13: qtserialbus would be upgraded from 5.15.8 to 5.15.10
> +gnu/packages/qt.scm:2070:13: qtquickcontrols2 would be upgraded from 5.15.8 to 5.15.10
> +@dots{}
> +@end example

So the main goal is to avoid repeating the ‘=’ sign as in
‘qtbase=6.5.2’, right?  That makes a lot of sense to me.

I’d maybe prefer ‘--target-version’ but otherwise LGTM!

Thanks,
Ludo’.




Reply sent to Maxim Cournoyer <maxim.cournoyer <at> gmail.com>:
You have taken responsibility. (Tue, 15 Aug 2023 14:03:02 GMT) Full text and rfc822 format available.

Notification sent to Maxim Cournoyer <maxim.cournoyer <at> gmail.com>:
bug acknowledged by developer. (Tue, 15 Aug 2023 14:03:02 GMT) Full text and rfc822 format available.

Message #13 received at 65235-done <at> debbugs.gnu.org (full text, mbox):

From: Maxim Cournoyer <maxim.cournoyer <at> gmail.com>
To: Ludovic Courtès <ludo <at> gnu.org>
Cc: 65235-done <at> debbugs.gnu.org, Josselin Poiret <dev <at> jpoiret.xyz>,
 Simon Tournier <zimon.toutoune <at> gmail.com>, Mathieu Othacehe <othacehe <at> gnu.org>,
 Tobias Geerinckx-Rice <me <at> tobias.gr>, Ricardo Wurmus <rekado <at> elephly.net>,
 Christopher Baines <guix <at> cbaines.net>
Subject: Re: bug#65235: [PATCH] refresh: Add --to-version option.
Date: Tue, 15 Aug 2023 10:02:52 -0400
Hi,

Ludovic Courtès <ludo <at> gnu.org> writes:

> Hi Maxim,
>
> Maxim Cournoyer <maxim.cournoyer <at> gmail.com> skribis:
>
>> * guix/scripts/refresh.scm (%options): Register 'to-version' long version.
>> (update-specification->update-spec): Add a fallback-version argument.
>> (options->update-specs): Honor to-version option.
>> * tests/guix-refresh.sh: Test it.
>> * doc/guix.texi (Invoking guix refresh): Document it.
>
> [...]
>
>> +In some specific cases, you may have many packages specified via a
>> +manifest or a module selection which should all be updated together; for
>> +these cases, the @option{--to-version} option can be provided to have
>> +them all refreshed to the same version, as shown in the examples below:
>> +
>> +@example
>> +$ guix refresh qtbase qtdeclarative --to-version=6.5.2
>> +gnu/packages/qt.scm:1248:13: qtdeclarative would be upgraded from 6.3.2 to 6.5.2
>> +gnu/packages/qt.scm:584:2: qtbase would be upgraded from 6.3.2 to 6.5.2
>> +@end example
>> +
>> +@example
>> +$ guix refresh --manifest=qt5-manifest.scm --to-version=5.15.10
>> +gnu/packages/qt.scm:1173:13: qtxmlpatterns would be upgraded from 5.15.8 to 5.15.10
>> +gnu/packages/qt.scm:1202:13: qtdeclarative would be upgraded from 5.15.8 to 5.15.10
>> +gnu/packages/qt.scm:1762:13: qtserialbus would be upgraded from 5.15.8 to 5.15.10
>> +gnu/packages/qt.scm:2070:13: qtquickcontrols2 would be upgraded from 5.15.8 to 5.15.10
>> +@dots{}
>> +@end example
>
> So the main goal is to avoid repeating the ‘=’ sign as in
> ‘qtbase=6.5.2’, right?  That makes a lot of sense to me.
>
> I’d maybe prefer ‘--target-version’ but otherwise LGTM!

I've attempted a quick poll on #guix and Efraim also voted vote
--target-version, so I've made change and pushed!  Tobias had suggested
'--update-version', which also made sense.

Thanks for the review!

-- 
Maxim




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Wed, 13 Sep 2023 11:24:10 GMT) Full text and rfc822 format available.

This bug report was last modified 1 year and 338 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.