| 1 |
# Copyright 1999-2003 Gentoo Technologies, Inc. |
| 2 |
# Distributed under the terms of the GNU General Public License v2 |
| 3 |
# $Header: /home/cvsroot/gentoo-x86/eclass/cannadic.eclass,v 1.4 2003/09/11 06:09:43 usata Exp $ |
| 4 |
# |
| 5 |
# Author: Mamoru KOMACHI <usata@gentoo.org> |
| 6 |
# |
| 7 |
# The cannadic eclass is used for installation and setup of Canna |
| 8 |
# compatible dictionaries within the Portage system. |
| 9 |
# |
| 10 |
|
| 11 |
ECLASS=cannadic |
| 12 |
INHERITED="$INHERITED $ECLASS" |
| 13 |
EXPORT_FUNCTIONS cannadic-install dicsdir-install update-cannadic-dir \ |
| 14 |
src_install pkg_setup pkg_postinst pkg_postrm |
| 15 |
|
| 16 |
IUSE="${IUSE} canna" |
| 17 |
|
| 18 |
DESCRIPTION="Based on the $ECLASS eclass" |
| 19 |
HOMEPAGE="http://canna.sourceforge.jp/" # you need to change this! |
| 20 |
SRC_URI="mirror://gentoo/${P}.tar.gz" |
| 21 |
|
| 22 |
LICENSE="public-domain" |
| 23 |
# I added all keywords form /usr/portage/profiles/keyword.desc atm since |
| 24 |
# cannadic source is basically plain text and will run on any platform |
| 25 |
KEYWORDS="~x86 ~ppc ~sparc ~alpha ~mips ~hpps ~arm ~amd64" |
| 26 |
SLOT="0" |
| 27 |
|
| 28 |
# I don't add Canna as a dependency because Anthy also uses cannadic |
| 29 |
DEPEND="${DEPEND} |
| 30 |
canna? ( app-i18n/canna )" |
| 31 |
|
| 32 |
S="${WORKDIR}" |
| 33 |
|
| 34 |
DICSDIRFILE="$(echo ${FILESDIR}/*.dics.dir)" |
| 35 |
CANNADICS="${CANNADICS}" # (optional) |
| 36 |
DOCS="README*" |
| 37 |
|
| 38 |
# You don't need to modify these |
| 39 |
#local cannadir dicsdir |
| 40 |
cannadir="/var/lib/canna/dic/canna" |
| 41 |
dicsdir="/var/lib/canna/dic/dics.d" |
| 42 |
|
| 43 |
# |
| 44 |
# pkg_setup() : sets up cannadic dir |
| 45 |
pkg_setup() { |
| 46 |
|
| 47 |
keepdir $cannadir |
| 48 |
fowners bin:bin $cannadir |
| 49 |
fperms 0775 $cannadir |
| 50 |
} |
| 51 |
|
| 52 |
# |
| 53 |
# cannadic-install() : installs dictionaries to cannadir |
| 54 |
# |
| 55 |
cannadic-install() { |
| 56 |
|
| 57 |
insinto $cannadir |
| 58 |
insopts -m0664 -o bin -g bin |
| 59 |
doins "$@" |
| 60 |
} |
| 61 |
|
| 62 |
# |
| 63 |
# dicsdir-install() : installs dics.dir from ${FILESDIR} |
| 64 |
# |
| 65 |
dicsdir-install() { |
| 66 |
|
| 67 |
insinto ${dicsdir} |
| 68 |
doins ${DICSDIRFILE} |
| 69 |
} |
| 70 |
|
| 71 |
# |
| 72 |
# src_install() : installs all dictionaries under ${WORKDIR} |
| 73 |
# plus dics.dir and docs |
| 74 |
# |
| 75 |
src_install() { |
| 76 |
|
| 77 |
for f in *.c[btl]d *.t ; do |
| 78 |
cannadic-install $f |
| 79 |
done 2>/dev/null |
| 80 |
|
| 81 |
if [ -n "`use canna`" ] ; then |
| 82 |
dicsdir-install || die |
| 83 |
fi |
| 84 |
|
| 85 |
dodoc ${DOCS} |
| 86 |
} |
| 87 |
|
| 88 |
# |
| 89 |
# update-cannadic-dir() : updates dics.dir for Canna Server, |
| 90 |
# script for this part taken from Debian GNU/Linux |
| 91 |
# |
| 92 |
# compiles dics.dir files for Canna Server |
| 93 |
# Copyright 2001 ISHIKAWA Mutsumi |
| 94 |
# Licensed under the GNU General Public License, version 2. See the file |
| 95 |
# /usr/portage/license/GPL-2 or <http://www.gnu.org/copyleft/gpl.txt>. |
| 96 |
update-cannadic-dir() { |
| 97 |
|
| 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 >${cannadir}/dics.dir.update-new<<-EOF |
| 104 |
# dics.dir -- automatically generated file by Portage. |
| 105 |
# DO NOT EDIT BY HAND. |
| 106 |
EOF |
| 107 |
|
| 108 |
for file in ${dicsdir}/*.dics.dir ; do |
| 109 |
echo "# $file" >> ${cannadir}/dics.dir.update-new |
| 110 |
cat $file >> ${cannadir}/dics.dir.update-new |
| 111 |
einfo "Added $file." |
| 112 |
done |
| 113 |
|
| 114 |
mv ${cannadir}/dics.dir.update-new ${cannadir}/dics.dir |
| 115 |
|
| 116 |
einfo |
| 117 |
einfo "Done." |
| 118 |
einfo |
| 119 |
} |
| 120 |
|
| 121 |
# |
| 122 |
# pkg_postinst() : updates dics.dir and print out notice after install |
| 123 |
# |
| 124 |
pkg_postinst() { |
| 125 |
|
| 126 |
if [ -n "`use canna`" ] ; then |
| 127 |
update-cannadic-dir |
| 128 |
einfo |
| 129 |
einfo "Please restart cannaserver to fit changes." |
| 130 |
einfo "and modify your config file (~/.canna) to enable dictionary." |
| 131 |
|
| 132 |
if [ -n "${CANNADICS}" ] ; then |
| 133 |
einfo "e.g) add $(for d in ${CANNADICS}; do |
| 134 |
echo -n \"$d\"\ |
| 135 |
done)to section use-dictionary()." |
| 136 |
einfo "For details, see documents under /usr/share/doc/${PF}" |
| 137 |
fi |
| 138 |
|
| 139 |
einfo |
| 140 |
fi |
| 141 |
} |
| 142 |
|
| 143 |
# |
| 144 |
# pkg_postrm() : updates dics.dir and print out notice after uninstall |
| 145 |
# |
| 146 |
pkg_postrm() { |
| 147 |
|
| 148 |
if [ -n "`use canna`" ] ; then |
| 149 |
update-cannadic-dir |
| 150 |
einfo |
| 151 |
einfo "Please restart cannaserver to fit changes." |
| 152 |
einfo "and modify your config file (~/.canna) to disable dictionary." |
| 153 |
|
| 154 |
if [ -n "${CANNADICS}" ] ; then |
| 155 |
einfo "e.g) delete $(for d in ${CANNADICS}; do |
| 156 |
echo -n \"$d\"\ |
| 157 |
done)from section use-dictionary()." |
| 158 |
fi |
| 159 |
|
| 160 |
einfo |
| 161 |
fi |
| 162 |
} |