[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#19219: Package names with digits following dashes
From: |
Mathieu Lirzin |
Subject: |
bug#19219: Package names with digits following dashes |
Date: |
Mon, 21 Dec 2015 19:27:23 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux) |
address@hidden (Ludovic Courtès) writes:
> Mathieu Lirzin <address@hidden> skribis:
>
>> I had the same issue when trying to create a package named
>> 'rxvt-unicode-256-color'. I have tried to fix
>> ‘package-name->name+version’ 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’s 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
>From 19d37ea3843d236a3e32127a724a712dba3c58db Mon Sep 17 00:00:00 2001
From: Mathieu Lirzin <address@hidden>
Date: Mon, 7 Dec 2015 05:20:08 +0100
Subject: [PATCH] utils: Improve 'package-name->name+version' version
detection.
Fixes <http://bugs.gnu.org/19219>.
* 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
- bug#19219: Package names with digits following dashes, Mathieu Lirzin, 2015/12/08
- bug#19219: Package names with digits following dashes, Ludovic Courtès, 2015/12/10
- bug#19219: Package names with digits following dashes,
Mathieu Lirzin <=
- bug#19219: Package names with digits following dashes, Ludovic Courtès, 2015/12/21
- bug#19219: Package names with digits following dashes, Mathieu Lirzin, 2015/12/22
- bug#19219: Package names with digits following dashes, Alex Kost, 2015/12/23
- bug#19219: New command-line syntax for package + version?, Ludovic Courtès, 2015/12/30
- bug#19219: New command-line syntax for package + version?, Mathieu Lirzin, 2015/12/30
- bug#19219: New command-line syntax for package + version?, Leo Famulari, 2015/12/30
- bug#19219: New command-line syntax for package + version?, Efraim Flashner, 2015/12/31
- bug#19219: New command-line syntax for package + version?, Alex Kost, 2015/12/31
- bug#19219: New command-line syntax for package + version?, Ludovic Courtès, 2015/12/31
- bug#19219: New command-line syntax for package + version?, Christopher Allan Webber, 2015/12/31