diff options
author | Ludovic Courtès <ludo@gnu.org> | 2015-03-20 22:05:04 +0100 |
---|---|---|
committer | Ludovic Courtès <ludo@gnu.org> | 2015-03-20 22:07:28 +0100 |
commit | 051edc95f12d3bb55fd67c6f2a3f4478df53a08f (patch) | |
tree | 690fcaf694d7694ba2200aa8b4b198d9371cc05d | |
parent | 9eeb3d8c28589cb3398c20593c4ea41a7cfb7249 (diff) | |
download | patches-051edc95f12d3bb55fd67c6f2a3f4478df53a08f.tar patches-051edc95f12d3bb55fd67c6f2a3f4478df53a08f.tar.gz |
guix package: '-s' sorts packages by name, then by version.
Before that it would sort them by name only, so the order in which two
packages with the same name but a different version would appear was
non-deterministic.
Reported by Tomáš Čech <sleep_walker@gnu.org>.
* guix/scripts/package.scm (find-packages-by-description)[version<?]:
New variable.
Change the 2nd argument to 'sort' to use 'string-compare' and resort
to 'version<?' when P1 and P2 have the same name.
-rw-r--r-- | guix/scripts/package.scm | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/guix/scripts/package.scm b/guix/scripts/package.scm index 41db191e70..3cc7ae760f 100644 --- a/guix/scripts/package.scm +++ b/guix/scripts/package.scm @@ -240,6 +240,8 @@ DURATION-RELATION with the current time." (define (find-packages-by-description rx) "Return the list of packages whose name, synopsis, or description matches RX." + (define version<? (negate version>=?)) + (sort (fold-packages (lambda (package result) (define matches? @@ -254,8 +256,11 @@ RX." result)) '()) (lambda (p1 p2) - (string<? (package-name p1) - (package-name p2))))) + (case (string-compare (package-name p1) (package-name p2) + (const '<) (const '=) (const '>)) + ((=) (version<? (package-version p1) (package-version p2))) + ((<) #t) + (else #f))))) (define-syntax-rule (leave-on-EPIPE exp ...) "Run EXP... in a context when EPIPE errors are caught and lead to 'exit' |