diff options
author | Ludovic Courtès <ludo@gnu.org> | 2019-01-13 15:36:49 +0100 |
---|---|---|
committer | Ludovic Courtès <ludo@gnu.org> | 2019-01-15 20:24:09 +0100 |
commit | 0ea939fb796fdd4f0d46d3534b2ec6135e0f3dc7 (patch) | |
tree | 4e2117fbad1e173ba079800d3fb00d8d64702184 /guix | |
parent | ee8099f5b688ce5f57790db4122f0b5b91a26216 (diff) | |
download | gnu-guix-0ea939fb796fdd4f0d46d3534b2ec6135e0f3dc7.tar gnu-guix-0ea939fb796fdd4f0d46d3534b2ec6135e0f3dc7.tar.gz |
guix package: '--list-available' can use data from the cache.
* gnu/packages.scm (fold-available-packages): New procedure.
* guix/scripts/package.scm (process-query): Use it instead of
'fold-packages'.
* tests/packages.scm ("fold-available-packages with/without cache"):
New test.
Diffstat (limited to 'guix')
-rw-r--r-- | guix/scripts/package.scm | 45 |
1 files changed, 25 insertions, 20 deletions
diff --git a/guix/scripts/package.scm b/guix/scripts/package.scm index e9bed0be1e..a633d2ee6d 100644 --- a/guix/scripts/package.scm +++ b/guix/scripts/package.scm @@ -736,29 +736,34 @@ processed, #f otherwise." (('list-available regexp) (let* ((regexp (and regexp (make-regexp* regexp))) - (available (fold-packages - (lambda (p r) - (let ((n (package-name p))) - (if (and (supported-package? p) - (not (package-superseded p))) - (if regexp - (if (regexp-exec regexp n) - (cons p r) - r) - (cons p r)) - r))) + (available (fold-available-packages + (lambda* (name version result + #:key outputs location + supported? superseded? + #:allow-other-keys) + (if (and supported? (not superseded?)) + (if regexp + (if (regexp-exec regexp name) + (cons `(,name ,version + ,outputs ,location) + result) + result) + (cons `(,name ,version + ,outputs ,location) + result)) + result)) '()))) (leave-on-EPIPE - (for-each (lambda (p) - (format #t "~a\t~a\t~a\t~a~%" - (package-name p) - (package-version p) - (string-join (package-outputs p) ",") - (location->string (package-location p)))) + (for-each (match-lambda + ((name version outputs location) + (format #t "~a\t~a\t~a\t~a~%" + name version + (string-join outputs ",") + (location->string location)))) (sort available - (lambda (p1 p2) - (string<? (package-name p1) - (package-name p2)))))) + (match-lambda* + (((name1 . _) (name2 . _)) + (string<? name1 name2)))))) #t)) (('search _) |