[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
05/08: refresh: Add '--type' option.
From: |
Ludovic Courtès |
Subject: |
05/08: refresh: Add '--type' option. |
Date: |
Wed, 21 Oct 2015 12:45:34 +0000 |
civodul pushed a commit to branch master
in repository guix.
commit bcb571cba499c29556d36f17554253d285d4d578
Author: Ludovic Courtès <address@hidden>
Date: Wed Oct 21 13:04:34 2015 +0200
refresh: Add '--type' option.
* guix/scripts/refresh.scm (%options, show-help): Add --type.
(lookup-updater): New procedure.
(update-package): Add 'updaters' parameter and honor it.
(guix-refresh)[options->updaters]: New procedure.
Use it, and honor --type.
---
doc/guix.texi | 28 +++++++++++++++++++-
guix/scripts/refresh.scm | 63 ++++++++++++++++++++++++++++++++-------------
2 files changed, 71 insertions(+), 20 deletions(-)
diff --git a/doc/guix.texi b/doc/guix.texi
index 3222a64..6f26568 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -4211,8 +4211,12 @@ gnu/packages/glib.scm:77:12: glib would be upgraded from
2.34.3 to 2.37.0
@end example
It does so by browsing each package's FTP directory and determining the
-highest version number of the source tarballs
address@hidden, this only works for GNU packages.}.
+highest version number of the source tarballs therein. The command
+knows how to update specific types of packages: GNU packages, ELPA
+packages, etc.---see the documentation for @option{--type} below. The
+are many packages, though, for which it lacks a method to determine
+whether a new upstream release is available. However, the mechanism is
+extensible, so feel free to get in touch with us to add a new method!
When passed @code{--update}, it modifies distribution source files to
update the version numbers and source tarball hashes of those packages'
@@ -4257,6 +4261,26 @@ The @code{non-core} subset refers to the remaining
packages. It is
typically useful in cases where an update of the core packages would be
inconvenient.
address@hidden address@hidden
address@hidden -t @var{updater}
+Select only packages handled by @var{updater}. Currently, @var{updater}
+may be one of:
+
address@hidden @code
address@hidden gnu
+the updater for GNU packages;
address@hidden elpa
+the updater for @uref{http://elpa.gnu.org/, ELPA} packages.
address@hidden table
+
+For instance, the following commands only checks for updates of Emacs
+packages hosted at @code{elpa.gnu.org}:
+
address@hidden
+$ guix refresh -t elpa
+gnu/packages/emacs.scm:856:13: emacs-auctex would be upgraded from 11.88.6 to
11.88.9
address@hidden example
+
@end table
In addition, @command{guix refresh} can be passed one or more package
diff --git a/guix/scripts/refresh.scm b/guix/scripts/refresh.scm
index 8e461ce..bbfdf24 100644
--- a/guix/scripts/refresh.scm
+++ b/guix/scripts/refresh.scm
@@ -65,6 +65,9 @@
(x
(leave (_ "~a: invalid selection; expected `core' or
`non-core'~%")
arg)))))
+ (option '(#\t "type") #t #f
+ (lambda (opt name arg result)
+ (alist-cons 'updater (string->symbol arg) result)))
(option '(#\l "list-dependent") #f #f
(lambda (opt name arg result)
(alist-cons 'list-dependent? #t result)))
@@ -106,6 +109,8 @@ specified with `--select'.\n"))
-s, --select=SUBSET select all the packages in SUBSET, one of
`core' or `non-core'"))
(display (_ "
+ -t, --type=UPDATER restrict to updates from UPDATER--e.g., 'gnu'"))
+ (display (_ "
-l, --list-dependent list top-level dependent packages that would need to
be rebuilt as a result of upgrading PACKAGE..."))
(newline)
@@ -136,14 +141,21 @@ specified with `--select'.\n"))
(list %gnu-updater
%elpa-updater))
-(define* (update-package store package #:key (key-download 'interactive))
+(define (lookup-updater name)
+ "Return the updater called NAME."
+ (find (lambda (updater)
+ (eq? name (upstream-updater-name updater)))
+ %updaters))
+
+(define* (update-package store package updaters
+ #:key (key-download 'interactive))
"Update the source file that defines PACKAGE with the new version.
KEY-DOWNLOAD specifies a download policy for missing OpenPGP keys; allowed
values: 'interactive' (default), 'always', and 'never'."
(let-values (((version tarball)
(catch #t
(lambda ()
- (package-update store package %updaters
+ (package-update store package updaters
#:key-download key-download))
(lambda _
(values #f #f))))
@@ -180,6 +192,19 @@ downloaded and authenticated; not updating~%")
(alist-cons 'argument arg result))
%default-options))
+ (define (options->updaters opts)
+ ;; Return the list of updaters to use.
+ (match (filter-map (match-lambda
+ (('updater . name)
+ (lookup-updater name))
+ (_ #f))
+ opts)
+ (()
+ ;; Use the default updaters.
+ %updaters)
+ (lst
+ lst)))
+
(define (keep-newest package lst)
;; If a newer version of PACKAGE is already in LST, return LST; otherwise
;; return LST minus the other version of PACKAGE in it, plus PACKAGE.
@@ -196,8 +221,8 @@ downloaded and authenticated; not updating~%")
(define core-package?
(let* ((input->package (match-lambda
- ((name (? package? package) _ ...) package)
- (_ #f)))
+ ((name (? package? package) _ ...) package)
+ (_ #f)))
(final-inputs (map input->package %final-inputs))
(core (append final-inputs
(append-map (compose (cut filter-map
input->package <>)
@@ -216,6 +241,7 @@ update would trigger a complete rebuild."
(let* ((opts (parse-options))
(update? (assoc-ref opts 'update?))
+ (updaters (options->updaters opts))
(list-dependent? (assoc-ref opts 'list-dependent?))
(key-download (assoc-ref opts 'key-download))
(packages
@@ -226,18 +252,18 @@ update would trigger a complete rebuild."
(specification->package spec))
(_ #f))
opts)
- (() ; default to all packages
- (let ((select? (match (assoc-ref opts 'select)
- ('core core-package?)
- ('non-core (negate core-package?))
- (_ (const #t)))))
- (fold-packages (lambda (package result)
- (if (select? package)
- (keep-newest package result)
- result))
- '())))
- (some ; user-specified packages
- some))))
+ (() ; default to all packages
+ (let ((select? (match (assoc-ref opts 'select)
+ ('core core-package?)
+ ('non-core (negate core-package?))
+ (_ (const #t)))))
+ (fold-packages (lambda (package result)
+ (if (select? package)
+ (keep-newest package result)
+ result))
+ '())))
+ (some ; user-specified packages
+ some))))
(with-error-handling
(cond
(list-dependent?
@@ -269,11 +295,12 @@ dependent packages are rebuilt: ~{~a~^ ~}~%"
(or (assoc-ref opts 'gpg-command)
(%gpg-command))))
(for-each
- (cut update-package store <> #:key-download key-download)
+ (cut update-package store <> updaters
+ #:key-download key-download)
packages))))
(else
(for-each (lambda (package)
- (match (package-update-path package %updaters)
+ (match (package-update-path package updaters)
((? upstream-source? source)
(let ((loc (or (package-field-location package 'version)
(package-location package))))
- branch master updated (45e1096 -> 053cfdb), Ludovic Courtès, 2015/10/21
- 01/08: http-client: '%http-cache-ttl' is really a parameter., Ludovic Courtès, 2015/10/21
- 03/08: import: elpa: Use 'http-fetch/cached' to retrieve the archive., Ludovic Courtès, 2015/10/21
- 08/08: import: cran: Avoid HTTP redirect., Ludovic Courtès, 2015/10/21
- 05/08: refresh: Add '--type' option.,
Ludovic Courtès <=
- 06/08: refresh: Remove exception catch-all., Ludovic Courtès, 2015/10/21
- 02/08: gnu-maintenance: Generalize, leading to (guix upstream)., Ludovic Courtès, 2015/10/21
- 04/08: import: elpa: Add updater., Ludovic Courtès, 2015/10/21
- 07/08: import: cran: Add updater., Ludovic Courtès, 2015/10/21