unofficial mirror of guix-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Mathieu Lirzin <mthl@gnu.org>
To: guix-devel@gnu.org
Subject: [PATCH 04/13] utils: Use '@' for separating package names and version numbers.
Date: Sun, 24 Jan 2016 21:19:22 +0100	[thread overview]
Message-ID: <1453666771-16869-5-git-send-email-mthl@gnu.org> (raw)
In-Reply-To: <1453666771-16869-1-git-send-email-mthl@gnu.org>

[-- Attachment #1: Type: text/plain, Size: 1992 bytes --]


Fixes <http://bugs.gnu.org/19219>.

* guix/build/utils.scm (package-name->name+version): Use '@' for
separating package names and version numbers instead of '-'.  This
provides the ability to use numbers in package names.
* guix/packages.scm (package-full-name): Add an optional SEPARATOR
argument defaulting to "@".
* doc/guix.texi (Invoking guix package, Invoking guix import): Adapt to
the new syntax.
* guix/ui.scm (package-specification->name+version+output): Likewise.
* guix/scripts/import/hackage.scm (show-help): Likewise.
* gnu/packages.scm (check-package-freshness, specification->package)
(specification->package+output): Likewise.
* emacs/guix-base.scm (guix-package-name-specification): Likewise.
* emacs/guix-main.scm (full-name->name+version)
(name+version->full-name): Likewise.
* tests/guix-build.sh: Likewise.
* tests/guix-lint.sh: Likewise.
* tests/guix-package.sh: Likewise.
* tests/packages.scm: Likewise.
* tests/ui.scm: Likewise.
* tests/utils.scm: Likewise.
* tests/graph.scm ("bag-emerged DAG"): Use 'package-full-name' optional
SEPARATOR argument.
* gnu/packages/commencement.scm (gcc-boot0): Likewise.
* NEWS: Mention new syntax.
---
 NEWS                            | 13 +++++++++++++
 doc/guix.texi                   | 12 ++++++------
 emacs/guix-base.el              |  2 +-
 emacs/guix-main.scm             |  4 ++--
 gnu/packages.scm                | 10 +++++-----
 gnu/packages/commencement.scm   |  2 +-
 guix/build/utils.scm            | 25 +++++++------------------
 guix/packages.scm               |  9 ++++++---
 guix/scripts/import/hackage.scm |  2 +-
 guix/ui.scm                     |  4 ++--
 tests/graph.scm                 |  2 +-
 tests/guix-build.sh             |  4 ++--
 tests/guix-lint.sh              |  2 +-
 tests/guix-package.sh           |  4 ++--
 tests/ui.scm                    |  6 +++---
 tests/utils.scm                 |  4 ++--
 16 files changed, 55 insertions(+), 50 deletions(-)


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0004-utils-Use-for-separating-package-names-and-version-n.patch --]
[-- Type: text/x-patch; name="0004-utils-Use-for-separating-package-names-and-version-n.patch", Size: 15128 bytes --]

diff --git a/NEWS b/NEWS
index 0084394..ed45ab4 100644
--- a/NEWS
+++ b/NEWS
@@ -14,17 +14,25 @@ Please send Guix bug reports to bug-guix@gnu.org.
 
 ** Package management
 
+*** New syntax for separating package names and version numbers
+
+Use ‘@’ instead of ‘-’ as a separator.  This new separator is a reserved
+character which is not allowed both in package names and version numbers.
+
 *** Emacs interface for system generations
 *** Emacs interface for hydra.gnu.org
 *** Changes in Emacs interface variables
+
 In the following names, BUFFER-TYPE means "info" or "list";
 ENTRY-TYPE means "package", "output" or "generation".
 
 **** Removed
+
 - guix-info-fill-column
 - guix-info-insert-ENTRY-TYPE-function
 
 **** Renamed
+
 - guix-info-ignore-empty-vals -> guix-info-ignore-empty-values
 - guix-output-name-width -> guix-generation-output-name-width
 - guix-buffer-name-function -> guix-ui-buffer-name-function
