build-system/gnu: Make 'first-subdirectory' deterministic.
Fixes <https://bugs.gnu.org/35387>. Reported by Christopher Baines <mail@cbaines.net>. * guix/build/gnu-build-system.scm (first-subdirectory): Rewrite using 'scandir' so that the result is deterministic.
This commit is contained in:
parent
92d00ca466
commit
cfd4e4d06e
|
@ -25,6 +25,7 @@
|
||||||
#:use-module (ice-9 match)
|
#:use-module (ice-9 match)
|
||||||
#:use-module (ice-9 regex)
|
#:use-module (ice-9 regex)
|
||||||
#:use-module (ice-9 format)
|
#:use-module (ice-9 format)
|
||||||
|
#:use-module (ice-9 ftw)
|
||||||
#:use-module (srfi srfi-1)
|
#:use-module (srfi srfi-1)
|
||||||
#:use-module (srfi srfi-19)
|
#:use-module (srfi srfi-19)
|
||||||
#:use-module (srfi srfi-34)
|
#:use-module (srfi srfi-34)
|
||||||
|
@ -58,19 +59,14 @@ See https://reproducible-builds.org/specs/source-date-epoch/."
|
||||||
(setenv "SOURCE_DATE_EPOCH" "1")
|
(setenv "SOURCE_DATE_EPOCH" "1")
|
||||||
#t)
|
#t)
|
||||||
|
|
||||||
(define (first-subdirectory dir)
|
(define (first-subdirectory directory)
|
||||||
"Return the path of the first sub-directory of DIR."
|
"Return the file name of the first sub-directory of DIRECTORY."
|
||||||
(file-system-fold (lambda (path stat result)
|
(match (scandir directory
|
||||||
(string=? path dir))
|
(lambda (file)
|
||||||
(lambda (path stat result) result) ; leaf
|
(and (not (member file '("." "..")))
|
||||||
(lambda (path stat result) result) ; down
|
(file-is-directory? (string-append directory "/"
|
||||||
(lambda (path stat result) result) ; up
|
file)))))
|
||||||
(lambda (path stat result) ; skip
|
((first . _) first)))
|
||||||
(or result path))
|
|
||||||
(lambda (path stat errno result) ; error
|
|
||||||
(error "first-subdirectory" (strerror errno)))
|
|
||||||
#f
|
|
||||||
dir))
|
|
||||||
|
|
||||||
(define* (set-paths #:key target inputs native-inputs
|
(define* (set-paths #:key target inputs native-inputs
|
||||||
(search-paths '()) (native-search-paths '())
|
(search-paths '()) (native-search-paths '())
|
||||||
|
|
Loading…
Reference in New Issue