diff options
author | Ludovic Courtès <ludo@gnu.org> | 2019-02-12 22:17:11 +0100 |
---|---|---|
committer | Ludovic Courtès <ludo@gnu.org> | 2019-02-12 23:30:16 +0100 |
commit | 739380542da7e434c581ec620edeb4348d6ece89 (patch) | |
tree | 85d7c3d1caf3ead51829016fb3787116cfbab588 /guix/inferior.scm | |
parent | 46765f82dbd541a6ab48ba84816dbcf701d8714b (diff) |
inferior: Add 'inferior-available-packages'.
* guix/inferior.scm (inferior-available-packages): New procedure.
* tests/inferior.scm ("inferior-available-packages"): New test.
Diffstat (limited to 'guix/inferior.scm')
-rw-r--r-- | guix/inferior.scm | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/guix/inferior.scm b/guix/inferior.scm index 6cfa146029..027418a98d 100644 --- a/guix/inferior.scm +++ b/guix/inferior.scm @@ -61,6 +61,7 @@ inferior-object? inferior-packages + inferior-available-packages lookup-inferior-packages inferior-package? @@ -256,6 +257,31 @@ equivalent. Return #f if the inferior could not be launched." vlist-null (inferior-packages inferior))) +(define (inferior-available-packages inferior) + "Return the list of name/version pairs corresponding to the set of packages +available in INFERIOR. + +This is faster and requires less resource-intensive than calling +'inferior-packages'." + (if (inferior-eval '(defined? 'fold-available-packages) + inferior) + (inferior-eval '(fold-available-packages + (lambda* (name version result + #:key supported? deprecated? + #:allow-other-keys) + (if (and supported? (not deprecated?)) + (acons name version result) + result)) + '()) + inferior) + + ;; As a last resort, if INFERIOR is old and lacks + ;; 'fold-available-packages', fall back to 'inferior-packages'. + (map (lambda (package) + (cons (inferior-package-name package) + (inferior-package-version package))) + (inferior-packages inferior)))) + (define* (lookup-inferior-packages inferior name #:optional version) "Return the sorted list of inferior packages matching NAME in INFERIOR, with highest version numbers first. If VERSION is true, return only packages with |