1 # Copyright 1999-2012 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
5 # @ECLASS: depend.apache.eclass
7 # apache-devs@gentoo.org
8 # @BLURB: Functions to allow ebuilds to depend on apache
10 # This eclass handles depending on apache in a sane way and provides information
11 # about where certain binaries and configuration files are located.
13 # To make use of this eclass simply call one of the need/want_apache functions
14 # described below. Make sure you use the need/want_apache call after you have
15 # defined DEPEND and RDEPEND. Also note that you can not rely on the automatic
16 # RDEPEND=DEPEND that portage does if you use this eclass.
18 # See Bug 107127 for more information.
22 # Here is an example of an ebuild depending on apache:
25 # DEPEND="virtual/Perl-CGI"
30 # Another example which demonstrates non-standard IUSE options for optional
34 # DEPEND="server? ( virtual/Perl-CGI )"
39 # depend.apache_pkg_setup server
50 die "EAPI=${EAPI} is not supported by depend.apache.eclass"
54 # ==============================================================================
56 # ==============================================================================
58 # @ECLASS-VARIABLE: APACHE_VERSION
60 # Stores the version of apache we are going to be ebuilding.
61 # This variable is set by the want/need_apache functions.
63 # @ECLASS-VARIABLE: APXS
65 # Path to the apxs tool.
66 # This variable is set by the want/need_apache functions.
68 # @ECLASS-VARIABLE: APACHE_BIN
70 # Path to the apache binary.
71 # This variable is set by the want/need_apache functions.
73 # @ECLASS-VARIABLE: APACHE_CTL
75 # Path to the apachectl tool.
76 # This variable is set by the want/need_apache functions.
78 # @ECLASS-VARIABLE: APACHE_BASEDIR
80 # Path to the server root directory.
81 # This variable is set by the want/need_apache functions (EAPI=0 through 5)
82 # or depend.apache_pkg_setup (EAPI=6 and later).
84 # @ECLASS-VARIABLE: APACHE_CONFDIR
86 # Path to the configuration file directory.
87 # This variable is set by the want/need_apache functions.
89 # @ECLASS-VARIABLE: APACHE_MODULES_CONFDIR
91 # Path where module configuration files are kept.
92 # This variable is set by the want/need_apache functions.
94 # @ECLASS-VARIABLE: APACHE_VHOSTS_CONFDIR
96 # Path where virtual host configuration files are kept.
97 # This variable is set by the want/need_apache functions.
99 # @ECLASS-VARIABLE: APACHE_MODULESDIR
101 # Path where we install modules.
102 # This variable is set by the want/need_apache functions (EAPI=0 through 5)
103 # or depend.apache_pkg_setup (EAPI=6 and later).
105 # @ECLASS-VARIABLE: APACHE_DEPEND
107 # Dependencies for Apache
108 APACHE_DEPEND="www-servers/apache"
110 # @ECLASS-VARIABLE: APACHE2_DEPEND
112 # Dependencies for Apache 2.x
113 APACHE2_DEPEND="=www-servers/apache-2*"
115 # @ECLASS-VARIABLE: APACHE2_2_DEPEND
117 # Dependencies for Apache 2.2.x
118 APACHE2_2_DEPEND="=www-servers/apache-2.2*"
120 # @ECLASS-VARIABLE: APACHE2_4_DEPEND
122 # Dependencies for Apache 2.4.x
123 APACHE2_4_DEPEND="=www-servers/apache-2.4*"
126 # ==============================================================================
128 # ==============================================================================
131 debug-print-function $FUNCNAME $*
133 # WARNING: Do not use these variables with anything that is put
134 # into the dependency cache (DEPEND/RDEPEND/etc)
136 APXS="/usr/sbin/apxs2"
137 APACHE_BIN="/usr/sbin/apache2"
138 APACHE_CTL="/usr/sbin/apache2ctl"
139 APACHE_INCLUDEDIR="/usr/include/apache2"
140 APACHE_CONFDIR="/etc/apache2"
141 APACHE_MODULES_CONFDIR="${APACHE_CONFDIR}/modules.d"
142 APACHE_VHOSTS_CONFDIR="${APACHE_CONFDIR}/vhosts.d"
151 _init_apache2_late() {
152 APACHE_BASEDIR="/usr/$(get_libdir)/apache2"
153 APACHE_MODULESDIR="${APACHE_BASEDIR}/modules"
157 debug-print-function $FUNCNAME $*
161 # ==============================================================================
163 # ==============================================================================
165 # @FUNCTION: depend.apache_pkg_setup
168 # An ebuild calls this in pkg_setup() to initialize variables for optional
169 # apache-2.x support. If the myiuse parameter is not given it defaults to
171 depend.apache_pkg_setup() {
172 debug-print-function $FUNCNAME $*
174 if [[ "${EBUILD_PHASE}" != "setup" ]]; then
175 die "$FUNCNAME() should be called in pkg_setup()"
178 local myiuse=${1:-apache2}
179 if has ${myiuse} ${IUSE}; then
180 if use ${myiuse}; then
196 # @FUNCTION: want_apache
199 # An ebuild calls this to get the dependency information for optional apache
200 # support. If the myiuse parameter is not given it defaults to apache2.
201 # An ebuild should additionally call depend.apache_pkg_setup() in pkg_setup()
202 # with the same myiuse parameter.
204 debug-print-function $FUNCNAME $*
208 # @FUNCTION: want_apache2
211 # An ebuild calls this to get the dependency information for optional apache-2.x
212 # support. If the myiuse parameter is not given it defaults to apache2.
213 # An ebuild should additionally call depend.apache_pkg_setup() in pkg_setup()
214 # with the same myiuse parameter.
216 debug-print-function $FUNCNAME $*
218 local myiuse=${1:-apache2}
219 IUSE="${IUSE} ${myiuse}"
220 DEPEND="${DEPEND} ${myiuse}? ( ${APACHE2_DEPEND} )"
221 RDEPEND="${RDEPEND} ${myiuse}? ( ${APACHE2_DEPEND} )"
224 # @FUNCTION: want_apache2_2
227 # An ebuild calls this to get the dependency information for optional
228 # apache-2.2.x support. If the myiuse parameter is not given it defaults to
230 # An ebuild should additionally call depend.apache_pkg_setup() in pkg_setup()
231 # with the same myiuse parameter.
233 debug-print-function $FUNCNAME $*
235 local myiuse=${1:-apache2}
236 IUSE="${IUSE} ${myiuse}"
237 DEPEND="${DEPEND} ${myiuse}? ( ${APACHE2_2_DEPEND} )"
238 RDEPEND="${RDEPEND} ${myiuse}? ( ${APACHE2_2_DEPEND} )"
241 # @FUNCTION: want_apache2_4
244 # An ebuild calls this to get the dependency information for optional
245 # apache-2.4.x support. If the myiuse parameter is not given it defaults to
247 # An ebuild should additionally call depend.apache_pkg_setup() in pkg_setup()
248 # with the same myiuse parameter.
250 debug-print-function $FUNCNAME $*
252 local myiuse=${1:-apache2}
253 IUSE="${IUSE} ${myiuse}"
254 DEPEND="${DEPEND} ${myiuse}? ( ${APACHE2_4_DEPEND} )"
255 RDEPEND="${RDEPEND} ${myiuse}? ( ${APACHE2_4_DEPEND} )"
258 # @FUNCTION: need_apache
260 # An ebuild calls this to get the dependency information for apache.
262 debug-print-function $FUNCNAME $*
266 # @FUNCTION: need_apache2
268 # An ebuild calls this to get the dependency information for apache-2.x.
270 debug-print-function $FUNCNAME $*
272 DEPEND="${DEPEND} ${APACHE2_DEPEND}"
273 RDEPEND="${RDEPEND} ${APACHE2_DEPEND}"
277 # @FUNCTION: need_apache2_2
279 # An ebuild calls this to get the dependency information for apache-2.2.x.
281 debug-print-function $FUNCNAME $*
283 DEPEND="${DEPEND} ${APACHE2_2_DEPEND}"
284 RDEPEND="${RDEPEND} ${APACHE2_2_DEPEND}"
288 # @FUNCTION: need_apache2_4
290 # An ebuild calls this to get the dependency information for apache-2.4.x.
292 debug-print-function $FUNCNAME $*
294 DEPEND="${DEPEND} ${APACHE2_4_DEPEND}"
295 RDEPEND="${RDEPEND} ${APACHE2_4_DEPEND}"
299 # @FUNCTION: has_apache
301 # An ebuild calls this to get runtime variables for an indirect apache
302 # dependency without USE-flag, in which case want_apache does not work.
303 # DO NOT call this function in global scope.
305 debug-print-function $FUNCNAME $*
307 if has_version '>=www-servers/apache-2'; then
314 # @FUNCTION: has_apache_threads
317 # An ebuild calls this to make sure thread-safety is enabled if apache has been
318 # built with a threaded MPM. If the myflag parameter is not given it defaults to
320 has_apache_threads() {
321 debug-print-function $FUNCNAME $*
325 die "depend.apache.eclass: has_apache_threads is not supported for EAPI=${EAPI:-0}"
329 if ! has_version 'www-servers/apache[threads]'; then
333 local myflag="${1:-threads}"
335 if ! use ${myflag}; then
337 eerror "You need to enable USE flag '${myflag}' to build a thread-safe version"
338 eerror "of ${CATEGORY}/${PN} for use with www-servers/apache"
339 die "Need missing USE flag '${myflag}'"
343 # @FUNCTION: has_apache_threads_in
344 # @USAGE: <myforeign> [myflag]
346 # An ebuild calls this to make sure thread-safety is enabled in a foreign
347 # package if apache has been built with a threaded MPM. If the myflag parameter
348 # is not given it defaults to threads.
349 has_apache_threads_in() {
350 debug-print-function $FUNCNAME $*
354 die "depend.apache.eclass: has_apache_threads_in is not supported for EAPI=${EAPI:-0}"
358 if ! has_version 'www-servers/apache[threads]'; then
363 local myflag="${2:-threads}"
365 if ! has_version "${myforeign}[${myflag}]"; then
367 eerror "You need to enable USE flag '${myflag}' in ${myforeign} to"
368 eerror "build a thread-safe version of ${CATEGORY}/${PN} for use"
369 eerror "with www-servers/apache"
370 die "Need missing USE flag '${myflag}' in ${myforeign}"
374 EXPORT_FUNCTIONS pkg_setup