>>>>> On Tue, 24 Apr 2018, Marty E Plummer wrote: > Reworked to be usable with app-dicts/dictd-* ebuilds to avoid code > duplication
I don't see much code duplication there, so I think it would be cleaner to have a second eclass, rather than adding conditionals to the existing one. > You can reference this pull request to get an idea as to the usage. > https://github.com/gentoo/gentoo/pull/8106 > Package-Manager: Portage-2.3.31, Repoman-2.3.9 > --- > eclass/dict.eclass | 75 ++++++++++++++++++++++++++++++++++++++++++ > eclass/freedict.eclass | 51 ---------------------------- > 2 files changed, 75 insertions(+), 51 deletions(-) > create mode 100644 eclass/dict.eclass > delete mode 100644 eclass/freedict.eclass > diff --git a/eclass/dict.eclass b/eclass/dict.eclass > new file mode 100644 > index 00000000000..8d523e3863e > --- /dev/null > +++ b/eclass/dict.eclass > @@ -0,0 +1,75 @@ > +# Copyright 1999-2018 Gentoo Foundation > +# Distributed under the terms of the GNU General Public License v2 > + > +# @ECLASS: dict.eclass > +# @MAINTAINER: > +# maintainer-nee...@gentoo.org > +# @AUTHOR: > +# Original author: Seemant Kulleen > +# @BLURB: Ease the installation of dict and freedict translation dictionaries > +# @DESCRIPTION: > +# This eclass exists to ease the installation of dictd and freedictd > translation > +# dictionaries. The only variables which need to be defined in the actual > +# ebuilds are FORLANG and TOLANG for the source and target languages, > +# respectively, and DICTS if the package ships more than one dictionary > +# and cannot be determined from ${PN}. > + > +# @ECLASS-VARIABLE: DICTS > +# @DESCRIPTION: > +# Array of dictionary files (foo.dict.dz and foo.index) to be installed > during > +# dict_src_install. > + > +# @ECLASS-VARIABLE: FORLANG > +# @DESCRIPTION: > +# Please see above for a description. > + > +# @ECLASS-VARIABLE: TOLANG > +# @DESCRIPTION: > +# Please see above for a description. > + > +if [[ -z ${_DICT_ECLASS} ]]; then > +_DICT_ECLASS=1 Unless dict.eclass is inherited by another eclass, this is not needed and will only unnecessarily add a variable to the environment. > + > +case ${EAPI:-0} in > + 6) ;; > + *) die "${ECLASS}.eclass is banned in EAPI=${EAPI}" ;; > +esac > + > +if [[ ${PN} == *freedict-* ]]; then > + MY_P=${PN/freedict-/} > + DICTS=( ${MY_P} ) > + > + DESCRIPTION="Freedict for language translation from ${FORLANG} to > ${TOLANG}" > + HOMEPAGE="http://freedict.sourceforge.net/" > + SRC_URI="http://freedict.sourceforge.net/download/linux/${MY_P}.tar.gz" > +elif [[ ${PN} == *dictd-* ]]; then > + MY_P=${PN/dictd-/} > + DICTS=( ${MY_P} ) > + > + DESCRIPTION="${MY_P} dictionary for dictd" > + HOMEPAGE="http://www.dict.org/" > +fi > + > +LICENSE="GPL-2+" > +SLOT="0" > +IUSE="" Why this empty assignment? Please remove. > + > +RDEPEND="app-text/dictd" > + > +S="${WORKDIR}" > + > +# @FUNCTION: dict_src_install > +# @DESCRIPTION: > +# The freedict src_install function, which is exported > +dict_src_install() { > + insinto /usr/$(get_libdir)/dict > + for dict in "${DICTS[@]}"; do Local variable declaration for dict is missing (but see below). > + doins ${dict}.dict.dz > + doins ${dict}.index > + done The loop is not needed, because doins accepts several arguments. For example: doins "${DICTS[@]/%/.dict.dz}" > + einstalldocs > +} > + > +EXPORT_FUNCTIONS src_install > + > +fi