From 583323ca1d1af5462f1b45f4be50f96bc8f1e46b Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Wed, 24 Jun 2015 17:48:02 +0200 Subject: linux-initrd: Populate cpio archives in a deterministic order. * gnu/build/linux-initrd.scm (write-cpio-archive)[files]: Use 'sort' instead of 'reverse'. --- gnu/build/linux-initrd.scm | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) (limited to 'gnu') 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 @@ (define* (write-cpio-archive output directory ;; 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