From 1b846da8c372bee78851439fd9e72b2499115e5a Mon Sep 17 00:00:00 2001 From: Mathieu Lirzin Date: Sun, 28 Feb 2016 23:11:36 +0100 Subject: utils: Use '@' for separating package names and version numbers. This provides the ability to use numbers in package names. Fixes . * 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. --- guix/utils.scm | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'guix/utils.scm') 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 ;;; Copyright © 2014 Eric Bavier ;;; Copyright © 2014 Ian Denhardt +;;; Copyright © 2016 Mathieu Lirzin ;;; Copyright © 2015 David Thompson ;;; ;;; This file is part of GNU Guix. @@ -31,8 +32,7 @@ (define-module (guix utils) #: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 @@ (define-module (guix utils) #: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 @@ (define-module (guix utils) gnu-triplet->nix-system %current-system %current-target-system + package-name->name+version version-compare version>? version>=? @@ -544,6 +544,15 @@ (define %current-target-system ;; 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)) -- cgit v1.2.3