build-system/gnu: Reset timestamps on build tree when source is a directory.

* guix/build/utils.scm (copy-recursively): Add #:keep-mtime? parameter
  and honor it.
* guix/build/gnu-build-system.scm (unpack): Use #:keep-mtime? #t.
* gnu/packages/admin.scm (shadow)[arguments]: Remove 'reset-timestamps'
  phase.
This commit is contained in:
Ludovic Courtès 2014-04-14 00:08:54 +02:00
parent 4eb202a3d8
commit 8d846470f2
3 changed files with 19 additions and 16 deletions

View file

@ -201,16 +201,7 @@ (define-public shadow
(delete-file (string-append bin "/groups")) (delete-file (string-append bin "/groups"))
(for-each delete-file (find-files man "^groups\\.")) (for-each delete-file (find-files man "^groups\\."))
#t)) #t))
(alist-cons-after %standard-phases))))
'unpack 'reset-timestamps
(lambda _
;; FIXME: Reset the file timestamps here, until the
;; 'unpack' phase does it for us. See
;; <https://lists.gnu.org/archive/html/guix-devel/2014-04/msg00098.html>.
(for-each (lambda (file)
(utime file 0 0 0))
(find-files "." "")))
%standard-phases)))))
(inputs (if (string-suffix? "-linux" (inputs (if (string-suffix? "-linux"
(or (%current-target-system) (or (%current-target-system)

View file

@ -97,7 +97,11 @@ (define* (unpack #:key source #:allow-other-keys)
(begin (begin
(mkdir "source") (mkdir "source")
(chdir "source") (chdir "source")
(copy-recursively source ".")
;; Preserve timestamps (set to the Epoch) on the copied tree so that
;; things work deterministically.
(copy-recursively source "."
#:keep-mtime? #t)
#t) #t)
(and (zero? (system* "tar" "xvf" source)) (and (zero? (system* "tar" "xvf" source))
(chdir (first-subdirectory "."))))) (chdir (first-subdirectory ".")))))

View file

@ -134,9 +134,12 @@ (define not-slash
(define* (copy-recursively source destination (define* (copy-recursively source destination
#:key #:key
(log (current-output-port)) (log (current-output-port))
(follow-symlinks? #f)) (follow-symlinks? #f)
keep-mtime?)
"Copy SOURCE directory to DESTINATION. Follow symlinks if FOLLOW-SYMLINKS? "Copy SOURCE directory to DESTINATION. Follow symlinks if FOLLOW-SYMLINKS?
is true; otherwise, just preserve them. Write verbose output to the LOG port." is true; otherwise, just preserve them. When KEEP-MTIME? is true, keep the
modification time of the files in SOURCE on those of DESTINATION. Write
verbose output to the LOG port."
(define strip-source (define strip-source
(let ((len (string-length source))) (let ((len (string-length source)))
(lambda (file) (lambda (file)
@ -152,10 +155,15 @@ (define strip-source
(let ((target (readlink file))) (let ((target (readlink file)))
(symlink target dest))) (symlink target dest)))
(else (else
(copy-file file dest))))) (copy-file file dest)
(when keep-mtime?
(set-file-time dest stat))))))
(lambda (dir stat result) ; down (lambda (dir stat result) ; down
(mkdir-p (string-append destination (let ((target (string-append destination
(strip-source dir)))) (strip-source dir))))
(mkdir-p target)
(when keep-mtime?
(set-file-time target stat))))
(lambda (dir stat result) ; up (lambda (dir stat result) ; up
result) result)
(const #t) ; skip (const #t) ; skip