From: Mathieu Lirzin <mthl@gnu.org>
To: "Ludovic Courtès" <ludo@gnu.org>
Cc: 19219@debbugs.gnu.org
Subject: bug#19219: Package names with digits following dashes
Date: Mon, 21 Dec 2015 19:27:23 +0100 [thread overview]
Message-ID: <87h9jblks4.fsf@gnu.org> (raw)
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")
[-- Attachment #1: Type: text/plain, Size: 710 bytes --]
ludo@gnu.org (Ludovic Courtès) writes:
> Mathieu Lirzin <mthl@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
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-utils-Improve-package-name-name-version-version-dete.patch --]
[-- Type: text/x-diff, Size: 3110 bytes --]
From 19d37ea3843d236a3e32127a724a712dba3c58db Mon Sep 17 00:00:00 2001
From: Mathieu Lirzin <mthl@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
next prev parent reply other threads:[~2015-12-21 18:28 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-11-29 20:31 bug#19219: Package names with digits following dashes Andreas Enge
2014-12-06 23:38 ` Ludovic Courtès
2015-12-08 18:42 ` Mathieu Lirzin
2015-12-10 13:36 ` Ludovic Courtès
2015-12-21 18:27 ` Mathieu Lirzin [this message]
2015-12-21 21:46 ` Ludovic Courtès
2015-12-22 21:23 ` Mathieu Lirzin
2015-12-23 8:05 ` Alex Kost
2015-12-30 14:07 ` bug#19219: New command-line syntax for package + version? Ludovic Courtès
2015-12-30 22:45 ` Mathieu Lirzin
2015-12-31 1:16 ` Leo Famulari
2015-12-31 8:09 ` Efraim Flashner
2016-01-01 15:55 ` Ludovic Courtès
2016-01-01 21:25 ` Leo Famulari
2016-01-01 21:45 ` Leo Famulari
2016-01-02 3:18 ` carl hansen
2015-12-31 8:19 ` Alex Kost
2015-12-31 11:27 ` Ludovic Courtès
2015-12-31 16:26 ` Christopher Allan Webber
2016-01-01 20:36 ` Andreas Enge
2016-01-09 3:04 ` Mathieu Lirzin
2016-01-18 8:10 ` Ludovic Courtès
2016-01-18 8:31 ` Mathieu Lirzin
2016-03-02 21:10 ` Mathieu Lirzin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87h9jblks4.fsf@gnu.org \
--to=mthl@gnu.org \
--cc=19219@debbugs.gnu.org \
--cc=ludo@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/guix.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.