From mboxrd@z Thu Jan 1 00:00:00 1970 From: Mathieu Lirzin Subject: [PATCH 04/13] utils: Use '@' for separating package names and version numbers. Date: Sun, 24 Jan 2016 21:19:22 +0100 Message-ID: <1453666771-16869-5-git-send-email-mthl@gnu.org> References: <1453666771-16869-1-git-send-email-mthl@gnu.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------2.7.0.rc3" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:46262) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aNR97-0003aB-Sp for guix-devel@gnu.org; Sun, 24 Jan 2016 15:20:29 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aNR95-0005cL-6w for guix-devel@gnu.org; Sun, 24 Jan 2016 15:20:25 -0500 In-Reply-To: <1453666771-16869-1-git-send-email-mthl@gnu.org> List-Id: "Development of GNU Guix and the GNU System distribution." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-devel-bounces+gcggd-guix-devel=m.gmane.org@gnu.org Sender: guix-devel-bounces+gcggd-guix-devel=m.gmane.org@gnu.org To: guix-devel@gnu.org This is a multi-part message in MIME format. --------------2.7.0.rc3 Content-Type: text/plain; charset=UTF-8; format=fixed Content-Transfer-Encoding: quoted-printable 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. * 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(-) --------------2.7.0.rc3 Content-Type: text/x-patch; name="0004-utils-Use-for-separating-package-names-and-version-n.patch" Content-Disposition: inline; filename="0004-utils-Use-for-separating-package-names-and-version-n.patch" Content-Transfer-Encoding: quoted-printable 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. =20 ** Package management =20 +*** New syntax for separating package names and version numbers + +Use =E2=80=98@=E2=80=99 instead of =E2=80=98-=E2=80=99 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". =20 **** Removed + - guix-info-fill-column - guix-info-insert-ENTRY-TYPE-function =20 **** 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 =20 **** 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 =20 +** Noteworthy bug fixes + +*** Numbers in package names are correctly handled (http://bugs.gnu.org/= 19219) + * Changes in 0.9.0 (since 0.8.3) =20 ** 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=C3=A8s= @* 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=C4=B1rl=C4=B1/Kammer Copyright @copyright{} 2015 Leo Famulari @@ -1244,14 +1244,14 @@ The @var{options} can be among the following: Install the specified @var{package}s. =20 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 numbe= r, +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.) =20 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\" . f= alse))" HTTP @end example =20 A specific package version may optionally be specified by following the -package name by a hyphen and a version number as in the following exampl= e: +package name by an at-sign and a version number as in the following exam= ple: =20 @example -guix import hackage mtl-2.1.3.1 +guix import hackage mtl@@2.1.3.1 @end example =20 @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 @@ =20 (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)))) =20 =0C 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))) =20 (define (name+version->full-name name version) - (string-append name "-" version)) + (string-append name "@" version)) =20 (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~%") =20 (define (specification->package spec) "Return a package matching SPEC. SPEC may be a package name, or a pac= kage -name followed by a hyphen and a version number. If the version number i= s 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 exam= ples: =20 guile - guile-2.0.9 + guile@2.0.9 guile:debug - guile-2.0.9:debug + guile@2.0.9:debug =20 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.sc= m 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 unpa= cks ;; 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 =C2=A9 2012, 2013, 2014, 2015 Ludovic Court=C3=A8s ;;; Copyright =C2=A9 2013 Andreas Enge ;;; Copyright =C2=A9 2013 Nikita Karetnikov +;;; Copyright =C2=A9 2016 Mathieu Lirzin ;;; Copyright =C2=A9 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))))) =20 (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)))) =20 (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 =C2=A9 2012, 2013, 2014, 2015 Ludovic Court=C3=A8s +;;; Copyright =C2=A9 2016 Mathieu Lirzin ;;; Copyright =C2=A9 2014, 2015 Mark H Weaver ;;; Copyright =C2=A9 2015 Eric Bavier ;;; @@ -342,9 +343,11 @@ name of its URI." package-cross-build-system-error?) =20 =20 -(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 packa= ge))) =20 (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/hackag= e.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-NAM= E -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 versi= on (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 na= me (or OUTPUT). SPEC may optionally contain a version number and an output name, as in these exam= ples: =20 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))))))) =20 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=3Dmips64el-linux-gnu --= dry-run --no-substitutes =20 # 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 =20 # 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"< "$module_dir/emacs.patch"<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"))) =20 (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.7.0.rc3--