GNU bug report logs - #36112
[PATCH] gnu: aspell.scm: Fix dictionaries with underscore/uppercase in name.

Previous Next

Package: guix-patches;

Reported by: Jens Mølgaard <jens <at> zete.tk>

Date: Thu, 6 Jun 2019 05:46:01 UTC

Severity: normal

Tags: patch

Done: Ludovic Courtès <ludo <at> gnu.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 36112 in the body.
You can then email your comments to 36112 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to guix-patches <at> gnu.org:
bug#36112; Package guix-patches. (Thu, 06 Jun 2019 05:46:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Jens Mølgaard <jens <at> zete.tk>:
New bug report received and forwarded. Copy sent to guix-patches <at> gnu.org. (Thu, 06 Jun 2019 05:46:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Jens Mølgaard <jens <at> zete.tk>
To: guix-patches <at> gnu.org
Subject: [PATCH] gnu: aspell.scm: Fix dictionaries with underscore/uppercase
 in name.
Date: Thu, 06 Jun 2019 17:44:46 +1200
[Message part 1 (text/plain, inline)]
Salut Guix!

Since the same string is used to generate both the package names and
source URLs of Aspell dictionaries, dictionaries pt-pt and pt-br have
been producing invalid URLs. Their upstream names are pt_PT and pt_BR.

This could be fixed by changing either the way package names or URLs are
generated. Rather than adapting URLs to special cases, it seems more
straightforward to let the dict-name string represent upstream name, and
then downcase and replace underscores to produce a package name in
accordance with the naming conventions.

This was the simplest/easiest thing I could come up with. Do let me know
if there is a smarter way!

Kind regards,
Jens M

[0001-gnu-aspell.scm-Fix-dictionaries-with-underscore-uppe.patch (text/x-patch, inline)]
From 2bc4b7b31004642fcf300fe49f7b27ebd0353774 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jens=20M=C3=B8lgaard?= <jens <at> zete.tk>
Date: Thu, 6 Jun 2019 17:06:56 +1200
Subject: [PATCH] gnu: aspell.scm: Fix dictionaries with underscore/uppercase
 in name.

---
 gnu/packages/aspell.scm | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/gnu/packages/aspell.scm b/gnu/packages/aspell.scm
index 1bbe57a4ef..19b22c11eb 100644
--- a/gnu/packages/aspell.scm
+++ b/gnu/packages/aspell.scm
@@ -32,7 +32,8 @@
   #:use-module (gnu packages)
   #:use-module (gnu packages base)
   #:use-module (gnu packages compression)
-  #:use-module (gnu packages perl))
+  #:use-module (gnu packages perl)
+  #:use-module (ice-9 regex))
 
 (define-public aspell
   (package
@@ -102,7 +103,12 @@ dictionaries, including personal ones.")
 (define* (aspell-dictionary dict-name full-name
                             #:key version sha256 (prefix "aspell6-"))
   (package
-    (name (string-append "aspell-dict-" dict-name))
+    (name (string-append
+           "aspell-dict-"
+           (regexp-substitute/global
+            ;; Downcase and replace underscore in package names 
+            ;; to follow Guix naming conventions.
+            #f "_" (string-downcase dict-name) 'pre "-" 'post)))
     (version version)
     (source (origin
               (method url-fetch)
@@ -281,7 +287,7 @@ dictionaries, including personal ones.")
                       "0w2k5l5rbqpliripgqwiqixz5ghnjf7i9ggbrc4ly4vy1ia10rmc")))
 
 (define-public aspell-dict-pt-br
-  (aspell-dictionary "pt-br" "Brazilian Portuguese"
+  (aspell-dictionary "pt_BR" "Brazilian Portuguese"
                      #:version "20090702-0"
                      #:prefix "aspell6-"
                      #:sha256
@@ -289,7 +295,7 @@ dictionaries, including personal ones.")
                       "1y09lx9zf2rnp55r16b2vgj953l3538z1vaqgflg9mdvm555bz3p")))
 
 (define-public aspell-dict-pt-pt
-  (aspell-dictionary "pt-pt" "Portuguese"
+  (aspell-dictionary "pt_PT" "Portuguese"
                      #:version "20070510-0"
                      #:prefix "aspell6-"
                      #:sha256
-- 
2.21.0

[signature.asc (application/pgp-signature, inline)]

Information forwarded to guix-patches <at> gnu.org:
bug#36112; Package guix-patches. (Thu, 06 Jun 2019 15:42:01 GMT) Full text and rfc822 format available.

Message #8 received at 36112 <at> debbugs.gnu.org (full text, mbox):

From: Ludovic Courtès <ludo <at> gnu.org>
To: Jens Mølgaard <jens <at> zete.tk>
Cc: 36112 <at> debbugs.gnu.org
Subject: Re: [bug#36112] [PATCH] gnu: aspell.scm: Fix dictionaries with
 underscore/uppercase in name.
Date: Thu, 06 Jun 2019 17:41:22 +0200
Salut !  :-)

Jens Mølgaard <jens <at> zete.tk> skribis:

> This could be fixed by changing either the way package names or URLs are
> generated. Rather than adapting URLs to special cases, it seems more
> straightforward to let the dict-name string represent upstream name, and
> then downcase and replace underscores to produce a package name in
> accordance with the naming conventions.
>
> This was the simplest/easiest thing I could come up with. Do let me know
> if there is a smarter way!

This looks like the right way to me!

> From 2bc4b7b31004642fcf300fe49f7b27ebd0353774 Mon Sep 17 00:00:00 2001
> From: =?UTF-8?q?Jens=20M=C3=B8lgaard?= <jens <at> zete.tk>
> Date: Thu, 6 Jun 2019 17:06:56 +1200
> Subject: [PATCH] gnu: aspell.scm: Fix dictionaries with underscore/uppercase
>  in name.
>
> ---
>  gnu/packages/aspell.scm | 14 ++++++++++----

Please provide a ChangeLog-style commit log.   :-)

  https://gnu.org/software/guix/manual/en/html_node/Submitting-Patches.html

> +    (name (string-append
> +           "aspell-dict-"
> +           (regexp-substitute/global
> +            ;; Downcase and replace underscore in package names 
> +            ;; to follow Guix naming conventions.
> +            #f "_" (string-downcase dict-name) 'pre "-" 'post)))

What about avoiding regexps with something like:

  (string-map (match-lambda
                (#\_ #\-)
                (chr chr))
              (string-downcase dict-name))

?

Thanks,
Ludo’.




Information forwarded to guix-patches <at> gnu.org:
bug#36112; Package guix-patches. (Fri, 07 Jun 2019 05:13:02 GMT) Full text and rfc822 format available.

Message #11 received at 36112 <at> debbugs.gnu.org (full text, mbox):

From: Jens Mølgaard <jens <at> zete.tk>
To: Ludovic Courtès <ludo <at> gnu.org>
Cc: 36112 <at> debbugs.gnu.org
Subject: Re: [bug#36112] [PATCH] gnu: aspell.scm: Fix dictionaries with
 underscore/uppercase in name.
Date: Fri, 07 Jun 2019 16:56:57 +1200
[Message part 1 (text/plain, inline)]
Thank you for the handholding, by the way... ;-)

Ludovic Courtès <ludo <at> gnu.org> writes:
> What about avoiding regexps with something like:
>
>   (string-map (match-lambda
>                 (#\_ #\-)
>                 (chr chr))
>               (string-downcase dict-name))
>
> ?

Yeah, that looks a lot nicer / more scheme-y to me as well. Was trying
to find something to use with string-map.

>
> Please provide a ChangeLog-style commit log.   :-)
>
>   https://gnu.org/software/guix/manual/en/html_node/Submitting-Patches.html
>

How is this one?

[0001-gnu-aspell.scm-Handle-dictionary-names-with-undersco.patch (text/x-patch, inline)]
From f2c43296e7e76d6343749f0fa04b0b9223710bb1 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jens=20M=C3=B8lgaard?= <jens <at> zete.tk>
Date: Thu, 6 Jun 2019 17:06:56 +1200
Subject: [PATCH] gnu: aspell.scm: Handle dictionary names with
 underscore/uppercase.

* gnu/packages/aspell.scm(aspell-dictionary)<name>:
Generate package name from upstream name.
(aspell-dict-pt-pt, aspell-dict-pt-br): Use upstream name for URL.
---
 gnu/packages/aspell.scm | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/gnu/packages/aspell.scm b/gnu/packages/aspell.scm
index 1bbe57a4ef..cbc9baeeb3 100644
--- a/gnu/packages/aspell.scm
+++ b/gnu/packages/aspell.scm
@@ -32,7 +32,8 @@
   #:use-module (gnu packages)
   #:use-module (gnu packages base)
   #:use-module (gnu packages compression)
-  #:use-module (gnu packages perl))
+  #:use-module (gnu packages perl)
+  #:use-module (ice-9 match))
 
 (define-public aspell
   (package
@@ -102,7 +103,14 @@ dictionaries, including personal ones.")
 (define* (aspell-dictionary dict-name full-name
                             #:key version sha256 (prefix "aspell6-"))
   (package
-    (name (string-append "aspell-dict-" dict-name))
+    (name (string-append
+           "aspell-dict-"
+           ;; Downcase and replace underscore in package names
+           ;; to follow Guix naming conventions.
+           (string-map (match-lambda
+                         (#\_ #\-)
+                         (chr chr))
+           (string-downcase dict-name))))
     (version version)
     (source (origin
               (method url-fetch)
@@ -281,7 +289,7 @@ dictionaries, including personal ones.")
                       "0w2k5l5rbqpliripgqwiqixz5ghnjf7i9ggbrc4ly4vy1ia10rmc")))
 
 (define-public aspell-dict-pt-br
-  (aspell-dictionary "pt-br" "Brazilian Portuguese"
+  (aspell-dictionary "pt_BR" "Brazilian Portuguese"
                      #:version "20090702-0"
                      #:prefix "aspell6-"
                      #:sha256
@@ -289,7 +297,7 @@ dictionaries, including personal ones.")
                       "1y09lx9zf2rnp55r16b2vgj953l3538z1vaqgflg9mdvm555bz3p")))
 
 (define-public aspell-dict-pt-pt
-  (aspell-dictionary "pt-pt" "Portuguese"
+  (aspell-dictionary "pt_PT" "Portuguese"
                      #:version "20070510-0"
                      #:prefix "aspell6-"
                      #:sha256
-- 
2.21.0

[signature.asc (application/pgp-signature, inline)]

Reply sent to Ludovic Courtès <ludo <at> gnu.org>:
You have taken responsibility. (Fri, 07 Jun 2019 07:33:02 GMT) Full text and rfc822 format available.

Notification sent to Jens Mølgaard <jens <at> zete.tk>:
bug acknowledged by developer. (Fri, 07 Jun 2019 07:33:02 GMT) Full text and rfc822 format available.

Message #16 received at 36112-done <at> debbugs.gnu.org (full text, mbox):

From: Ludovic Courtès <ludo <at> gnu.org>
To: Jens Mølgaard <jens <at> zete.tk>
Cc: 36112-done <at> debbugs.gnu.org
Subject: Re: [bug#36112] [PATCH] gnu: aspell.scm: Fix dictionaries with
 underscore/uppercase in name.
Date: Fri, 07 Jun 2019 09:32:22 +0200
Hi Jens,

Jens Mølgaard <jens <at> zete.tk> skribis:

> From f2c43296e7e76d6343749f0fa04b0b9223710bb1 Mon Sep 17 00:00:00 2001
> From: =?UTF-8?q?Jens=20M=C3=B8lgaard?= <jens <at> zete.tk>
> Date: Thu, 6 Jun 2019 17:06:56 +1200
> Subject: [PATCH] gnu: aspell.scm: Handle dictionary names with
>  underscore/uppercase.
>
> * gnu/packages/aspell.scm(aspell-dictionary)<name>:
> Generate package name from upstream name.
> (aspell-dict-pt-pt, aspell-dict-pt-br): Use upstream name for URL.

Applied, thanks!

Ludo’.




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Fri, 05 Jul 2019 11:24:04 GMT) Full text and rfc822 format available.

This bug report was last modified 4 years and 295 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.