aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNikita Karetnikov <nikita@karetnikov.org>2013-09-25 03:34:49 +0000
committerNikita Karetnikov <nikita@karetnikov.org>2013-09-26 15:41:43 +0000
commit64d2e973fb2f22a42c6dec5065070343695e5848 (patch)
tree2f7839ce6d3c245c65d36a8a8755dbb5ca5680d6
parent4658b2c47b7322bf7d8e1049557dc0ffc14ef88b (diff)
downloadpatches-64d2e973fb2f22a42c6dec5065070343695e5848.tar
patches-64d2e973fb2f22a42c6dec5065070343695e5848.tar.gz
guix package: Add 'link-to-empty-profile'.
* guix/scripts/package.scm (link-to-empty-profile): New function. (roll-back): Use it.
-rw-r--r--guix/scripts/package.scm18
1 files changed, 11 insertions, 7 deletions
diff --git a/guix/scripts/package.scm b/guix/scripts/package.scm
index ed1e72c4ae..786502705e 100644
--- a/guix/scripts/package.scm
+++ b/guix/scripts/package.scm
@@ -214,6 +214,15 @@ all of PACKAGES, a list of name/version/output/path/deps tuples."
(compose string->number (cut match:substring <> 1)))
0))
+(define (link-to-empty-profile generation)
+ "Link GENERATION, a string, to the empty profile."
+ (let* ((drv (profile-derivation (%store) '()))
+ (prof (derivation->output-path drv "out")))
+ (when (not (build-derivations (%store) (list drv)))
+ (leave (_ "failed to build the empty profile~%")))
+
+ (switch-symlinks generation prof)))
+
(define (roll-back profile)
"Roll back to the previous generation of PROFILE."
(let* ((number (generation-number profile))
@@ -236,13 +245,8 @@ all of PACKAGES, a list of name/version/output/path/deps tuples."
(_ "nothing to do: already at the empty profile~%")))
((or (zero? previous-number) ; going to emptiness
(not (file-exists? previous-generation)))
- (let* ((drv (profile-derivation (%store) '()))
- (prof (derivation->output-path drv "out")))
- (when (not (build-derivations (%store) (list drv)))
- (leave (_ "failed to build the empty profile~%")))
-
- (switch-symlinks previous-generation prof)
- (switch-link)))
+ (link-to-empty-profile previous-generation)
+ (switch-link))
(else (switch-link))))) ; anything else
(define (generation-time profile number)