From 9ba78f3ccfe92d409a7126133d32e977e6fcd52b Mon Sep 17 00:00:00 2001 From: Hilton Chain Date: Mon, 3 Mar 2025 23:47:10 +0800 Subject: [PATCH] build/cargo: Don't vendor self. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * guix/build/cargo-build-system.scm (crate-src?, configure): Exclude self. * gnu/packages/gnome.scm (librsvg)[#:phases]: Remove ‘dont-vendor-self’. * gnu/packages/python-crypto.scm (python-cryptography)[#:arguments]: Likewise. * gnu/packages/python-xyz.scm (python-libcst)[#:arguments]: Likewise. * gnu/packages/syndication.scm (newsboat)[#:arguments]: Likewise. * gnu/packages/antivirus.scm (clamav)[#:arguments]: Likewise. Change-Id: I5e01721fb705937f5fcf858c21b6d7e27ade6c10 --- gnu/packages/antivirus.scm | 5 +--- gnu/packages/gnome.scm | 5 ---- gnu/packages/python-crypto.scm | 5 ---- gnu/packages/python-xyz.scm | 5 ---- gnu/packages/syndication.scm | 5 ---- guix/build/cargo-build-system.scm | 43 ++++++++++++++++--------------- 6 files changed, 23 insertions(+), 45 deletions(-) diff --git a/gnu/packages/antivirus.scm b/gnu/packages/antivirus.scm index 4a01115abd920fb0758aa5a96b4966dd6d9c1e81..d2060fa3852af572e148f399c59c59cf88816690 100644 --- a/gnu/packages/antivirus.scm +++ b/gnu/packages/antivirus.scm @@ -116,10 +116,7 @@ (add-after 'configure 'fix-cargo-inputs-vendoring (lambda _ ;; Reproduce the original layout, fails with config. - (rename-file ".cargo/config" ".cargo/config.toml") - ;; Wrongly placed by configure - (delete-file-recursively - (string-append ".cargo/vendor/clamav-" #$version ".tar.zst")))) + (rename-file ".cargo/config" ".cargo/config.toml"))) (add-after 'patch-cargo-checksums 'cmake-configure (lambda* (#:key outputs #:allow-other-keys) ((assoc-ref cmake:%standard-phases 'configure) diff --git a/gnu/packages/gnome.scm b/gnu/packages/gnome.scm index 97ad6e9d69924cd92aa825611eb34a8f0439ced0..e760e4bcc81e4783b7aa28f7fcd70650998866ec 100644 --- a/gnu/packages/gnome.scm +++ b/gnu/packages/gnome.scm @@ -3807,11 +3807,6 @@ for dealing with different structured file formats.") "--host=" #$(%current-target-system))) #~("--enable-vala"))) args))) - (add-after 'configure 'dont-vendor-self - (lambda* (#:key vendor-dir #:allow-other-keys) - ;; Don't keep the whole tarball in the vendor directory - (delete-file-recursively - (string-append vendor-dir "/" #$name "-" #$version ".tar.xz")))) (replace 'build (assoc-ref gnu:%standard-phases 'build)) (replace 'check diff --git a/gnu/packages/python-crypto.scm b/gnu/packages/python-crypto.scm index 8887da9e002da9425f4ecf7a19ebea27d2c0dc2a..8f413b45e1a12852cd57600016b7c277e36972bd 100644 --- a/gnu/packages/python-crypto.scm +++ b/gnu/packages/python-crypto.scm @@ -561,11 +561,6 @@ is used by the Requests library to verify HTTPS requests.") #:install-source? #false #:phases #~(modify-phases %standard-phases - (add-after 'configure 'dont-vendor-self - (lambda* (#:key vendor-dir #:allow-other-keys) - ;; Don't keep the whole tarball in the vendor directory - (delete-file-recursively - (string-append vendor-dir "/cryptography-" #$version ".tar.zst")))) (replace 'build (assoc-ref py:%standard-phases 'build)) (delete 'check) diff --git a/gnu/packages/python-xyz.scm b/gnu/packages/python-xyz.scm index 2ab52e82c22e012344d251d5bc67246daa502400..09ee9389736f102df9873ff269716555459ea17c 100644 --- a/gnu/packages/python-xyz.scm +++ b/gnu/packages/python-xyz.scm @@ -23742,11 +23742,6 @@ members = [ (add-after 'unpack 'prepare-source (lambda _ (delete-file "native/Cargo.lock"))) - (add-after 'configure 'dont-vendor-self - (lambda* (#:key vendor-dir #:allow-other-keys) - ;; Don't keep the whole tarball in the vendor directory - (delete-file-recursively - (string-append vendor-dir "/libcst-" #$version ".tar.zst")))) (replace 'build (assoc-ref py:%standard-phases 'build)) (add-after 'install 'wrap diff --git a/gnu/packages/syndication.scm b/gnu/packages/syndication.scm index 30a1370c6ddf05584081e989a5a204b5202dcd78..d6bb6be749480d50016569e031fb82eb8fdb5b3b 100644 --- a/gnu/packages/syndication.scm +++ b/gnu/packages/syndication.scm @@ -312,11 +312,6 @@ cards.") (("if curl-config") (string-append "if " (search-input-file inputs "/bin/curl-config")))))) - (add-after 'configure 'dont-vendor-self - (lambda* (#:key vendor-dir #:allow-other-keys) - ;; Don't keep the whole tarball in the vendor directory - (delete-file-recursively - (string-append vendor-dir "/" #$name "-" #$version ".tar.xz")))) (add-after 'unpack 'patch-source (lambda* (#:key outputs #:allow-other-keys) (substitute* "Makefile" diff --git a/guix/build/cargo-build-system.scm b/guix/build/cargo-build-system.scm index e129c1a7f1a9d68e43e27e467ca691b1203b53d0..9e0994d3606383b4958c5817b8303afb1932159c 100644 --- a/guix/build/cargo-build-system.scm +++ b/guix/build/cargo-build-system.scm @@ -71,27 +71,28 @@ root package." (call-with-input-file manifest-file get-string-all) "[package]")))) -(define (crate-src? path) +(define* (crate-src? path #:key source) "Check if PATH refers to a crate source, namely a gzipped tarball with a Cargo.toml file present at its root." - (if (directory-exists? path) - ;; The build system only handles sources containing single crate. - ;; Workspaces should be packaged into crates (via 'package phase) - ;; and used in inputs. - (cargo-package? path) - (and (not (string-suffix? "py" path)) ;sanity-check.py - ;; First we print out all file names within the tarball to see - ;; if it looks like the source of a crate. However, the tarball - ;; will include an extra path component which we would like to - ;; ignore (since we're interested in checking if a Cargo.toml - ;; exists at the root of the archive, but not nested anywhere - ;; else). We do this by cutting up each output line and only - ;; looking at the second component. We then check if it matches - ;; Cargo.toml exactly and short circuit if it does. - (invoke "sh" "-c" - (string-append "tar -tf " path - " | cut -d/ -f2" - " | grep -q '^Cargo.toml$'"))))) + (and (not (string=? path source)) ;Exclude self. + (if (directory-exists? path) + ;; The build system only handles sources containing single crate. + ;; Workspaces should be packaged into crates (via 'package phase) + ;; and used in inputs. + (cargo-package? path) + (and (not (string-suffix? "py" path)) ;sanity-check.py + ;; First we print out all file names within the tarball to see + ;; if it looks like the source of a crate. However, the tarball + ;; will include an extra path component which we would like to + ;; ignore (since we're interested in checking if a Cargo.toml + ;; exists at the root of the archive, but not nested anywhere + ;; else). We do this by cutting up each output line and only + ;; looking at the second component. We then check if it matches + ;; Cargo.toml exactly and short circuit if it does. + (invoke "sh" "-c" + (string-append "tar -tf " path + " | cut -d/ -f2" + " | grep -q '^Cargo.toml$'")))))) (define* (unpack-rust-crates #:key inputs (vendor-dir "guix-vendor") #:allow-other-keys) @@ -156,7 +157,7 @@ libraries or executables." (format #t "error: Possible pre-generated file found: ~a~%" file))) (find-files "." (negate empty-file?))))) -(define* (configure #:key inputs +(define* (configure #:key source inputs target system (cargo-target #f) (vendor-dir "guix-vendor") @@ -173,7 +174,7 @@ libraries or executables." ((name . path) (let* ((basepath (strip-store-file-name path)) (crate-dir (string-append vendor-dir "/" basepath))) - (and (crate-src? path) + (and (crate-src? path #:source source) ;; Gracefully handle duplicate inputs (not (file-exists? crate-dir)) (if (directory-exists? path)