~ruther/guix-local

051edc95f12d3bb55fd67c6f2a3f4478df53a08f — Ludovic Courtès 11 years ago 9eeb3d8
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.
1 files changed, 7 insertions(+), 2 deletions(-)

M guix/scripts/package.scm
M guix/scripts/package.scm => guix/scripts/package.scm +7 -2
@@ 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'