Gentoo Archives: gentoo-dev

From: Doug Freed <dwfreed@×××.edu>
To: gentoo-dev@l.g.o
Subject: [gentoo-dev] [PATCH] depend.apache.eclass: fix for EAPI=6
Date: Wed, 07 Dec 2016 03:11:20
Message-Id: 1481080226-29956-1-git-send-email-dwfreed@mtu.edu
1 This also fixes various other code smells. I wrote this back in the start of
2 October, and never got around to sending it to the list for review. A note:
3 given how extensively this patch changes the eclass, it is suggested that it
4 actually become depend.apache-r1 and only support EAPI=6, and the EAPI=6
5 ebuilds that presently inherit depend.apache can inherit this instead.
6 ---
7 eclass/depend.apache.eclass | 156 ++++++++++++++++++++++++++------------------
8 1 file changed, 93 insertions(+), 63 deletions(-)
9
10 diff --git a/eclass/depend.apache.eclass b/eclass/depend.apache.eclass
11 index b69c2ec..2ef18cf 100644
12 --- a/eclass/depend.apache.eclass
13 +++ b/eclass/depend.apache.eclass
14 @@ -36,23 +36,21 @@
15 # want_apache2 server
16 #
17 # pkg_setup() {
18 -# depend.apache_pkg_setup server
19 +# depend.apache_pkg_setup
20 # }
21 # @CODE
22 -
23 -inherit multilib
24 +#
25 +# NOTE: Unless you have an indirect dependency on Apache, if you have your
26 +# own pkg_setup, you must call depend.apache_pkg_setup to get the variables
27 +# provided by this eclass.
28
29 case ${EAPI:-0} in
30 - 0|1|2|3|4|5)
31 + 2|3|4|5)
32 + inherit multilib
33 ;;
34 6)
35 - ewarn
36 - ewarn "EAPI=${EAPI} is not supported by depend.apache.eclass."
37 - ewarn "This means that ${CATEGORY}/${PF} is most likely buggy."
38 - ewarn "Please file a report on https://bugs.gentoo.org/"
39 - ewarn
40 ;;
41 - *)
42 + 0|1|*)
43 die "EAPI=${EAPI} is not supported by depend.apache.eclass"
44 ;;
45 esac
46 @@ -64,47 +62,47 @@ esac
47 # @ECLASS-VARIABLE: APACHE_VERSION
48 # @DESCRIPTION:
49 # Stores the version of apache we are going to be ebuilding.
50 -# This variable is set by the want/need_apache functions.
51 +# This variable is set by depend.apache-pkg_setup.
52
53 # @ECLASS-VARIABLE: APXS
54 # @DESCRIPTION:
55 # Path to the apxs tool.
56 -# This variable is set by the want/need_apache functions.
57 +# This variable is set by depend.apache-pkg_setup.
58
59 # @ECLASS-VARIABLE: APACHE_BIN
60 # @DESCRIPTION:
61 # Path to the apache binary.
62 -# This variable is set by the want/need_apache functions.
63 +# This variable is set by depend.apache-pkg_setup.
64
65 # @ECLASS-VARIABLE: APACHE_CTL
66 # @DESCRIPTION:
67 # Path to the apachectl tool.
68 -# This variable is set by the want/need_apache functions.
69 +# This variable is set by depend.apache-pkg_setup.
70
71 # @ECLASS-VARIABLE: APACHE_BASEDIR
72 # @DESCRIPTION:
73 # Path to the server root directory.
74 -# This variable is set by the want/need_apache functions.
75 +# This variable is set by depend.apache-pkg_setup.
76
77 # @ECLASS-VARIABLE: APACHE_CONFDIR
78 # @DESCRIPTION:
79 # Path to the configuration file directory.
80 -# This variable is set by the want/need_apache functions.
81 +# This variable is set by depend.apache-pkg_setup.
82
83 # @ECLASS-VARIABLE: APACHE_MODULES_CONFDIR
84 # @DESCRIPTION:
85 # Path where module configuration files are kept.
86 -# This variable is set by the want/need_apache functions.
87 +# This variable is set by depend.apache-pkg_setup.
88
89 # @ECLASS-VARIABLE: APACHE_VHOSTS_CONFDIR
90 # @DESCRIPTION:
91 # Path where virtual host configuration files are kept.
92 -# This variable is set by the want/need_apache functions.
93 +# This variable is set by depend.apache-pkg_setup.
94
95 # @ECLASS-VARIABLE: APACHE_MODULESDIR
96 # @DESCRIPTION:
97 # Path where we install modules.
98 -# This variable is set by the want/need_apache functions.
99 +# This variable is set by depend.apache-pkg_setup.
100
101 # @ECLASS-VARIABLE: APACHE_DEPEND
102 # @DESCRIPTION:
103 @@ -126,6 +124,17 @@ APACHE2_2_DEPEND="=www-servers/apache-2.2*"
104 # Dependencies for Apache 2.4.x
105 APACHE2_4_DEPEND="=www-servers/apache-2.4*"
106
107 +# @ECLASS-VARIABLE: APACHE_DEPENDENCY
108 +# @INTERNAL
109 +# @DESCRIPTION:
110 +# Whether we want or need Apache (used in pkg_setup)
111 +APACHE_DEPENDENCY="none"
112 +
113 +# @ECLASS-VARIABLE: APACHE_USEFLAG
114 +# @INTERNAL
115 +# @DESCRIPTION:
116 +# What useflag indicates we want apache2, defaults to apache2
117 +APACHE_USEFLAG="apache2"
118
119 # ==============================================================================
120 # INTERNAL FUNCTIONS
121 @@ -134,8 +143,6 @@ APACHE2_4_DEPEND="=www-servers/apache-2.4*"
122 _init_apache2() {
123 debug-print-function $FUNCNAME $*
124
125 - # WARNING: Do not use these variables with anything that is put
126 - # into the dependency cache (DEPEND/RDEPEND/etc)
127 APACHE_VERSION="2"
128 APXS="/usr/sbin/apxs2"
129 APACHE_BIN="/usr/sbin/apache2"
130 @@ -153,16 +160,42 @@ _init_no_apache() {
131 APACHE_VERSION="0"
132 }
133
134 +# @FUNCTION: _apache_dependency
135 +# @USAGE: { want | need } dependency [myiuse]
136 +# @DESCRIPTION:
137 +# Sets up apache dependencies. First parameter is the literal string "want" or
138 +# "need" to indicate the type of dependency. Second parameter is the dependency
139 +# string for {R,}DEPEND. Third parameter overrides the default useflag
140 +# indicating apache2 is wanted.
141 +_apache_dependency() {
142 + debug-print-function $FUNCNAME $*
143 +
144 + case $1 in
145 + want)
146 + APACHE_USEFLAG="${3:-${APACHE_USEFLAG}}"
147 + IUSE="${IUSE} ${APACHE_USEFLAG}"
148 + DEPEND="${DEPEND} ${APACHE_USEFLAG}? ( $2 )"
149 + RDEPEND="${RDEPEND} ${APACHE_USEFLAG}? ( $2 )"
150 + ;;
151 + need)
152 + DEPEND="${DEPEND} $2"
153 + RDEPEND="${RDEPEND} $2"
154 + ;;
155 + *)
156 + die "Invalid first parameter to $FUNCNAME"
157 + ;;
158 + esac
159 + APACHE_DEPENDENCY="$1"
160 +}
161 +
162 # ==============================================================================
163 # PUBLIC FUNCTIONS
164 # ==============================================================================
165
166 # @FUNCTION: depend.apache_pkg_setup
167 -# @USAGE: [myiuse]
168 # @DESCRIPTION:
169 -# An ebuild calls this in pkg_setup() to initialize variables for optional
170 -# apache-2.x support. If the myiuse parameter is not given it defaults to
171 -# apache2.
172 +# An ebuild calls this in pkg_setup() to initialize variables for apache-2.x
173 +# support.
174 depend.apache_pkg_setup() {
175 debug-print-function $FUNCNAME $*
176
177 @@ -170,14 +203,23 @@ depend.apache_pkg_setup() {
178 die "$FUNCNAME() should be called in pkg_setup()"
179 fi
180
181 - local myiuse=${1:-apache2}
182 - if has ${myiuse} ${IUSE}; then
183 - if use ${myiuse}; then
184 + case ${APACHE_DEPENDENCY} in
185 + want)
186 + if use ${APACHE_USEFLAG}; then
187 + _init_apache2
188 + else
189 + _init_no_apache
190 + fi
191 + ;;
192 + need)
193 _init_apache2
194 - else
195 - _init_no_apache
196 - fi
197 - fi
198 + ;;
199 + none)
200 + ;;
201 + *)
202 + die "Invalid APACHE_DEPENDENCY setting"
203 + ;;
204 + esac
205 }
206
207 # @FUNCTION: want_apache
208 @@ -185,8 +227,6 @@ depend.apache_pkg_setup() {
209 # @DESCRIPTION:
210 # An ebuild calls this to get the dependency information for optional apache
211 # support. If the myiuse parameter is not given it defaults to apache2.
212 -# An ebuild should additionally call depend.apache_pkg_setup() in pkg_setup()
213 -# with the same myiuse parameter.
214 want_apache() {
215 debug-print-function $FUNCNAME $*
216 want_apache2 "$@"
217 @@ -197,15 +237,9 @@ want_apache() {
218 # @DESCRIPTION:
219 # An ebuild calls this to get the dependency information for optional apache-2.x
220 # support. If the myiuse parameter is not given it defaults to apache2.
221 -# An ebuild should additionally call depend.apache_pkg_setup() in pkg_setup()
222 -# with the same myiuse parameter.
223 want_apache2() {
224 debug-print-function $FUNCNAME $*
225 -
226 - local myiuse=${1:-apache2}
227 - IUSE="${IUSE} ${myiuse}"
228 - DEPEND="${DEPEND} ${myiuse}? ( ${APACHE2_DEPEND} )"
229 - RDEPEND="${RDEPEND} ${myiuse}? ( ${APACHE2_DEPEND} )"
230 + _apache_dependency want "${APACHE2_DEPEND}" "$@"
231 }
232
233 # @FUNCTION: want_apache2_2
234 @@ -214,15 +248,20 @@ want_apache2() {
235 # An ebuild calls this to get the dependency information for optional
236 # apache-2.2.x support. If the myiuse parameter is not given it defaults to
237 # apache2.
238 -# An ebuild should additionally call depend.apache_pkg_setup() in pkg_setup()
239 -# with the same myiuse parameter.
240 want_apache2_2() {
241 debug-print-function $FUNCNAME $*
242 + _apache_dependency want "${APACHE2_2_DEPEND}" "$@"
243 +}
244
245 - local myiuse=${1:-apache2}
246 - IUSE="${IUSE} ${myiuse}"
247 - DEPEND="${DEPEND} ${myiuse}? ( ${APACHE2_2_DEPEND} )"
248 - RDEPEND="${RDEPEND} ${myiuse}? ( ${APACHE2_2_DEPEND} )"
249 +# @FUNCTION: want_apache2_4
250 +# @USAGE: [myiuse]
251 +# @DESCRIPTION:
252 +# An ebuild calls this to get the dependency information for optional
253 +# apache-2.4.x support. If the myiuse parameter is not given it defaults to
254 +# apache2.
255 +want_apache2_4() {
256 + debug-print-function $FUNCNAME $*
257 + _apache_dependency want "${APACHE2_4_DEPEND}" "$@"
258 }
259
260 # @FUNCTION: need_apache
261 @@ -238,10 +277,7 @@ need_apache() {
262 # An ebuild calls this to get the dependency information for apache-2.x.
263 need_apache2() {
264 debug-print-function $FUNCNAME $*
265 -
266 - DEPEND="${DEPEND} ${APACHE2_DEPEND}"
267 - RDEPEND="${RDEPEND} ${APACHE2_DEPEND}"
268 - _init_apache2
269 + _apache_dependency need "${APACHE2_DEPEND}" "$@"
270 }
271
272 # @FUNCTION: need_apache2_2
273 @@ -249,21 +285,15 @@ need_apache2() {
274 # An ebuild calls this to get the dependency information for apache-2.2.x.
275 need_apache2_2() {
276 debug-print-function $FUNCNAME $*
277 -
278 - DEPEND="${DEPEND} ${APACHE2_2_DEPEND}"
279 - RDEPEND="${RDEPEND} ${APACHE2_2_DEPEND}"
280 - _init_apache2
281 + _apache_dependency need "${APACHE2_2_DEPEND}" "$@"
282 }
283
284 # @FUNCTION: need_apache2_4
285 # @DESCRIPTION:
286 # An ebuild calls this to get the dependency information for apache-2.4.x.
287 need_apache2_4() {
288 - debug-print-function $FUNCNAME $*
289 -
290 - DEPEND="${DEPEND} ${APACHE2_4_DEPEND}"
291 - RDEPEND="${RDEPEND} ${APACHE2_4_DEPEND}"
292 - _init_apache2
293 + debug-print-function $FUNCNAME $*
294 + _apache_dependency need "${APACHE2_4_DEPEND}" "$@"
295 }
296
297 # @FUNCTION: has_apache
298 @@ -290,7 +320,7 @@ has_apache() {
299 has_apache_threads() {
300 debug-print-function $FUNCNAME $*
301
302 - if ! built_with_use www-servers/apache threads; then
303 + if ! has_version 'www-servers/apache[threads]'; then
304 return
305 fi
306
307 @@ -313,14 +343,14 @@ has_apache_threads() {
308 has_apache_threads_in() {
309 debug-print-function $FUNCNAME $*
310
311 - if ! built_with_use www-servers/apache threads; then
312 + if ! has_version 'www-servers/apache[threads]'; then
313 return
314 fi
315
316 local myforeign="$1"
317 local myflag="${2:-threads}"
318
319 - if ! built_with_use ${myforeign} ${myflag}; then
320 + if ! has_version "${myforeign}[${myflag}]"; then
321 echo
322 eerror "You need to enable USE flag '${myflag}' in ${myforeign} to"
323 eerror "build a thread-safe version of ${CATEGORY}/${PN} for use"
324 --
325 1.9.1

Replies

Subject Author
Re: [gentoo-dev] [PATCH] depend.apache.eclass: fix for EAPI=6 "Andreas K. Huettel" <dilfridge@g.o>