Subject: [bug#48570] [WIP] [PATCH] Add

From: Nicolò Balzarotti <[email-masked]>
Date: Fri, 21 May 2021 18:29:09 +0200

Hi!

I created a package for tagainijisho and its dependency (kanjivg).

I marked this as WIP because I have a few doubts:
- kanjivg distributes an xml file generated by joining xml files stored
  in the repo.  I'm not sure where this xml should be installed
  (under /share/something?)
- kanjivg: guix lint fails with: updater 'github' failed to find
  upstream releases, but I don't know why
- two other xml required by tagainijisho use non-versioned urls, is
  there something we can do about this?

It's the first time I use this program but it seems to be working ok.

Thanks,
Nicolò

>From fa44401753d5c70f0e177270072b8eb70d166dd6 Mon Sep 17 00:00:00 2001
From: nixo <[email-masked]>
Date: Fri, 21 May 2021 18:15:04 +0200
Subject: [PATCH 1/2] gnu: Add kanjivg.

* gnu/packages/education.scm (kanjivg): New variable.
---
 gnu/packages/education.scm | 44 ++++++++++++++++++++++++++++++++++++++
 1 file changed, 44 insertions(+)

diff --git a/gnu/packages/education.scm b/gnu/packages/education.scm
index 0986d2a19e..043933abe0 100644
--- a/gnu/packages/education.scm
+++ b/gnu/packages/education.scm
@@ -405,6 +405,50 @@ specialized device.")
     (home-page "https://bipede.fr/contrib/")
     (license license:gpl3)))
 
