diff options
author | Ludovic Courtès <ludo@gnu.org> | 2013-09-27 01:17:01 +0200 |
---|---|---|
committer | Ludovic Courtès <ludo@gnu.org> | 2013-09-27 01:23:59 +0200 |
commit | d7ddb257c9d22c794d6b26af64a57901ccee71e0 (patch) | |
tree | ecd2d88571ed6c7477163d8cfd034a1b0c2b4192 /guix | |
parent | 03f4ef28b17ef2b53eb56dbd3fa382569677490b (diff) | |
download | gnu-guix-d7ddb257c9d22c794d6b26af64a57901ccee71e0.tar gnu-guix-d7ddb257c9d22c794d6b26af64a57901ccee71e0.tar.gz |
guix package: '--delete-generations' deletes generations older than specified.
* guix/scripts/package.scm (matching-generations): Add
'duration-relation' keyword parameter.
(guix-package)[process-action](delete-generations): Pass
#:duration-relation >.
* tests/guix-package.sh: Add test.
* doc/guix.texi (Invoking guix package): Clarify the meaning of
durations for '--list-durations' and '--delete-durations'.
Diffstat (limited to 'guix')
-rw-r--r-- | guix/scripts/package.scm | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/guix/scripts/package.scm b/guix/scripts/package.scm index 35a5129d25..5c7c165cbb 100644 --- a/guix/scripts/package.scm +++ b/guix/scripts/package.scm @@ -258,9 +258,12 @@ all of PACKAGES, a list of name/version/output/path/deps tuples." (make-time time-utc 0 (stat:ctime (stat (format #f "~a-~a-link" profile number))))) -(define* (matching-generations str #:optional (profile %current-profile)) +(define* (matching-generations str #:optional (profile %current-profile) + #:key (duration-relation <=)) "Return the list of available generations matching a pattern in STR. See -'string->generations' and 'string->duration' for the list of valid patterns." +'string->generations' and 'string->duration' for the list of valid patterns. +When STR is a duration pattern, return all the generations whose ctime has +DURATION-RELATION with the current time." (define (valid-generations lst) (define (valid-generation? n) (any (cut = n <>) (generation-numbers profile))) @@ -309,7 +312,7 @@ all of PACKAGES, a list of name/version/output/path/deps tuples." (subtract-duration (time-at-midnight (current-time)) duration)))) (delete #f (map (lambda (x) - (and (<= s (cdr x)) + (and (duration-relation s (cdr x)) (first x))) generation-ctime-alist)))))) @@ -887,7 +890,11 @@ more information.~%")) ;; Do not delete the zeroth generation. ((equal? 0 (string->number pattern)) (exit 0)) - ((matching-generations pattern profile) + + ;; If PATTERN is a duration, match generations that are + ;; older than the specified duration. + ((matching-generations pattern profile + #:duration-relation >) => (lambda (numbers) (if (null-list? numbers) |