Subject: [bug#76750] [PATCH 1/2] gnu: icu4c: Extract uri into a separate procedure.

From: Tomas Volf <[email-masked]>
Date: Tue, 4 Mar 2025 23:08:18 +0100

* gnu/packages/icu4c.scm (icu4?-uri, icu4c-uri, icu4j-uri): New procedures.
(icu4c, icu4c-73, icu4c-75, icu4c-70, icu4c-69)[source]: Use icu4c-uri.
(java-icu4j)[source]: Use icu4j-uri.

Change-Id: Iad114631de530e32e4691bc88421d70f015f31d0
---
 gnu/packages/icu4c.scm | 56 +++++++++++++++---------------------------
 1 file changed, 20 insertions(+), 36 deletions(-)

diff --git a/gnu/packages/icu4c.scm b/gnu/packages/icu4c.scm
index 0ca917305d..fadea0bbdb 100644
--- a/gnu/packages/icu4c.scm
+++ b/gnu/packages/icu4c.scm
@@ -43,18 +43,27 @@ (define-module (gnu packages icu4c)
   #:use-module (guix build-system ant)
   #:use-module (guix build-system gnu))
 
+(define (icu4?-uri variant version)
+  (string-append
+   "https://github.com/unicode-org/icu/releases/download/release-"
+   (string-map (lambda (x) (if (char=? x #\.) #\- x)) version)
+   "/icu4" variant "-"
+   (string-map (lambda (x) (if (char=? x #\.) #\_ x)) version)
+   "-src.tgz"))
+
+(define (icu4c-uri version)
+  (icu4?-uri "c" version))
+
+(define (icu4j-uri version)
+  (icu4?-uri "j" version))
+
 (define-public icu4c
   (package
     (name "icu4c")
     (version "71.1")
     (source (origin
               (method url-fetch)
-              (uri (string-append
-                    "https://github.com/unicode-org/icu/releases/download/release-"
-                    (string-map (lambda (x) (if (char=? x #\.) #\- x)) version)
-                    "/icu4c-"
-                    (string-map (lambda (x) (if (char=? x #\.) #\_ x)) version)
-                    "-src.tgz"))
+              (uri (icu4c-uri version))
               (sha256
                (base32 "1gqywaqj9jmdwrng9lm6inyqmi5j2cz36db9dcqg3yk13zjyd9v7"))))
     (build-system gnu-build-system)
@@ -117,12 +126,7 @@ (define-public icu4c-73
     (version "73.1")
     (source (origin
               (method url-fetch)
-              (uri (string-append
-                    "https://github.com/unicode-org/icu/releases/download/release-"
-                    (string-map (lambda (x) (if (char=? x #\.) #\- x)) version)
-                    "/icu4c-"
-                    (string-map (lambda (x) (if (char=? x #\.) #\_ x)) version)
-                    "-src.tgz"))
+              (uri (icu4c-uri version))
               (sha256
                (base32
                 "0iccpdvc0kvpww5a31k9gjkqigyz016i7v80r9zamd34w4fl6mx4"))
@@ -140,12 +144,7 @@ (define-public icu4c-75
     (version "75.1")
     (source (origin
               (method url-fetch)
-              (uri (string-append
-                    "https://github.com/unicode-org/icu/releases/download/release-"
-                    (string-map (lambda (x) (if (char=? x #\.) #\- x)) version)
-                    "/icu4c-"
-                    (string-map (lambda (x) (if (char=? x #\.) #\_ x)) version)
-                    "-src.tgz"))
+              (uri (icu4c-uri version))
               (sha256
                (base32
                 "1vya31v549pq89kgr02jajwi7gc7qw0mv6n4265pxs6jwkrqv5nb"))))))
@@ -156,12 +155,7 @@ (define-public icu4c-70
     (version "70.1")
     (source (origin
               (method url-fetch)
-              (uri (string-append
-                    "https://github.com/unicode-org/icu/releases/download/release-"
-                    (string-map (lambda (x) (if (char=? x #\.) #\- x)) version)
-                    "/icu4c-"
-                    (string-map (lambda (x) (if (char=? x #\.) #\_ x)) version)
-                    "-src.tgz"))
+              (uri (icu4c-uri version))
               (sha256
                (base32
                 "1m9zgkaf5lyh65nyc6n0n5bs2f5k53nnj1ih6nskpwbvq4l5884d"))))
@@ -186,12 +180,7 @@ (define-public icu4c-69
     (version "69.1")
     (source (origin
               (method url-fetch)
-              (uri (string-append
-                    "https://github.com/unicode-org/icu/releases/download/release-"
-                    (string-map (lambda (x) (if (char=? x #\.) #\- x)) version)
-                    "/icu4c-"
-                    (string-map (lambda (x) (if (char=? x #\.) #\_ x)) version)
-                    "-src.tgz"))
+              (uri (icu4c-uri version))
               (sha256
                (base32
                 "0icps0avkwy5df3wwc5kybxcg63hcgk4phdh9g244g0xrmx7pfjc"))))))
@@ -219,12 +208,7 @@ (define-public java-icu4j
     (version "70.1")
     (source (origin
               (method url-fetch)
-              (uri (string-append
-                    "https://github.com/unicode-org/icu/releases/download/release-"
-                    (string-map (lambda (x) (if (char=? x #\.) #\- x)) version)
-                    "/icu4j-"
-                    (string-map (lambda (x) (if (char=? x #\.) #\_ x)) version)
-                    ".tgz"))
+              (uri (icu4j-uri version))
               (sha256
                (base32 "0qrs75iyzn19kf54q55jn8wf6xjlpkrihdwqpxm39jdh2hz4cgvj"))))
     (build-system ant-build-system)
-- 
2.48.1