From 42ed3aa37a9bc6db86bd809adf6b6ffdb4ac2c44 Mon Sep 17 00:00:00 2001 From: Danny Milosavljevic Date: Fri, 6 Mar 2026 22:01:43 +0100 Subject: [PATCH] build-system/cargo: Work around "cargo package" weirdness. * guix/build/cargo-build-system.scm (package): Modify. Closes: guix/guix#6825 Change-Id: I0ab97662e52d53ca1558c40bd9c1cbd28eae0197 --- guix/build/cargo-build-system.scm | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/guix/build/cargo-build-system.scm b/guix/build/cargo-build-system.scm index 92d01783d1..323c71a8a5 100644 --- a/guix/build/cargo-build-system.scm +++ b/guix/build/cargo-build-system.scm @@ -390,10 +390,20 @@ directory = '" vendor-dir "'") port) (for-each (lambda (crate) (invoke "tar" "xzf" crate "-C" vendor-dir)) - (find-files "target/package" "\\.crate$")) + (map (lambda (f) (string-append "target/package/" f)) + (scandir "target/package" + (lambda (f) (string-suffix? ".crate" f))))) (patch-cargo-checksums #:vendor-dir vendor-dir)) cargo-package-crates)) + ;; Cargo creates target/package/tmp-crate/ as scratch space during + ;; packaging and leaves .crate file copies there after uplifting them + ;; to target/package/. Delete it so the repacking scandir does not + ;; pick the tmp-crate directory instead of the extracted crate + ;; directory when crate names sort after "tmp-crate" alphabetically. + (when (file-exists? "target/package/tmp-crate") + (delete-file-recursively "target/package/tmp-crate")) + ;; 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"