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