Gentoo Archives: gentoo-commits

From: Alessandro Barbieri <lssndrbarbieri@×××××.com>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/proj/guru:dev commit in: eclass/
Date: Sun, 26 Jun 2022 02:36:41
Message-Id: 1656210584.1a5c41863841d242001fd2d398f054fa6de807e0.Alessandro-Barbieri@gentoo
1 commit: 1a5c41863841d242001fd2d398f054fa6de807e0
2 Author: Alessandro Barbieri <lssndrbarbieri <AT> gmail <DOT> com>
3 AuthorDate: Wed Jun 22 02:44:38 2022 +0000
4 Commit: Alessandro Barbieri <lssndrbarbieri <AT> gmail <DOT> com>
5 CommitDate: Sun Jun 26 02:29:44 2022 +0000
6 URL: https://gitweb.gentoo.org/repo/proj/guru.git/commit/?id=1a5c4186
7
8 cannadic.eclass: add cannadic eclass
9
10 Signed-off-by: Alessandro Barbieri <lssndrbarbieri <AT> gmail.com>
11
12 eclass/cannadic.eclass | 149 +++++++++++++++++++++++++++++++++++++++++++++++++
13 1 file changed, 149 insertions(+)
14
15 diff --git a/eclass/cannadic.eclass b/eclass/cannadic.eclass
16 new file mode 100644
17 index 000000000..4e8914f39
18 --- /dev/null
19 +++ b/eclass/cannadic.eclass
20 @@ -0,0 +1,149 @@
21 +# Copyright 1999-2022 Gentoo Authors
22 +# Distributed under the terms of the GNU General Public License v2
23 +
24 +# @ECLASS: cannadic.eclass
25 +# @MAINTAINER:
26 +# Alessandro Barbieri <lssndrbarbieri@×××××.com>
27 +# @AUTHOR:
28 +# Mamoru KOMACHI <usata@g.o>
29 +# @SUPPORTED_EAPIS: 8
30 +# @BLURB: Function for Canna compatible dictionaries
31 +# @DESCRIPTION:
32 +# The cannadic eclass is used for installation and setup of Canna
33 +# compatible dictionaries.
34 +
35 +case ${EAPI} in
36 + 8) ;;
37 + *) die "EAPI=${EAPI:-0} is not supported" ;;
38 +esac
39 +
40 +EXPORT_FUNCTIONS src_install pkg_postinst pkg_postrm
41 +
42 +if [[ -z ${_CANNADIC_ECLASS} ]]; then
43 +_CANNADIC_ECLASS=1
44 +
45 +SRC_URI="mirror://gentoo/${P}.tar.gz"
46 +
47 +# You don't need to modify these
48 +readonly _CANNADIC_CANNA_DIR="/var/lib/canna/dic/canna"
49 +readonly _CANNADIC_DICS_DIR="/etc/canna/dics.dir.d/"
50 +
51 +# @FUNCTION: cannadic-install
52 +# @DESCRIPTION:
53 +# Installs dictionaries to ${EPREFIX}/var/lib/canna/dic/canna
54 +cannadic-install() {
55 + insinto ${_CANNADIC_CANNA_DIR}
56 + insopts -m 0664 -o canna -g canna
57 + doins "${@}"
58 +}
59 +
60 +# @FUNCTION: dicsdir-install
61 +# @DESCRIPTION:
62 +# Installs dics.dir from ${DICSDIRFILE}
63 +dicsdir-install() {
64 + insinto ${_CANNADIC_DICS_DIR}
65 + doins ${DICSDIRFILE}
66 +}
67 +
68 +# @FUNCTION: cannadic_src_install
69 +# @DESCRIPTION:
70 +# Installs all dictionaries under ${WORKDIR}
71 +# plus dics.dir and docs
72 +cannadic_src_install() {
73 + keepdir ${_CANNADIC_CANNA_DIR}
74 + fowners canna:canna ${_CANNADIC_CANNA_DIR}
75 + fperms 0775 ${_CANNADIC_CANNA_DIR}
76 +
77 + local f
78 + for f in *.c[btl]d *.t; do
79 + if [[ -s ${f} ]]; then
80 + cannadic-install "${f}"
81 + fi
82 + done 2> /dev/null
83 +
84 + dicsdir-install
85 +
86 + einstalldocs
87 +}
88 +
89 +# @FUNCTION: update-cannadic-dir
90 +# @DESCRIPTION:
91 +# Updates dics.dir for Canna Server, script for this part taken from Debian GNU/Linux
92 +#
93 +# compiles dics.dir files for Canna Server
94 +# Copyright 2001 ISHIKAWA Mutsumi
95 +# Licensed under the GNU General Public License, version 2. See the file
96 +# /usr/portage/license/GPL-2 or <http://www.gnu.org/copyleft/gpl.txt>.
97 +update-cannadic-dir() {
98 + einfo
99 + einfo "Updating dics.dir for Canna ..."
100 + einfo
101 +
102 + # write new dics.dir file in case we are interrupted
103 + cat <<-EOF > "${EROOT}${_CANNADIC_CANNA_DIR}/dics.dir.update-new" || die
104 + # dics.dir -- automatically generated file by Portage.
105 + # DO NOT EDIT BY HAND.
106 + EOF
107 +
108 + local f
109 + for f in "${EROOT}${_CANNADIC_DICS_DIR}"/*.dics.dir; do
110 + echo "# ${f}" >> "${EROOT}${_CANNADIC_CANNA_DIR}/dics.dir.update-new" || die
111 + cat "${f}" >> "${EROOT}${_CANNADIC_CANNA_DIR}/dics.dir.update-new" || die
112 + einfo "Added ${f}."
113 + done
114 +
115 + mv "${EROOT}${_CANNADIC_CANNA_DIR}/dics.dir.update-new" "${EROOT}${_CANNADIC_CANNA_DIR}/dics.dir" || die
116 +
117 + einfo
118 + einfo "Done."
119 + einfo
120 +}
121 +
122 +# @FUNCTION: cannadic_pkg_postinst
123 +# @DESCRIPTION:
124 +# Updates dics.dir and print out notice after install
125 +cannadic_pkg_postinst() {
126 + debug-print-function ${FUNCNAME} "${@}"
127 +
128 + update-cannadic-dir
129 +
130 + einfo "Please restart cannaserver for changes to propagate."
131 + einfo "You need to modify your config file (~/.canna) to enable dictionaries."
132 +
133 + if [[ -n ${CANNADICS} ]]; then
134 + einfo "e.g) add"
135 + einfo
136 + einfo " $(IFS=' ' ; echo ${CANNADICS[*]})"
137 + einfo
138 + einfo "to section use-dictionary()."
139 + einfo "For details, see documents under ${EROOT}/usr/share/doc/${PF}."
140 + fi
141 +
142 + einfo "If you do not have ~/.canna, you can find sample files in ${EROOT}/usr/share/canna."
143 + ewarn "If you are upgrading from existing dictionary, you may need to recreate"
144 + ewarn "user dictionary if you have one."
145 +}
146 +
147 +# @FUNCTION: cannadic_pkg_postrm
148 +# @DESCRIPTION:
149 +# Updates dics.dir and print out notice after uninstall
150 +cannadic_pkg_postrm() {
151 + debug-print-function ${FUNCNAME} "${@}"
152 +
153 + update-cannadic-dir
154 +
155 + einfo "Please restart cannaserver for changes to propagate."
156 + einfo "and modify your config file (~/.canna) to disable dictionary."
157 +
158 + if [[ -n ${CANNADICS} ]]; then
159 + einfo "e.g) delete"
160 + einfo
161 + einfo " $(IFS=' ' ; echo ${CANNADICS[*]})"
162 + einfo
163 + einfo "from section use-dictionary()."
164 + fi
165 +
166 + einfo
167 +}
168 +
169 +fi