Drop $Id$ per council decision in bug #611234.
[gentoo.git] / eclass / cannadic.eclass
1 # Copyright 1999-2012 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3
4 # @ECLASS: cannadic.eclass
5 # @AUTHOR:
6 # Original author: Mamoru KOMACHI <usata@gentoo.org>
7 # @BLURB: Function for Canna compatible dictionaries
8 # @DESCRIPTION:
9 # The cannadic eclass is used for installation and setup of Canna
10 # compatible dictionaries within the Portage system.
11
12
13 EXPORT_FUNCTIONS src_install pkg_setup pkg_postinst pkg_postrm
14
15 IUSE=""
16
17 HOMEPAGE="http://canna.sourceforge.jp/"         # you need to change this!
18 SRC_URI="mirror://gentoo/${P}.tar.gz"
19
20 LICENSE="public-domain"
21 SLOT="0"
22
23 S="${WORKDIR}"
24
25 DICSDIRFILE="${FILESDIR}/*.dics.dir"
26 CANNADICS="${CANNADICS}"                        # (optional)
27 DOCS="README*"
28
29 # You don't need to modify these
30 #local cannadir dicsdir
31 cannadir="${ROOT}/var/lib/canna/dic/canna"
32 dicsdir="${ROOT}/var/lib/canna/dic/dics.d"
33
34 # @FUNCTION: cannadic_pkg_setup
35 # @DESCRIPTION:
36 # Sets up cannadic dir
37 cannadic_pkg_setup() {
38
39         keepdir $cannadir
40         fowners bin:bin $cannadir
41         fperms 0775 $cannadir
42 }
43
44 # @FUNCTION: cannadic-install
45 # @DESCRIPTION:
46 # Installs dictionaries to cannadir
47 cannadic-install() {
48
49         insinto $cannadir
50         insopts -m0664 -o bin -g bin
51         doins "$@"
52 }
53
54 # @FUNCTION: dicsdir-install
55 # @DESCRIPTION:
56 # Installs dics.dir from ${DICSDIRFILE}
57 dicsdir-install() {
58
59         insinto ${dicsdir}
60         doins ${DICSDIRFILE}
61 }
62
63 # @FUNCTION: cannadic_src_install
64 # @DESCRIPTION:
65 # Installs all dictionaries under ${WORKDIR}
66 # plus dics.dir and docs
67 cannadic_src_install() {
68
69         for f in *.c[btl]d *.t ; do
70                 cannadic-install $f
71         done 2>/dev/null
72
73         dicsdir-install || die
74
75         dodoc ${DOCS}
76 }
77
78 # @FUNCTION: update-cannadic-dir
79 # @DESCRIPTION:
80 # Updates dics.dir for Canna Server, script for this part taken from Debian GNU/Linux
81 #
82 #  compiles dics.dir files for Canna Server
83 #  Copyright 2001 ISHIKAWA Mutsumi
84 #  Licensed under the GNU General Public License, version 2.  See the file
85 #  /usr/portage/license/GPL-2 or <http://www.gnu.org/copyleft/gpl.txt>.
86 update-cannadic-dir() {
87
88         einfo
89         einfo "Updating dics.dir for Canna ..."
90         einfo
91
92         # write new dics.dir file in case we are interrupted
93         cat >${cannadir}/dics.dir.update-new<<-EOF
94         # dics.dir -- automatically generated file by Portage.
95         # DO NOT EDIT BY HAND.
96         EOF
97
98         for file in ${dicsdir}/*.dics.dir ; do
99                 echo "# $file" >> ${cannadir}/dics.dir.update-new
100                 cat $file >> ${cannadir}/dics.dir.update-new
101                 einfo "Added $file."
102         done
103
104         mv ${cannadir}/dics.dir.update-new ${cannadir}/dics.dir
105
106         einfo
107         einfo "Done."
108         einfo
109 }
110
111 # @FUNCTION: cannadic_pkg_postinst
112 # @DESCRIPTION:
113 # Updates dics.dir and print out notice after install
114 cannadic_pkg_postinst() {
115         update-cannadic-dir
116         einfo
117         einfo "Please restart cannaserver to fit the changes."
118         einfo "You need to modify your config file (~/.canna) to enable dictionaries."
119
120         if [ -n "${CANNADICS}" ] ; then
121                 einfo "e.g) add $(for d in ${CANNADICS}; do
122                                 echo -n "\"$d\" "
123                                 done)to section use-dictionary()."
124                 einfo "For details, see documents under /usr/share/doc/${PF}"
125         fi
126
127         einfo "If you do not have ~/.canna, you can find sample files in /usr/share/canna."
128         ewarn "If you are upgrading from existing dictionary, you may need to recreate"
129         ewarn "user dictionary if you have one."
130         einfo
131 }
132
133 # @FUNCTION: cannadic_pkg_postrm
134 # @DESCRIPTION:
135 # Updates dics.dir and print out notice after uninstall
136 cannadic_pkg_postrm() {
137         update-cannadic-dir
138         einfo
139         einfo "Please restart cannaserver to fit changes."
140         einfo "and modify your config file (~/.canna) to disable dictionary."
141
142         if [ -n "${CANNADICS}" ] ; then
143                 einfo "e.g) delete $(for d in ${CANNADICS}; do
144                                 echo -n "\"$d\" "
145                                 done)from section use-dictionary()."
146         fi
147
148         einfo
149 }