mirror of
https://git.in.rschanz.org/ryan77627/guix.git
synced 2024-11-07 07:26:13 -05:00
build: cargo-build-system: Reset timestamps in crates.
This fixes reproducibility in rust crates from the package phase, see <https://issues.guix.gnu.org/50015>. * guix/build/cargo-build-system.scm (package): After running 'cargo package' on the source unpack the tarball, reset the timestamps and repack it.
This commit is contained in:
parent
48e5110c25
commit
fafbad0ce2
1 changed files with 26 additions and 1 deletions
|
@ -242,7 +242,32 @@ (define* (package #:key
|
|||
;;error: invalid inclusion of reserved file name Cargo.toml.orig in package source
|
||||
(when (file-exists? "Cargo.toml.orig")
|
||||
(delete-file "Cargo.toml.orig"))
|
||||
(apply invoke `("cargo" "package" ,@cargo-package-flags))))
|
||||
(apply invoke `("cargo" "package" ,@cargo-package-flags))
|
||||
|
||||
;; Then unpack the crate, reset the timestamp of all contained files, and
|
||||
;; repack them. This is necessary to ensure that they are reproducible.
|
||||
(with-directory-excursion "target/package"
|
||||
(for-each
|
||||
(lambda (crate)
|
||||
(invoke "tar" "xf" crate)
|
||||
(delete-file crate)
|
||||
;; Some of the crate names have underscores, so we need to
|
||||
;; search the current directory to find the unpacked crate.
|
||||
(let ((dir
|
||||
(car (scandir "."
|
||||
(lambda (file)
|
||||
(and (not (member file '("." "..")))
|
||||
(not (string-suffix? ".crate" file))))))))
|
||||
;; XXX: copied from (gnu build install)
|
||||
(for-each (lambda (file)
|
||||
(let ((s (lstat file)))
|
||||
(unless (eq? (stat:type s) 'symlink)
|
||||
(utime file 0 0 0 0))))
|
||||
(find-files dir #:directories? #t))
|
||||
(apply invoke "tar" "czf" (string-append dir ".crate")
|
||||
(find-files dir #:directories? #t))
|
||||
(delete-file-recursively dir)))
|
||||
(find-files "." "\\.crate$")))))
|
||||
(format #t "Not installing cargo sources, skipping `cargo package`.~%"))
|
||||
#t)
|
||||
|
||||
|
|
Loading…
Reference in a new issue