guix package: Sort the list of generation numbers in '--list-generations'.

* guix/scripts/package.scm (generation-numbers): Sort the result.
This commit is contained in:
Ludovic Courtès 2013-09-21 22:35:14 +02:00
parent 4d497632ce
commit 99882c613c
1 changed files with 6 additions and 5 deletions

View File

@ -97,7 +97,7 @@
"-([0-9]+)"))) "-([0-9]+)")))
(define (generation-numbers profile) (define (generation-numbers profile)
"Return the list of generation numbers of PROFILE, or '(0) if no "Return the sorted list of generation numbers of PROFILE, or '(0) if no
former profiles were found." former profiles were found."
(define* (scandir name #:optional (select? (const #t)) (define* (scandir name #:optional (select? (const #t))
(entry<? (@ (ice-9 i18n) string-locale<?))) (entry<? (@ (ice-9 i18n) string-locale<?)))
@ -140,10 +140,11 @@ former profiles were found."
(() ; no profiles (() ; no profiles
'(0)) '(0))
((profiles ...) ; former profiles around ((profiles ...) ; former profiles around
(map (compose string->number (sort (map (compose string->number
(cut match:substring <> 1) (cut match:substring <> 1)
(cute regexp-exec (profile-regexp profile) <>)) (cute regexp-exec (profile-regexp profile) <>))
profiles)))) profiles)
<))))
(define (previous-generation-number profile number) (define (previous-generation-number profile number)
"Return the number of the generation before generation NUMBER of "Return the number of the generation before generation NUMBER of