1
0
mirror of https://git.savannah.gnu.org/git/guix.git synced 2026-05-28 20:12:11 +02:00

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.
This commit is contained in:
Ludovic Courtès
2015-04-18 22:30:07 +02:00
parent e7bf0e4465
commit 724311a26b
2 changed files with 12 additions and 5 deletions
+8 -4
View File
@@ -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)))))