summaryrefslogtreecommitdiff
path: root/guix/scripts
diff options
context:
space:
mode:
authorKonrad Hinsen <konrad.hinsen@fastmail.net>2019-09-18 09:52:18 +0200
committerLudovic Courtès <ludo@gnu.org>2019-09-18 23:08:29 +0200
commitda551107129d22dfb2a4278a55b702a7340e7f51 (patch)
tree3dfe5fe5ae266925c1b1c189bb2b80fe230677c3 /guix/scripts
parentee25048e51dd45ad91a1ad4b0f25f4013843c52b (diff)
downloadpatches-da551107129d22dfb2a4278a55b702a7340e7f51.tar
patches-da551107129d22dfb2a4278a55b702a7340e7f51.tar.gz
scripts: pull: Add options for generation management
* guix/scripts/pull.scm (%options) Add --roll-back, --switch-generation, --delete-generations (process-generation-change): New function (guix-pull): Execute generation management operations * doc/guix.texi: Document the generation management operations Signed-off-by: Ludovic Courtès <ludo@gnu.org>
Diffstat (limited to 'guix/scripts')
-rw-r--r--guix/scripts/pull.scm41
1 files changed, 40 insertions, 1 deletions
diff --git a/guix/scripts/pull.scm b/guix/scripts/pull.scm
index 4b03cea2e3..c9835cef34 100644
--- a/guix/scripts/pull.scm
+++ b/guix/scripts/pull.scm
@@ -38,7 +38,8 @@
#:use-module (guix git)
#:use-module (git)
#:use-module (gnu packages)
- #:use-module ((guix scripts package) #:select (build-and-use-profile))
+ #:use-module ((guix scripts package) #:select (build-and-use-profile
+ delete-matching-generations))
#:use-module ((gnu packages base) #:select (canonical-package))
#:use-module (gnu packages guile)
#:use-module ((gnu packages bootstrap)
@@ -92,6 +93,14 @@ Download and deploy the latest version of Guix.\n"))
-l, --list-generations[=PATTERN]
list generations matching PATTERN"))
(display (G_ "
+ --roll-back roll back to the previous generation"))
+ (display (G_ "
+ -d, --delete-generations[=PATTERN]
+ delete generations matching PATTERN"))
+ (display (G_ "
+ -S, --switch-generation=PATTERN
+ switch to a generation matching PATTERN"))
+ (display (G_ "
-p, --profile=PROFILE use PROFILE instead of ~/.config/guix/current"))
(display (G_ "
-v, --verbosity=LEVEL use the given verbosity LEVEL"))
@@ -120,6 +129,18 @@ Download and deploy the latest version of Guix.\n"))
(lambda (opt name arg result)
(cons `(query list-generations ,arg)
result)))
+ (option '("roll-back") #f #f
+ (lambda (opt name arg result)
+ (cons '(generation roll-back)
+ result)))
+ (option '(#\S "switch-generation") #t #f
+ (lambda (opt name arg result)
+ (cons `(generation switch ,arg)
+ result)))
+ (option '(#\d "delete-generations") #f #t
+ (lambda (opt name arg result)
+ (cons `(generation delete ,arg)
+ result)))
(option '(#\N "news") #f #f
(lambda (opt name arg result)
(cons '(query display-news) result)))
@@ -505,6 +526,22 @@ list of package changes.")))))
(display-profile-news profile
#:current-is-newer? #t))))
+(define (process-generation-change opts profile)
+ "Process a request to change the current generation (roll-back, switch, delete)."
+ (unless (assoc-ref opts 'dry-run?)
+ (match (assoc-ref opts 'generation)
+ (('roll-back)
+ (with-store store
+ (roll-back* store profile)))
+ (('switch pattern)
+ (let ((number (relative-generation-spec->number profile pattern)))
+ (if number
+ (switch-to-generation* profile number)
+ (leave (G_ "cannot switch to generation '~a'~%") pattern))))
+ (('delete pattern)
+ (with-store store
+ (delete-matching-generations store profile pattern))))))
+
(define (channel-list opts)
"Return the list of channels to use. If OPTS specify a channel file,
channels are read from there; otherwise, if ~/.config/guix/channels.scm
@@ -572,6 +609,8 @@ Use '~/.config/guix/channels.scm' instead."))
(profile (or (assoc-ref opts 'profile) %current-profile)))
(cond ((assoc-ref opts 'query)
(process-query opts profile))
+ ((assoc-ref opts 'generation)
+ (process-generation-change opts profile))
(else
(with-store store
(ensure-default-profile)