diff options
| author | Ludovic Courtès <ludo@gnu.org> | 2015-11-11 23:05:43 +0100 |
|---|---|---|
| committer | Ludovic Courtès <ludo@gnu.org> | 2015-11-11 23:29:20 +0100 |
| commit | 3a96d7c3dd864e4312df723ea54c2f710f55380c (patch) | |
| tree | 7e8ec13fadda544f33c095e8742314210c4db6a0 | |
| parent | 6237b9fa39c6ab3283c50b96520b990c8612abc1 (diff) | |
guix gc: Error out when extra arguments are passed.
Fixes <http://bugs.gnu.org/21817>.
Reported by Petter Berntsen <petter@mykolab.ch>.
* guix/scripts/gc.scm (guix-gc)[assert-no-extra-arguments]: New
procedure.
Use it for actions 'collect-garbage', 'optimize', and 'verify'.
* tests/guix-gc.sh: Add tests.
| -rw-r--r-- | guix/scripts/gc.scm | 7 | ||||
| -rw-r--r-- | tests/guix-gc.sh | 8 |
2 files changed, 14 insertions, 1 deletions
diff --git a/guix/scripts/gc.scm b/guix/scripts/gc.scm index 89a68d51d01..fe1bb93f7f0 100644 --- a/guix/scripts/gc.scm +++ b/guix/scripts/gc.scm | |||
| @@ -182,6 +182,10 @@ Invoke the garbage collector.\n")) | |||
| 182 | (('argument . arg) arg) | 182 | (('argument . arg) arg) |
| 183 | (_ #f)) | 183 | (_ #f)) |
| 184 | opts))) | 184 | opts))) |
| 185 | (define (assert-no-extra-arguments) | ||
| 186 | (unless (null? paths) | ||
| 187 | (leave (_ "extraneous arguments: ~{~a ~}~%") paths))) | ||
| 188 | |||
| 185 | (define (list-relatives relatives) | 189 | (define (list-relatives relatives) |
| 186 | (for-each (compose (lambda (path) | 190 | (for-each (compose (lambda (path) |
| 187 | (for-each (cut simple-format #t "~a~%" <>) | 191 | (for-each (cut simple-format #t "~a~%" <>) |
| @@ -192,6 +196,7 @@ Invoke the garbage collector.\n")) | |||
| 192 | 196 | ||
| 193 | (case (assoc-ref opts 'action) | 197 | (case (assoc-ref opts 'action) |
| 194 | ((collect-garbage) | 198 | ((collect-garbage) |
| 199 | (assert-no-extra-arguments) | ||
| 195 | (let ((min-freed (assoc-ref opts 'min-freed))) | 200 | (let ((min-freed (assoc-ref opts 'min-freed))) |
| 196 | (if min-freed | 201 | (if min-freed |
| 197 | (collect-garbage store min-freed) | 202 | (collect-garbage store min-freed) |
| @@ -205,8 +210,10 @@ Invoke the garbage collector.\n")) | |||
| 205 | ((list-referrers) | 210 | ((list-referrers) |
| 206 | (list-relatives referrers)) | 211 | (list-relatives referrers)) |
| 207 | ((optimize) | 212 | ((optimize) |
| 213 | (assert-no-extra-arguments) | ||
| 208 | (optimize-store store)) | 214 | (optimize-store store)) |
| 209 | ((verify) | 215 | ((verify) |
| 216 | (assert-no-extra-arguments) | ||
| 210 | (let ((options (assoc-ref opts 'verify-options))) | 217 | (let ((options (assoc-ref opts 'verify-options))) |
| 211 | (exit | 218 | (exit |
| 212 | (verify-store store | 219 | (verify-store store |
diff --git a/tests/guix-gc.sh b/tests/guix-gc.sh index c1eb66cef53..a100f186f51 100644 --- a/tests/guix-gc.sh +++ b/tests/guix-gc.sh | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | # GNU Guix --- Functional package management for GNU | 1 | # GNU Guix --- Functional package management for GNU |
| 2 | # Copyright © 2013 Ludovic Courtès <ludo@gnu.org> | 2 | # Copyright © 2013, 2015 Ludovic Courtès <ludo@gnu.org> |
| 3 | # | 3 | # |
| 4 | # This file is part of GNU Guix. | 4 | # This file is part of GNU Guix. |
| 5 | # | 5 | # |
| @@ -25,6 +25,12 @@ guix gc --version | |||
| 25 | trap "rm -f guix-gc-root" EXIT | 25 | trap "rm -f guix-gc-root" EXIT |
| 26 | rm -f guix-gc-root | 26 | rm -f guix-gc-root |
| 27 | 27 | ||
| 28 | # For some operations, passing extra arguments is an error. | ||
| 29 | for option in "" "-C 500M" "--verify" "--optimize" | ||
| 30 | do | ||
| 31 | if guix gc $option whatever; then false; else true; fi | ||
| 32 | done | ||
| 33 | |||
| 28 | # Check the references of a .drv. | 34 | # Check the references of a .drv. |
| 29 | drv="`guix build guile-bootstrap -d`" | 35 | drv="`guix build guile-bootstrap -d`" |
| 30 | out="`guix build guile-bootstrap`" | 36 | out="`guix build guile-bootstrap`" |
