build: cargo-build-system: Don't try to package when skipping build.

* guix/build/cargo-build-system.scm (package): If the package isn't
going to be built then use the source instead.
This commit is contained in:
Efraim Flashner 2021-11-10 19:48:12 +02:00
parent 59fffe7738
commit 1963daf94c
No known key found for this signature in database
GPG Key ID: 41AAE7DCCA3D8351

View File

@ -210,12 +210,28 @@ directory = '" port)
#t))
(define* (package #:key
source
skip-build?
install-source?
(cargo-package-flags '("--no-metadata" "--no-verify"))
#:allow-other-keys)
"Run 'cargo-package' for a given Cargo package."
(if install-source?
(apply invoke `("cargo" "package" ,@cargo-package-flags))
(if skip-build?
(begin
(install-file source "target/package")
(with-directory-excursion "target/package"
(for-each
(lambda (file)
(make-file-writable file)
;; Strip the hash and replace '.tar.gz' with '.crate'.
(rename-file file
(string-append (string-drop-right
(string-drop file 35)
(string-length ".tar.gz"))
".crate")))
(find-files "." "\\.tar\\.gz$"))))
(apply invoke `("cargo" "package" ,@cargo-package-flags)))
(format #t "Not installing cargo sources, skipping `cargo package`.~%"))
#t)