/[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.1 Revision 1.45
1# Copyright 1999-2004 Gentoo Foundation 1# Copyright 1999-2009 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.1 2004/07/16 10:48:22 stuart Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/depend.apache.eclass,v 1.45 2009/05/26 16:41:56 arfrever Exp $
4 4
5ECLASS="depend.apache" 5# @ECLASS: depend.apache.eclass
6INHERITED="$INHERITED $ECLASS" 6# @MAINTAINER:
7IUSE="apache apache2" 7# apache-devs@gentoo.org
8# @BLURB: Functions to allow ebuilds to depend on apache
9# @DESCRIPTION:
10# This eclass handles depending on apache in a sane way and provides information
11# about where certain binaries and configuration files are located.
12#
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.
17#
18# See Bug 107127 for more information.
19#
20# @EXAMPLE:
21#
22# Here is an example of an ebuild depending on apache:
23#
24# @CODE
25# DEPEND="virtual/Perl-CGI"
26# RDEPEND="${DEPEND}"
27# need_apache2
28# @CODE
29#
30# Another example which demonstrates non-standard IUSE options for optional
31# apache support:
32#
33# @CODE
34# DEPEND="server? ( virtual/Perl-CGI )"
35# RDEPEND="${DEPEND}"
36# want_apache2 server
37#
38# pkg_setup() {
39# depend.apache_pkg_setup server
40# }
41# @CODE
8 42
9# call this function to work out which version of the apache web server 43inherit multilib
10# your ebuild should be installing itself to use
11 44
12detect_apache_useflags() { 45# ==============================================================================
13 USE_APACHE1= 46# INTERNAL VARIABLES
14 USE_APACHE2= 47# ==============================================================================
15 USE_APACHE_MULTIPLE=
16 48
17 useq apache2 && USE_APACHE2=1 49# @ECLASS-VARIABLE: APACHE_VERSION
18 useq apache && USE_APACHE1=1 50# @DESCRIPTION:
51# Stores the version of apache we are going to be ebuilding.
52# This variable is set by the want/need_apache functions.
19 53
20 [ -n "$USE_APACHE1" ] && [ -n "$USE_APACHE2" ] && USE_APACHE_MULTIPLE=1 54# @ECLASS-VARIABLE: APXS
21} 55# @DESCRIPTION:
56# Path to the apxs tool.
57# This variable is set by the want/need_apache functions.
22 58
23detect_apache_installed() { 59# @ECLASS-VARIABLE: APACHE_BIN
24 HAS_APACHE1= 60# @DESCRIPTION:
25 HAS_APACHE2= 61# Path to the apache binary.
26 HAS_APACHE_MULTIPLE= 62# This variable is set by the want/need_apache functions.
27 HAS_APACHE_ANY=
28 63
29 has_version '=net-www/apache-1*' && HAS_APACHE1=1 && HAS_APACHE_ANY=1 64# @ECLASS-VARIABLE: APACHE_CTL
30 has_version '=net-www/apache-2*' && HAS_APACHE2=1 && HAS_APACHE_ANY=1 65# @DESCRIPTION:
66# Path to the apachectl tool.
67# This variable is set by the want/need_apache functions.
31 68
32 [ -n "${HAVE_APACHE1}" ] && [ -n "${HAVE_APACHE2}" && HAVE_APACHE_MULTIPLE=1 69# @ECLASS-VARIABLE: APACHE_BASEDIR
33} 70# @DESCRIPTION:
71# Path to the server root directory.
72# This variable is set by the want/need_apache functions.
34 73
35# call this function from your pkg_setup 74# @ECLASS-VARIABLE: APACHE_CONFDIR
75# @DESCRIPTION:
76# Path to the configuration file directory.
77# This variable is set by the want/need_apache functions.
36 78
79# @ECLASS-VARIABLE: APACHE_MODULES_CONFDIR
80# @DESCRIPTION:
81# Path where module configuration files are kept.
82# This variable is set by the want/need_apache functions.
83
84# @ECLASS-VARIABLE: APACHE_VHOSTS_CONFDIR
85# @DESCRIPTION:
86# Path where virtual host configuration files are kept.
87# This variable is set by the want/need_apache functions.
88
89# @ECLASS-VARIABLE: APACHE_MODULESDIR
90# @DESCRIPTION:
91# Path where we install modules.
92# This variable is set by the want/need_apache functions.
93
94# @ECLASS-VARIABLE: APACHE_DEPEND
95# @DESCRIPTION:
96# Dependencies for Apache
97APACHE_DEPEND="www-servers/apache"
98
99# @ECLASS-VARIABLE: APACHE2_DEPEND
100# @DESCRIPTION:
101# Dependencies for Apache 2.x
102APACHE2_DEPEND="=www-servers/apache-2*"
103
104# @ECLASS-VARIABLE: APACHE2_2_DEPEND
105# @DESCRIPTION:
106# Dependencies for Apache 2.2.x
107APACHE2_2_DEPEND="=www-servers/apache-2.2*"
108
109# ==============================================================================
110# INTERNAL FUNCTIONS
111# ==============================================================================
112
113_init_apache2() {
114 debug-print-function $FUNCNAME $*
115
116 # WARNING: Do not use these variables with anything that is put
117 # into the dependency cache (DEPEND/RDEPEND/etc)
118 APACHE_VERSION="2"
119 APXS="/usr/sbin/apxs2"
120 APACHE_BIN="/usr/sbin/apache2"
121 APACHE_CTL="/usr/sbin/apache2ctl"
122 APACHE_INCLUDEDIR="/usr/include/apache2"
123 APACHE_BASEDIR="/usr/$(get_libdir)/apache2"
124 APACHE_CONFDIR="/etc/apache2"
125 APACHE_MODULES_CONFDIR="${APACHE_CONFDIR}/modules.d"
126 APACHE_VHOSTS_CONFDIR="${APACHE_CONFDIR}/vhosts.d"
127 APACHE_MODULESDIR="${APACHE_BASEDIR}/modules"
128}
129
130_init_no_apache() {
131 debug-print-function $FUNCNAME $*
132 APACHE_VERSION="0"
133}
134
135# ==============================================================================
136# PUBLIC FUNCTIONS
137# ==============================================================================
138
139# @FUNCTION: depend.apache_pkg_setup
140# @USAGE: [myiuse]
141# @DESCRIPTION:
142# An ebuild calls this in pkg_setup() to initialize variables for optional
143# apache-2.x support. If the myiuse parameter is not given it defaults to
144# apache2.
145depend.apache_pkg_setup() {
146 debug-print-function $FUNCNAME $*
147
148 if [[ "${EBUILD_PHASE}" != "setup" ]]; then
149 die "$FUNCNAME() should be called in pkg_setup()"
150 fi
151
152 local myiuse=${1:-apache2}
153 if has ${myiuse} ${IUSE}; then
154 if use ${myiuse}; then
155 _init_apache2
156 else
157 _init_no_apache
158 fi
159 fi
160}
161
162# @FUNCTION: want_apache
163# @USAGE: [myiuse]
164# @DESCRIPTION:
165# An ebuild calls this to get the dependency information for optional apache
166# support. If the myiuse parameter is not given it defaults to apache2.
167# An ebuild should additionally call depend.apache_pkg_setup() in pkg_setup()
168# with the same myiuse parameter.
169want_apache() {
170 debug-print-function $FUNCNAME $*
171 want_apache2 "$@"
172}
173
174# @FUNCTION: want_apache2
175# @USAGE: [myiuse]
176# @DESCRIPTION:
177# An ebuild calls this to get the dependency information for optional apache-2.x
178# support. If the myiuse parameter is not given it defaults to apache2.
179# An ebuild should additionally call depend.apache_pkg_setup() in pkg_setup()
180# with the same myiuse parameter.
181want_apache2() {
182 debug-print-function $FUNCNAME $*
183
184 local myiuse=${1:-apache2}
185 IUSE="${IUSE} ${myiuse}"
186 DEPEND="${DEPEND} ${myiuse}? ( ${APACHE2_DEPEND} )"
187 RDEPEND="${RDEPEND} ${myiuse}? ( ${APACHE2_DEPEND} )"
188}
189
190# @FUNCTION: want_apache2_2
191# @USAGE: [myiuse]
192# @DESCRIPTION:
193# An ebuild calls this to get the dependency information for optional
194# apache-2.2.x support. If the myiuse parameter is not given it defaults to
195# apache2.
196# An ebuild should additionally call depend.apache_pkg_setup() in pkg_setup()
197# with the same myiuse parameter.
198want_apache2_2() {
199 debug-print-function $FUNCNAME $*
200
201 local myiuse=${1:-apache2}
202 IUSE="${IUSE} ${myiuse}"
203 DEPEND="${DEPEND} ${myiuse}? ( ${APACHE2_2_DEPEND} )"
204 RDEPEND="${RDEPEND} ${myiuse}? ( ${APACHE2_2_DEPEND} )"
205}
206
207# @FUNCTION: need_apache
208# @DESCRIPTION:
209# An ebuild calls this to get the dependency information for apache.
37depend_apache() { 210need_apache() {
38 detect_apache_installed 211 debug-print-function $FUNCNAME $*
39 detect_apache_useflags 212 need_apache2
213}
40 214
41 # deal with the multiple cases first - much easier 215# @FUNCTION: need_apache2
42 if [ -n "$USE_APACHE_MULTIPLE" ]; then 216# @DESCRIPTION:
217# An ebuild calls this to get the dependency information for apache-2.x.
218need_apache2() {
219 debug-print-function $FUNCNAME $*
220
221 DEPEND="${DEPEND} ${APACHE2_DEPEND}"
222 RDEPEND="${RDEPEND} ${APACHE2_DEPEND}"
223 _init_apache2
224}
225
226# @FUNCTION: need_apache2_2
227# @DESCRIPTION:
228# An ebuild calls this to get the dependency information for apache-2.2.x.
229need_apache2_2() {
230 debug-print-function $FUNCNAME $*
231
232 DEPEND="${DEPEND} ${APACHE2_2_DEPEND}"
233 RDEPEND="${RDEPEND} ${APACHE2_2_DEPEND}"
234 _init_apache2
235}
236
237# @FUNCTION: has_apache
238# @DESCRIPTION:
239# An ebuild calls this to get runtime variables for an indirect apache
240# dependency without USE-flag, in which case want_apache does not work.
241# DO NOT call this function in global scope.
242has_apache() {
243 debug-print-function $FUNCNAME $*
244
245 if has_version '>=www-servers/apache-2'; then
246 _init_apache2
247 else
248 _init_no_apache
249 fi
250}
251
252# @FUNCTION: has_apache_threads
253# @USAGE: [myflag]
254# @DESCRIPTION:
255# An ebuild calls this to make sure thread-safety is enabled if apache has been
256# built with a threaded MPM. If the myflag parameter is not given it defaults to
257# threads.
258has_apache_threads() {
259 debug-print-function $FUNCNAME $*
260
261 if ! built_with_use www-servers/apache threads; then
262 return
263 fi
264
265 local myflag="${1:-threads}"
266
267 if ! use ${myflag}; then
43 echo 268 echo
44 eerror "You have both the apache and apache2 USE flags set" 269 eerror "You need to enable USE flag '${myflag}' to build a thread-safe version"
45 eerror 270 eerror "of ${CATEGORY}/${PN} for use with www-servers/apache"
46 eerror "Please set only ONE of these USE flags, and try again" 271 die "Need missing USE flag '${myflag}'"
272 fi
273}
274
275# @FUNCTION: has_apache_threads_in
276# @USAGE: <myforeign> [myflag]
277# @DESCRIPTION:
278# An ebuild calls this to make sure thread-safety is enabled in a foreign
279# package if apache has been built with a threaded MPM. If the myflag parameter
280# is not given it defaults to threads.
281has_apache_threads_in() {
282 debug-print-function $FUNCNAME $*
283
284 if ! built_with_use www-servers/apache threads; then
285 return
286 fi
287
288 local myforeign="$1"
289 local myflag="${2:-threads}"
290
291 if ! built_with_use ${myforeign} ${myflag}; then
47 echo 292 echo
48 die "Multiple Apache USE flags set - you can only have one set at a time" 293 eerror "You need to enable USE flag '${myflag}' in ${myforeign} to"
49 fi 294 eerror "build a thread-safe version of ${CATEGORY}/${PN} for use"
50 295 eerror "with www-servers/apache"
51 if [ -n "$USE_APACHE2" ] ; then 296 die "Need missing USE flag '${myflag}' in ${myforeign}"
52 if [ -z "$HAS_APACHE2" -a -n "$HAS_APACHE_ANY" ] ; then
53 echo
54 eerror "You have the 'apache2' USE flag set, but only have Apache v1 installed"
55 eerror "If you really meant to upgrade to Apache v2, please install Apache v2"
56 eerror "before installing $CATEGORY/${PN}-${PVR}"
57 echo
58 die "Automatic upgrade of Apache would be forced; avoiding"
59 else
60 einfo "Apache 2 support enabled"
61 DETECT_APACHE=2
62 return
63 fi 297 fi
64 fi
65
66 if [ -n "$USE_APACHE1" ]; then
67 if [ -z "$HAS_APACHE1" -a -n "$HAS_APACHE_ANY" ]; then
68 echo
69 eerror "You have the 'apache' USE flag set, but only have a later version of"
70 eerror "Apache installed on your computer. Please use the 'apache2' USE flag"
71 eerror "or downgrade to Apache v1 before installing $CATEGORY/${PN}-${PVR}"
72 echo
73 die "Avoiding installing older version of Apache"
74 else
75 einfo "Apache 1 support enabled"
76 DETECT_APACHE=1
77 return
78 fi
79 fi
80} 298}
81 299
300EXPORT_FUNCTIONS pkg_setup

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.45

  ViewVC Help
Powered by ViewVC 1.1.20