From 66018f1c338375796a8a2d5130bae5cdb9a48b5f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ludovic=20Court=C3=A8s?= <ludo@gnu.org>
Date: Sun, 15 Sep 2013 23:20:16 +0200
Subject: [PATCH] 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'.
---
 guix/build/utils.scm  | 39 +++++++++++++++++++++------------------
 guix/scripts/pull.scm |  4 +---
 2 files changed, 22 insertions(+), 21 deletions(-)

diff --git a/guix/build/utils.scm b/guix/build/utils.scm
index 06e88b1ff8e..8cc9c1ee1f8 100644
--- a/guix/build/utils.scm
+++ b/guix/build/utils.scm
@@ -185,29 +185,32 @@ (define (delete-file-recursively dir)
                     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<?))
 
 
 ;;;
diff --git a/guix/scripts/pull.scm b/guix/scripts/pull.scm
index f3d87a63c06..adcaa49721b 100644
--- a/guix/scripts/pull.scm
+++ b/guix/scripts/pull.scm
@@ -116,9 +116,7 @@ (define builder
                    ;; 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"))
-- 
GitLab