1 # Copyright 1999-2012 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
4 # @ECLASS: depend.apache.eclass
6 # apache-devs@gentoo.org
7 # @BLURB: Functions to allow ebuilds to depend on apache
9 # This eclass handles depending on apache in a sane way and provides information
10 # about where certain binaries and configuration files are located.
12 # To make use of this eclass simply call one of the need/want_apache functions
13 # described below. Make sure you use the need/want_apache call after you have
14 # defined DEPEND and RDEPEND. Also note that you can not rely on the automatic
15 # RDEPEND=DEPEND that portage does if you use this eclass.
17 # See Bug 107127 for more information.
21 # Here is an example of an ebuild depending on apache:
24 # DEPEND="virtual/Perl-CGI"
29 # Another example which demonstrates non-standard IUSE options for optional
33 # DEPEND="server? ( virtual/Perl-CGI )"
38 # depend.apache_pkg_setup server
49 die "EAPI=${EAPI} is not supported by depend.apache.eclass"
53 # ==============================================================================
55 # ==============================================================================
57 # @ECLASS-VARIABLE: APACHE_VERSION
59 # Stores the version of apache we are going to be ebuilding.
60 # This variable is set by the want/need_apache functions.
62 # @ECLASS-VARIABLE: APXS
64 # Path to the apxs tool.
65 # This variable is set by the want/need_apache functions.
67 # @ECLASS-VARIABLE: APACHE_BIN
69 # Path to the apache binary.
70 # This variable is set by the want/need_apache functions.
72 # @ECLASS-VARIABLE: APACHE_CTL
74 # Path to the apachectl tool.
75 # This variable is set by the want/need_apache functions.
77 # @ECLASS-VARIABLE: APACHE_BASEDIR
79 # Path to the server root directory.
80 # This variable is set by the want/need_apache functions (EAPI=0 through 5)
81 # or depend.apache_pkg_setup (EAPI=6 and later).
83 # @ECLASS-VARIABLE: APACHE_CONFDIR
85 # Path to the configuration file directory.
86 # This variable is set by the want/need_apache functions.
88 # @ECLASS-VARIABLE: APACHE_MODULES_CONFDIR
90 # Path where module configuration files are kept.
91 # This variable is set by the want/need_apache functions.
93 # @ECLASS-VARIABLE: APACHE_VHOSTS_CONFDIR
95 # Path where virtual host configuration files are kept.
96 # This variable is set by the want/need_apache functions.
98 # @ECLASS-VARIABLE: APACHE_MODULESDIR
100 # Path where we install modules.
101 # This variable is set by the want/need_apache functions (EAPI=0 through 5)
102 # or depend.apache_pkg_setup (EAPI=6 and later).
104 # @ECLASS-VARIABLE: APACHE_DEPEND
106 # Dependencies for Apache
107 APACHE_DEPEND="www-servers/apache"
109 # @ECLASS-VARIABLE: APACHE2_DEPEND
111 # Dependencies for Apache 2.x
112 APACHE2_DEPEND="=www-servers/apache-2*"
114 # @ECLASS-VARIABLE: APACHE2_2_DEPEND
116 # Dependencies for Apache 2.2.x
117 APACHE2_2_DEPEND="=www-servers/apache-2.2*"
119 # @ECLASS-VARIABLE: APACHE2_4_DEPEND
121 # Dependencies for Apache 2.4.x
122 APACHE2_4_DEPEND="=www-servers/apache-2.4*"
125 # ==============================================================================
127 # ==============================================================================
130 debug-print-function $FUNCNAME $*
132 # WARNING: Do not use these variables with anything that is put
133 # into the dependency cache (DEPEND/RDEPEND/etc)
136 APACHE_BIN="/usr/sbin/apache2"
137 APACHE_CTL="/usr/sbin/apache2ctl"
138 APACHE_INCLUDEDIR="/usr/include/apache2"
139 APACHE_CONFDIR="/etc/apache2"
140 APACHE_MODULES_CONFDIR="${APACHE_CONFDIR}/modules.d"
141 APACHE_VHOSTS_CONFDIR="${APACHE_CONFDIR}/vhosts.d"
150 _init_apache2_late() {
151 APACHE_BASEDIR="/usr/$(get_libdir)/apache2"
152 APACHE_MODULESDIR="${APACHE_BASEDIR}/modules"
156 debug-print-function $FUNCNAME $*
160 # ==============================================================================
162 # ==============================================================================
164 # @FUNCTION: depend.apache_pkg_setup
167 # An ebuild calls this in pkg_setup() to initialize variables for optional
168 # apache-2.x support. If the myiuse parameter is not given it defaults to
170 depend.apache_pkg_setup() {
171 debug-print-function $FUNCNAME $*
173 if [[ "${EBUILD_PHASE}" != "setup" ]]; then
174 die "$FUNCNAME() should be called in pkg_setup()"
177 local myiuse=${1:-apache2}
181 if has ${myiuse} ${IUSE}; then
182 if use ${myiuse}; then
190 if in_iuse ${myiuse}; then
191 if use ${myiuse}; then
202 # @FUNCTION: want_apache
205 # An ebuild calls this to get the dependency information for optional apache
206 # support. If the myiuse parameter is not given it defaults to apache2.
207 # An ebuild should additionally call depend.apache_pkg_setup() in pkg_setup()
208 # with the same myiuse parameter.
210 debug-print-function $FUNCNAME $*
214 # @FUNCTION: want_apache2
217 # An ebuild calls this to get the dependency information for optional apache-2.x
218 # support. If the myiuse parameter is not given it defaults to apache2.
219 # An ebuild should additionally call depend.apache_pkg_setup() in pkg_setup()
220 # with the same myiuse parameter.
222 debug-print-function $FUNCNAME $*
224 local myiuse=${1:-apache2}
225 IUSE="${IUSE} ${myiuse}"
226 DEPEND="${DEPEND} ${myiuse}? ( ${APACHE2_DEPEND} )"
227 RDEPEND="${RDEPEND} ${myiuse}? ( ${APACHE2_DEPEND} )"
230 # @FUNCTION: want_apache2_2
233 # An ebuild calls this to get the dependency information for optional
234 # apache-2.2.x support. If the myiuse parameter is not given it defaults to
236 # An ebuild should additionally call depend.apache_pkg_setup() in pkg_setup()
237 # with the same myiuse parameter.
239 debug-print-function $FUNCNAME $*
241 local myiuse=${1:-apache2}
242 IUSE="${IUSE} ${myiuse}"
243 DEPEND="${DEPEND} ${myiuse}? ( ${APACHE2_2_DEPEND} )"
244 RDEPEND="${RDEPEND} ${myiuse}? ( ${APACHE2_2_DEPEND} )"
247 # @FUNCTION: want_apache2_4
250 # An ebuild calls this to get the dependency information for optional
251 # apache-2.4.x support. If the myiuse parameter is not given it defaults to
253 # An ebuild should additionally call depend.apache_pkg_setup() in pkg_setup()
254 # with the same myiuse parameter.
256 debug-print-function $FUNCNAME $*
258 local myiuse=${1:-apache2}
259 IUSE="${IUSE} ${myiuse}"
260 DEPEND="${DEPEND} ${myiuse}? ( ${APACHE2_4_DEPEND} )"
261 RDEPEND="${RDEPEND} ${myiuse}? ( ${APACHE2_4_DEPEND} )"
264 # @FUNCTION: need_apache
266 # An ebuild calls this to get the dependency information for apache.
268 debug-print-function $FUNCNAME $*
272 # @FUNCTION: need_apache2
274 # An ebuild calls this to get the dependency information for apache-2.x.
276 debug-print-function $FUNCNAME $*
278 DEPEND="${DEPEND} ${APACHE2_DEPEND}"
279 RDEPEND="${RDEPEND} ${APACHE2_DEPEND}"
283 # @FUNCTION: need_apache2_2
285 # An ebuild calls this to get the dependency information for apache-2.2.x.
287 debug-print-function $FUNCNAME $*
289 DEPEND="${DEPEND} ${APACHE2_2_DEPEND}"
290 RDEPEND="${RDEPEND} ${APACHE2_2_DEPEND}"
294 # @FUNCTION: need_apache2_4
296 # An ebuild calls this to get the dependency information for apache-2.4.x.
298 debug-print-function $FUNCNAME $*
300 DEPEND="${DEPEND} ${APACHE2_4_DEPEND}"
301 RDEPEND="${RDEPEND} ${APACHE2_4_DEPEND}"
305 # @FUNCTION: has_apache
307 # An ebuild calls this to get runtime variables for an indirect apache
308 # dependency without USE-flag, in which case want_apache does not work.
309 # DO NOT call this function in global scope.
311 debug-print-function $FUNCNAME $*
313 if has_version '>=www-servers/apache-2'; then
320 # @FUNCTION: has_apache_threads
323 # An ebuild calls this to make sure thread-safety is enabled if apache has been
324 # built with a threaded MPM. If the myflag parameter is not given it defaults to
326 has_apache_threads() {
327 debug-print-function $FUNCNAME $*
331 die "depend.apache.eclass: has_apache_threads is not supported for EAPI=${EAPI:-0}"
335 if ! has_version 'www-servers/apache[threads]'; then
339 local myflag="${1:-threads}"
341 if ! use ${myflag}; then
343 eerror "You need to enable USE flag '${myflag}' to build a thread-safe version"
344 eerror "of ${CATEGORY}/${PN} for use with www-servers/apache"
345 die "Need missing USE flag '${myflag}'"
349 # @FUNCTION: has_apache_threads_in
350 # @USAGE: <myforeign> [myflag]
352 # An ebuild calls this to make sure thread-safety is enabled in a foreign
353 # package if apache has been built with a threaded MPM. If the myflag parameter
354 # is not given it defaults to threads.
355 has_apache_threads_in() {
356 debug-print-function $FUNCNAME $*
360 die "depend.apache.eclass: has_apache_threads_in is not supported for EAPI=${EAPI:-0}"
364 if ! has_version 'www-servers/apache[threads]'; then
369 local myflag="${2:-threads}"
371 if ! has_version "${myforeign}[${myflag}]"; then
373 eerror "You need to enable USE flag '${myflag}' in ${myforeign} to"
374 eerror "build a thread-safe version of ${CATEGORY}/${PN} for use"
375 eerror "with www-servers/apache"
376 die "Need missing USE flag '${myflag}' in ${myforeign}"
380 EXPORT_FUNCTIONS pkg_setup