Gentoo Archives: gentoo-dev

From: Ulrich Mueller <ulm@g.o>
To: gentoo-dev@l.g.o
Cc: "Marty E. Plummer" <hanetzer@×××××××××.com>
Subject: Re: [gentoo-dev] [PATCH] freedict.eclass: rename dict.eclass, generalize
Date: Wed, 25 Apr 2018 05:28:24
Message-Id: 23264.4588.243239.14061@a1i15.kph.uni-mainz.de
In Reply to: [gentoo-dev] [PATCH] freedict.eclass: rename dict.eclass, generalize by "Marty E. Plummer"
1 >>>>> On Tue, 24 Apr 2018, Marty E Plummer wrote:
2
3 > Reworked to be usable with app-dicts/dictd-* ebuilds to avoid code
4 > duplication
5
6 I don't see much code duplication there, so I think it would be
7 cleaner to have a second eclass, rather than adding conditionals to
8 the existing one.
9
10 > You can reference this pull request to get an idea as to the usage.
11
12 > https://github.com/gentoo/gentoo/pull/8106
13
14 > Package-Manager: Portage-2.3.31, Repoman-2.3.9
15 > ---
16 > eclass/dict.eclass | 75 ++++++++++++++++++++++++++++++++++++++++++
17 > eclass/freedict.eclass | 51 ----------------------------
18 > 2 files changed, 75 insertions(+), 51 deletions(-)
19 > create mode 100644 eclass/dict.eclass
20 > delete mode 100644 eclass/freedict.eclass
21 > diff --git a/eclass/dict.eclass b/eclass/dict.eclass
22 > new file mode 100644
23 > index 00000000000..8d523e3863e
24 > --- /dev/null
25 > +++ b/eclass/dict.eclass
26 > @@ -0,0 +1,75 @@
27 > +# Copyright 1999-2018 Gentoo Foundation
28 > +# Distributed under the terms of the GNU General Public License v2
29 > +
30 > +# @ECLASS: dict.eclass
31 > +# @MAINTAINER:
32 > +# maintainer-needed@g.o
33 > +# @AUTHOR:
34 > +# Original author: Seemant Kulleen
35 > +# @BLURB: Ease the installation of dict and freedict translation dictionaries
36 > +# @DESCRIPTION:
37 > +# This eclass exists to ease the installation of dictd and freedictd translation
38 > +# dictionaries. The only variables which need to be defined in the actual
39 > +# ebuilds are FORLANG and TOLANG for the source and target languages,
40 > +# respectively, and DICTS if the package ships more than one dictionary
41 > +# and cannot be determined from ${PN}.
42 > +
43 > +# @ECLASS-VARIABLE: DICTS
44 > +# @DESCRIPTION:
45 > +# Array of dictionary files (foo.dict.dz and foo.index) to be installed during
46 > +# dict_src_install.
47 > +
48 > +# @ECLASS-VARIABLE: FORLANG
49 > +# @DESCRIPTION:
50 > +# Please see above for a description.
51 > +
52 > +# @ECLASS-VARIABLE: TOLANG
53 > +# @DESCRIPTION:
54 > +# Please see above for a description.
55 > +
56 > +if [[ -z ${_DICT_ECLASS} ]]; then
57 > +_DICT_ECLASS=1
58
59 Unless dict.eclass is inherited by another eclass, this is not needed
60 and will only unnecessarily add a variable to the environment.
61
62 > +
63 > +case ${EAPI:-0} in
64 > + 6) ;;
65 > + *) die "${ECLASS}.eclass is banned in EAPI=${EAPI}" ;;
66 > +esac
67 > +
68 > +if [[ ${PN} == *freedict-* ]]; then
69 > + MY_P=${PN/freedict-/}
70 > + DICTS=( ${MY_P} )
71 > +
72 > + DESCRIPTION="Freedict for language translation from ${FORLANG} to ${TOLANG}"
73 > + HOMEPAGE="http://freedict.sourceforge.net/"
74 > + SRC_URI="http://freedict.sourceforge.net/download/linux/${MY_P}.tar.gz"
75 > +elif [[ ${PN} == *dictd-* ]]; then
76 > + MY_P=${PN/dictd-/}
77 > + DICTS=( ${MY_P} )
78 > +
79 > + DESCRIPTION="${MY_P} dictionary for dictd"
80 > + HOMEPAGE="http://www.dict.org/"
81 > +fi
82 > +
83 > +LICENSE="GPL-2+"
84 > +SLOT="0"
85 > +IUSE=""
86
87 Why this empty assignment? Please remove.
88
89 > +
90 > +RDEPEND="app-text/dictd"
91 > +
92 > +S="${WORKDIR}"
93 > +
94 > +# @FUNCTION: dict_src_install
95 > +# @DESCRIPTION:
96 > +# The freedict src_install function, which is exported
97 > +dict_src_install() {
98 > + insinto /usr/$(get_libdir)/dict
99 > + for dict in "${DICTS[@]}"; do
100
101 Local variable declaration for dict is missing (but see below).
102
103 > + doins ${dict}.dict.dz
104 > + doins ${dict}.index
105 > + done
106
107 The loop is not needed, because doins accepts several arguments.
108 For example:
109 doins "${DICTS[@]/%/.dict.dz}"
110
111 > + einstalldocs
112 > +}
113 > +
114 > +EXPORT_FUNCTIONS src_install
115 > +
116 > +fi

Replies

Subject Author
Re: [gentoo-dev] [PATCH] freedict.eclass: rename dict.eclass, generalize "Marty E. Plummer" <hanetzer@×××××××××.com>