guix-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

17/373: build: cargo-build-system: Don't try to package when skipping bu


From: guix-commits
Subject: 17/373: build: cargo-build-system: Don't try to package when skipping build.
Date: Sun, 16 Apr 2023 07:10:16 -0400 (EDT)

efraim pushed a commit to branch rust-team
in repository guix.

commit cc171e190ac6f9f5ac54257b0a4151e2096b68ad
Author: Efraim Flashner <efraim@flashner.co.il>
AuthorDate: Wed Nov 10 19:48:12 2021 +0200

    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.
---
 guix/build/cargo-build-system.scm | 18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)

diff --git a/guix/build/cargo-build-system.scm 
b/guix/build/cargo-build-system.scm
index 41766228c2..5d7bfc8eb3 100644
--- a/guix/build/cargo-build-system.scm
+++ b/guix/build/cargo-build-system.scm
@@ -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)
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]