[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
195/276: build: cargo-build-system: Reset timestamps in crates.
From: |
guix-commits |
Subject: |
195/276: build: cargo-build-system: Reset timestamps in crates. |
Date: |
Wed, 18 Oct 2023 04:50:03 -0400 (EDT) |
efraim pushed a commit to branch rust-team
in repository guix.
commit fafbad0ce2dc9d94bc03b5e9e5ec8dad759ca929
Author: Efraim Flashner <efraim@flashner.co.il>
AuthorDate: Wed Oct 4 12:20:14 2023 +0300
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.
---
guix/build/cargo-build-system.scm | 27 ++++++++++++++++++++++++++-
1 file changed, 26 insertions(+), 1 deletion(-)
diff --git a/guix/build/cargo-build-system.scm
b/guix/build/cargo-build-system.scm
index 9094ea41d1..8bf6ba510b 100644
--- a/guix/build/cargo-build-system.scm
+++ b/guix/build/cargo-build-system.scm
@@ -242,7 +242,32 @@ directory = '" port)
;;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)
- 188/276: gnu: Add rust-count-instructions-0.1., (continued)
- 188/276: gnu: Add rust-count-instructions-0.1., guix-commits, 2023/10/18
- 182/276: gnu: Add rust-page-size-0.6., guix-commits, 2023/10/18
- 187/276: gnu: b3sum: Update to 1.5.0., guix-commits, 2023/10/18
- 192/276: gnu: python-orjson: Update to 3.9.7., guix-commits, 2023/10/18
- 189/276: gnu: rust-oorandom-11: Rename from rust-oorandom-11.1., guix-commits, 2023/10/18
- 193/276: gnu: python-pyopenssl: Update to 23.2.0., guix-commits, 2023/10/18
- 191/276: gnu: rust-smallvec-1: Update to 1.11.1., guix-commits, 2023/10/18
- 181/276: gnu: Add rust-memmap2-0.7., guix-commits, 2023/10/18
- 194/276: gnu: rust-simdutf8-0.1: Update to 0.1.4., guix-commits, 2023/10/18
- 197/276: gnu: rust-actix-web-codegen-0.2: Fix inputs., guix-commits, 2023/10/18
- 195/276: build: cargo-build-system: Reset timestamps in crates.,
guix-commits <=
- 200/276: gnu: rust-afl-0.12: Remove check-for-pregenerated-files phase., guix-commits, 2023/10/18
- 196/276: build: cargo-build-system: Strip enough prefix in package., guix-commits, 2023/10/18
- 203/276: gnu: rust-autocompress-0.2: Skip build., guix-commits, 2023/10/18
- 207/276: gnu: rust-ravif-0.6: Update to 0.6.6., guix-commits, 2023/10/18
- 210/276: gnu: rust-pcap-sys-0.1: Remove bundled libraries., guix-commits, 2023/10/18
- 214/276: gnu: rust-rustls-native-certs-0.4: Add missing input., guix-commits, 2023/10/18
- 218/276: build: cargo-build-system: Find more pregenerated files., guix-commits, 2023/10/18
- 219/276: gnu: rust-glutin-egl-sys-0.1: Update to 0.1.6., guix-commits, 2023/10/18
- 217/276: gnu: rust-fat-macho-0.4: Remove precompiled files., guix-commits, 2023/10/18
- 220/276: gnu: rust-mp4parse-0.12: Update to 0.12.1., guix-commits, 2023/10/18