/[gentoo-x86]/eclass/depend.apache.eclass
Gentoo

Diff of /eclass/depend.apache.eclass

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 1.35 Revision 1.42
1# Copyright 1999-2007 Gentoo Foundation 1# Copyright 1999-2007 Gentoo Foundation
2# Distributed under the terms of the GNU General Public License v2 2# Distributed under the terms of the GNU General Public License v2
3# $Header: /var/cvsroot/gentoo-x86/eclass/depend.apache.eclass,v 1.35 2007/11/25 14:27:52 hollow Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/depend.apache.eclass,v 1.42 2008/02/06 21:20:41 hollow Exp $
4 4
5# @ECLASS: depend.apache.eclass 5# @ECLASS: depend.apache.eclass
6# @MAINTAINER: apache-devs@gentoo.org 6# @MAINTAINER: apache-devs@gentoo.org
7# @BLURB: Functions to allow ebuilds to depend on apache 7# @BLURB: Functions to allow ebuilds to depend on apache
8# @DESCRIPTION: 8# @DESCRIPTION:
9# This eclass handles depending on apache in a sane way and providing 9# This eclass handles depending on apache in a sane way and provides information
10# information about where certain interfaces are located. 10# about where certain binaries and configuration files are located.
11# 11#
12# @NOTE: If you use this, be sure you use the need_* call after you have defined 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
13# DEPEND and RDEPEND. Also note that you can not rely on the automatic 14# defined DEPEND and RDEPEND. Also note that you can not rely on the automatic
14# RDEPEND=DEPEND that portage does if you use this eclass. 15# RDEPEND=DEPEND that portage does if you use this eclass.
15# 16#
16# See bug 107127 for more information. 17# See Bug 107127 for more information.
18#
19# @EXAMPLE:
20#
21# Here is an example of an ebuild depending on apache:
22#
23# @CODE
24# DEPEND="virtual/Perl-CGI"
25# RDEPEND="${DEPEND}"
26# need_apache2
27# @CODE
28#
29# Another example which demonstrates non-standard IUSE options for optional
30# apache support:
31#
32# @CODE
33# DEPEND="server? ( virtual/Perl-CGI )"
34# RDEPEND="${DEPEND}"
35# want_apache2 server
36# @CODE
17 37
18inherit multilib 38inherit multilib
19 39
20# ============================================================================== 40# ==============================================================================
21# INTERNAL VARIABLES 41# INTERNAL VARIABLES
22# ============================================================================== 42# ==============================================================================
23 43
24# @ECLASS-VARIABLE: APACHE_VERSION 44# @ECLASS-VARIABLE: APACHE_VERSION
25# @DESCRIPTION: 45# @DESCRIPTION:
26# Stores the version of apache we are going to be ebuilding. This variable is 46# Stores the version of apache we are going to be ebuilding.
27# set by the need_apache functions. 47# This variable is set by the want/need_apache functions.
28#APACHE_VERSION="2"
29 48
30# @ECLASS-VARIABLE: APXS2 49# @ECLASS-VARIABLE: APXS
31# @DESCRIPTION: 50# @DESCRIPTION:
32# Paths to the apxs tool 51# Path to the apxs tool.
33APXS2="/usr/sbin/apxs2" 52# This variable is set by the want/need_apache functions.
34 53
54# @ECLASS-VARIABLE: APACHE_BIN
55# @DESCRIPTION:
56# Path to the apache binary.
57# This variable is set by the want/need_apache functions.
58
35# @ECLASS-VARIABLE: APACHECTL2 59# @ECLASS-VARIABLE: APACHE_CTL
36# @DESCRIPTION: 60# @DESCRIPTION:
37# Path to the apachectl tool 61# Path to the apachectl tool.
38APACHECTL2="/usr/sbin/apache2ctl" 62# This variable is set by the want/need_apache functions.
39 63
40# @ECLASS-VARIABLE: APACHE2_BASEDIR 64# @ECLASS-VARIABLE: APACHE_BASEDIR
41# @DESCRIPTION: 65# @DESCRIPTION:
42# Path to the server root directory 66# Path to the server root directory.
43APACHE2_BASEDIR="/usr/$(get_libdir)/apache2" 67# This variable is set by the want/need_apache functions.
44 68
45# @ECLASS-VARIABLE: APACHE2_CONFDIR 69# @ECLASS-VARIABLE: APACHE_CONFDIR
46# @DESCRIPTION: 70# @DESCRIPTION:
47# Path to the configuration file directory 71# Path to the configuration file directory.
48APACHE2_CONFDIR="/etc/apache2" 72# This variable is set by the want/need_apache functions.
49 73
50# @ECLASS-VARIABLE: APACHE2_MODULES_CONFDIR 74# @ECLASS-VARIABLE: APACHE_MODULES_CONFDIR
51# @DESCRIPTION: 75# @DESCRIPTION:
52# Path where module configuration files are kept 76# Path where module configuration files are kept.
53APACHE2_MODULES_CONFDIR="${APACHE2_CONFDIR}/modules.d" 77# This variable is set by the want/need_apache functions.
54 78
55# @ECLASS-VARIABLE: APACHE2_VHOSTDIR 79# @ECLASS-VARIABLE: APACHE_VHOSTS_CONFDIR
56# @DESCRIPTION: 80# @DESCRIPTION:
57# Path where virtual host configuration files are kept 81# Path where virtual host configuration files are kept.
58APACHE2_VHOSTDIR="${APACHE2_CONFDIR}/vhosts.d" 82# This variable is set by the want/need_apache functions.
59 83
60# @ECLASS-VARIABLE: APACHE2_MODULESDIR 84# @ECLASS-VARIABLE: APACHE_MODULESDIR
61# @DESCRIPTION: 85# @DESCRIPTION:
62# Path where we install modules 86# Path where we install modules.
63APACHE2_MODULESDIR="${APACHE2_BASEDIR}/modules" 87# This variable is set by the want/need_apache functions.
88
89# @ECLASS-VARIABLE: APACHE_DEPEND
90# @DESCRIPTION:
91# Dependencies for Apache
92APACHE_DEPEND="www-servers/apache"
64 93
65# @ECLASS-VARIABLE: APACHE2_DEPEND 94# @ECLASS-VARIABLE: APACHE2_DEPEND
66# @DESCRIPTION: 95# @DESCRIPTION:
67# Dependencies for Apache 2.x 96# Dependencies for Apache 2.x
68APACHE2_DEPEND="=www-servers/apache-2*" 97APACHE2_DEPEND="=www-servers/apache-2*"
69 98
70# @ECLASS-VARIABLE: APACHE2_0_DEPEND
71# @DESCRIPTION:
72# Dependencies for Apache 2.0.x
73APACHE2_0_DEPEND="=www-servers/apache-2.0*"
74
75# @ECLASS-VARIABLE: APACHE2_2_DEPEND 99# @ECLASS-VARIABLE: APACHE2_2_DEPEND
76# @DESCRIPTION: 100# @DESCRIPTION:
77# Dependencies for Apache 2.2.x 101# Dependencies for Apache 2.2.x
78APACHE2_2_DEPEND="=www-servers/apache-2.2*" 102APACHE2_2_DEPEND="=www-servers/apache-2.2*"
79 103
80# @ECLASS-VARIABLE: WANT_APACHE_DEPEND
81# @DESCRIPTION:
82# Dependency magic based on useflag to use the right DEPEND
83WANT_APACHE_DEPEND="apache2? ( ${APACHE2_DEPEND} )"
84
85# ============================================================================== 104# ==============================================================================
86# INTERNAL FUNCTIONS 105# INTERNAL FUNCTIONS
87# ============================================================================== 106# ==============================================================================
88 107
89# @FUNCTION: uses_apache2 108_init_apache2() {
90# @DESCRIPTION:
91# sets up all of the environment variables required for an apache2 module
92uses_apache2() {
93 debug-print-function $FUNCNAME $* 109 debug-print-function $FUNCNAME $*
94 110
95 # WARNING: Do not use these variables with anything that is put 111 # WARNING: Do not use these variables with anything that is put
96 # into the dependency cache (DEPEND/RDEPEND/etc) 112 # into the dependency cache (DEPEND/RDEPEND/etc)
97 APACHE_VERSION="2" 113 APACHE_VERSION="2"
98 USE_APACHE="2" 114 APXS="/usr/sbin/apxs2"
99 APXS="${APXS2}" 115 APACHE_BIN="/usr/sbin/apache2"
100 APACHECTL="${APACHECTL2}" 116 APACHE_CTL="/usr/sbin/apache2ctl"
101 APACHE_BASEDIR="${APACHE2_BASEDIR}" 117 APACHE_INCLUDEDIR="/usr/include/apache2"
102 APACHE_CONFDIR="${APACHE2_CONFDIR}" 118 APACHE_BASEDIR="/usr/$(get_libdir)/apache2"
119 APACHE_CONFDIR="/etc/apache2"
103 APACHE_MODULES_CONFDIR="${APACHE2_MODULES_CONFDIR}" 120 APACHE_MODULES_CONFDIR="${APACHE_CONFDIR}/modules.d"
104 APACHE_VHOSTSDIR="${APACHE2_VHOSTSDIR}" 121 APACHE_VHOSTS_CONFDIR="${APACHE_CONFDIR}/vhosts.d"
105 APACHE_MODULESDIR="${APACHE2_MODULESDIR}" 122 APACHE_MODULESDIR="${APACHE_BASEDIR}/modules"
106} 123}
107 124
108# @FUNCTION: doesnt_use_apache 125_init_no_apache() {
109# @DESCRIPTION:
110# sets up all of the environment variables required for optional apache usage
111doesnt_use_apache() {
112 debug-print-function $FUNCNAME $* 126 debug-print-function $FUNCNAME $*
113
114 APACHE_VERSION="0" 127 APACHE_VERSION="0"
115 USE_APACHE="0"
116} 128}
117 129
118# ============================================================================== 130# ==============================================================================
119# PUBLIC FUNCTIONS 131# PUBLIC FUNCTIONS
120# ============================================================================== 132# ==============================================================================
121 133
122# @FUNCTION: want_apache 134# @FUNCTION: want_apache
135# @USAGE: [myiuse]
136# @DESCRIPTION:
137# An ebuild calls this to get the dependency information for optional apache
138# support. If the myiuse parameter is not given it defaults to apache2.
139want_apache() {
140 debug-print-function $FUNCNAME $*
141 want_apache2 "$@"
142}
143
144# @FUNCTION: want_apache2
145# @USAGE: [myiuse]
123# @DESCRIPTION: 146# @DESCRIPTION:
124# An ebuild calls this to get the dependency information for optional apache-2.x 147# An ebuild calls this to get the dependency information for optional apache-2.x
125# support. 148# support. If the myiuse parameter is not given it defaults to apache2.
126want_apache() { 149want_apache2() {
127 debug-print-function $FUNCNAME $* 150 debug-print-function $FUNCNAME $*
128 151
129 IUSE="${IUSE} apache2" 152 local myiuse=${1:-apache2}
153 IUSE="${IUSE} ${myiuse}"
130 DEPEND="${DEPEND} ${WANT_APACHE_DEPEND}" 154 DEPEND="${DEPEND} ${myiuse}? ( ${APACHE2_DEPEND} )"
131 RDEPEND="${RDEPEND} ${WANT_APACHE_DEPEND}" 155 RDEPEND="${RDEPEND} ${myiuse}? ( ${APACHE2_DEPEND} )"
132 156
133 if use apache2 ; then 157 if use ${myiuse} ; then
134 uses_apache2 158 _init_apache2
135 else 159 else
136 doesnt_use_apache 160 _init_no_apache
137 fi 161 fi
162}
163
164# @FUNCTION: want_apache2_2
165# @USAGE: [myiuse]
166# @DESCRIPTION:
167# An ebuild calls this to get the dependency information for optional
168# apache-2.2.x support. If the myiuse parameter is not given it defaults to
169# apache2.
170want_apache2_2() {
171 debug-print-function $FUNCNAME $*
172
173 local myiuse=${1:-apache2}
174 IUSE="${IUSE} ${myiuse}"
175 DEPEND="${DEPEND} ${myiuse}? ( ${APACHE2_2_DEPEND} )"
176 RDEPEND="${RDEPEND} ${myiuse}? ( ${APACHE2_2_DEPEND} )"
177
178 if use ${myiuse} ; then
179 _init_apache2
180 else
181 _init_no_apache
182 fi
183}
184
185# @FUNCTION: need_apache
186# @DESCRIPTION:
187# An ebuild calls this to get the dependency information for apache.
188need_apache() {
189 debug-print-function $FUNCNAME $*
190 need_apache2
138} 191}
139 192
140# @FUNCTION: need_apache2 193# @FUNCTION: need_apache2
141# @DESCRIPTION: 194# @DESCRIPTION:
142# An ebuild calls this to get the dependency information for apache-2.x. An 195# An ebuild calls this to get the dependency information for apache-2.x.
143# ebuild should use this in order for future changes to the build infrastructure
144# to happen seamlessly. All an ebuild needs to do is include the line
145# need_apache2 somewhere.
146need_apache2() { 196need_apache2() {
147 debug-print-function $FUNCNAME $* 197 debug-print-function $FUNCNAME $*
148 198
149 DEPEND="${DEPEND} ${APACHE2_DEPEND}" 199 DEPEND="${DEPEND} ${APACHE2_DEPEND}"
150 RDEPEND="${RDEPEND} ${APACHE2_DEPEND}" 200 RDEPEND="${RDEPEND} ${APACHE2_DEPEND}"
151 uses_apache2 201 _init_apache2
152}
153
154# @FUNCTION: need_apache2_0
155# @DESCRIPTION:
156# Works like need_apache2 above, but its used by modules that only support
157# apache 2.0 and do not work with higher versions.
158need_apache2_0() {
159 debug-print-function $FUNCNAME $*
160
161 DEPEND="${DEPEND} ${APACHE2_0_DEPEND}"
162 RDEPEND="${RDEPEND} ${APACHE2_0_DEPEND}"
163 uses_apache2
164} 202}
165 203
166# @FUNCTION: need_apache2_2 204# @FUNCTION: need_apache2_2
167# @DESCRIPTION: 205# @DESCRIPTION:
168# Works like need_apache2 above, but its used by modules that only support 206# An ebuild calls this to get the dependency information for apache-2.2.x.
169# apache 2.2 and do not work with lower versions.
170need_apache2_2() { 207need_apache2_2() {
171 debug-print-function $FUNCNAME $* 208 debug-print-function $FUNCNAME $*
172 209
173 DEPEND="${DEPEND} ${APACHE2_2_DEPEND}" 210 DEPEND="${DEPEND} ${APACHE2_2_DEPEND}"
174 RDEPEND="${RDEPEND} ${APACHE2_2_DEPEND}" 211 RDEPEND="${RDEPEND} ${APACHE2_2_DEPEND}"
175 uses_apache2 212 _init_apache2
176} 213}
177 214
178# @FUNCTION: need_apache 215# @FUNCTION: check_apache_threads
216# @USAGE: [myflag]
179# @DESCRIPTION: 217# @DESCRIPTION:
180# Legacy alias for need_apache2 218# An ebuild calls this to make sure thread-safety is enabled if apache has been
181need_apache() { 219# built with a threaded MPM. If the myflag parameter is not given it defaults to
182 need_apache2 220# threads.
183} 221check_apache_threads() {
184
185# @FUNCTION: apr_config
186# @DESCRIPTION:
187# Version magic to get the correct apr-config binary based on the (probably)
188# installed version of apache. This is needed to get modules to link to the
189# same apr/apu as apache (i.e. link 0.9 for 2.0, 1.x for 2.2)
190apr_config() {
191 debug-print-function $FUNCNAME $* 222 debug-print-function $FUNCNAME $*
192 223
193 local default="${1:-1}" 224 if ! built_with_use www-servers/apache threads ; then
194 if [[ "${USE_APACHE}" == "2" ]]; then 225 return
195 if has_version ${APACHE2_0_DEPEND}; then
196 echo apr-config
197 else
198 echo apr-1-config
199 fi 226 fi
200 else 227
201 if [[ "${default}" == "0" ]]; then 228 local myflag="${1:-threads}"
202 echo apr-config 229
203 elif [[ "${default}" == "1" ]]; then 230 if ! use ${myflag} ; then
204 echo apr-1-config 231 echo
205 else 232 eerror "You need to enable USE flag '${myflag}' to build a thread-safe version"
206 die "Unknown version specifier: ${default}" 233 eerror "of ${CATEGORY}/${PN} for use with www-servers/apache"
234 die "Need missing USE flag '${myflag}'"
207 fi 235 fi
208 fi
209} 236}
210 237
211# @FUNCTION: apu_config 238# @FUNCTION: check_apache_threads_in
239# @USAGE: <myforeign> [myflag]
212# @DESCRIPTION: 240# @DESCRIPTION:
213# Version magic to get the correct apu-config binary based on the (probably) 241# An ebuild calls this to make sure thread-safety is enabled in a foreign
214# installed version of apache. This is needed to get modules to link to the 242# package if apache has been built with a threaded MPM. If the myflag parameter
215# same apr/apu as apache (i.e. link 0.9 for 2.0, 1.x for 2.2) 243# is not given it defaults to threads.
216apu_config() { 244check_apache_threads_in() {
217 debug-print-function $FUNCNAME $* 245 debug-print-function $FUNCNAME $*
218 246
219 local default="${1:-1}" 247 if ! built_with_use www-servers/apache threads ; then
220 if [[ "${USE_APACHE}" == "2" ]]; then 248 return
221 if has_version ${APACHE2_0_DEPEND}; then
222 echo apu-config
223 else
224 echo apu-1-config
225 fi 249 fi
226 else 250
227 if [[ "${default}" == "0" ]]; then 251 local myforeign="$1"
228 echo apu-config 252 local myflag="${2:-threads}"
229 elif [[ "${default}" == "1" ]]; then 253
230 echo apu-1-config 254 if ! built_with_use ${myforeign} ${myflag} ; then
231 else 255 echo
232 die "Unknown version specifier: ${default}" 256 eerror "You need to enable USE flag '${myflag}' in ${myforeign} to"
257 eerror "build a thread-safe version of ${CATEGORY}/${PN} for use"
258 eerror "with www-servers/apache"
259 die "Need missing USE flag '${myflag}' in ${myforeign}"
233 fi 260 fi
234 fi
235} 261}

Legend:
Removed from v.1.35  
changed lines
  Added in v.1.42

  ViewVC Help
Powered by ViewVC 1.1.20