From mboxrd@z Thu Jan 1 00:00:00 1970 From: Mathieu Lirzin Subject: bug#19219: Package names with digits following dashes Date: Mon, 21 Dec 2015 19:27:23 +0100 Message-ID: <87h9jblks4.fsf@gnu.org> References: <20141129203122.GA15720@debian> <87ppbws61p.fsf@gnu.org> <874mfssrxd.fsf@gnu.org> <87si3ah1d1.fsf@gnu.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:46697) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aB5Bn-0003nI-Gd for bug-guix@gnu.org; Mon, 21 Dec 2015 13:28:08 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aB5Bi-0002ah-GD for bug-guix@gnu.org; Mon, 21 Dec 2015 13:28:07 -0500 Received: from debbugs.gnu.org ([208.118.235.43]:51497) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aB5Bi-0002ad-Cl for bug-guix@gnu.org; Mon, 21 Dec 2015 13:28:02 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84) (envelope-from ) id 1aB5Bi-0005U3-63 for bug-guix@gnu.org; Mon, 21 Dec 2015 13:28:02 -0500 Sender: "Debbugs-submit" Resent-Message-ID: In-Reply-To: <87si3ah1d1.fsf@gnu.org> ("Ludovic \=\?utf-8\?Q\?Court\=C3\=A8s\=22'\?\= \=\?utf-8\?Q\?s\?\= message of "Thu, 10 Dec 2015 14:36:26 +0100") List-Id: Bug reports for GNU Guix List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-guix-bounces+gcggb-bug-guix=m.gmane.org@gnu.org Sender: bug-guix-bounces+gcggb-bug-guix=m.gmane.org@gnu.org To: Ludovic =?UTF-8?Q?Court=C3=A8s?= Cc: 19219@debbugs.gnu.org --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable ludo@gnu.org (Ludovic Court=C3=A8s) writes: > Mathieu Lirzin skribis: > >> I had the same issue when trying to create a package named >> 'rxvt-unicode-256-color'. I have tried to fix >> =E2=80=98package-name->name+version=E2=80=99 by matching the last hyphen= and check if >> the next character is a number. > > Sounds like a reasonable approach (better than what I submitted), but we > would need test for the various corner cases. Could you augment the > test that=E2=80=99s in tests/utils.scm? The test case contains the example "guile-2.0.6.65-134c9" which invalidates my proposal. Here is another idea which identifies the version part by the presence of dots. WDYT? -- Mathieu Lirzin --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=0001-utils-Improve-package-name-name-version-version-dete.patch >From 19d37ea3843d236a3e32127a724a712dba3c58db Mon Sep 17 00:00:00 2001 From: Mathieu Lirzin Date: Mon, 7 Dec 2015 05:20:08 +0100 Subject: [PATCH] utils: Improve 'package-name->name+version' version detection. Fixes . * guix/build/utils.scm (package-name->name+version): Use a more generic heuristic to detect version. Usage of digits in names is now possible. * tests/utils.scm ("package-name->name+version"): Add some cases. --- guix/build/utils.scm | 29 +++++++++++++++-------------- tests/utils.scm | 6 +++++- 2 files changed, 20 insertions(+), 15 deletions(-) diff --git a/guix/build/utils.scm b/guix/build/utils.scm index e3f9edc..0ace2c7 100644 --- a/guix/build/utils.scm +++ b/guix/build/utils.scm @@ -100,25 +100,26 @@ 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. The version part must contain a dot to be properly detected." ;; 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)))))) + (let ((lst (reverse (string->list name)))) + (let loop ((chars lst) (suffix '()) (retry #t) (dots #f)) + (match chars + (() + (values name #f)) + ((#\- rest ...) + (cond (dots (values (list->string (reverse rest)) + (list->string suffix))) + (retry (loop rest (cons #\- suffix) #f #f)) + (else (values name #f)))) + ((head tail ...) + (loop tail (cons head suffix) retry (or dots (char=? #\. head)))))))) (define parallel-job-count ;; Number of processes to be passed next to GNU Make's `-j' argument. diff --git a/tests/utils.scm b/tests/utils.scm index 04a859f..a7d8900 100644 --- a/tests/utils.scm +++ b/tests/utils.scm @@ -68,7 +68,11 @@ '(("foo" "0.9.1b") ("foo-bar" "1.0") ("foo-bar2" #f) - ("guile" "2.0.6.65-134c9") ; as produced by `git-version-gen' + ("emacs" "24.5") + ("font-adobe-100-dpi" #f) + ("rxvt-unicode-256-color" "9.21") + ("guile" "2.0.6.65-134c9") ;as produced by Gnulib 'git-version-gen' + ("guile" "2.1.1.75-a147") ;and with a different hash ("nixpkgs" "1.0pre22125_a28fe19") ("gtk2" "2.38.0")))) -- 2.6.3 --=-=-=--