summary refs log tree commit diff
path: root/gnu/build/linux-initrd.scm
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2015-06-24 17:48:02 +0200
committerLudovic Courtès <ludo@gnu.org>2015-06-24 18:05:03 +0200
commit583323ca1d1af5462f1b45f4be50f96bc8f1e46b (patch)
tree2cbe53a763ccb5ca1dbbee8e13ad41c055e9c0cc /gnu/build/linux-initrd.scm
parente8277f90c88be9d65b948c299620fd9d6d9b28ae (diff)
downloadguix-583323ca1d1af5462f1b45f4be50f96bc8f1e46b.tar.gz
linux-initrd: Populate cpio archives in a deterministic order.
* gnu/build/linux-initrd.scm (write-cpio-archive)[files]: Use 'sort' instead
  of 'reverse'.
Diffstat (limited to 'gnu/build/linux-initrd.scm')
-rw-r--r--gnu/build/linux-initrd.scm31
1 files changed, 16 insertions, 15 deletions
diff --git a/gnu/build/linux-initrd.scm b/gnu/build/linux-initrd.scm
index 2c148836f3..815c7a0aeb 100644
--- a/gnu/build/linux-initrd.scm
+++ b/gnu/build/linux-initrd.scm
@@ -49,21 +49,22 @@ COMPRESS? is true, compress it using GZIP.  On success, return OUTPUT."
   ;; directories."
 
   (define files
-    ;; XXX: Use a deterministic order.
-    (reverse
-     (file-system-fold (const #t)                 ;enter?
-                       (lambda (file stat result) ;leaf
-                         (cons file result))
-                       (lambda (dir stat result)  ;down
-                         (if (string=? dir directory)
-                             result
-                             (cons dir result)))
-                       (lambda (file stat result)
-                         result)
-                       (const #f)                 ;skip
-                       (const #f)                 ;error
-                       '()
-                       directory)))
+    ;; Use 'sort' so that (1) the order of files is deterministic, and (2)
+    ;; directories appear before the files they contain.
+    (sort (file-system-fold (const #t)                 ;enter?
+                            (lambda (file stat result) ;leaf
+                              (cons file result))
+                            (lambda (dir stat result)  ;down
+                              (if (string=? dir directory)
+                                  result
+                                  (cons dir result)))
+                            (lambda (file stat result)
+                              result)
+                            (const #f)                 ;skip
+                            (const #f)                 ;error
+                            '()
+                            directory)
+          string<?))
 
   (call-with-output-file output
     (lambda (port)