nar: Produce archives with files sorted in C collation order.

* guix/nar.scm (write-file) <directory>: Pass 'string<?' as the second
  argument to 'scandir'.
* tests/nar.scm ("write-file puts file in C locale collation order"):
  New test.
This commit is contained in:
Ludovic Courtès 2014-02-21 20:17:29 +01:00
parent 36bbbbd150
commit 96c7448f37
2 changed files with 33 additions and 3 deletions

View file

@ -177,8 +177,13 @@ sub-directories of FILE as needed."
((directory)
(write-string "type" p)
(write-string "directory" p)
(let ((entries (remove (cut member <> '("." ".."))
(scandir f))))
(let* ((select? (negate (cut member <> '("." ".."))))
;; 'scandir' defaults to 'string-locale<?' to sort files, but
;; this happens to be case-insensitive (at least in 'en_US'
;; locale on libc 2.18.) Conversely, we want files to be
;; sorted in a case-sensitive fashion.
(entries (scandir f select? string<?)))
(for-each (lambda (e)
(let ((f (string-append f "/" e)))
(write-string "entry" p)