scripts: refresh: Add -m manifest option.

* guix/scripts/refresh.scm (%options): Add -m option,
(show-help): document it,
(packages-from-manifest): new procedure,
(guix-refresh): use packages from manifest if specified, otherwise
keep the previous behaviour.
* doc/guix.texi (Invoking guix refresh): document new option.
This commit is contained in:
Mathieu Othacehe 2017-05-04 09:14:02 +02:00
parent d5cb2ac7f9
commit 1335ac3141
No known key found for this signature in database
GPG key ID: 8354763531769CA6
2 changed files with 36 additions and 3 deletions

View file

@ -5875,6 +5875,11 @@ 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 typically useful in cases where an update of the core packages would be
inconvenient. inconvenient.
@item --manifest=@var{file}
@itemx -m @var{file}
Select all the packages from the manifest in @var{file}. This is useful to
check if any packages of the user manifest can be updated.
@item --type=@var{updater} @item --type=@var{updater}
@itemx -t @var{updater} @itemx -t @var{updater}
Select only packages handled by @var{updater} (may be a comma-separated Select only packages handled by @var{updater} (may be a comma-separated

View file

@ -4,6 +4,7 @@
;;; Copyright © 2014 Eric Bavier <bavier@member.fsf.org> ;;; Copyright © 2014 Eric Bavier <bavier@member.fsf.org>
;;; Copyright © 2015 Alex Kost <alezost@gmail.com> ;;; Copyright © 2015 Alex Kost <alezost@gmail.com>
;;; Copyright © 2016 Ben Woodcroft <donttrustben@gmail.com> ;;; Copyright © 2016 Ben Woodcroft <donttrustben@gmail.com>
;;; Copyright © 2017 Mathieu Othacehe <m.othacehe@gmail.com>
;;; ;;;
;;; This file is part of GNU Guix. ;;; This file is part of GNU Guix.
;;; ;;;
@ -27,6 +28,7 @@ (define-module (guix scripts refresh)
#:use-module (guix store) #:use-module (guix store)
#:use-module (guix utils) #:use-module (guix utils)
#:use-module (guix packages) #:use-module (guix packages)
#:use-module (guix profiles)
#:use-module (guix upstream) #:use-module (guix upstream)
#:use-module (guix discovery) #:use-module (guix discovery)
#:use-module (guix graph) #:use-module (guix graph)
@ -79,6 +81,9 @@ (define %options
(option '(#\L "list-updaters") #f #f (option '(#\L "list-updaters") #f #f
(lambda args (lambda args
(list-updaters-and-exit))) (list-updaters-and-exit)))
(option '(#\m "manifest") #t #f
(lambda (opt name arg result)
(alist-cons 'manifest 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)))
@ -125,6 +130,8 @@ (define (show-help)
-s, --select=SUBSET select all the packages in SUBSET, one of -s, --select=SUBSET select all the packages in SUBSET, one of
`core' or `non-core'")) `core' or `non-core'"))
(display (G_ " (display (G_ "
-m, --manifest=FILE select all the packages from the manifest in FILE"))
(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')"))
(display (G_ " (display (G_ "
@ -306,6 +313,24 @@ (define (full-name package)
(map full-name covering)))) (map full-name covering))))
(return #t)))) (return #t))))
;;;
;;; Manifest.
;;;
(define (manifest->packages manifest)
"Return the list of packages in MANIFEST."
(filter-map (lambda (entry)
(let ((item (manifest-entry-item entry)))
(if (package? item) item #f)))
(manifest-entries manifest)))
(define (packages-from-manifest manifest)
"Return the list of packages in loaded MANIFEST."
(let* ((user-module (make-user-module '((guix profiles) (gnu))))
(manifest (load* manifest user-module)))
(manifest->packages manifest)))
;;; ;;;
;;; Entry point. ;;; Entry point.
@ -378,8 +403,7 @@ (define core-package?
;; the command line. ;; the command line.
(warn? (or (assoc-ref opts 'argument) (warn? (or (assoc-ref opts 'argument)
(assoc-ref opts 'expression))) (assoc-ref opts 'expression)))
(args-packages
(packages
(match (filter-map (match-lambda (match (filter-map (match-lambda
(('argument . spec) (('argument . spec)
;; Take either the specified version or the ;; Take either the specified version or the
@ -400,7 +424,11 @@ (define core-package?
result)) result))
'()))) '())))
(some ; user-specified packages (some ; user-specified packages
some)))) some)))
(packages
(match (assoc-ref opts 'manifest)
(#f args-packages)
((? string? file) (packages-from-manifest file)))))
(with-error-handling (with-error-handling
(with-store store (with-store store
(run-with-store store (run-with-store store