Subject: [bug#39086] [PATCH 3/5] gnu: Add unicode-cldr-common.

From: Leo Prikler <[email-masked]>
Date: Fri, 17 Jan 2020 11:41:16 +0100

Am Freitag, den 17.01.2020, 08:41 +0100 schrieb Ricardo Wurmus:
> Leo Prikler <[email-masked]> writes:
> 
> > Am Donnerstag, den 16.01.2020, 22:08 +0100 schrieb Ricardo Wurmus:
> > > Leo Prikler <[email-masked]> writes:
> > > 
> > > > * gnu/packages/ibus (unicode-cldr-commmon): New package.
> > > 
> > > This should be:
> > > 
> > >     * gnu/packages/ibus.scm (unicode-cldr-commmon): New variable.
> > > 
> > > You know, I wonder if these things really belong to ibus.scm.  I
> > > remember a TODO somewhere in the code that bemoaned the lack of
> > > versioned Unicode data files.  Perhaps we should just add a new
> > > module
> > > (gnu packages unicode) — what do you think?
> > I don't mind either way, but these packages don't fix the
> > TODO.  They
> > add yet unseen features.
> 
> That’s okay.  I just think we should start that new unicode.scm
> module
> to finally have a place for these data files.  That would be a more
> appropriate place than ibus.scm.
I agree.  Incidentally, I just coded up a ucd package to use with ibus
or other packages that need the database.  I copied some of the recipe
from the gentoo ebuild, specifically the idea to use the zipped
sources.
From 1c660d4c18aaee9046b958ce05d50c142f0767f7 Mon Sep 17 00:00:00 2001
From: Leo Prikler <[email-masked]>
Date: Fri, 17 Jan 2020 11:20:46 +0100
Subject: [PATCH 6/7] gnu: Add ucd.

* gnu/packages/unicode.scm (ucd): New variable.
---
 gnu/packages/unicode.scm | 29 +++++++++++++++++++++++++++++
 1 file changed, 29 insertions(+)

diff --git a/gnu/packages/unicode.scm b/gnu/packages/unicode.scm
index 4206d0db2e..39f2548317 100644
--- a/gnu/packages/unicode.scm
+++ b/gnu/packages/unicode.scm
@@ -22,6 +22,35 @@
   #:use-module (guix download)
   #:use-module (guix build-system trivial))
 
+(define-public ucd
+  (package
+    (name "ucd")
+    (version "12.0.0")
+    (source
+     (origin
+       (method url-fetch/zipbomb)
+       (uri (string-append "https://www.unicode.org/Public/zipped/" version
+                           "/UCD.zip"))
+       (sha256
+        (base32
+         "1ighy39cjkmqnv1797wrxjz76mv1fdw7zp5j04q55bkwxsdkvrmh"))))
+    (build-system trivial-build-system)
+    (arguments
+     `(#:modules ((guix build utils))
+       #:builder
+       (let ((out (string-append %output "/share/ucd")))
+         (use-modules (guix build utils))
+         (mkdir-p out)
+         (copy-recursively (assoc-ref %build-inputs "source") out)
+         #t)))
+    (home-page "https://www.unicode.org")
+    (synopsis "Unicode Character Database")
+    (description
+     "The Unicode Character Database (UCD) consists of a number of data files
+listing Unicode character properties and related data.  It also includes test
+data for conformance to several important Unicode algorithms.")
+    (license unicode)))
+
 (define (unicode-emoji-file name version hash)
   (origin
     (method url-fetch)
-- 
2.25.0

From 20c30687c1ae0623232bd8fc41566fe271c5c20a Mon Sep 17 00:00:00 2001
From: Leo Prikler <[email-masked]>
Date: Fri, 17 Jan 2020 11:35:24 +0100
Subject: [PATCH 7/7] gnu: Use new ucd package in ibus.

* gnu/packages/ibus.scm (ibus)[native-inputs]: Add ucd.
Remove unicode-nameslist and unicode-blocks.
(arguments)[configure-flags]: Update accordingly.
(phases)<prepare-ucd-dir>: Remove phase.
---
 gnu/packages/ibus.scm | 24 +++---------------------
 1 file changed, 3 insertions(+), 21 deletions(-)

diff --git a/gnu/packages/ibus.scm b/gnu/packages/ibus.scm
index 16dfbf4888..c0766c06bd 100644
--- a/gnu/packages/ibus.scm
+++ b/gnu/packages/ibus.scm
@@ -82,16 +82,11 @@
                                 (assoc-ref %build-inputs "unicode-cldr-common")
                                 "/share/unicode/cldr/common/annotations")
                                (string-append "--with-ucd-dir="
-                                              (getcwd) "/ucd")
+                                              (assoc-ref %build-inputs "ucd")
+                                              "/share/ucd")
                                "--enable-wayland")
        #:phases
        (modify-phases %standard-phases
-         (add-after 'unpack 'prepare-ucd-dir
-           (lambda* (#:key inputs #:allow-other-keys)
-             (mkdir-p "../ucd")
-             (symlink (assoc-ref inputs "unicode-blocks") "../ucd/Blocks.txt")
-             (symlink (assoc-ref inputs "unicode-nameslist") "../ucd/NamesList.txt")
-             #t))
          (add-after 'unpack 'patch-python-target-directories
            (lambda* (#:key outputs #:allow-other-keys)
              (let ((root (string-append (assoc-ref outputs "out")
@@ -158,22 +153,9 @@
     (native-inputs
      `(("glib" ,glib "bin") ; for glib-genmarshal
        ("gobject-introspection" ,gobject-introspection) ; for g-ir-compiler
-
+       ("ucd" ,ucd)
        ("unicode-emoji" ,unicode-emoji)
        ("unicode-cldr-common" ,unicode-cldr-common)
-       ;; XXX TODO: Move Unicode data to its own (versioned) package.
-       ("unicode-nameslist"
-        ,(origin
-           (method url-fetch)
-           (uri "https://www.unicode.org/Public/12.0.0/ucd/NamesList.txt")
-           (sha256
-            (base32 "0vsq8gx7hws8mvxy3nlglpwxw7ky57q0fs09d7w9xgb2ylk7fz61"))))
-       ("unicode-blocks"
-        ,(origin
-           (method url-fetch)
-           (uri "https://www.unicode.org/Public/12.0.0/ucd/Blocks.txt")
-           (sha256
-            (base32 "041sk54v6rjzb23b9x7yjdwzdp2wc7gvfz7ybavgg4gbh51wm8x1"))))
        ("vala" ,vala)
        ("pkg-config" ,pkg-config)))
     (native-search-paths
-- 
2.25.0