summaryrefslogtreecommitdiff
path: root/guix/import/utils.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/utils.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/utils.scm')
-rw-r--r--guix/import/utils.scm13
1 files changed, 9 insertions, 4 deletions
diff --git a/guix/import/utils.scm b/guix/import/utils.scm
index b74393e617..7de95349cd 100644
--- a/guix/import/utils.scm
+++ b/guix/import/utils.scm
@@ -263,16 +263,21 @@ package definition."
((package-inputs ...)
`((native-inputs (,'quasiquote ,package-inputs))))))
-(define* (package->definition guix-package #:optional append-version?)
+(define* (package->definition guix-package #:optional append-version?/string)
+ "If APPEND-VERSION?/STRING is #t, append the package's major+minor
+version. If APPEND-VERSION?/string is a string, append this string."
(match guix-package
((or
('package ('name name) ('version version) . rest)
('let _ ('package ('name name) ('version version) . rest)))
`(define-public ,(string->symbol
- (if append-version?
- (string-append name "-" (version-major+minor version))
- version))
+ (cond
+ ((string? append-version?/string)
+ (string-append name "-" append-version?/string))
+ ((= append-version?/string #t)
+ (string-append name "-" (version-major+minor version)))
+ ((#t) version)))
,guix-package))))
(define (build-system-modules)