diff mbox series

[bug#62968] Add skktools.

Message ID 3892d2a81cef75c2f7d81ada5600c28739651c40.1681997174.git.gemmaro.dev@gmail.com
State New
Headers show
Series [bug#62968] Add skktools. | expand

Commit Message

gemmaro April 20, 2023, 2:06 p.m. UTC
Hello,

This patch adds skktools, which are SKK dictionary maintenance tools.

Some notes about this patch:

* skktools has skkdic-* programs and a number of scripts.
* Some scripts were excluded from the installation target because they
  are not available on modern systems.
* To install Emacs Lisp file, emacs-build-system is partially used
  with reference to the guile-wisp package definition [1].

I submitted this package to the Guix-jp channel ([2], thanks ROCKTAKEY
for review!), and I thought it would be nice to have it on the
official channel too.

1: https://git.savannah.gnu.org/cgit/guix.git/tree/gnu/packages/guile-xyz.scm?id=f3424ada316a9962818b60ae22236efce8bd9fb7#n2107
2: https://gitlab.com/guix-jp/channel/-/merge_requests/8

Regards,
gemmaro.

* gnu/packages/language.scm (skktools): New variable.
---
 gnu/packages/language.scm | 157 ++++++++++++++++++++++++++++++++++++++
 1 file changed, 157 insertions(+)


base-commit: 61d15695752997427ed9c3491470dd76b11bd00a
diff mbox series

Patch

diff --git a/gnu/packages/language.scm b/gnu/packages/language.scm
index 208fab4f5b..c53efd2fa0 100644
--- a/gnu/packages/language.scm
+++ b/gnu/packages/language.scm
@@ -6,6 +6,7 @@ 
 ;;; Copyright © 2020 Ricardo Wurmus <rekado@elephly.net>
 ;;; Copyright © 2020, 2022 Julien Lepiller <julien@lepiller.eu>
 ;;; Copyright © 2022 Milran <milranmike@protonmail.com>
+;;; Copyright © 2023 gemmaro <gemmaro.dev@gmail.com>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -29,6 +30,7 @@  (define-module (gnu packages language)
   #:use-module (gnu packages audio)
   #:use-module (gnu packages base)
   #:use-module (gnu packages compression)
+  #:use-module (gnu packages dbm)
   #:use-module (gnu packages docbook)
   #:use-module (gnu packages emacs)
   #:use-module (gnu packages freedesktop)
@@ -49,6 +51,8 @@  (define-module (gnu packages language)
   #:use-module (gnu packages python)
   #:use-module (gnu packages perl-check)
   #:use-module (gnu packages qt)
+  #:use-module (gnu packages ruby)
+  #:use-module (gnu packages scheme)
   #:use-module (gnu packages sqlite)
   #:use-module (gnu packages serialization)
   #:use-module (gnu packages swig)
@@ -931,6 +935,159 @@  (define-public libskk
      "libskk is a library to deal with Japanese kana-to-kanji conversion method.")
     (license license:gpl3+)))
 
+(define-public skktools
+  (package
+    (name "skktools")
+    (version "1.3.4")
+    (source (origin
+              (method git-fetch)
+              (uri (git-reference
+                    (url "https://github.com/skk-dev/skktools")
+                    (commit (string-append "skktools-"
+                                           (string-replace-substring version
+                                                                     "." "_")))))
+              (file-name (git-file-name name version))
+              (sha256
+               (base32
+                "1zway8jsm18279xq8zlpr84iqiw373x3v0ysay74n9bjqxbl234a"))
+              (modules '((guix build utils)))
+              (snippet '(begin
+                          ;; Maybe requires jgawk
+                          (delete-file "unannotation.awk")
+                          (delete-file "convert2skk/edict2skk.awk")
+                          (delete-file "convert2skk/wnn2skk.awk")
+                          (delete-file "convert2skk/wnn2skk.sed") ;Used with wnn2skk.awk
+                          (delete-file "convert2skk/wnn2skk.sh") ;Depends on 2 files above
+                          ;; Requires jperl
+                          (delete-file "convert2skk/alpha-kana.pl")
+                          (delete-file "convert2skk/atok2skk.pl")
+                          (delete-file "convert2skk/read.me") ;Readme for jperl scripts
+                          (delete-file "convert2skk/wx2skk.pl")
+                          (delete-file-recursively "dbm")
+                          ;; Needs a lot requirements
+                          (delete-file "convert2skk/doc2skk.sh")
+                          ;; Obsolete scripts
+                          (delete-file-recursively "convert2skk/obsolete")
+                          ;; Contains syntax error
+                          (delete-file "convert2skk/pubdic2list")))))
+    (build-system gnu-build-system)
+    (arguments
+     `(#:test-target "test"
+       #:modules ((guix build gnu-build-system)
+                  ((guix build emacs-build-system)
+                   #:prefix emacs:)
+                  (guix build utils)
+                  (guix build emacs-utils))
+       #:imported-modules (,@%gnu-build-system-modules
+                           (guix build emacs-build-system)
+                           (guix build emacs-utils))
+       #:phases (modify-phases %standard-phases
+                  (add-before 'install 'fix-library-loading
+                    (lambda* (#:key outputs #:allow-other-keys)
+                      (for-each (lambda (path)
+                                  (substitute* path
+                                    (("require 'skkdictools'")
+                                     "require_relative 'skkdictools'")))
+                                (list "filters/annotation-filter.rb"
+                                      "filters/asayaKe.rb"
+                                      "filters/complete-numerative.rb"
+                                      "filters/conjugation.rb"
+                                      "filters/make-tankan-dic.rb"))))
+                  (add-after 'install 'install-scripts
+                    (lambda* (#:key outputs #:allow-other-keys)
+                      (let ((share (string-append (assoc-ref outputs "out")
+                                                  "/share/skktools")))
+                        (install-file "filters/skkdictools.rb" share)
+                        (for-each (lambda (file)
+                                    (invoke "chmod" "755" file)
+                                    (install-file file share))
+                                  (append (find-files "." "\\.rb$")
+                                          (find-files "." "\\.scm$")
+                                          (find-files "." "\\.py$")
+                                          (find-files "convert2skk" "\\.pl")
+                                          (find-files "convert2skk" "\\.rb")
+                                          (list "convert2skk/adddummy"
+                                                "convert2skk/list2skk"
+                                                "convert2skk/removedummy"
+                                                "convert2skk/skk2list")
+                                          (find-files "filters" "\\.rb$"))))))
+                  ;; Install and make autoloads for skk-xml.el.
+                  (add-after 'install 'install-emacs-files
+                    (assoc-ref emacs:%standard-phases
+                               'install))
+                  (add-after 'install-emacs-files 'compile-emacs-files
+                    (assoc-ref emacs:%standard-phases
+                               'build))
+                  (add-after 'compile-emacs-files 'make-autoloads
+                    (assoc-ref emacs:%standard-phases
+                               'make-autoloads))
+                  (add-after 'install 'install-docs
+                    (lambda* (#:key outputs #:allow-other-keys)
+                      (let ((doc (string-append (assoc-ref outputs "out")
+                                                "/share/doc/"
+                                                ,name "-"
+                                                ,version)))
+                        (install-file "ChangeLog" doc)
+                        (for-each (lambda (file)
+                                    (install-file file doc))
+                                  (append (find-files "READMEs")))
+                        (copy-file "filters/README.md"
+                                   (string-append doc "/README.filters.md"))
+                        (copy-file "convert2skk/README.md"
+                                   (string-append doc "/README.convert2skk.md")))))
+                  (add-after 'wrap-scripts 'check-scripts
+                    ;; Skipped tests for:
+                    ;; * skk2cdb.py: Requires cdb file
+                    (lambda* (#:key outputs #:allow-other-keys)
+                      (let ((out (string-append (assoc-ref outputs "out")
+                                                "/share/skktools")))
+                        (for-each (lambda (args)
+                                    (apply invoke
+                                           (string-append out "/"
+                                                          (car args))
+                                           (cdr args)))
+                                  '(("abbrev-convert.rb")
+                                    ("abbrev-simplify-keys.rb")
+                                    ("adddummy")
+                                    ("annotation-filter.rb")
+                                    ("aozora2skk.rb")
+                                    ("asayaKe.rb")
+                                    ("canna2skk.rb" "/dev/null")
+                                    ("chasen2skk.rb")
+                                    ("complete-numerative.rb")
+                                    ("conjugation.rb")
+                                    ("ctdicconv.rb")
+                                    ("dic-it2skk.rb" "/dev/null")
+                                    ("ipadic2skk.rb")
+                                    ("list2skk")
+                                    ("make-tankan-dic.rb")
+                                    ("prime2skk.rb")
+                                    ("removedummy")
+                                    ("saihenkan.rb")
+                                    ("skk2list")
+                                    ("/skkdic-diff.scm" "/dev/null"
+                                     "/dev/null")
+                                    ("skk-wordpicker.rb")))))))))
+    (native-inputs (list
+                    ;; for skkdic-expr2
+                    pkg-config
+                    ;; for installing Emacs Lisp files
+                    emacs-minimal))
+    (inputs (list bdb-4.8
+                  glib ;for skkdic-expr2
+                  ;; For scripts
+                  gauche
+                  perl
+                  python-2
+                  ruby))
+    (home-page "https://github.com/skk-dev/skktools")
+    (synopsis "SKK dictionary maintenance tools")
+    (description
+     "The skktools are SKK dictionary maintenance tools.  Note that the
+scripts are located under the share directory, while there might be
+some missing interpreters and might not work.")
+    (license license:gpl2)))
+
 (define-public mecab
   (package
     (name "mecab")