Gentoo Archives: gentoo-commits

From: David Seifert <soap@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: eclass/
Date: Sat, 19 Jun 2021 22:54:54
Message-Id: 1624143267.b6e19f99d5f0314e03d92b28779b980956eb1e6a.soap@gentoo
1 commit: b6e19f99d5f0314e03d92b28779b980956eb1e6a
2 Author: David Seifert <soap <AT> gentoo <DOT> org>
3 AuthorDate: Sat Jun 19 22:54:27 2021 +0000
4 Commit: David Seifert <soap <AT> gentoo <DOT> org>
5 CommitDate: Sat Jun 19 22:54:27 2021 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=b6e19f99
7
8 cannadic.eclass: Port to EAPI 7
9
10 * Add whitelist
11 * eclassdoc
12 * `EROOT` in `pkg_*` phases only
13
14 Signed-off-by: David Seifert <soap <AT> gentoo.org>
15
16 eclass/cannadic.eclass | 97 +++++++++++++++++++++++++++-----------------------
17 1 file changed, 53 insertions(+), 44 deletions(-)
18
19 diff --git a/eclass/cannadic.eclass b/eclass/cannadic.eclass
20 index 7392d5ce6a9..5df857d1858 100644
21 --- a/eclass/cannadic.eclass
22 +++ b/eclass/cannadic.eclass
23 @@ -1,4 +1,4 @@
24 -# Copyright 1999-2017 Gentoo Foundation
25 +# Copyright 1999-2021 Gentoo Authors
26 # Distributed under the terms of the GNU General Public License v2
27
28 # @ECLASS: cannadic.eclass
29 @@ -6,40 +6,33 @@
30 # cjk@g.o
31 # @AUTHOR:
32 # Mamoru KOMACHI <usata@g.o>
33 +# @SUPPORTED_EAPIS: 7
34 # @BLURB: Function for Canna compatible dictionaries
35 # @DESCRIPTION:
36 # The cannadic eclass is used for installation and setup of Canna
37 -# compatible dictionaries within the Portage system.
38 +# compatible dictionaries.
39
40 -inherit eutils
41 +case ${EAPI} in
42 + 7) ;;
43 + *) die "EAPI=${EAPI:-0} is not supported" ;;
44 +esac
45
46 -EXPORT_FUNCTIONS pkg_setup pkg_postinst pkg_postrm src_install
47 +EXPORT_FUNCTIONS src_install pkg_postinst pkg_postrm
48
49 -HOMEPAGE="http://canna.osdn.jp/" # you need to change this!
50 -SRC_URI="mirror://gentoo/${P}.tar.gz"
51 +if [[ -z ${_CANNADIC_ECLASS} ]]; then
52 +_CANNADIC_ECLASS=1
53
54 -DICSDIRFILE="${FILESDIR}/*.dics.dir"
55 -CANNADICS="${CANNADICS}" # (optional)
56 +SRC_URI="mirror://gentoo/${P}.tar.gz"
57
58 # You don't need to modify these
59 -CANNADIC_CANNA_DIR="${EROOT:-${ROOT}}"var/lib/canna/dic/canna
60 -CANNADIC_DICS_DIR="${EROOT:-${ROOT}}"var/lib/canna/dic/dics.d
61 -readonly CANNADIC_CANNA_DIR CANNADIC_DICS_DIR
62 -
63 -# @FUNCTION: cannadic_pkg_setup
64 -# @DESCRIPTION:
65 -# Sets up ${CANNADIC_CANNA_DIR}
66 -cannadic_pkg_setup() {
67 - keepdir "${CANNADIC_CANNA_DIR}"
68 - fowners bin:bin "${CANNADIC_CANNA_DIR}"
69 - fperms 0775 "${CANNADIC_CANNA_DIR}"
70 -}
71 +readonly _CANNADIC_CANNA_DIR="/var/lib/canna/dic/canna"
72 +readonly _CANNADIC_DICS_DIR="/var/lib/canna/dic/dics.d"
73
74 # @FUNCTION: cannadic-install
75 # @DESCRIPTION:
76 -# Installs dictionaries to ${CANNADIC_CANNA_DIR}
77 +# Installs dictionaries to ${EPREFIX}/var/lib/canna/dic/canna
78 cannadic-install() {
79 - insinto "${CANNADIC_CANNA_DIR}"
80 + insinto ${_CANNADIC_CANNA_DIR}
81 insopts -m 0664 -o bin -g bin
82 doins "${@}"
83 }
84 @@ -48,8 +41,8 @@ cannadic-install() {
85 # @DESCRIPTION:
86 # Installs dics.dir from ${DICSDIRFILE}
87 dicsdir-install() {
88 - insinto "${CANNADIC_DICS_DIR}"
89 - doins "${DICSDIRFILE}"
90 + insinto ${_CANNADIC_DICS_DIR}
91 + doins ${DICSDIRFILE}
92 }
93
94 # @FUNCTION: cannadic_src_install
95 @@ -57,14 +50,18 @@ dicsdir-install() {
96 # Installs all dictionaries under ${WORKDIR}
97 # plus dics.dir and docs
98 cannadic_src_install() {
99 + keepdir ${_CANNADIC_CANNA_DIR}
100 + fowners bin:bin ${_CANNADIC_CANNA_DIR}
101 + fperms 0775 ${_CANNADIC_CANNA_DIR}
102 +
103 local f
104 for f in *.c[btl]d *.t; do
105 - if [[ -s "${f}" ]]; then
106 + if [[ -s ${f} ]]; then
107 cannadic-install "${f}"
108 fi
109 done 2> /dev/null
110
111 - dicsdir-install || die
112 + dicsdir-install
113
114 einstalldocs
115 }
116 @@ -83,19 +80,20 @@ update-cannadic-dir() {
117 einfo
118
119 # write new dics.dir file in case we are interrupted
120 - cat <<-EOF > "${CANNADIC_CANNA_DIR}"/dics.dir.update-new
121 - # dics.dir -- automatically generated file by Portage.
122 - # DO NOT EDIT BY HAND.
123 + cat <<-EOF > "${EROOT}${_CANNADIC_CANNA_DIR}"/dics.dir.update-new || die
124 + # dics.dir -- automatically generated file by Portage.
125 + # DO NOT EDIT BY HAND.
126 EOF
127
128 local f
129 - for f in "${CANNADIC_DICS_DIR}"/*.dics.dir; do
130 - echo "# ${f}" >> "${CANNADIC_CANNA_DIR}"/dics.dir.update-new
131 - cat "${f}" >> "${CANNADIC_CANNA_DIR}"/dics.dir.update-new
132 + for f in "${EROOT}${_CANNADIC_DICS_DIR}"/*.dics.dir; do
133 + echo "# ${f}" >> "${EROOT}${_CANNADIC_CANNA_DIR}"/dics.dir.update-new || die
134 + cat "${f}" >> "${EROOT}${_CANNADIC_CANNA_DIR}"/dics.dir.update-new || die
135 einfo "Added ${f}."
136 done
137
138 - mv "${CANNADIC_CANNA_DIR}"/dics.dir.update-new "${CANNADIC_CANNA_DIR}"/dics.dir
139 + mv "${EROOT}${_CANNADIC_CANNA_DIR}"/dics.dir.update-new \
140 + "${EROOT}${_CANNADIC_CANNA_DIR}"/dics.dir || die
141
142 einfo
143 einfo "Done."
144 @@ -106,36 +104,47 @@ update-cannadic-dir() {
145 # @DESCRIPTION:
146 # Updates dics.dir and print out notice after install
147 cannadic_pkg_postinst() {
148 + debug-print-function ${FUNCNAME} "${@}"
149 +
150 update-cannadic-dir
151
152 - einfo
153 - einfo "Please restart cannaserver to fit the changes."
154 + einfo "Please restart cannaserver for changes to propagate."
155 einfo "You need to modify your config file (~/.canna) to enable dictionaries."
156
157 - if [[ -n "${CANNADICS}" ]]; then
158 - einfo "e.g) add $(for d in ${CANNADICS}; do echo -n "\"${d}\" "; done)to section use-dictionary()."
159 - einfo "For details, see documents under /usr/share/doc/${PF}."
160 + if [[ -n ${CANNADICS} ]]; then
161 + einfo "e.g) add"
162 + einfo
163 + einfo " $(IFS=' ' ; echo ${CANNADICS[*]})"
164 + einfo
165 + einfo "to section use-dictionary()."
166 + einfo "For details, see documents under ${EROOT}/usr/share/doc/${PF}."
167 fi
168
169 - einfo "If you do not have ~/.canna, you can find sample files in /usr/share/canna."
170 + einfo "If you do not have ~/.canna, you can find sample files in ${EROOT}/usr/share/canna."
171 ewarn "If you are upgrading from existing dictionary, you may need to recreate"
172 ewarn "user dictionary if you have one."
173 - einfo
174 }
175
176 # @FUNCTION: cannadic_pkg_postrm
177 # @DESCRIPTION:
178 # Updates dics.dir and print out notice after uninstall
179 cannadic_pkg_postrm() {
180 + debug-print-function ${FUNCNAME} "${@}"
181 +
182 update-cannadic-dir
183
184 - einfo
185 - einfo "Please restart cannaserver to fit changes."
186 + einfo "Please restart cannaserver for changes to propagate."
187 einfo "and modify your config file (~/.canna) to disable dictionary."
188
189 - if [[ -n "${CANNADICS}" ]]; then
190 - einfo "e.g) delete $(for d in ${CANNADICS}; do echo -n "\"${d}\" "; done)from section use-dictionary()."
191 + if [[ -n ${CANNADICS} ]]; then
192 + einfo "e.g) delete"
193 + einfo
194 + einfo " $(IFS=' ' ; echo ${CANNADICS[*]})"
195 + einfo
196 + einfo "from section use-dictionary()."
197 fi
198
199 einfo
200 }
201 +
202 +fi