packages: Sort Scheme file lists used by 'fold-packages'.

* gnu/packages.scm (scheme-files): Call 'sort' on result.
This commit is contained in:
Ludovic Courtès 2014-12-21 12:28:10 +01:00
parent ce44657aab
commit d95523fb8b
1 changed files with 23 additions and 18 deletions

View File

@ -105,24 +105,29 @@
(append environment `((,%distro-root-directory . "gnu/packages")))))) (append environment `((,%distro-root-directory . "gnu/packages"))))))
(define* (scheme-files directory) (define* (scheme-files directory)
"Return the list of Scheme files found under DIRECTORY." "Return the list of Scheme files found under DIRECTORY, recursively. The
(file-system-fold (const #t) ; enter? returned list is sorted in alphabetical order."
(lambda (path stat result) ; leaf
(if (string-suffix? ".scm" path) ;; Sort entries so that 'fold-packages' works in a deterministic fashion
(cons path result) ;; regardless of details of the underlying file system.
result)) (sort (file-system-fold (const #t) ; enter?
(lambda (path stat result) ; down (lambda (path stat result) ; leaf
result) (if (string-suffix? ".scm" path)
(lambda (path stat result) ; up (cons path result)
result) result))
(const #f) ; skip (lambda (path stat result) ; down
(lambda (path stat errno result) result)
(warning (_ "cannot access `~a': ~a~%") (lambda (path stat result) ; up
path (strerror errno)) result)
result) (const #f) ; skip
'() (lambda (path stat errno result)
directory (warning (_ "cannot access `~a': ~a~%")
stat)) path (strerror errno))
result)
'()
directory
stat)
string<?))
(define file-name->module-name (define file-name->module-name
(let ((not-slash (char-set-complement (char-set #\/)))) (let ((not-slash (char-set-complement (char-set #\/))))