>From 7fef43249b704db3c4d511b2f1b62428740cfa73 Mon Sep 17 00:00:00 2001 From: Mathieu Lirzin Date: Sun, 24 Jan 2016 01:54:44 +0100 Subject: [PATCH] utils: Use '@' for separating package names and version numbers. Fixes . * 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. * emacs/guix-ui-package.el (guix-packages-by-name): Likewise. * tests/guix-build.sh: Likewise. * 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. * 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 ++-- emacs/guix-ui-package.el | 3 +-- 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 ++-- 17 files changed, 56 insertions(+), 52 deletions(-) diff --git a/NEWS b/NEWS index 0084394..ed45ab4 100644 --- a/NEWS +++ b/NEWS @@ -14,17 +14,25 @@ Please send Guix bug reports to address@hidden ** Package management +*** New syntax for separating package names and version numbers + +Use address@hidden 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 a650a55..73dc5be 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -13,7 +13,7 @@ Copyright @copyright{} 2012, 2013, 2014, 2015, 2016 Ludovic address@hidden Copyright @copyright{} 2013, 2014 Andreas address@hidden Copyright @copyright{} 2013 Nikita address@hidden -Copyright @copyright{} 2015 Mathieu address@hidden +Copyright @copyright{} 2015, 2016 Mathieu address@hidden Copyright @copyright{} 2014 Pierre-Antoine address@hidden 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 address@hidden, 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 address@hidden, 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)))) 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\"." +\"address@hidden: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/emacs/guix-ui-package.el b/emacs/guix-ui-package.el index 2951452..80877c5 100644 --- a/emacs/guix-ui-package.el +++ b/emacs/guix-ui-package.el @@ -915,7 +915,7 @@ See `guix-package-info-type'." (defun guix-packages-by-name (name &optional profile) "Display Guix packages with NAME. NAME is a string with name specification. It may optionally contain -a version number. Examples: \"guile\", \"guile-2.0.11\". +a version number. Examples: \"guile\", \"address@hidden". If PROFILE is nil, use `guix-current-profile'. Interactively with prefix, prompt for PROFILE." @@ -923,7 +923,6 @@ Interactively with prefix, prompt for PROFILE." (list (guix-read-package-name) (guix-ui-read-profile))) (guix-package-get-display profile 'name name)) - ;;;###autoload (defun guix-search-by-regexp (regexp &optional params profile) "Search for Guix packages by REGEXP. 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 + address@hidden guile:debug - guile-2.0.9:debug + address@hidden: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 ;;; Copyright © 2013 Andreas Enge ;;; Copyright © 2013 Nikita Karetnikov +;;; Copyright © 2016 Mathieu Lirzin ;;; Copyright © 2015 Mark H Weaver ;;; ;;; 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 \"address@hidden", 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 +;;; Copyright © 2016 Mathieu Lirzin ;;; Copyright © 2014, 2015 Mark H Weaver ;;; Copyright © 2015 Eric Bavier ;;; @@ -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 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 + address@hidden guile:debug - guile-2.0.9:debug + address@hidden: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 address@hidden # PASS, version found +if guix build -n address@hidden; # 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 address@hidden 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"< "$module_dir/emacs.patch"<name+version+output spec)) list)) '("guile" - "guile-2.0.9" + "address@hidden" "guile:debug" - "guile-2.0.9:debug" - "guile-cairo-1.4.1"))) + "address@hidden:debug" + "address@hidden"))) (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") -- 2.6.3