summaryrefslogtreecommitdiff
path: root/guix/import/crate.scm
diff options
context:
space:
mode:
authorHartmut Goebel <h.goebel@crazy-compilers.com>2020-11-14 21:31:33 +0100
committerHartmut Goebel <h.goebel@crazy-compilers.com>2020-12-02 22:09:23 +0100
commit45584061a9ebe961e2be08ee94c3fe8ad74e2713 (patch)
treea92671f40ed4ff909d5cb3c576c16846eb2b45ca /guix/import/crate.scm
parent9a48e35be853e10ba9b21bb91ef52a66b4264c84 (diff)
downloadguix-patches-45584061a9ebe961e2be08ee94c3fe8ad74e2713.tar
guix-patches-45584061a9ebe961e2be08ee94c3fe8ad74e2713.tar.gz
import: crate: Trim version for names after left-most non-zero part.
This complies to how versions are matched for caret requirements in crates: An update is allowed if the new version number does not modify the left-most non-zero digit in the major, minor, patch grouping. * guix/import/crate.scm (version->semver-prefix): New function. (make-crate-sexp)[format-inputs]: Use it. (make-crate-sexp): Use it to pass shorter version to package->definition. * guix/import/utils.scm (package->definition): Change optional parameter APPEND-VERSION? into APPEND-VERSION?/STRING. If it is a string, append its value to name. * tests/crate.scm: Adjust tests accordingly.
Diffstat (limited to 'guix/import/crate.scm')
-rw-r--r--guix/import/crate.scm10
1 files changed, 8 insertions, 2 deletions
diff --git a/guix/import/crate.scm b/guix/import/crate.scm
index 20efa131d5..b133529ba7 100644
--- a/guix/import/crate.scm
+++ b/guix/import/crate.scm
@@ -150,6 +150,12 @@ record or #f if it was not found."
((args ...)
`((arguments (,'quasiquote ,args))))))
+(define (version->semver-prefix version)
+ "Return the version up to and including the first non-zero part"
+ (first
+ (map match:substring
+ (list-matches "^(0+\\.){,2}[0-9]+" version))))
+
(define* (make-crate-sexp #:key name version cargo-inputs cargo-development-inputs
home-page synopsis description license build?)
"Return the `package' s-expression for a rust package with the given NAME,
@@ -160,7 +166,7 @@ and LICENSE."
(match-lambda
((name version)
(list (crate-name->package-name name)
- (version-major+minor version))))
+ (version->semver-prefix version))))
inputs))
(let* ((port (http-fetch (crate-uri name version)))
@@ -194,7 +200,7 @@ and LICENSE."
((license) license)
(_ `(list ,@license)))))))
(close-port port)
- (package->definition pkg #t)))
+ (package->definition pkg (version->semver-prefix version))))
(define (string->license string)
(filter-map (lambda (license)