@@ -32,6 +40,7 @@ ENTRY-TYPE means "package", "output" or "generation".
 - guix-search-params -> guix-package-search-params
 
 **** Replaced
+
 - guix-list-column-format, guix-list-column-value-methods ->
   guix-ENTRY-TYPE-list-format
 - guix-info-displayed-params, guix-info-insert-methods,
@@ -42,6 +51,10 @@ ENTRY-TYPE means "package", "output" or "generation".
   guix-ENTRY-TYPE-list-describe-warning-count
 - guix-package-info-fill-heading -> guix-info-fill
 
+** Noteworthy bug fixes
+
+*** Numbers in package names are correctly handled (http://bugs.gnu.org/19219)
+
 * Changes in 0.9.0 (since 0.8.3)
 
 ** Package management
diff --git a/doc/guix.texi b/doc/guix.texi
index 4ce6ef5..1173d94 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -13,7 +13,7 @@
 Copyright @copyright{} 2012, 2013, 2014, 2015, 2016 Ludovic Courtès@*
 Copyright @copyright{} 2013, 2014 Andreas Enge@*
 Copyright @copyright{} 2013 Nikita Karetnikov@*
-Copyright @copyright{} 2015 Mathieu Lirzin@*
+Copyright @copyright{} 2015, 2016 Mathieu Lirzin@*
 Copyright @copyright{} 2014 Pierre-Antoine Rault@*
 Copyright @copyright{} 2015 Taylan Ulrich Bayırlı/Kammer
 Copyright @copyright{} 2015 Leo Famulari
@@ -1244,14 +1244,14 @@ The @var{options} can be among the following:
 Install the specified @var{package}s.
 
 Each @var{package} may specify either a simple package name, such as
-@code{guile}, or a package name followed by a hyphen and version number,
-such as @code{guile-1.8.8} or simply @code{guile-1.8} (in the latter
+@code{guile}, or a package name followed by an at-sign and version number,
+such as @code{guile@@1.8.8} or simply @code{guile@@1.8} (in the latter
 case, the newest version prefixed by @code{1.8} is selected.)
 
 If no version number is specified, the
 newest available version will be selected.  In addition, @var{package}
 may contain a colon, followed by the name of one of the outputs of the
-package, as in @code{gcc:doc} or @code{binutils-2.22:lib}
+package, as in @code{gcc:doc} or @code{binutils@@2.22:lib}
 (@pxref{Packages with Multiple Outputs}).  Packages with a corresponding
 name (and optionally version) are searched for among the GNU
 distribution modules (@pxref{Package Modules}).
@@ -4390,10 +4390,10 @@ guix import hackage -t -e "'((\"network-uri\" . false))" HTTP
 @end example
 
 A specific package version may optionally be specified by following the
-package name by a hyphen and a version number as in the following example:
+package name by an at-sign and a version number as in the following example:
 
 @example
-guix import hackage mtl-2.1.3.1
+guix import hackage mtl@@2.1.3.1
 @end example
 
 @item elpa
diff --git a/emacs/guix-base.el b/emacs/guix-base.el
index d720a87..6f13c0f 100644
--- a/emacs/guix-base.el
+++ b/emacs/guix-base.el
@@ -43,7 +43,7 @@
 
 (defun guix-package-name-specification (name version &optional output)
   "Return Guix package specification by its NAME, VERSION and OUTPUT."
-  (concat name "-" version
+  (concat name "@" version
           (when output (concat ":" output))))
 
 \f
diff --git a/emacs/guix-main.scm b/emacs/guix-main.scm
index 236c882..ffb873e 100644
--- a/emacs/guix-main.scm
+++ b/emacs/guix-main.scm
@@ -86,13 +86,13 @@
 (define (full-name->name+version spec)
   "Given package specification SPEC with or without output,
 return two values: name and version.  For example, for SPEC
-\"foo-0.9.1b:lib\", return \"foo\" and \"0.9.1b\"."
+\"foo@0.9.1b:lib\", return \"foo\" and \"0.9.1b\"."
   (let-values (((name version output)
                 (package-specification->name+version+output spec)))
     (values name version)))
 
 (define (name+version->full-name name version)
-  (string-append name "-" version))
+  (string-append name "@" version))
 
 (define* (make-package-specification name #:optional version output)
   (let ((full-name (if version
diff --git a/gnu/packages.scm b/gnu/packages.scm
index b309a78..3a32442 100644
--- a/gnu/packages.scm
+++ b/gnu/packages.scm
@@ -327,7 +327,7 @@ it."
                           (_ "looking for the latest release of GNU ~a...") name)
             ((? upstream-source? source)
              (let ((latest-version
-                    (string-append (upstream-source-package source) "-"
+                    (string-append (upstream-source-package source) "@"
                                    (upstream-source-version source))))
               (when (version>? latest-version full-name)
                 (format (current-error-port)
@@ -345,8 +345,8 @@ but ~a is available upstream~%")
 
 (define (specification->package spec)
   "Return a package matching SPEC.  SPEC may be a package name, or a package
-name followed by a hyphen and a version number.  If the version number is not
-present, return the preferred newest version."
+name followed by an at-sign and a version number.  If the version number is
+not present, return the preferred newest version."
   (let-values (((name version)
                 (package-name->name+version spec)))
     (match (find-best-packages-by-name name version)
@@ -369,9 +369,9 @@ present, return the preferred newest version."
 optionally contain a version number and an output name, as in these examples:
 
   guile
-  guile-2.0.9
+  guile@2.0.9
   guile:debug
-  guile-2.0.9:debug
+  guile@2.0.9:debug
 
 If SPEC does not specify a version number, return the preferred newest
 version; if SPEC does not specify an output, return OUTPUT."
diff --git a/gnu/packages/commencement.scm b/gnu/packages/commencement.scm
index 73b27a2..f2a43fa 100644
--- a/gnu/packages/commencement.scm
+++ b/gnu/packages/commencement.scm
@@ -227,7 +227,7 @@
                             ;; Drop trailing letters, as gmp-6.0.0a unpacks
                             ;; into gmp-6.0.0.
                             `(symlink ,(string-trim-right
-                                        (package-full-name lib)
+                                        (package-full-name lib "-")
                                         char-set:letter)
                                       ,(package-name lib)))
                           (list gmp mpfr mpc))))
diff --git a/guix/build/utils.scm b/guix/build/utils.scm
index e3f9edc..e899e77 100644
--- a/guix/build/utils.scm
+++ b/guix/build/utils.scm
@@ -2,6 +2,7 @@
 ;;; Copyright © 2012, 2013, 2014, 2015 Ludovic Courtès <ludo@gnu.org>
 ;;; Copyright © 2013 Andreas Enge <andreas@enge.fr>
 ;;; Copyright © 2013 Nikita Karetnikov <nikita@karetnikov.org>
+;;; Copyright © 2016 Mathieu Lirzin <mthl@gnu.org>
 ;;; Copyright © 2015 Mark H Weaver <mhw@netris.org>
 ;;;
 ;;; This file is part of GNU Guix.
@@ -100,25 +101,13 @@ is typically a \"PACKAGE-VERSION\" string."
                (+ 34 (string-length (%store-directory)))))
 
 (define (package-name->name+version name)
-  "Given NAME, a package name like \"foo-0.9.1b\", return two values:
-\"foo\" and \"0.9.1b\".  When the version part is unavailable, NAME and
-#f are returned.  The first hyphen followed by a digit is considered to
-introduce the version part."
+  "Given NAME, a package name like \"foo@0.9.1b\", return two values: \"foo\"
+and \"0.9.1b\".  When the version part is unavailable, NAME and #f are
+returned.  Both parts must not contain any '@'."
   ;; See also `DrvName' in Nix.
-
-  (define number?
-    (cut char-set-contains? char-set:digit <>))
-
-  (let loop ((chars   (string->list name))
-             (prefix '()))
-    (match chars
-      (()
-       (values name #f))
-      ((#\- (? number? n) rest ...)
-       (values (list->string (reverse prefix))
-               (list->string (cons n rest))))
-      ((head tail ...)
-       (loop tail (cons head prefix))))))
+  (match (string-split name #\@)
+    ((name version) (values name version))
+    (_              (values name #f))))
 
 (define parallel-job-count
   ;; Number of processes to be passed next to GNU Make's `-j' argument.
diff --git a/guix/packages.scm b/guix/packages.scm
index 41f3e20..c43b36f 100644
--- a/guix/packages.scm
+++ b/guix/packages.scm
@@ -1,5 +1,6 @@
 ;;; GNU Guix --- Functional package management for GNU
 ;;; Copyright © 2012, 2013, 2014, 2015 Ludovic Courtès <ludo@gnu.org>
+;;; Copyright © 2016 Mathieu Lirzin <mthl@gnu.org>
 ;;; Copyright © 2014, 2015 Mark H Weaver <mhw@netris.org>
 ;;; Copyright © 2015 Eric Bavier <bavier@member.fsf.org>
 ;;;
@@ -342,9 +343,11 @@ name of its URI."
   package-cross-build-system-error?)
 
 
-(define (package-full-name package)
-  "Return the full name of PACKAGE--i.e., `NAME-VERSION'."
-  (string-append (package-name package) "-" (package-version package)))
+(define* (package-full-name package #:optional (separator "@"))
+  "Return a string which is the concatenation of PACKAGE name, SEPARATOR, and
+PACKAGE version.  SEPARATOR is a optional argument defaulting to \"@\".
+PACKAGE must be a <package> record."
+  (string-append (package-name package) separator (package-version package)))
 
 (define (%standard-patch-inputs)
   (let* ((canonical (module-ref (resolve-interface '(gnu packages base))
diff --git a/guix/scripts/import/hackage.scm b/guix/scripts/import/hackage.scm
index 4e84278..f2c2002 100644
--- a/guix/scripts/import/hackage.scm
+++ b/guix/scripts/import/hackage.scm
@@ -46,7 +46,7 @@
 (define (show-help)
   (display (_ "Usage: guix import hackage PACKAGE-NAME
 Import and convert the Hackage package for PACKAGE-NAME.  If PACKAGE-NAME
-includes a suffix constituted by a dash followed by a numerical version (as
+includes a suffix constituted by a at-sign followed by a numerical version (as
 used with Guix packages), then a definition for the specified version of the
 package will be generated.  If no version suffix is pecified, then the
 generated package definition will correspond to the latest available
diff --git a/guix/ui.scm b/guix/ui.scm
index 6fd16bb..3778851 100644
--- a/guix/ui.scm
+++ b/guix/ui.scm
@@ -1079,9 +1079,9 @@ package name, version number (or #f), and output name (or OUTPUT).  SPEC may
 optionally contain a version number and an output name, as in these examples:
 
   guile
-  guile-2.0.9
+  guile@2.0.9
   guile:debug
-  guile-2.0.9:debug
+  guile@2.0.9:debug
 "
   (let*-values (((name sub-drv)
                  (match (string-rindex spec #\:)
diff --git a/tests/graph.scm b/tests/graph.scm
index 4f85432..dd5ebcf 100644
--- a/tests/graph.scm
+++ b/tests/graph.scm
@@ -113,7 +113,7 @@ edges."
                      (map (lambda (destination)
                             (list "p-0.drv"
                                   (string-append
-                                   (package-full-name destination)
+                                   (package-full-name destination "-")
                                    ".drv")))
                           implicit)))))))
 
diff --git a/tests/guix-build.sh b/tests/guix-build.sh
index f7fb3c5..82900ad 100644
--- a/tests/guix-build.sh
+++ b/tests/guix-build.sh
@@ -149,8 +149,8 @@ guix build coreutils --target=mips64el-linux-gnu --dry-run --no-substitutes
 
 # Parsing package names and versions.
 guix build -n time		# PASS
-guix build -n time-1.7		# PASS, version found
-if guix build -n time-3.2;	# FAIL, version not found
+guix build -n time@1.7		# PASS, version found
+if guix build -n time@3.2;	# FAIL, version not found
 then false; else true; fi
 if guix build -n something-that-will-never-exist; # FAIL
 then false; else true; fi
diff --git a/tests/guix-lint.sh b/tests/guix-lint.sh
index 5015b5c..c105521 100644
--- a/tests/guix-lint.sh
+++ b/tests/guix-lint.sh
@@ -75,4 +75,4 @@ if guix lint -c synopsis,invalid-checker dummy 2>&1 | \
 then true; else false; fi
 
 # Make sure specifying multiple packages works.
-guix lint -c inputs-should-be-native dummy dummy-42 dummy
+guix lint -c inputs-should-be-native dummy dummy@42 dummy
diff --git a/tests/guix-package.sh b/tests/guix-package.sh
index cf1a185..273a011 100644
--- a/tests/guix-package.sh
+++ b/tests/guix-package.sh
@@ -207,13 +207,13 @@ cat > "$module_dir/foo.scm"<<EOF
 EOF
 
 guix package -A emacs-foo-bar -L "$module_dir" | grep 42
-guix package -i emacs-foo-bar-42 -n -L "$module_dir"
+guix package -i emacs-foo-bar@42 -n -L "$module_dir"
 
 # Same thing using the 'GUIX_PACKAGE_PATH' environment variable.
 GUIX_PACKAGE_PATH="$module_dir"
 export GUIX_PACKAGE_PATH
 guix package -A emacs-foo-bar | grep 42
-guix package -i emacs-foo-bar-42 -n
+guix package -i emacs-foo-bar@42 -n
 
 # Make sure patches that live under $GUIX_PACKAGE_PATH are found.
 cat > "$module_dir/emacs.patch"<<EOF
diff --git a/tests/ui.scm b/tests/ui.scm
index bd4c907..f28e623 100644
--- a/tests/ui.scm
+++ b/tests/ui.scm
@@ -108,10 +108,10 @@ Second line" 24))
                (package-specification->name+version+output spec))
            list))
        '("guile"
-         "guile-2.0.9"
+         "guile@2.0.9"
          "guile:debug"
-         "guile-2.0.9:debug"
-         "guile-cairo-1.4.1")))
+         "guile@2.0.9:debug"
+         "guile-cairo@1.4.1")))
 
 (test-equal "integer"
   '(1)
diff --git a/tests/utils.scm b/tests/utils.scm
index a05faab..ac622ee 100644
--- a/tests/utils.scm
+++ b/tests/utils.scm
@@ -59,14 +59,14 @@
           ((name version)
            (let*-values (((full-name)
                           (if version
-                              (string-append name "-" version)
+                              (string-append name "@" version)
                               name))
                          ((name* version*)
                           (package-name->name+version full-name)))
              (and (equal? name* name)
                   (equal? version* version)))))
          '(("foo" "0.9.1b")
-           ("foo-bar" "1.0")
+           ("foo-14-bar" "320")
            ("foo-bar2" #f)
            ("guile" "2.0.6.65-134c9") ; as produced by `git-version-gen'
            ("nixpkgs" "1.0pre22125_a28fe19")

  parent reply	other threads:[~2016-01-24 20:20 UTC|newest]

Thread overview: 65+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-24 20:19 [PATCH 00/13] New syntax 'package@version' and compilation improvements Mathieu Lirzin
2016-01-24 20:19 ` [PATCH 01/13] tests: Use 'dummy-origin' for lint tests when possible Mathieu Lirzin
2016-01-26 15:58   ` Ludovic Courtès
2016-01-24 20:19 ` [PATCH 02/13] lint: Remove an unneeded clause in 'check-patch-file-names' Mathieu Lirzin
2016-01-26 16:00   ` Ludovic Courtès
2016-01-24 20:19 ` [PATCH 03/13] lint: Rewrite 'check-patch-file-names' Mathieu Lirzin
2016-01-26 16:01   ` Ludovic Courtès
2016-01-24 20:19 ` Mathieu Lirzin [this message]
2016-01-25 11:37   ` [PATCH 04/13] utils: Use '@' for separating package names and version numbers Alex Kost
2016-01-25 20:56     ` Mathieu Lirzin
2016-01-26 16:22       ` Ludovic Courtès
2016-01-26 20:52         ` Mathieu Lirzin
2016-01-26 21:08           ` Ludovic Courtès
2016-02-19 20:49         ` Mathieu Lirzin
2016-02-23 11:11           ` Ludovic Courtès
2016-02-29  0:28             ` Mathieu Lirzin
2016-02-29 16:00               ` Ludovic Courtès
2016-03-02 21:35                 ` Mathieu Lirzin
2016-03-05  1:28                 ` Nils Gillmann
2016-03-05  9:24                   ` Alex Kost
2016-03-05  9:36                   ` Mathieu Lirzin
2016-03-03 10:29               ` Alex Kost
2016-03-03 16:55                 ` Ludovic Courtès
2016-03-04 10:19                   ` Alex Kost
2016-03-04 23:03                 ` Mathieu Lirzin
2016-03-04 23:25                   ` Ludovic Courtès
2016-03-05  1:08                     ` Mathieu Lirzin
2016-03-05  9:16                   ` Alex Kost
2016-01-25 14:04   ` Thompson, David
2016-01-25 21:41     ` Mathieu Lirzin
2016-01-25 23:33       ` Alex Kost
2016-01-26 17:57         ` Mathieu Lirzin
2016-01-24 20:19 ` [PATCH 05/13] packages: Use '@' in package record printers Mathieu Lirzin
2016-01-26 16:22   ` Ludovic Courtès
2016-01-24 20:19 ` [PATCH 06/13] build: Generate man pages after compiling guile objects Mathieu Lirzin
2016-01-26 16:52   ` Ludovic Courtès
2016-01-26 20:08     ` Mathieu Lirzin
2016-01-28  2:37       ` Eric Bavier
2016-01-28 15:44         ` Mathieu Lirzin
2016-01-28 15:59           ` Eric Bavier
2016-01-28 17:00             ` Mathieu Lirzin
2016-01-29  0:27               ` Eric Bavier
2016-01-29 16:17                 ` Mathieu Lirzin
2016-01-29 16:46                   ` Eric Bavier
2016-01-29 22:56                     ` Mathieu Lirzin
2016-01-31  9:17                       ` Ludovic Courtès
2016-01-24 20:19 ` [PATCH 07/13] build: Add 'DL' silent rule Mathieu Lirzin
2016-01-26 16:28   ` Ludovic Courtès
2016-01-26 17:44     ` Mathieu Lirzin
2016-01-26 19:22       ` Taylan Ulrich Bayırlı/Kammer
2016-01-26 21:06       ` Ludovic Courtès
2016-01-26 21:14         ` Mathieu Lirzin
2016-01-24 20:19 ` [PATCH 08/13] build: Add 'DOT' " Mathieu Lirzin
2016-01-26 16:28   ` Ludovic Courtès
2016-01-24 20:19 ` [PATCH 09/13] build: Add 'EMACS' " Mathieu Lirzin
2016-01-26 16:28   ` Ludovic Courtès
2016-01-24 20:19 ` [PATCH 10/13] build: Add 'HELP2MAN' " Mathieu Lirzin
2016-01-26 16:29   ` Ludovic Courtès
2016-01-24 20:19 ` [PATCH 11/13] build: Delete emacs/guix-autoloads.el when 'make clean' Mathieu Lirzin
2016-01-26 16:33   ` Ludovic Courtès
2016-01-26 22:55     ` Mathieu Lirzin
2016-01-24 20:19 ` [PATCH 12/13] build: Use 'GEN' and 'at' silent rules Mathieu Lirzin
2016-01-26 16:34   ` Ludovic Courtès
2016-01-24 20:19 ` [PATCH 13/13] Update .gitignore Mathieu Lirzin
2016-01-26 16:34   ` Ludovic Courtès

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://guix.gnu.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1453666771-16869-5-git-send-email-mthl@gnu.org \
    --to=mthl@gnu.org \
    --cc=guix-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).