diff options
author | Ludovic Courtès <ludo@gnu.org> | 2015-04-18 22:30:07 +0200 |
---|---|---|
committer | Ludovic Courtès <ludo@gnu.org> | 2015-04-18 22:57:52 +0200 |
commit | 724311a26b5205dd5721439389ab70aab4082371 (patch) | |
tree | ed008a2e9b709cb74b3973efbaace6d984b8333c /gnu/packages.scm | |
parent | e7bf0e446553d928b2adef84a70f274f242b1b88 (diff) | |
download | guix-724311a26b5205dd5721439389ab70aab4082371.tar guix-724311a26b5205dd5721439389ab70aab4082371.tar.gz |
packages: Allow package lookups with version prefixes.
* gnu/packages.scm (find-packages-by-name): Sort MATCHING according to
'version>?'. Use 'string-prefix?' instead of 'string=?' to compare
against VERSION.
* doc/guix.texi (Invoking guix package): Add example and explanation.
Diffstat (limited to 'gnu/packages.scm')
-rw-r--r-- | gnu/packages.scm | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/gnu/packages.scm b/gnu/packages.scm index 6ef0fb6de7..9eb4877be8 100644 --- a/gnu/packages.scm +++ b/gnu/packages.scm @@ -211,14 +211,18 @@ same package twice." (let ((packages (delay (fold-packages (lambda (p r) (vhash-cons (package-name p) p r)) - vlist-null)))) + vlist-null))) + (version>? (lambda (p1 p2) + (version>? (package-version p1) (package-version p2))))) (lambda* (name #:optional version) "Return the list of packages with the given NAME. If VERSION is not #f, -then only return packages whose version is equal to VERSION." - (let ((matching (vhash-fold* cons '() name (force packages)))) +then only return packages whose version is prefixed by VERSION, sorted in +decreasing version order." + (let ((matching (sort (vhash-fold* cons '() name (force packages)) + version>?))) (if version (filter (lambda (package) - (string=? (package-version package) version)) + (string-prefix? version (package-version package))) matching) matching))))) |