GNU bug report logs -
#19219
Package names with digits following dashes
Previous Next
Reported by: Andreas Enge <andreas <at> enge.fr>
Date: Sat, 29 Nov 2014 20:32:02 UTC
Severity: normal
Tags: fixed, patch
Done: Mathieu Lirzin <mthl <at> gnu.org>
Bug is archived. No further changes may be made.
Full log
View this message in rfc822 format
[Message part 1 (text/plain, inline)]
ludo <at> gnu.org (Ludovic Courtès) writes:
> Mathieu Lirzin <mthl <at> gnu.org> 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
[0001-utils-Improve-package-name-name-version-version-dete.patch (text/x-diff, inline)]
From 19d37ea3843d236a3e32127a724a712dba3c58db Mon Sep 17 00:00:00 2001
From: Mathieu Lirzin <mthl <at> gnu.org>
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
This bug report was last modified 9 years and 80 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.