Work around behavior of old 'scandir' in Guile 2.0.5.

Problem reported by John Darrington <john@darrington.wattle.id.au>.

* guix/nar.scm (write-file): Filter out "." and ".." from the result of
  'scandir'.  Previously we did this by passing a suitable predicate.
This commit is contained in:
Mark H Weaver 2014-04-06 19:46:16 -04:00
parent 030daf7133
commit d2d8779b21
1 changed files with 13 additions and 7 deletions

View File

@ -1,5 +1,6 @@
;;; GNU Guix --- Functional package management for GNU ;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2012, 2013, 2014 Ludovic Courtès <ludo@gnu.org> ;;; Copyright © 2012, 2013, 2014 Ludovic Courtès <ludo@gnu.org>
;;; Copyright © 2014 Mark H Weaver <mhw@netris.org>
;;; ;;;
;;; This file is part of GNU Guix. ;;; This file is part of GNU Guix.
;;; ;;;
@ -177,13 +178,18 @@ sub-directories of FILE as needed."
((directory) ((directory)
(write-string "type" p) (write-string "type" p)
(write-string "directory" p) (write-string "directory" p)
(let* ((select? (negate (cut member <> '("." "..")))) (let ((entries
;; NOTE: Guile 2.0.5's 'scandir' returns all subdirectories
;; 'scandir' defaults to 'string-locale<?' to sort files, but ;; unconditionally, including "." and "..", regardless of the
;; this happens to be case-insensitive (at least in 'en_US' ;; 'select?' predicate passed to it, so we have to filter
;; locale on libc 2.18.) Conversely, we want files to be ;; those out externally.
;; sorted in a case-sensitive fashion. (filter (negate (cut member <> '("." "..")))
(entries (scandir f select? string<?))) ;; '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.
(scandir f (const #t) string<?))))
(for-each (lambda (e) (for-each (lambda (e)
(let ((f (string-append f "/" e))) (let ((f (string-append f "/" e)))
(write-string "entry" p) (write-string "entry" p)