diff options
author | Mathieu Lirzin <mthl@gnu.org> | 2016-02-28 23:11:36 +0100 |
---|---|---|
committer | Mathieu Lirzin <mthl@gnu.org> | 2016-03-02 21:41:41 +0100 |
commit | 1b846da8c372bee78851439fd9e72b2499115e5a (patch) | |
tree | 64702b006ce99e7bfd95538152218a63decf3152 /guix/utils.scm | |
parent | fad155d47ea22c7ffd042ffddd03b0a6babd3b65 (diff) | |
download | gnu-guix-1b846da8c372bee78851439fd9e72b2499115e5a.tar gnu-guix-1b846da8c372bee78851439fd9e72b2499115e5a.tar.gz |
utils: Use '@' for separating package names and version numbers.
This provides the ability to use numbers in package names.
Fixes <http://bugs.gnu.org/19219>.
* guix/utils.scm (package-name->name+version): New procedure.
* gnu/packages.scm (%find-package): Add a FALLBACK? keyword argument.
Use the previous method when no package is found.
(specification->package+output, specification->package): Adapt
documentation to new syntax.
* doc/guix.texi (Invoking guix package, Invoking guix import): Likewise.
* guix/ui.scm (package-specification->name+version+output): Likewise.
* guix/scripts/import/hackage.scm (show-help): Likewise.
* tests/guix-build.sh: Adapt to new syntax.
* tests/guix-lint.sh: Likewise.
* tests/guix-package.sh: Likewise.
* tests/ui.scm ("package-specification->name+version+output"): Likewise.
* tests/utils.scm ("package-name->name+version"): Likewise.
* NEWS: Mention new syntax.
Diffstat (limited to 'guix/utils.scm')
-rw-r--r-- | guix/utils.scm | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/guix/utils.scm b/guix/utils.scm index c61f105513..de541799fa 100644 --- a/guix/utils.scm +++ b/guix/utils.scm @@ -3,6 +3,7 @@ ;;; Copyright © 2013, 2014, 2015 Mark H Weaver <mhw@netris.org> ;;; Copyright © 2014 Eric Bavier <bavier@member.fsf.org> ;;; Copyright © 2014 Ian Denhardt <ian@zenhack.net> +;;; Copyright © 2016 Mathieu Lirzin <mthl@gnu.org> ;;; Copyright © 2015 David Thompson <davet@gnu.org> ;;; ;;; This file is part of GNU Guix. @@ -31,8 +32,7 @@ #:use-module (rnrs bytevectors) #:use-module (rnrs io ports) #:use-module ((rnrs bytevectors) #:select (bytevector-u8-set!)) - #:use-module ((guix build utils) - #:select (dump-port package-name->name+version)) + #:use-module ((guix build utils) #:select (dump-port)) #:use-module ((guix build syscalls) #:select (errno mkdtemp!)) #:use-module (ice-9 vlist) #:use-module (ice-9 format) @@ -42,7 +42,6 @@ #:use-module (ice-9 match) #:use-module (ice-9 format) #:use-module (system foreign) - #:re-export (package-name->name+version) #:export (bytevector->base16-string base16-string->bytevector @@ -66,6 +65,7 @@ gnu-triplet->nix-system %current-system %current-target-system + package-name->name+version version-compare version>? version>=? @@ -544,6 +544,15 @@ returned by `config.guess'." ;; cross-building to. (make-parameter #f)) +(define (package-name->name+version spec) + "Given SPEC, a package name like \"foo@0.9.1b\", return two values: \"foo\" +and \"0.9.1b\". When the version part is unavailable, SPEC and #f are +returned. Both parts must not contain any '@'." + (match (string-rindex spec #\@) + (#f (values spec #f)) + (idx (values (substring spec 0 idx) + (substring spec (1+ idx)))))) + (define version-compare (let ((strverscmp (let ((sym (or (dynamic-func "strverscmp" (dynamic-link)) |