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
45 # ==============================================================================
47 # ==============================================================================
49 # @ECLASS-VARIABLE: APACHE_VERSION
51 # Stores the version of apache we are going to be ebuilding.
52 # This variable is set by the want/need_apache functions.
54 # @ECLASS-VARIABLE: APXS
56 # Path to the apxs tool.
57 # This variable is set by the want/need_apache functions.
59 # @ECLASS-VARIABLE: APACHE_BIN
61 # Path to the apache binary.
62 # This variable is set by the want/need_apache functions.
64 # @ECLASS-VARIABLE: APACHE_CTL
66 # Path to the apachectl tool.
67 # This variable is set by the want/need_apache functions.
69 # @ECLASS-VARIABLE: APACHE_BASEDIR
71 # Path to the server root directory.
72 # This variable is set by the want/need_apache functions.
74 # @ECLASS-VARIABLE: APACHE_CONFDIR
76 # Path to the configuration file directory.
77 # This variable is set by the want/need_apache functions.
79 # @ECLASS-VARIABLE: APACHE_MODULES_CONFDIR
81 # Path where module configuration files are kept.
82 # This variable is set by the want/need_apache functions.
84 # @ECLASS-VARIABLE: APACHE_VHOSTS_CONFDIR
86 # Path where virtual host configuration files are kept.
87 # This variable is set by the want/need_apache functions.
89 # @ECLASS-VARIABLE: APACHE_MODULESDIR
91 # Path where we install modules.
92 # This variable is set by the want/need_apache functions.
94 # @ECLASS-VARIABLE: APACHE_DEPEND
96 # Dependencies for Apache
97 APACHE_DEPEND="www-servers/apache"
99 # @ECLASS-VARIABLE: APACHE2_DEPEND
101 # Dependencies for Apache 2.x
102 APACHE2_DEPEND="=www-servers/apache-2*"
104 # @ECLASS-VARIABLE: APACHE2_2_DEPEND
106 # Dependencies for Apache 2.2.x
107 APACHE2_2_DEPEND="=www-servers/apache-2.2*"
109 # @ECLASS-VARIABLE: APACHE2_4_DEPEND
111 # Dependencies for Apache 2.4.x
112 APACHE2_4_DEPEND="=www-servers/apache-2.4*"
115 # ==============================================================================
117 # ==============================================================================
120 debug-print-function $FUNCNAME $*
122 # WARNING: Do not use these variables with anything that is put
123 # into the dependency cache (DEPEND/RDEPEND/etc)
125 APXS="/usr/sbin/apxs2"
126 APACHE_BIN="/usr/sbin/apache2"
127 APACHE_CTL="/usr/sbin/apache2ctl"
128 APACHE_INCLUDEDIR="/usr/include/apache2"
129 APACHE_BASEDIR="/usr/$(get_libdir)/apache2"
130 APACHE_CONFDIR="/etc/apache2"
131 APACHE_MODULES_CONFDIR="${APACHE_CONFDIR}/modules.d"
132 APACHE_VHOSTS_CONFDIR="${APACHE_CONFDIR}/vhosts.d"
133 APACHE_MODULESDIR="${APACHE_BASEDIR}/modules"
137 debug-print-function $FUNCNAME $*
141 # ==============================================================================
143 # ==============================================================================
145 # @FUNCTION: depend.apache_pkg_setup
148 # An ebuild calls this in pkg_setup() to initialize variables for optional
149 # apache-2.x support. If the myiuse parameter is not given it defaults to
151 depend.apache_pkg_setup() {
152 debug-print-function $FUNCNAME $*
154 if [[ "${EBUILD_PHASE}" != "setup" ]]; then
155 die "$FUNCNAME() should be called in pkg_setup()"
158 local myiuse=${1:-apache2}
159 if has ${myiuse} ${IUSE}; then
160 if use ${myiuse}; then
168 # @FUNCTION: want_apache
171 # An ebuild calls this to get the dependency information for optional apache
172 # support. If the myiuse parameter is not given it defaults to apache2.
173 # An ebuild should additionally call depend.apache_pkg_setup() in pkg_setup()
174 # with the same myiuse parameter.
176 debug-print-function $FUNCNAME $*
180 # @FUNCTION: want_apache2
183 # An ebuild calls this to get the dependency information for optional apache-2.x
184 # support. If the myiuse parameter is not given it defaults to apache2.
185 # An ebuild should additionally call depend.apache_pkg_setup() in pkg_setup()
186 # with the same myiuse parameter.
188 debug-print-function $FUNCNAME $*
190 local myiuse=${1:-apache2}
191 IUSE="${IUSE} ${myiuse}"
192 DEPEND="${DEPEND} ${myiuse}? ( ${APACHE2_DEPEND} )"
193 RDEPEND="${RDEPEND} ${myiuse}? ( ${APACHE2_DEPEND} )"
196 # @FUNCTION: want_apache2_2
199 # An ebuild calls this to get the dependency information for optional
200 # apache-2.2.x support. If the myiuse parameter is not given it defaults to
202 # An ebuild should additionally call depend.apache_pkg_setup() in pkg_setup()
203 # with the same myiuse parameter.
205 debug-print-function $FUNCNAME $*
207 local myiuse=${1:-apache2}
208 IUSE="${IUSE} ${myiuse}"
209 DEPEND="${DEPEND} ${myiuse}? ( ${APACHE2_2_DEPEND} )"
210 RDEPEND="${RDEPEND} ${myiuse}? ( ${APACHE2_2_DEPEND} )"
213 # @FUNCTION: need_apache
215 # An ebuild calls this to get the dependency information for apache.
217 debug-print-function $FUNCNAME $*
221 # @FUNCTION: need_apache2
223 # An ebuild calls this to get the dependency information for apache-2.x.
225 debug-print-function $FUNCNAME $*
227 DEPEND="${DEPEND} ${APACHE2_DEPEND}"
228 RDEPEND="${RDEPEND} ${APACHE2_DEPEND}"
232 # @FUNCTION: need_apache2_2
234 # An ebuild calls this to get the dependency information for apache-2.2.x.
236 debug-print-function $FUNCNAME $*
238 DEPEND="${DEPEND} ${APACHE2_2_DEPEND}"
239 RDEPEND="${RDEPEND} ${APACHE2_2_DEPEND}"
243 # @FUNCTION: need_apache2_4
245 # An ebuild calls this to get the dependency information for apache-2.4.x.
247 debug-print-function $FUNCNAME $*
249 DEPEND="${DEPEND} ${APACHE2_4_DEPEND}"
250 RDEPEND="${RDEPEND} ${APACHE2_4_DEPEND}"
254 # @FUNCTION: has_apache
256 # An ebuild calls this to get runtime variables for an indirect apache
257 # dependency without USE-flag, in which case want_apache does not work.
258 # DO NOT call this function in global scope.
260 debug-print-function $FUNCNAME $*
262 if has_version '>=www-servers/apache-2'; then
269 # @FUNCTION: has_apache_threads
272 # An ebuild calls this to make sure thread-safety is enabled if apache has been
273 # built with a threaded MPM. If the myflag parameter is not given it defaults to
275 has_apache_threads() {
276 debug-print-function $FUNCNAME $*
278 if ! built_with_use www-servers/apache threads; then
282 local myflag="${1:-threads}"
284 if ! use ${myflag}; then
286 eerror "You need to enable USE flag '${myflag}' to build a thread-safe version"
287 eerror "of ${CATEGORY}/${PN} for use with www-servers/apache"
288 die "Need missing USE flag '${myflag}'"
292 # @FUNCTION: has_apache_threads_in
293 # @USAGE: <myforeign> [myflag]
295 # An ebuild calls this to make sure thread-safety is enabled in a foreign
296 # package if apache has been built with a threaded MPM. If the myflag parameter
297 # is not given it defaults to threads.
298 has_apache_threads_in() {
299 debug-print-function $FUNCNAME $*
301 if ! built_with_use www-servers/apache threads; then
306 local myflag="${2:-threads}"
308 if ! built_with_use ${myforeign} ${myflag}; then
310 eerror "You need to enable USE flag '${myflag}' in ${myforeign} to"
311 eerror "build a thread-safe version of ${CATEGORY}/${PN} for use"
312 eerror "with www-servers/apache"
313 die "Need missing USE flag '${myflag}' in ${myforeign}"
317 EXPORT_FUNCTIONS pkg_setup