me
/
guix
Archived
1
0
Fork 0

refresh: Add --target-version option.

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

Reviewed-by: Ludovic Courtès <ludo@gnu.org>
Maxim Cournoyer 2023-08-11 17:09:08 -04:00
parent 2279e3e604
commit 2884abb3df
No known key found for this signature in database
GPG Key ID: 1260E46482E63562
3 changed files with 50 additions and 8 deletions

View File

@ -14529,6 +14529,26 @@ gnu/packages/guile.scm:147:2: guile: updating from version 2.0.10 to version 2.0
@dots{} @dots{}
@end example @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{--target-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 --target-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 --target-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, Sometimes the upstream name differs from the package name used in Guix,
and @command{guix refresh} needs a little help. Most updaters honor the and @command{guix refresh} needs a little help. Most updaters honor the
@code{upstream-name} property in package definitions, which can be used @code{upstream-name} property in package definitions, which can be used

View File

@ -10,6 +10,7 @@
;;; Copyright © 2020 Simon Tournier <zimon.toutoune@gmail.com> ;;; Copyright © 2020 Simon Tournier <zimon.toutoune@gmail.com>
;;; Copyright © 2021 Sarah Morgensen <iskarian@mgsn.dev> ;;; Copyright © 2021 Sarah Morgensen <iskarian@mgsn.dev>
;;; Copyright © 2022 Hartmut Goebel <h.goebel@crazy-compilers.com> ;;; Copyright © 2022 Hartmut Goebel <h.goebel@crazy-compilers.com>
;;; Copyright © 2023 Maxim Cournoyer maxim.cournoyer@gmail.com>
;;; ;;;
;;; This file is part of GNU Guix. ;;; This file is part of GNU Guix.
;;; ;;;
@ -106,6 +107,9 @@
(option '(#\m "manifest") #t #f (option '(#\m "manifest") #t #f
(lambda (opt name arg result) (lambda (opt name arg result)
(alist-cons 'manifest arg result))) (alist-cons 'manifest arg result)))
(option '("target-version") #t #f
(lambda (opt name arg result)
(alist-cons 'target-version arg result)))
(option '(#\e "expression") #t #f (option '(#\e "expression") #t #f
(lambda (opt name arg result) (lambda (opt name arg result)
(alist-cons 'expression arg result))) (alist-cons 'expression arg result)))
@ -164,6 +168,9 @@ specified with `--select'.\n"))
'module:(gnu packages guile)'")) 'module:(gnu packages guile)'"))
(display (G_ " (display (G_ "
-m, --manifest=FILE select all the packages from the manifest in FILE")) -m, --manifest=FILE select all the packages from the manifest in FILE"))
(display (G_ "
--target-version=VERSION
update the package or packages to VERSION"))
(display (G_ " (display (G_ "
-t, --type=UPDATER,... restrict to updates from the specified updaters -t, --type=UPDATER,... restrict to updates from the specified updaters
(e.g., 'gnu')")) (e.g., 'gnu')"))
@ -213,17 +220,20 @@ specified with `--select'.\n"))
(define* (update-spec package #:optional version) (define* (update-spec package #:optional version)
(%update-spec package 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@2.0=2.0.8\", return a <update> "Given SPEC, a package name like \"guile@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 #\=) (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)) (idx (update-spec (specification->package (substring spec 0 idx))
(substring spec (1+ idx)))))) (substring spec (1+ idx))))))
(define (options->update-specs opts) (define (options->update-specs opts)
"Return the list of <update-spec> records requested by OPTS, honoring "Return the list of <update-spec> records requested by OPTS, honoring
options like '--recursive'." options like '--recursive'."
(define target-version (assoc-ref opts 'target-version))
(define core-package? (define core-package?
(let* ((input->package (match-lambda (let* ((input->package (match-lambda
((name (? package? package) _ ...) package) ((name (? package? package) _ ...) package)
@ -263,13 +273,18 @@ update would trigger a complete rebuild."
;; Update specs explicitly passed as command-line arguments. ;; Update specs explicitly passed as command-line arguments.
(match (append-map (match-lambda (match (append-map (match-lambda
(('argument . spec) (('argument . spec)
;; Take either the specified version or the ;; Take either the specified version or the latest
;; latest one. ;; one. The version specified as part of a spec
(list (update-specification->update-spec spec))) ;; takes precedence, with the command-line specified
;; --target-version used as a fallback.
(list (update-specification->update-spec
spec target-version)))
(('expression . exp) (('expression . exp)
(list (update-spec (read/eval-package-expression exp)))) (list (update-spec (read/eval-package-expression exp)
target-version)))
(('manifest . manifest) (('manifest . manifest)
(map update-spec (packages-from-manifest manifest))) (map (cut update-spec <> target-version)
(packages-from-manifest manifest)))
(_ (_
'())) '()))
opts) opts)

View File

@ -109,6 +109,13 @@ case "$(guix refresh -t test guile=2.0.0 2>&1)" in
*"failed to find"*"2.0.0"*) true;; *"failed to find"*"2.0.0"*) true;;
*) false;; *) false;;
esac esac
guix refresh -t test guile --target-version=2.0.0 # XXX: should return non-zero?
case "$(guix refresh -t test guile --target-version=2.0.0 2>&1)" in
*"failed to find"*"2.0.0"*) true;;
*) false;;
esac
for spec in "guile=1.6.4" "guile@3=1.6.4" for spec in "guile=1.6.4" "guile@3=1.6.4"
do do
guix refresh -t test "$spec" guix refresh -t test "$spec"