aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark H Weaver <mhw@netris.org>2014-04-06 19:46:16 -0400
committerMark H Weaver <mhw@netris.org>2014-04-07 04:20:30 -0400
commitd2d8779b2175b48dca7005a4b9de45cf84e0826a (patch)
tree8f4b3dcfc7408335bfd31828d2b19ae90ce096b8
parent030daf7133ce16a87b0a06e310c6e143911df668 (diff)
downloadguix-d2d8779b2175b48dca7005a4b9de45cf84e0826a.tar
guix-d2d8779b2175b48dca7005a4b9de45cf84e0826a.tar.gz
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.
-rw-r--r--guix/nar.scm20
1 files changed, 13 insertions, 7 deletions
diff --git a/guix/nar.scm b/guix/nar.scm
index b6421434e9..5b602df90b 100644
--- a/guix/nar.scm
+++ b/guix/nar.scm
@@ -1,5 +1,6 @@
;;; GNU Guix --- Functional package management for GNU
;;; 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.
;;;
@@ -177,13 +178,18 @@ sub-directories of FILE as needed."
((directory)
(write-string "type" p)
(write-string "directory" p)
- (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<?)))
+ (let ((entries
+ ;; NOTE: Guile 2.0.5's 'scandir' returns all subdirectories
+ ;; unconditionally, including "." and "..", regardless of the
+ ;; 'select?' predicate passed to it, so we have to filter
+ ;; those out externally.
+ (filter (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.
+ (scandir f (const #t) string<?))))
(for-each (lambda (e)
(let ((f (string-append f "/" e)))
(write-string "entry" p)