app-i18n/skk-jisyo: amd64 stable wrt bug #696120
[gentoo.git] / app-i18n / skk-jisyo / skk-jisyo-999999.ebuild
1 # Copyright 1999-2019 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
3
4 EAPI="7"
5 USE_RUBY="ruby24 ruby25 ruby26"
6
7 inherit git-r3 ruby-single
8
9 MY_PN=${PN^^}
10
11 DESCRIPTION="Jisyo (dictionary) files for the SKK Japanese-input software"
12 HOMEPAGE="https://skk-dev.github.io/dict"
13 EGIT_REPO_URI="https://github.com/skk-dev/dict"
14
15 LICENSE="GPL-2 freedist public-domain"
16 SLOT="0"
17 KEYWORDS=""
18 IUSE="cdb ${USE_RUBY//ruby/ruby_targets_ruby}"
19
20 DEPEND="${RUBY_DEPS}
21         app-i18n/skktools
22         virtual/awk
23         cdb? (
24                 || (
25                         dev-db/tinycdb
26                         dev-db/cdb
27                 )
28         )"
29 RDEPEND=""
30
31 DOCS=( ChangeLog{,.{1..3}} committers.txt edict_doc.txt )
32
33 SKKTOOLS_DIR="${EPREFIX}/usr/share/skktools/convert2skk"
34
35 src_prepare() {
36         rm -f ${MY_PN}.{wrong*,noregist,not_wrong,hukugougo,notes,requested,pubdic+}
37
38         default
39 }
40
41 cdb_make() {
42         cdbmake "${1}" "${1}.tmp"
43 }
44
45 tinycdb_make() {
46         cdb -c "${1}"
47 }
48
49 src_compile() {
50         local ctdic="${MY_PN}.china_taiwan" ruby
51         mv ${ctdic}{.header,}
52         for ruby in ${RUBY_TARGETS_PREFERENCE}; do
53                 if use ruby_targets_${ruby}; then
54                         ${ruby} ${SKKTOOLS_DIR}/ctdicconv.rb csv/${ctdic##*.}.csv | skkdic-expr2 >> ${ctdic}
55                         break
56                 fi
57         done
58
59         if use cdb; then
60                 local cdbmake=cdb_make f
61                 if has_version dev-db/tinycdb; then
62                         cdbmake=tinycdb_make
63                 fi
64                 for f in {,zipcode/}${MY_PN}.*; do
65                         LC_ALL=C awk '
66                                 /^[^;]/ {
67                                         s = substr($0, index($0, " ") + 1)
68                                         print "+" length($1) "," length(s) ":" $1 "->" s
69                                 }
70                                 END {
71                                         print ""
72                                 }
73                         ' ${f} | ${cdbmake} ${f}.cdb || die
74                 done
75         fi
76 }
77
78 src_install() {
79         insinto /usr/share/skk
80         doins {,zipcode/}${MY_PN}.*
81
82         einstalldocs
83         docinto zipcode
84         dodoc zipcode/README.md
85 }