/[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.29 Revision 1.39
1# Copyright 1999-2005 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.29 2007/01/01 22:27:01 swegener Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/depend.apache.eclass,v 1.39 2008/02/03 14:12:44 hollow Exp $
4
5# @ECLASS: depend.apache.eclass
6# @MAINTAINER: apache-devs@gentoo.org
7# @BLURB: Functions to allow ebuilds to depend on apache
8# @DESCRIPTION:
9# This eclass handles depending on apache in a sane way and providing
10# information about where certain interfaces are located.
11#
12# @NOTE: If you use this, be sure you use the need_* call after you have defined
13# 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#
16# See bug 107127 for more information.
4 17
5inherit multilib 18inherit multilib
6 19
7# This eclass handles depending on apache in a sane way and providing 20# ==============================================================================
8# information about where certain interfaces are located. 21# INTERNAL VARIABLES
22# ==============================================================================
9 23
10# NOTE: If you use this, be sure you use the need_* call after you have 24# @ECLASS-VARIABLE: APACHE_VERSION
11# defined DEPEND and RDEPEND. Also note that you can not rely on the 25# @DESCRIPTION:
12# automatic RDEPEND=DEPEND that portage does if you use this eclass. 26# Stores the version of apache we are going to be ebuilding. This variable is
13# See bug 107127 for more information. 27# set by the need_apache functions.
14 28
15###### 29# @ECLASS-VARIABLE: APXS
16## Apache Common Variables 30# @DESCRIPTION:
17## 31# Paths to the apxs tool
18## These are internal variables used by this, and other apache-related eclasses,
19## and thus should not need to be used by the ebuilds themselves (the ebuilds
20## should know what version of Apache they are building against).
21######
22 32
23#### 33# @ECLASS-VARIABLE: APACHECTL
24## APACHE_VERSION 34# @DESCRIPTION:
25## 35# Path to the apachectl tool
26## Stores the version of apache we are going to be ebuilding. This variable is
27## set by the need_apache{|1|2} functions.
28##
29####
30#APACHE_VERSION='2'
31 36
32#### 37# @ECLASS-VARIABLE: APACHE_BASEDIR
33## APXS1, APXS2 38# @DESCRIPTION:
34## 39# Path to the server root directory
35## Paths to the apxs tools
36####
37APXS1="/usr/sbin/apxs"
38APXS2="/usr/sbin/apxs2"
39 40
40#### 41# @ECLASS-VARIABLE: APACHE_CONFDIR
41## APACHECTL1, APACHECTL2 42# @DESCRIPTION:
42## 43# Path to the configuration file directory
43## Paths to the apachectl tools
44####
45APACHECTL1="/usr/sbin/apachectl"
46APACHECTL2="/usr/sbin/apache2ctl"
47 44
48#### 45# @ECLASS-VARIABLE: APACHE_MODULES_CONFDIR
49## APACHE1_BASEDIR, APACHE2_BASEDIR 46# @DESCRIPTION:
50## 47# Path where module configuration files are kept
51## Paths to the server root directories
52####
53APACHE1_BASEDIR="/usr/$(get_libdir)/apache"
54APACHE2_BASEDIR="/usr/$(get_libdir)/apache2"
55 48
56#### 49# @ECLASS-VARIABLE: APACHE_VHOSTS_CONFDIR
57## APACHE1_CONFDIR, APACHE2_CONFDIR 50# @DESCRIPTION:
58## 51# Path where virtual host configuration files are kept
59## Paths to the configuration file directories (usually under
60## $APACHE?_BASEDIR/conf)
61####
62APACHE1_CONFDIR="/etc/apache"
63APACHE2_CONFDIR="/etc/apache2"
64 52
65#### 53# @ECLASS-VARIABLE: APACHE_MODULESDIR
66## APACHE1_MODULES_CONFDIR, APACHE2_MODULES_CONFDIR 54# @DESCRIPTION:
67## 55# Path where we install modules
68## Paths where module configuration files are kept
69####
70APACHE1_MODULES_CONFDIR="${APACHE1_CONFDIR}/modules.d"
71APACHE2_MODULES_CONFDIR="${APACHE2_CONFDIR}/modules.d"
72 56
73#### 57# @ECLASS-VARIABLE: APACHE_DEPEND
74## APACHE1_VHOSTDIR, APACHE2_VHOSTDIR 58# @DESCRIPTION:
75## 59# Dependencies for Apache
76## Paths where virtual host configuration files are kept 60APACHE_DEPEND="www-servers/apache"
77####
78APACHE1_VHOSTDIR="${APACHE1_CONFDIR}/vhosts.d"
79APACHE2_VHOSTDIR="${APACHE2_CONFDIR}/vhosts.d"
80 61
81#### 62# @ECLASS-VARIABLE: APACHE2_DEPEND
82## APACHE1_MODULESDIR, APACHE2_MODULESDIR 63# @DESCRIPTION:
83## 64# Dependencies for Apache 2.x
84## Paths where we install modules 65APACHE2_DEPEND="=www-servers/apache-2*"
85####
86APACHE1_MODULESDIR="${APACHE1_BASEDIR}/modules"
87APACHE2_MODULESDIR="${APACHE2_BASEDIR}/modules"
88 66
89#### 67# @ECLASS-VARIABLE: APACHE2_2_DEPEND
90## APACHE1_DEPEND, APACHE2_DEPEND 68# @DESCRIPTION:
91## APACHE2_0_DEPEND, APACHE2_2_DEPEND
92##
93## Dependencies for apache 1.x and apache 2.x 69# Dependencies for Apache 2.2.x
94####
95APACHE1_DEPEND="=net-www/apache-1*"
96APACHE2_DEPEND="=net-www/apache-2*"
97APACHE2_0_DEPEND="=net-www/apache-2.0*"
98APACHE2_2_DEPEND="=net-www/apache-2.2*" 70APACHE2_2_DEPEND="=www-servers/apache-2.2*"
99 71
100#### 72# ==============================================================================
101## NEED_APACHE_DEPEND 73# INTERNAL FUNCTIONS
102## 74# ==============================================================================
103## Dependency magic based on useflags to use the right DEPEND
104## If you change this, please check the DEPENDS in need_apache()
105####
106 75
107NEED_APACHE_DEPEND="apache2? ( ${APACHE2_DEPEND} ) !apache2? ( ${APACHE1_DEPEND} )" 76_init_apache2() {
108WANT_APACHE_DEPEND="apache2? ( ${APACHE2_DEPEND} ) !apache2? ( apache? ( ${APACHE1_DEPEND} ) )" 77 debug-print-function $FUNCNAME $*
109 78
110####
111# uses_apache1()
112#
113# sets up all of the environment variables required by an apache1 module
114####
115
116uses_apache1() {
117 debug-print-function $FUNCNAME $*
118 # WARNING: Do not use these variables with anything that is put 79 # WARNING: Do not use these variables with anything that is put
119 # into the dependency cache (DEPEND/RDEPEND/etc) 80 # into the dependency cache (DEPEND/RDEPEND/etc)
120 APACHE_VERSION='1' 81 APACHE_VERSION="2"
121 APXS="$APXS1" 82 APXS="/usr/sbin/apxs2"
122 USE_APACHE2= 83 APACHE_BIN="/usr/sbin/apache2"
84 APACHE_CTL="/usr/sbin/apache2ctl"
85 # legacy alias
123 APACHECTL="${APACHECTL1}" 86 APACHECTL="${APACHE_CTL}"
124 APACHE_BASEDIR="${APACHE1_BASEDIR}" 87 APACHE_BASEDIR="/usr/$(get_libdir)/apache2"
125 APACHE_CONFDIR="${APACHE1_CONFDIR}" 88 APACHE_CONFDIR="/etc/apache2"
126 APACHE_MODULES_CONFDIR="${APACHE1_MODULES_CONFDIR}" 89 APACHE_MODULES_CONFDIR="${APACHE_CONFDIR}/modules.d"
127 APACHE_VHOSTSDIR="${APACHE1_VHOSTSDIR}" 90 APACHE_VHOSTS_CONFDIR="${APACHE_CONFDIR}/vhosts.d"
128 APACHE_MODULESDIR="${APACHE1_MODULESDIR}" 91 APACHE_MODULESDIR="${APACHE_BASEDIR}/modules"
129} 92}
130 93
131#### 94_init_no_apache() {
132# uses_apache2()
133#
134# sets up all of the environment variables required by an apache2 module
135####
136
137uses_apache2() {
138 debug-print-function $FUNCNAME $* 95 debug-print-function $FUNCNAME $*
139 # WARNING: Do not use these variables with anything that is put
140 # into the dependency cache (DEPEND/RDEPEND/etc)
141 APACHE_VERSION='2' 96 APACHE_VERSION="0"
142 USE_APACHE2=2
143 APXS="$APXS2"
144 APACHECTL="${APACHECTL2}"
145 APACHE_BASEDIR="${APACHE2_BASEDIR}"
146 APACHE_CONFDIR="${APACHE2_CONFDIR}"
147 APACHE_MODULES_CONFDIR="${APACHE2_MODULES_CONFDIR}"
148 APACHE_VHOSTSDIR="${APACHE2_VHOSTSDIR}"
149 APACHE_MODULESDIR="${APACHE2_MODULESDIR}"
150} 97}
151 98
152doesnt_use_apache() { 99# ==============================================================================
100# PUBLIC FUNCTIONS
101# ==============================================================================
102
103# @FUNCTION: want_apache
104# @DESCRIPTION:
105# An ebuild calls this to get the dependency information for optional apache-2.x
106# support.
107want_apache2() {
153 debug-print-function $FUNCNAME $* 108 debug-print-function $FUNCNAME $*
154 APACHE_VERSION='0' 109
155 USE_APACHE= 110 local myiuse=${1:-apache2}
111 IUSE="${IUSE} ${myiuse}"
112 DEPEND="${DEPEND} ${myiuse}? ( ${APACHE2_DEPEND} )"
113 RDEPEND="${RDEPEND} ${myiuse}? ( ${APACHE2_DEPEND} )"
114
115 if use ${myiuse} ; then
116 _init_apache2
117 else
118 _init_no_apache
119 fi
156} 120}
157 121
158#### 122# @FUNCTION: want_apache
159## need_apache1 123# @DESCRIPTION:
160##
161## An ebuild calls this to get the dependency information 124# An ebuild calls this to get the dependency information for optional
162## for apache-1.x. An ebuild should use this in order for 125# apache-2.2.x support.
163## future changes to the build infrastructure to happen 126want_apache2_2() {
164## seamlessly. All an ebuild needs to do is include the
165## line need_apache1 somewhere.
166####
167need_apache1() {
168 debug-print-function $FUNCNAME $* 127 debug-print-function $FUNCNAME $*
169 128
129 local myiuse=${1:-apache2}
130 IUSE="${IUSE} ${myiuse}"
170 DEPEND="${DEPEND} ${APACHE1_DEPEND}" 131 DEPEND="${DEPEND} ${myiuse}? ( ${APACHE2_2_DEPEND} )"
171 RDEPEND="${RDEPEND} ${APACHE1_DEPEND}" 132 RDEPEND="${RDEPEND} ${myiuse}? ( ${APACHE2_2_DEPEND} )"
172 APACHE_VERSION='1' 133
134 if use ${myiuse} ; then
135 _init_apache2
136 else
137 _init_no_apache
138 fi
173} 139}
174 140
175#### 141# @FUNCTION: want_apache
176## need_apache2 142# @DESCRIPTION:
177##
178## An ebuild calls this to get the dependency information 143# An ebuild calls this to get the dependency information for optional apache
179## for apache-2.x. An ebuild should use this in order for 144# support.
180## future changes to the build infrastructure to happen 145want_apache() {
181## seamlessly. All an ebuild needs to do is include the 146 debug-print-function $FUNCNAME $*
182## line need_apache2 somewhere. 147 want_apache2 "$@"
183#### 148}
149
150# @FUNCTION: need_apache2
151# @DESCRIPTION:
152# Works like need_apache, but its used by modules that only support
153# apache 2.x and do not work with other versions.
184need_apache2() { 154need_apache2() {
185 debug-print-function $FUNCNAME $* 155 debug-print-function $FUNCNAME $*
186 156
187 DEPEND="${DEPEND} ${APACHE2_DEPEND}" 157 DEPEND="${DEPEND} ${APACHE2_DEPEND}"
188 RDEPEND="${RDEPEND} ${APACHE2_DEPEND}" 158 RDEPEND="${RDEPEND} ${APACHE2_DEPEND}"
189 APACHE_VERSION='2' 159 _init_apache2
190} 160}
191 161
192#### 162# @FUNCTION: need_apache2_2
193## need_apache2_0 163# @DESCRIPTION:
194##
195## Works like need_apache2 above, but its used by modules 164# Works like need_apache, but its used by modules that only support
196## that only support apache 2.0 and do not work with 165# apache 2.2.x and do not work with other versions.
197## higher versions
198##
199####
200need_apache2_0() {
201 debug-print-function $FUNCNAME $*
202
203 DEPEND="${DEPEND} ${APACHE2_0_DEPEND}"
204 RDEPEND="${RDEPEND} ${APACHE2_0_DEPEND}"
205 APACHE_VERSION='2'
206}
207
208####
209## need_apache2_2
210##
211## Works like need_apache2 above, but its used by modules
212## that only support apache 2.2.
213##
214####
215need_apache2_2() { 166need_apache2_2() {
216 debug-print-function $FUNCNAME $* 167 debug-print-function $FUNCNAME $*
217 168
218 DEPEND="${DEPEND} ${APACHE2_2_DEPEND}" 169 DEPEND="${DEPEND} ${APACHE2_2_DEPEND}"
219 RDEPEND="${RDEPEND} ${APACHE2_2_DEPEND}" 170 RDEPEND="${RDEPEND} ${APACHE2_2_DEPEND}"
220 APACHE_VERSION='2' 171 _init_apache2
221} 172}
222 173
223#### 174# @FUNCTION: need_apache
224## DO NOT CHANGE THIS FUNCTION UNLESS YOU UNDERSTAND THE CONSEQUENCES IT 175# @DESCRIPTION:
225## WILL HAVE ON THE CACHE! There MUST be a apache2? () block in DEPEND for 176# An ebuild calls this to get the dependency information for apache. An
226## things to work correct in the dependency calculation stage. 177# ebuild should use this in order for future changes to the build infrastructure
227## 178# to happen seamlessly. All an ebuild needs to do is include the line
228## This function can take a variable amount of arguments specifying the 179# need_apache somewhere.
229## versions of apache the ebuild supports
230##
231## If no arguments are specified, then all versions are assumed to be supported
232##
233## If both 1.3 and 2.x are specified, the apache2 USE-flag will be used in
234## DEPEND/RDEPEND to determine which version to use.
235##
236## Currently supported versions: 1.3 2.0 2.2 2.x
237need_apache() { 180need_apache() {
238 debug-print-function $FUNCNAME $* 181 debug-print-function $FUNCNAME $*
239
240 local supports13 supports20 supports22 supports2x
241
242 if [ $# -eq 0 ]; then
243 supports13=yes
244 supports2x=yes
245 else
246 while [ $# -gt 0 ]; do
247 case "$1" in
248 1.3) supports13=yes; shift;;
249 2.0) supports20=yes; shift;;
250 2.2) supports22=yes; shift;;
251 2.x) supports2x=yes; shift;;
252 *) die "Unknown version specifier: $1";;
253 esac
254 done
255 fi
256
257 if [[ "${supports20}" == "yes" && "${supports22}" == "yes" ]]; then
258 supports2x=yes;
259 fi
260
261 debug-print "supports13: ${supports13}"
262 debug-print "supports20: ${supports20}"
263 debug-print "supports22: ${supports22}"
264 debug-print "supports2x: ${supports2x}"
265
266 if [ "${supports13}" != "yes" ]; then
267 if [ "${supports2x}" == "yes" ]; then
268 need_apache2 182 need_apache2
269 elif [ "${supports20}" == "yes" ]; then
270 need_apache2_0
271 elif [ "${supports22}" == "yes" ]; then
272 need_apache2_2
273 fi
274 elif [ "${supports13}" == "yes" ]; then
275 if [[ "${supports2x}" == "yes" ||
276 "${supports20}" == "yes" ||
277 "${supports22}" == "yes" ]]; then
278
279 # we support both apache-1.3 and apache-2.*, set up USE-flag based
280 # DEPEND and RDEPEND, determined by which apache-2.x we support
281
282 IUSE="${IUSE} apache2"
283
284 if [ "${supports2x}" != "yes" ]; then
285 if [ "${supports20}" == "yes" ]; then
286 NEED_APACHE_DEPEND="apache2? ( ${APACHE2_0_DEPEND} ) !apache2? ( ${APACHE1_DEPEND} )"
287 elif [ "${supports22}" == "yes" ]; then
288 NEED_APACHE_DEPEND="apache2? ( ${APACHE2_2_DEPEND} ) !apache2? ( ${APACHE1_DEPEND} )"
289 fi
290 fi
291
292 DEPEND="${DEPEND} ${NEED_APACHE_DEPEND}"
293 RDEPEND="${RDEPEND} ${NEED_APACHE_DEPEND}"
294
295 if useq apache2; then
296 uses_apache2
297 else
298 uses_apache1
299 fi
300 else
301 need_apache1
302 fi
303 fi
304
305} 183}
306
307want_apache() {
308 debug-print-function $FUNCNAME $*
309
310 IUSE="${IUSE} apache apache2"
311 DEPEND="${DEPEND} ${WANT_APACHE_DEPEND}"
312 RDEPEND="${RDEPEND} ${WANT_APACHE_DEPEND}"
313 if useq apache2 ; then
314 uses_apache2
315 elif useq apache ; then
316 uses_apache1
317 else
318 doesnt_use_apache
319 fi
320}

Legend:
Removed from v.1.29  
changed lines
  Added in v.1.39

  ViewVC Help
Powered by ViewVC 1.1.20