summaryrefslogtreecommitdiff
path: root/guix
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2015-04-06 21:26:12 +0200
committerLudovic Courtès <ludo@gnu.org>2015-04-06 21:27:32 +0200
commitd26eb84d140af8d2119509d7da440b4f035608c5 (patch)
tree2d9f1a959a5fed4142aba4fe8368995063e743e9 /guix
parent381ac93b5ed7bd51f8f3ab6a8b0127f8ea6288f8 (diff)
guix package: Never remove the current generation and warn about it.
Fixes <http://bugs.gnu.org/19978>. Reported by taylanbayirli@gmail.com (Taylan Ulrich Bayırlı/Kammer). * guix/scripts/package.scm (delete-matching-generations): Warn when CURRENT is in NUMBERS, and always remove it before calling 'delete-generations'. * tests/guix-package.sh: Add --switch-generation=2 invocation before --delete-generations=3 invocation. Add --delete-generations=1.. test case.
Diffstat (limited to 'guix')
-rw-r--r--guix/scripts/package.scm13
1 files changed, 10 insertions, 3 deletions
diff --git a/guix/scripts/package.scm b/guix/scripts/package.scm
index 7074243ed9..3a7afb724b 100644
--- a/guix/scripts/package.scm
+++ b/guix/scripts/package.scm
@@ -254,9 +254,16 @@ denote ranges as interpreted by 'matching-derivations'."
#:duration-relation >)
=>
(lambda (numbers)
- (if (null-list? numbers)
- (exit 1)
- (delete-generations (%store) profile numbers))))
+ (when (memv current numbers)
+ (warning (_ "not removing generation ~a, which is current~%")
+ current))
+
+ ;; Make sure we don't inadvertently remove the current
+ ;; generation.
+ (let ((numbers (delv current numbers)))
+ (if (null-list? numbers)
+ (exit 1)
+ (delete-generations (%store) profile numbers)))))
(else
(leave (_ "invalid syntax: ~a~%") pattern)))))