[PATCH] gnu: aspell.scm: Fix dictionaries with underscore/uppercase in name.

  • Done
  • quality assurance status badge
Details
2 participants
  • Jens Mølgaard
  • Ludovic Courtès
Owner
unassigned
Submitted by
Jens Mølgaard
Severity
normal
J
J
Jens Mølgaard wrote on 6 Jun 2019 07:44
(address . guix-patches@gnu.org)
871s07jmi9.fsf@zete.tk
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
From 2bc4b7b31004642fcf300fe49f7b27ebd0353774 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jens=20M=C3=B8lgaard?= <jens@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(-)

Toggle diff (48 lines)
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
-----BEGIN PGP SIGNATURE-----

iQIzBAEBCAAdFiEE/VzWzPUn4Rzyui0RiZ866GcCScAFAlz4qE4ACgkQiZ866GcC
ScC61w/+IX+zRPBrUAmKl18l3MtbL4ZEKfI534H2xQBMcLzFSAVlJZRrdvejzLJH
NgG1EE3jPX8TushD4t2pd1dvo2vfUV+PoMaCKdAMZP1yRaXOTzGc5iuc3KwLtUxF
g6W6wZfEMFHrUmgsQ7bKW4mfJowGz2dP/NVrj06UmHiCxtj9+NEJdDcwZ5Yn2RY0
i3ZokR7eVz0ZfGu+FPwkadOkKnGnT9WNzUXsNLLD8fmxIjowm9HWXzBND5xjnJHt
lgZnf0OH4vuzsr1lA0roXL5+IrHSdQtzLbqGPfJ47lRs+oJXq76lA0AAAnX6h+Ww
V7rJoSFEH/viinA0tmNbNiFNN9oPeAyNPJsWWz9FpCqLyxGNj6rGnChNlAEemFF1
PBPtCN9UQYHTKJsB3g+evQPJHk0nCfN0I2qUkSLi+Om36RYdhBWGY52gmUMaWef+
/7zP6PbcFWNSKvRrqLknfR8ZvgKewrXkHZoU5bA+6yVRtCyvaQi8TOR/Lk3wGyS0
2T6ZZ6iArS9pxm+sD0vzfEHGFNlVyXVed59PkyaFPTQ0mNmt3ckTcBmqA0TyCGMK
v447pOIec833XTTflKUVbMID9346YdREgeOL8V1MHOLttRl3t7vHqOGCiLpaGZV0
Jw7SkVgJJZLpkmiSa1aSpNV+jG0LbdtI43AN1ajrTLM0sJyQg1Y=
=p2Ie
-----END PGP SIGNATURE-----

L
L
Ludovic Courtès wrote on 6 Jun 2019 17:41
(name . Jens Mølgaard)(address . jens@zete.tk)(address . 36112@debbugs.gnu.org)
87tvd2lo0t.fsf@gnu.org
Salut ! :-)

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

Toggle quote (9 lines)
> 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!

Toggle quote (9 lines)
> From 2bc4b7b31004642fcf300fe49f7b27ebd0353774 Mon Sep 17 00:00:00 2001
> From: =?UTF-8?q?Jens=20M=C3=B8lgaard?= <jens@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. :-)


Toggle quote (7 lines)
> + (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’.
J
J
Jens Mølgaard wrote on 7 Jun 2019 06:56
(name . Ludovic Courtès)(address . ludo@gnu.org)(address . 36112@debbugs.gnu.org)
87r286ngbq.fsf@zete.tk
Thank you for the handholding, by the way... ;-)

Ludovic Courtès <ludo@gnu.org> writes:
Toggle quote (9 lines)
> 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.

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

How is this one?
From f2c43296e7e76d6343749f0fa04b0b9223710bb1 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jens=20M=C3=B8lgaard?= <jens@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(-)

Toggle diff (50 lines)
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
-----BEGIN PGP SIGNATURE-----

iQIzBAEBCAAdFiEE/VzWzPUn4Rzyui0RiZ866GcCScAFAlz57pkACgkQiZ866GcC
ScArNRAAjPTFYu8iKIjagn04dCwaJ78wxcEuGBOMuIKJSpSO7Bpgff+Rb4HVNh/v
iFKVBMRBU8POH1yYJaurBZsHN9NRv9x3tdcQgUiXL0pRb5Hqu1QQXsgWI8WU7EBc
3G+pP5Oy7Y6X090QQ4wF+kawn1Lan0bOxA3vbPVNuLvmo+B0AIk72qgKtpCVlldL
GV2C+0FpzCkp7EyVV2GJNyWg569LQRTg5uuTo3+HxY9ZU1YACpJyqDxg+rO8w7iX
D3WTKyL1ub3p3jLKOY31CS/UD7lDH7XdkhbmGIcyZAwUb4m7rb8jztD0ihtrKzmE
Xi7J2/rM1O4Gmcxw7YX8pzL6StXvV8lfjTfcDHvuwvf+ufKuAft0TuJcCNnaSLo6
VXH2Qu9MuBeWTa2X7D+tkG9lyo44MWisrooDZ3r8tEawjJ4XuonIPqmOo6Yyszbm
OOjFLb/n2yHImoClzp2DC7eQ5P5nR/G6oawVG1oN2q1WCHYVuuBzhgilpiWjllAh
Y56lcYDx5BAfmgvZ1ZkdLLyZf7ZuoFvSAdYQiVdfkf0TRmHq+x8WYQMLpPkn92xR
IyQyrTlt+CBapewNSofamV5+BpnyAz/sNIQ1jokTKdJlkAHTMcKID9Q5pVpZ5phu
eBxyIcQyh28Jk6yk53YSKEzVz5hrhwn4yEZsD9tIjDpkrqQNxWI=
=sbsa
-----END PGP SIGNATURE-----

L
L
Ludovic Courtès wrote on 7 Jun 2019 09:32
(name . Jens Mølgaard)(address . jens@zete.tk)(address . 36112-done@debbugs.gnu.org)
871s05kfzt.fsf@gnu.org
Hi Jens,

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

Toggle quote (10 lines)
> From f2c43296e7e76d6343749f0fa04b0b9223710bb1 Mon Sep 17 00:00:00 2001
> From: =?UTF-8?q?Jens=20M=C3=B8lgaard?= <jens@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’.
Closed
?