+(define-public kanjivg
+  (package
+    (name "kanjivg")
+    (version "20160426")
+    (source
+     (origin
+       (method git-fetch)
+       (uri (git-reference
+             (url "https://github.com/KanjiVG/kanjivg")
+             (commit (string-append "r" version))))
+       (file-name (git-file-name name version))
+       (sha256
+        (base32 "10pkcay9zixr0nwwcm4z360w7pkcr1v91kp7889qbsfj8123mywh"))))
+    (build-system gnu-build-system)
+    (arguments
+     `(#:tests? #f                      ; no check target
+       #:phases
+       (modify-phases %standard-phases
+         (delete 'configure)
+         (replace 'build
+           (lambda _
+             (invoke "python" "kvg.py" "release")))
+         (replace 'install
+           (lambda* (#:key outputs #:allow-other-keys)
+             (let ((out (assoc-ref outputs "out"))
+                   (fname "kanjivg.xml"))
+               (mkdir-p out)
+               ;; FIXME: No idea in which path it should be copied (and if
+               ;; other files are needed)
+               (copy-file fname (string-append out "/" fname))))))))
+    (native-inputs
+     ;; Does not work with python3
+     `(("python2" ,python-2)))
+    (synopsis "Kanji description and vectorial data in correct stroke order")
+    (description "KanjiVG is a description of the sinographs (or kanji) used
+by the Japanese language.  For each character, it provides a SVG file that
+gives the shape, direction and of each of its strokes.  This file is also
+enriched with exhaustive information about the components of the character,
+the type of stroke employed, etc.
+
+Using KanjiVG, it is possible to create stroke order diagrams or animations
+and kanji dictionaries.")
+    (home-page "https://kanjivg.tagaini.net")
+    (license license:cc-by-sa3.0)))
 (define-public childsplay
   (package
     (name "childsplay")
-- 
2.31.1

>From aff1c570b2885f5c36810f5faddedd801ad55f0e Mon Sep 17 00:00:00 2001
From: nixo <[email-masked]>
Date: Fri, 21 May 2021 18:15:38 +0200
Subject: [PATCH 2/2] gnu: Add tagainijisho.

* gnu/packages/education.scm (tagainijisho): New variable.
---
 gnu/packages/education.scm | 94 ++++++++++++++++++++++++++++++++++++++
 1 file changed, 94 insertions(+)

diff --git a/gnu/packages/education.scm b/gnu/packages/education.scm
index 043933abe0..cd28e35b78 100644
--- a/gnu/packages/education.scm
+++ b/gnu/packages/education.scm
@@ -449,6 +449,100 @@ Using KanjiVG, it is possible to create stroke order diagrams or animations
 and kanji dictionaries.")
     (home-page "https://kanjivg.tagaini.net")
     (license license:cc-by-sa3.0)))
+
+(define-public tagainijisho
+  ;; latest release (1.0.3) requires qt4, using latest commit
+  (let ((commit "18078719be75b6b49cffb2f8a22978c635c6b617"))
+    (package
+      (name "tagainijisho")
+      (version (string-append "1.0.3." (string-take commit 7)))
+      (source
+       (origin
+         (method git-fetch)
+         (uri (git-reference
+               (url "https://github.com/Gnurou/tagainijisho")
+               (commit commit)))
+         (file-name (git-file-name name version))
+         (sha256
+          (base32 "1i6vcj30q0427ggdjqrsyqb9dg8b8kd0vzmjdzrxabn9wv05vnz4"))))
+      (build-system qt-build-system)
+      (arguments
+       `(#:tests? #f                    ; no test target
+         #:configure-flags
+         `("-DEMBED_SQLITE=OFF"
+           ,(string-append "-DCMAKE_PREFIX_PATH=" (assoc-ref %outputs "out")))
+         #:phases
+         (modify-phases %standard-phases
+           (add-before 'build 'make-output-bin
+             (lambda* (#:key outputs #:allow-other-keys)
+               (mkdir-p (string-append (assoc-ref outputs "out") "/bin"))))
+           (add-after 'unpack 'add-extra-src
+             (lambda* (#:key inputs outputs #:allow-other-keys)
+               (let ((jmdict (assoc-ref inputs "jmdict"))
+                     (gunzip (which "gunzip"))
+                     (out "3rdparty/JMdict.gz"))
+                 (mkdir-p "3rdparty")
+                 (copy-file jmdict out)
+                 (invoke gunzip out))))
+           (add-after 'unpack 'add-kanjidic2
+             (lambda* (#:key inputs outputs #:allow-other-keys)
+               (let ((kanjidic2 (assoc-ref inputs "kanjidic2"))
+                     (gunzip (which "gunzip"))
+                     (out "3rdparty/kanjidic2.xml.gz"))
+                 (mkdir-p "3rdparty")
+                 (copy-file kanjidic2 out)
+                 (invoke gunzip out))))
+           (add-after 'unpack 'add-kanjivg
+             (lambda* (#:key inputs outputs #:allow-other-keys)
+               (let* ((fname "kanjivg.xml")
+                      (kanjivg
+                       (string-append (assoc-ref inputs "kanjivg") "/" fname))
+                      (out (string-append "3rdparty/" fname)))
+                 (mkdir-p "3rdparty")
+                 (copy-file kanjivg out))))
+           (add-after 'unpack 'make-source-writable
+             ;; build requires to modify a .cc file
+             (lambda _
+               (chmod "src/core/kanjidic2/DictionaryDescriptions.cc" #o600))))))
+      (inputs
+       `(("jmdict"
+          ;; URL is not versioned!
+          ;; https://github.com/Gnurou/tagainijisho/blob/master/src/core/jmdict/CMakeLists.txt#L5
+          ,(origin
+             (method url-fetch)
+             (uri
+              '("http://ftp.edrdg.org/pub/Nihongo/JMdict.gz"
+                "http://www.bcit-broadcast.com/monash/JMdict.gz"
+                "ftp://ftp.net.usf.edu/pub/ftp.monash.edu.au/pub/nihongo/JMdict.gz"))
+             (sha256
+              (base32
+               "0nw39gg2i485b85zx7a5isiims83dpmdchcks9974ryb3z0zackm"))))
+         ("kanjidic2"
+          ;; URL is not versioned!
+          ;; https://github.com/Gnurou/tagainijisho/blob/master/src/core/kanjidic2/CMakeLists.txt#L4
+          ,(origin
+             (method url-fetch)
+             (uri "http://www.edrdg.org/kanjidic/kanjidic2.xml.gz")
+             (sha256
+              (base32
+               "0l2n3bqcfz2x6xns7w02dv01xz3cssbfvbjhlymd88sqsdbfn456"))))
+         ("kanjivg" ,kanjivg)
+         ("qtbase" ,qtbase)
+         ("qttools" ,qttools)
+         ("sqlite" ,sqlite)))
+      (synopsis "Japanese dictionary and learning assistant")
+      (description "Tagaini Jisho is a Japanese dictionary and learning
+assistant.  It is designed to help you remember Japanese vocabulary and
+kanji (later referred as 'entries') by presenting them in a way that makes it
+easy to create connections between them.  It does so by keeping track of all
+the entries you already know and want to study, and letting you tag and annote
+them, in addition to providing easy navigation between related entries.  A
+powerful search engine also allows you to search for entries very precisely.
+Finally, Tagaini let you produce printed material (including a handy foldable
+pocket book) so let you study anywhere.")
+      (home-page "https://www.tagaini.net/")
+      (license license:gpl3+))))
+
 (define-public childsplay
   (package
     (name "childsplay")
-- 
2.31.1