utils: 'find-files' returns a sorted list.

* guix/build/utils.scm (find-files): Sort the result lexicographically.
* guix/scripts/pull.scm (unpack): Don't sort the result of 'find-files'.
master
Ludovic Courtès 2013-09-15 23:20:16 +02:00
parent 8ce3104e0e
commit 66018f1c33
2 changed files with 22 additions and 21 deletions

View File

@ -185,29 +185,32 @@ but ignore errors."
lstat))
(define (find-files dir regexp)
"Return the list of files under DIR whose basename matches REGEXP."
"Return the lexicographically sorted list of files under DIR whose basename
matches REGEXP."
(define file-rx
(if (regexp? regexp)
regexp
(make-regexp regexp)))
(file-system-fold (const #t)
(lambda (file stat result) ; leaf
(if (regexp-exec file-rx (basename file))
(cons file result)
result))
(lambda (dir stat result) ; down
result)
(lambda (dir stat result) ; up
result)
(lambda (file stat result) ; skip
result)
(lambda (file stat errno result)
(format (current-error-port) "find-files: ~a: ~a~%"
file (strerror errno))
#f)
'()
dir))
;; Sort the result to get deterministic results.
(sort (file-system-fold (const #t)
(lambda (file stat result) ; leaf
(if (regexp-exec file-rx (basename file))
(cons file result)
result))
(lambda (dir stat result) ; down
result)
(lambda (dir stat result) ; up
result)
(lambda (file stat result) ; skip
result)
(lambda (file stat errno result)
(format (current-error-port) "find-files: ~a: ~a~%"
file (strerror errno))
#f)
'()
dir)
string<?))
;;;

View File

@ -116,9 +116,7 @@ files."
;; download), we must build it first to avoid errors since
;; (gnutls) is unavailable.
(cons (string-append out "/guix/build/download.scm")
;; Sort the file names to get deterministic results.
(sort (find-files out "\\.scm") string<?)))
(find-files out "\\.scm")))
;; Remove the "fake" (guix config).
(delete-file (string-append out "/guix/config.scm"))