dev-cpp/pangomm: stable 2.42.1 for hppa, bug #717144
[gentoo.git] / eclass / cannadic.eclass
index 015e13451a6a32428000b2780f3d0113a4c82d4e..7392d5ce6a9b669ae9c1fd8c1063747282f38ac6 100644 (file)
@@ -1,64 +1,55 @@
-# Copyright 1999-2012 Gentoo Foundation
+# Copyright 1999-2017 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
-# $Id$
 
 # @ECLASS: cannadic.eclass
+# @MAINTAINER:
+# cjk@gentoo.org
 # @AUTHOR:
-# Original author: Mamoru KOMACHI <usata@gentoo.org>
+# Mamoru KOMACHI <usata@gentoo.org>
 # @BLURB: Function for Canna compatible dictionaries
 # @DESCRIPTION:
 # The cannadic eclass is used for installation and setup of Canna
 # compatible dictionaries within the Portage system.
 
+inherit eutils
 
-EXPORT_FUNCTIONS src_install pkg_setup pkg_postinst pkg_postrm
+EXPORT_FUNCTIONS pkg_setup pkg_postinst pkg_postrm src_install
 
-IUSE=""
-
-HOMEPAGE="http://canna.sourceforge.jp/"                # you need to change this!
+HOMEPAGE="http://canna.osdn.jp/"               # you need to change this!
 SRC_URI="mirror://gentoo/${P}.tar.gz"
 
-LICENSE="public-domain"
-SLOT="0"
-
-S="${WORKDIR}"
-
 DICSDIRFILE="${FILESDIR}/*.dics.dir"
 CANNADICS="${CANNADICS}"                       # (optional)
-DOCS="README*"
 
 # You don't need to modify these
-#local cannadir dicsdir
-cannadir="${ROOT}/var/lib/canna/dic/canna"
-dicsdir="${ROOT}/var/lib/canna/dic/dics.d"
+CANNADIC_CANNA_DIR="${EROOT:-${ROOT}}"var/lib/canna/dic/canna
+CANNADIC_DICS_DIR="${EROOT:-${ROOT}}"var/lib/canna/dic/dics.d
+readonly CANNADIC_CANNA_DIR CANNADIC_DICS_DIR
 
 # @FUNCTION: cannadic_pkg_setup
 # @DESCRIPTION:
-# Sets up cannadic dir
+# Sets up ${CANNADIC_CANNA_DIR}
 cannadic_pkg_setup() {
-
-       keepdir $cannadir
-       fowners bin:bin $cannadir
-       fperms 0775 $cannadir
+       keepdir "${CANNADIC_CANNA_DIR}"
+       fowners bin:bin "${CANNADIC_CANNA_DIR}"
+       fperms 0775 "${CANNADIC_CANNA_DIR}"
 }
 
 # @FUNCTION: cannadic-install
 # @DESCRIPTION:
-# Installs dictionaries to cannadir
+# Installs dictionaries to ${CANNADIC_CANNA_DIR}
 cannadic-install() {
-
-       insinto $cannadir
-       insopts -m0664 -o bin -g bin
-       doins "$@"
+       insinto "${CANNADIC_CANNA_DIR}"
+       insopts -m 0664 -o bin -g bin
+       doins "${@}"
 }
 
 # @FUNCTION: dicsdir-install
 # @DESCRIPTION:
 # Installs dics.dir from ${DICSDIRFILE}
 dicsdir-install() {
-
-       insinto ${dicsdir}
-       doins ${DICSDIRFILE}
+       insinto "${CANNADIC_DICS_DIR}"
+       doins "${DICSDIRFILE}"
 }
 
 # @FUNCTION: cannadic_src_install
@@ -66,14 +57,16 @@ dicsdir-install() {
 # Installs all dictionaries under ${WORKDIR}
 # plus dics.dir and docs
 cannadic_src_install() {
-
-       for f in *.c[btl]d *.t ; do
-               cannadic-install $f
-       done 2>/dev/null
+       local f
+       for f in *.c[btl]d *.t; do
+               if [[ -s "${f}" ]]; then
+                       cannadic-install "${f}"
+               fi
+       done 2> /dev/null
 
        dicsdir-install || die
 
-       dodoc ${DOCS}
+       einstalldocs
 }
 
 # @FUNCTION: update-cannadic-dir
@@ -85,24 +78,24 @@ cannadic_src_install() {
 #  Licensed under the GNU General Public License, version 2.  See the file
 #  /usr/portage/license/GPL-2 or <http://www.gnu.org/copyleft/gpl.txt>.
 update-cannadic-dir() {
-
        einfo
        einfo "Updating dics.dir for Canna ..."
        einfo
 
        # write new dics.dir file in case we are interrupted
-       cat >${cannadir}/dics.dir.update-new<<-EOF
+       cat <<-EOF > "${CANNADIC_CANNA_DIR}"/dics.dir.update-new
        # dics.dir -- automatically generated file by Portage.
        # DO NOT EDIT BY HAND.
        EOF
 
-       for file in ${dicsdir}/*.dics.dir ; do
-               echo "# $file" >> ${cannadir}/dics.dir.update-new
-               cat $file >> ${cannadir}/dics.dir.update-new
-               einfo "Added $file."
+       local f
+       for f in "${CANNADIC_DICS_DIR}"/*.dics.dir; do
+               echo "# ${f}" >> "${CANNADIC_CANNA_DIR}"/dics.dir.update-new
+               cat "${f}" >> "${CANNADIC_CANNA_DIR}"/dics.dir.update-new
+               einfo "Added ${f}."
        done
 
-       mv ${cannadir}/dics.dir.update-new ${cannadir}/dics.dir
+       mv "${CANNADIC_CANNA_DIR}"/dics.dir.update-new "${CANNADIC_CANNA_DIR}"/dics.dir
 
        einfo
        einfo "Done."
@@ -114,15 +107,14 @@ update-cannadic-dir() {
 # Updates dics.dir and print out notice after install
 cannadic_pkg_postinst() {
        update-cannadic-dir
+
        einfo
        einfo "Please restart cannaserver to fit the changes."
        einfo "You need to modify your config file (~/.canna) to enable dictionaries."
 
-       if [ -n "${CANNADICS}" ] ; then
-               einfo "e.g) add $(for d in ${CANNADICS}; do
-                               echo -n "\"$d\" "
-                               done)to section use-dictionary()."
-               einfo "For details, see documents under /usr/share/doc/${PF}"
+       if [[ -n "${CANNADICS}" ]]; then
+               einfo "e.g) add $(for d in ${CANNADICS}; do echo -n "\"${d}\" "; done)to section use-dictionary()."
+               einfo "For details, see documents under /usr/share/doc/${PF}."
        fi
 
        einfo "If you do not have ~/.canna, you can find sample files in /usr/share/canna."
@@ -136,14 +128,13 @@ cannadic_pkg_postinst() {
 # Updates dics.dir and print out notice after uninstall
 cannadic_pkg_postrm() {
        update-cannadic-dir
+
        einfo
        einfo "Please restart cannaserver to fit changes."
        einfo "and modify your config file (~/.canna) to disable dictionary."
 
-       if [ -n "${CANNADICS}" ] ; then
-               einfo "e.g) delete $(for d in ${CANNADICS}; do
-                               echo -n "\"$d\" "
-                               done)from section use-dictionary()."
+       if [[ -n "${CANNADICS}" ]]; then
+               einfo "e.g) delete $(for d in ${CANNADICS}; do echo -n "\"${d}\" "; done)from section use-dictionary()."
        fi
 
        einfo