1 # Copyright 1999-2017 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
4 # @ECLASS: cannadic.eclass
8 # Mamoru KOMACHI <usata@gentoo.org>
9 # @BLURB: Function for Canna compatible dictionaries
11 # The cannadic eclass is used for installation and setup of Canna
12 # compatible dictionaries within the Portage system.
16 EXPORT_FUNCTIONS pkg_setup pkg_postinst pkg_postrm src_install
18 HOMEPAGE="http://canna.osdn.jp/" # you need to change this!
19 SRC_URI="mirror://gentoo/${P}.tar.gz"
21 DICSDIRFILE="${FILESDIR}/*.dics.dir"
22 CANNADICS="${CANNADICS}" # (optional)
24 # You don't need to modify these
25 CANNADIC_CANNA_DIR="${EROOT:-${ROOT}}"var/lib/canna/dic/canna
26 CANNADIC_DICS_DIR="${EROOT:-${ROOT}}"var/lib/canna/dic/dics.d
27 readonly CANNADIC_CANNA_DIR CANNADIC_DICS_DIR
29 # @FUNCTION: cannadic_pkg_setup
31 # Sets up ${CANNADIC_CANNA_DIR}
32 cannadic_pkg_setup() {
33 keepdir "${CANNADIC_CANNA_DIR}"
34 fowners bin:bin "${CANNADIC_CANNA_DIR}"
35 fperms 0775 "${CANNADIC_CANNA_DIR}"
38 # @FUNCTION: cannadic-install
40 # Installs dictionaries to ${CANNADIC_CANNA_DIR}
42 insinto "${CANNADIC_CANNA_DIR}"
43 insopts -m 0664 -o bin -g bin
47 # @FUNCTION: dicsdir-install
49 # Installs dics.dir from ${DICSDIRFILE}
51 insinto "${CANNADIC_DICS_DIR}"
52 doins "${DICSDIRFILE}"
55 # @FUNCTION: cannadic_src_install
57 # Installs all dictionaries under ${WORKDIR}
58 # plus dics.dir and docs
59 cannadic_src_install() {
61 for f in *.c[btl]d *.t; do
62 if [[ -s "${f}" ]]; then
63 cannadic-install "${f}"
67 dicsdir-install || die
72 # @FUNCTION: update-cannadic-dir
74 # Updates dics.dir for Canna Server, script for this part taken from Debian GNU/Linux
76 # compiles dics.dir files for Canna Server
77 # Copyright 2001 ISHIKAWA Mutsumi
78 # Licensed under the GNU General Public License, version 2. See the file
79 # /usr/portage/license/GPL-2 or <http://www.gnu.org/copyleft/gpl.txt>.
80 update-cannadic-dir() {
82 einfo "Updating dics.dir for Canna ..."
85 # write new dics.dir file in case we are interrupted
86 cat <<-EOF > "${CANNADIC_CANNA_DIR}"/dics.dir.update-new
87 # dics.dir -- automatically generated file by Portage.
88 # DO NOT EDIT BY HAND.
92 for f in "${CANNADIC_DICS_DIR}"/*.dics.dir; do
93 echo "# ${f}" >> "${CANNADIC_CANNA_DIR}"/dics.dir.update-new
94 cat "${f}" >> "${CANNADIC_CANNA_DIR}"/dics.dir.update-new
98 mv "${CANNADIC_CANNA_DIR}"/dics.dir.update-new "${CANNADIC_CANNA_DIR}"/dics.dir
105 # @FUNCTION: cannadic_pkg_postinst
107 # Updates dics.dir and print out notice after install
108 cannadic_pkg_postinst() {
112 einfo "Please restart cannaserver to fit the changes."
113 einfo "You need to modify your config file (~/.canna) to enable dictionaries."
115 if [[ -n "${CANNADICS}" ]]; then
116 einfo "e.g) add $(for d in ${CANNADICS}; do echo -n "\"${d}\" "; done)to section use-dictionary()."
117 einfo "For details, see documents under /usr/share/doc/${PF}."
120 einfo "If you do not have ~/.canna, you can find sample files in /usr/share/canna."
121 ewarn "If you are upgrading from existing dictionary, you may need to recreate"
122 ewarn "user dictionary if you have one."
126 # @FUNCTION: cannadic_pkg_postrm
128 # Updates dics.dir and print out notice after uninstall
129 cannadic_pkg_postrm() {
133 einfo "Please restart cannaserver to fit changes."
134 einfo "and modify your config file (~/.canna) to disable dictionary."
136 if [[ -n "${CANNADICS}" ]]; then
137 einfo "e.g) delete $(for d in ${CANNADICS}; do echo -n "\"${d}\" "; done)from section use-dictionary()."