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

Diff of /eclass/apache-module.eclass

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

Revision 1.19 Revision 1.25
1# Copyright 1999-2007 Gentoo Foundation 1# Copyright 1999-2011 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/apache-module.eclass,v 1.19 2007/05/12 02:28:51 chtekk Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/apache-module.eclass,v 1.25 2011/12/27 17:55:12 fauli Exp $
4
5# @ECLASS: apache-module.eclass
6# @MAINTAINER:
7# apache-devs@gentoo.org
8# @BLURB: Provides a common set of functions for apache modules
9# @DESCRIPTION:
10# This eclass handles apache modules in a sane way.
11#
12# To make use of this eclass simply call one of the need/want_apache functions
13# described in depend.apache.eclass. Make sure you use the need/want_apache call
14# after you have defined DEPEND and RDEPEND. Also note that you can not rely on
15# the automatic RDEPEND=DEPEND that portage does if you use this eclass.
16#
17# See Bug 107127 for more information.
18#
19# @EXAMPLE:
20#
21# Here is a simple example of an ebuild for mod_foo:
22#
23# @CODE
24# APACHE2_MOD_CONF="42_mod_foo"
25# APACHE2_MOD_DEFINE="FOO"
26# need_apache2
27# @CODE
28#
29# A more complicated example for a module with non-standard locations:
30#
31# @CODE
32# APXS2_S="${S}/apache22/src"
33# APACHE2_MOD_FILE="${APXS2_S}/${PN}.so"
34# APACHE2_MOD_CONF="42_${PN}"
35# APACHE2_MOD_DEFINE="FOO"
36# DOCFILES="docs/*.html"
37# need_apache2_2
38# @CODE
39#
40# A basic module configuration which just loads the module into apache:
41#
42# @CODE
43# <IfDefine FOO>
44# LoadModule foo_module modules/mod_foo.so
45# </IfDefine>
46# @CODE
4 47
5inherit depend.apache 48inherit depend.apache
6 49
7# This eclass provides a common set of functions for Apache modules. 50# ==============================================================================
51# PUBLIC VARIABLES
52# ==============================================================================
8 53
9# NOTE: If you use this, be sure you use the need_* call after you have 54# @VARIABLE: APXS2_S
10# defined DEPEND and RDEPEND. Also note that you can not rely on the 55# @DESCRIPTION:
11# automatic RDEPEND=DEPEND that Portage does if you use this eclass. 56# Path to temporary build directory. (Defaults to `${S}/src' if it exists,
12# See bug 107127 for more information. 57# `${S}' otherwise)
13 58
14###### 59# @VARIABLE: APXS2_ARGS
15## Common ebuild variables 60# @DESCRIPTION:
16###### 61# Arguments to pass to the apxs tool. (Defaults to `-c ${PN}.c')
17 62
18#### 63# @VARIABLE: APACHE2_EXECFILES
19## APXS1_S, APXS2_S 64# @DESCRIPTION:
20## 65# List of files that will be installed into ${APACHE_MODULE_DIR} beside
21## Paths to temporary build directories 66# ${APACHE2_MOD_FILE}. In addition, this function also sets the executable
22#### 67# permission on those files.
23APXS1_S=""
24APXS2_S=""
25 68
26#### 69# @VARIABLE: APACHE2_MOD_CONF
27## APXS1_ARGS, APXS2_ARGS 70# @DESCRIPTION:
28## 71# Module configuration file installed by src_install (minus the .conf suffix and
29## Arguments to pass to the apxs tool 72# relative to ${FILESDIR}).
30####
31APXS1_ARGS=""
32APXS2_ARGS=""
33 73
34#### 74# @VARIABLE: APACHE2_MOD_DEFINE
35## APACHE1_MOD_FILE, APACHE2_MOD_FILE 75# @DESCRIPTION:
36##
37## Name of the module that src_install installs (only, minus the .so)
38####
39APACHE1_MOD_FILE=""
40APACHE2_MOD_FILE=""
41
42####
43## APACHE1_MOD_CONF, APACHE2_MOD_CONF
44##
45## Configuration file installed by src_install
46####
47APACHE1_MOD_CONF=""
48APACHE2_MOD_CONF=""
49
50####
51## APACHE1_MOD_DEFINE, APACHE2_MOD_DEFINE
52##
53## Name of define (eg FOO) to use in conditional loading of the installed 76# Name of define (e.g. FOO) to use in conditional loading of the installed
54## module/it's config file, multiple defines should be space separated 77# module/its config file, multiple defines should be space separated.
55####
56APACHE1_MOD_DEFINE=""
57APACHE2_MOD_DEFINE=""
58 78
59#### 79# @VARIABLE: APACHE2_MOD_FILE
60## DOCFILES 80# @DESCRIPTION:
61## 81# Name of the module that src_install installs minus the .so suffix. (Defaults
82# to `${APXS2_S}/.libs/${PN}.so')
83
84# @VARIABLE: APACHE2_VHOST_CONF
85# @DESCRIPTION:
86# Virtual host configuration file installed by src_install (minus the .conf
87# suffix and relative to ${FILESDIR}).
88
89# @VARIABLE: DOCFILES
90# @DESCRIPTION:
62## If the exported src_install() is being used, and ${DOCFILES} is non-zero, 91# If the exported src_install() is being used, and ${DOCFILES} is non-zero, some
63## some sed-fu is applied to split out html documentation (if any) from normal 92# sed-fu is applied to split out html documentation (if any) from normal
64## documentation, and dodoc'd or dohtml'd 93# documentation, and dodoc'd or dohtml'd.
65####
66DOCFILES=""
67 94
68###### 95# ==============================================================================
69## Utility functions 96# INTERNAL FUNCTIONS
70###### 97# ==============================================================================
71 98
72#### 99# Internal function to construct the default ${APXS2_S} path if required.
73## apache_cd_dir
74##
75## Return the path to our temporary build dir
76####
77apache_cd_dir() { 100apache_cd_dir() {
78 debug-print-function $FUNCNAME $* 101 debug-print-function $FUNCNAME $*
79 102
80 if [[ "${APACHE_VERSION}" == "1" ]] ; then 103 local CD_DIR="${APXS2_S}"
81 [[ -n "${APXS1_S}" ]] && CD_DIR="${APXS1_S}"
82 else
83 [[ -n "${APXS2_S}" ]] && CD_DIR="${APXS2_S}"
84 fi
85 104
86 # XXX - Is this really needed? Can't we just return ${S}?
87 if [[ -z "${CD_DIR}" ]] ; then 105 if [[ -z "${CD_DIR}" ]] ; then
88 if [[ -d "${S}/src" ]] ; then 106 if [[ -d "${S}/src" ]] ; then
89 CD_DIR="${S}/src" 107 CD_DIR="${S}/src"
90 else 108 else
91 CD_DIR="${S}" 109 CD_DIR="${S}"
92 fi 110 fi
93 fi 111 fi
94 112
95 debug-print apache_cd_dir: "CD_DIR=${CD_DIR}" 113 debug-print $FUNCNAME "CD_DIR=${CD_DIR}"
96 echo "${CD_DIR}" 114 echo "${CD_DIR}"
97} 115}
98 116
99#### 117# Internal function to construct the default ${APACHE2_MOD_FILE} if required.
100## apache_mod_file
101##
102## Return the path to the module file
103####
104apache_mod_file() { 118apache_mod_file() {
105 debug-print-function $FUNCNAME $* 119 debug-print-function $FUNCNAME $*
106 120
107 if [[ "${APACHE_VERSION}" == "1" ]] ; then 121 local MOD_FILE="${APACHE2_MOD_FILE:-$(apache_cd_dir)/.libs/${PN}.so}"
108 [[ -n "${APACHE1_MOD_FILE}" ]] && MOD_FILE="${APACHE1_MOD_FILE}"
109 [[ -z "${MOD_FILE}" ]] && MOD_FILE="$(apache_cd_dir)/${PN}.so"
110 else
111 [[ -n "${APACHE2_MOD_FILE}" ]] && MOD_FILE="${APACHE2_MOD_FILE}"
112 [[ -z "${MOD_FILE}" ]] && MOD_FILE="$(apache_cd_dir)/.libs/${PN}.so"
113 fi
114 122
115 debug-print apache_mod_file: "MOD_FILE=${MOD_FILE}" 123 debug-print $FUNCNAME "MOD_FILE=${MOD_FILE}"
116 echo "${MOD_FILE}" 124 echo "${MOD_FILE}"
117} 125}
118 126
119####
120## apache_doc_magic
121##
122## Some magic for picking out html files from ${DOCFILES}. It takes 127# Internal function for picking out html files from ${DOCFILES}. It takes an
123## an optional first argument `html'; if the first argument is equals 128# optional first argument `html'; if the first argument is equals `html', only
124## `html', only html files are returned, otherwise normal (non-html) 129# html files are returned, otherwise normal (non-html) docs are returned.
125## docs are returned.
126####
127apache_doc_magic() { 130apache_doc_magic() {
128 debug-print-function $FUNCNAME $* 131 debug-print-function $FUNCNAME $*
132
133 local DOCS=
129 134
130 if [[ -n "${DOCFILES}" ]] ; then 135 if [[ -n "${DOCFILES}" ]] ; then
131 if [[ "x$1" == "xhtml" ]] ; then 136 if [[ "x$1" == "xhtml" ]] ; then
132 DOCS="`echo ${DOCFILES} | sed -e 's/ /\n/g' | sed -e '/^[^ ]*.html$/ !d'`" 137 DOCS="`echo ${DOCFILES} | sed -e 's/ /\n/g' | sed -e '/^[^ ]*.html$/ !d'`"
133 else 138 else
134 DOCS="`echo ${DOCFILES} | sed 's, *[^ ]*\+.html, ,g'`" 139 DOCS="`echo ${DOCFILES} | sed 's, *[^ ]*\+.html, ,g'`"
135 fi 140 fi
141 fi
136 142
137 debug-print apache_doc_magic: "DOCS=${DOCS}" 143 debug-print $FUNCNAME "DOCS=${DOCS}"
138 echo "${DOCS}" 144 echo "${DOCS}"
139 fi
140} 145}
141 146
142###### 147# ==============================================================================
143## Apache 1.x ebuild functions - !!! DEPRECATED !!! 148# EXPORTED FUNCTIONS
144###### 149# ==============================================================================
145 150
146#### 151# @FUNCTION: apache-module_src_compile
147## apache1_src_compile - !!! DEPRECATED !!! 152# @DESCRIPTION:
148#### 153# The default action is to call ${APXS} with the value of ${APXS2_ARGS}. If a
154# module requires a different build setup than this, use ${APXS} in your own
155# src_compile routine.
149apache1_src_compile() { 156apache-module_src_compile() {
150 debug-print-function $FUNCNAME $* 157 debug-print-function $FUNCNAME $*
151 158
152 CD_DIR=$(apache_cd_dir) 159 local CD_DIR=$(apache_cd_dir)
153 cd ${CD_DIR} || die "cd ${CD_DIR} failed"
154 APXS1_ARGS="${APXS1_ARGS:--c ${PN}.c}"
155 ${APXS1} ${APXS1_ARGS} || die "${APXS1} ${APXS1_ARGS} failed"
156}
157
158####
159## apache1_src_install - !!! DEPRECATED !!!
160####
161apache1_src_install() {
162 debug-print-function $FUNCNAME $*
163
164 CD_DIR=$(apache_cd_dir)
165 cd ${CD_DIR} || die "cd ${CD_DIR} failed"
166
167 MOD_FILE=$(apache_mod_file)
168
169 exeinto ${APACHE1_MODULESDIR}
170 doexe ${MOD_FILE} || die "internal ebuild error: '${MOD_FILE}' not found"
171 [ -n "${APACHE1_EXECFILES}" ] && doexe ${APACHE1_EXECFILES}
172
173 if [ -n "${APACHE1_MOD_CONF}" ] ; then
174 insinto ${APACHE1_MODULES_CONFDIR}
175 doins ${FILESDIR}/${APACHE1_MOD_CONF}.conf || die "internal ebuild error: '${FILESDIR}/${APACHE1_MOD_CONF}.conf' not found."
176 fi
177
178 cd ${S}
179
180 if [ -n "${DOCFILES}" ] ; then
181 OTHER_DOCS=$(apache_doc_magic)
182 HTML_DOCS=$(apache_doc_magic html)
183
184 [ -n "${OTHER_DOCS}" ] && dodoc ${OTHER_DOCS}
185 [ -n "${HTML_DOCS}" ] && dohtml ${HTML_DOCS}
186 fi
187}
188
189####
190## apache1_pkg_postinst - !!! DEPRECATED !!!
191####
192apache1_pkg_postinst() {
193 debug-print-function $FUNCNAME $*
194
195 if [ -n "${APACHE1_MOD_DEFINE}" ]; then
196 local my_opts="-D ${APACHE1_MOD_DEFINE// / -D }"
197
198 einfo
199 einfo "To enable ${PN}, you need to edit your /etc/conf.d/apache file and"
200 einfo "add '${my_opts}' to APACHE_OPTS."
201 einfo
202 fi
203 if [ -n "${APACHE1_MOD_CONF}" ] ; then
204 einfo
205 einfo "Configuration file installed as"
206 einfo " ${APACHE1_MODULES_CONFDIR}/$(basename ${APACHE1_MOD_CONF}).conf"
207 einfo "You may want to edit it before turning the module on in /etc/conf.d/apache"
208 einfo
209 fi
210}
211
212######
213## Apache 2.x ebuild functions
214######
215
216####
217## apache2_pkg_setup
218##
219## Checks to see if APACHE2_MT_UNSAFE is set to anything other than "no". If it is, then
220## we check what the MPM style used by Apache is, if it isnt prefork, we let the user
221## know they need prefork, and then exit the build.
222####
223apache2_pkg_setup() {
224 debug-print-function $FUNCNAME $*
225
226 if [[ -n "${APACHE2_SAFE_MPMS}" ]] ; then
227 INSTALLED_MPM="$(${ROOT}/usr/sbin/apxs2 -q MPM_NAME)"
228
229 if hasq ${INSTALLED_MPM} ${APACHE2_SAFE_MPMS} ; then
230 INSTALLED_MPM_SAFE="yes"
231 fi
232
233 if [[ -z "${INSTALLED_MPM_SAFE}" ]] ; then
234 eerror "The module you are trying to install (${PN})"
235 eerror "will only work with one of the following MPMs:"
236 eerror " ${APACHE2_SAFE_MPMS}"
237 eerror "You do not currently have any of these MPMs installed."
238 eerror "Please re-install apache with the correct mpm-* USE flag set."
239 die "No safe MPM installed."
240 fi
241 fi
242}
243
244####
245## apache2_src_compile
246##
247## The default action is to call ${APXS2} with the value of
248## ${APXS2_ARGS}. If a module requires a different build setup
249## than this, use ${APXS2} in your own src_compile routine.
250####
251apache2_src_compile() {
252 debug-print-function $FUNCNAME $*
253
254 CD_DIR=$(apache_cd_dir)
255 cd "${CD_DIR}" || die "cd ${CD_DIR} failed" 160 cd "${CD_DIR}" || die "cd ${CD_DIR} failed"
161
256 APXS2_ARGS="${APXS2_ARGS:--c ${PN}.c}" 162 APXS2_ARGS="${APXS2_ARGS:--c ${PN}.c}"
257 ${APXS2} ${APXS2_ARGS} || die "${APXS2} ${APXS2_ARGS} failed" 163 ${APXS} ${APXS2_ARGS} || die "${APXS} ${APXS2_ARGS} failed"
258} 164}
259 165
260#### 166# @FUNCTION: apache-module_src_install
261## apache2_src_install 167# @DESCRIPTION:
262##
263## This installs the files into apache's directories. The module is installed 168# This installs the files into apache's directories. The module is installed
264## from a directory chosen as above (APXS2_S or ${S}/src). In addition, 169# from a directory chosen as above (apache_cd_dir). In addition, this function
265## this function can also set the executable permission on files listed in EXECFILES. 170# can also set the executable permission on files listed in
266## The configuration file name is listed in CONFFILE without the .conf extensions, 171# ${APACHE2_EXECFILES}. The configuration file name is listed in
267## so if you configuration is 55_mod_foo.conf, CONFFILE would be 55_mod_foo. 172# ${APACHE2_MOD_CONF} without the .conf extensions, so if you configuration is
173# 55_mod_foo.conf, APACHE2_MOD_CONF would be 55_mod_foo. ${DOCFILES} contains
268## DOCFILES contains the list of files you want filed as documentation. 174# the list of files you want filed as documentation.
269####
270apache2_src_install() { 175apache-module_src_install() {
271 debug-print-function $FUNCNAME $* 176 debug-print-function $FUNCNAME $*
272 177
273 CD_DIR=$(apache_cd_dir) 178 local CD_DIR=$(apache_cd_dir)
274 cd "${CD_DIR}" || die "cd ${CD_DIR} failed" 179 cd "${CD_DIR}" || die "cd ${CD_DIR} failed"
275 180
276 MOD_FILE=$(apache_mod_file) 181 local MOD_FILE=$(apache_mod_file)
277 182
278 exeinto "${APACHE2_MODULESDIR}" 183 exeinto "${APACHE_MODULESDIR}"
279 doexe ${MOD_FILE} || die "internal ebuild error: '${MOD_FILE}' not found" 184 doexe ${MOD_FILE} || die "internal ebuild error: '${MOD_FILE}' not found"
280 [[ -n "${APACHE2_EXECFILES}" ]] && doexe ${APACHE2_EXECFILES} 185 [[ -n "${APACHE2_EXECFILES}" ]] && doexe ${APACHE2_EXECFILES}
281 186
282 if [[ -n "${APACHE2_MOD_CONF}" ]] ; then 187 if [[ -n "${APACHE2_MOD_CONF}" ]] ; then
283 insinto "${APACHE2_MODULES_CONFDIR}" 188 insinto "${APACHE_MODULES_CONFDIR}"
284 doins "${FILESDIR}/${APACHE2_MOD_CONF}.conf" || die "internal ebuild error: '${FILESDIR}/${APACHE2_MOD_CONF}.conf' not found" 189 set -- ${APACHE2_MOD_CONF}
190 newins "${FILESDIR}/${1}.conf" "$(basename ${2:-$1}).conf" \
191 || die "internal ebuild error: '${FILESDIR}/${1}.conf' not found"
285 fi 192 fi
286 193
287 if [[ -n "${APACHE2_VHOSTFILE}" ]] ; then 194 if [[ -n "${APACHE2_VHOST_CONF}" ]] ; then
288 insinto "${APACHE2_VHOSTDIR}" 195 insinto "${APACHE_VHOSTS_CONFDIR}"
289 doins "${FILESDIR}/${APACHE2_VHOSTFILE}.conf" || die "internal ebuild error: '${FILESDIR}/${APACHE2_VHOSTFILE}.conf' not found" 196 set -- ${APACHE2_VHOST_CONF}
197 newins "${FILESDIR}/${1}.conf" "$(basename ${2:-$1}).conf " \
198 || die "internal ebuild error: '${FILESDIR}/${1}.conf' not found"
290 fi 199 fi
291 200
292 cd "${S}" 201 cd "${S}"
293 202
294 if [[ -n "${DOCFILES}" ]] ; then 203 if [[ -n "${DOCFILES}" ]] ; then
295 OTHER_DOCS=$(apache_doc_magic) 204 local OTHER_DOCS=$(apache_doc_magic)
296 HTML_DOCS=$(apache_doc_magic html) 205 local HTML_DOCS=$(apache_doc_magic html)
297 206
298 [[ -n "${OTHER_DOCS}" ]] && dodoc ${OTHER_DOCS} 207 [[ -n "${OTHER_DOCS}" ]] && dodoc ${OTHER_DOCS}
299 [[ -n "${HTML_DOCS}" ]] && dohtml ${HTML_DOCS} 208 [[ -n "${HTML_DOCS}" ]] && dohtml ${HTML_DOCS}
300 fi 209 fi
301} 210}
302 211
212# @FUNCTION: apache-module_pkg_postinst
213# @DESCRIPTION:
214# This prints out information about the installed module and how to enable it.
303apache2_pkg_postinst() { 215apache-module_pkg_postinst() {
304 debug-print-function $FUNCNAME $* 216 debug-print-function $FUNCNAME $*
305 217
306 if [[ -n "${APACHE2_MOD_DEFINE}" ]] ; then 218 if [[ -n "${APACHE2_MOD_DEFINE}" ]] ; then
307 local my_opts="-D ${APACHE2_MOD_DEFINE// / -D }" 219 local my_opts="-D ${APACHE2_MOD_DEFINE// / -D }"
308 220
311 einfo "add '${my_opts}' to APACHE2_OPTS." 223 einfo "add '${my_opts}' to APACHE2_OPTS."
312 einfo 224 einfo
313 fi 225 fi
314 226
315 if [[ -n "${APACHE2_MOD_CONF}" ]] ; then 227 if [[ -n "${APACHE2_MOD_CONF}" ]] ; then
228 set -- ${APACHE2_MOD_CONF}
316 einfo 229 einfo
317 einfo "Configuration file installed as" 230 einfo "Configuration file installed as"
318 einfo " ${APACHE2_MODULES_CONFDIR}/$(basename ${APACHE2_MOD_CONF}).conf" 231 einfo " ${APACHE_MODULES_CONFDIR}/$(basename ${2:-$1}).conf"
319 einfo "You may want to edit it before turning the module on in /etc/conf.d/apache2" 232 einfo "You may want to edit it before turning the module on in /etc/conf.d/apache2"
320 einfo 233 einfo
321 fi 234 fi
322
323 if [[ -n "${APACHE2_SAFE_MPMS}" ]] ; then
324 INSTALLED_MPM="$(${ROOT}/usr/sbin/apxs2 -q MPM_NAME)"
325
326 if ! hasq ${INSTALLED_MPM} ${APACHE2_SAFE_MPMS} ; then
327 INSTALLED_MPM_UNSAFE="${INSTALLED_MPM_UNSAFE} ${mpm}"
328 else
329 INSTALLED_MPM_SAFE="${INSTALLED_MPM_SAFE} ${mpm}"
330 fi
331
332 if [[ -n "${INSTALLED_MPM_UNSAFE}" ]] ; then
333 ewarn "You have one or more MPMs installed that will not work with"
334 ewarn "this module (${PN}). Please make sure that you only enable"
335 ewarn "this module if you are using one of the following MPMs:"
336 ewarn " ${INSTALLED_MPM_SAFE}"
337 fi
338 fi
339} 235}
340 236
341######
342## Apache dual (1.x or 2.x) ebuild functions - Apache 1.X DEPRECATED!
343##
344## This is where the magic happens. We provide dummy routines of all of the functions
345## provided by all of the specifics. We use APACHE_ECLASS_VER_* to see which versions
346## to call. If a function is provided by a given section (ie pkg_postinst in Apache 2.x)
347## the exported routine simply does nothing.
348######
349
350apache-module_pkg_setup() {
351 debug-print-function $FUNCNAME $*
352
353 if [[ ${APACHE_VERSION} -eq "2" ]] ; then
354 apache2_pkg_setup
355 fi
356}
357
358apache-module_src_compile() {
359 debug-print-function $FUNCNAME $*
360
361 if [[ ${APACHE_VERSION} -eq "1" ]] ; then
362 apache1_src_compile
363 else
364 apache2_src_compile
365 fi
366}
367
368apache-module_src_install() {
369 debug-print-function $FUNCNAME $*
370
371 if [[ ${APACHE_VERSION} -eq "1" ]] ; then
372 apache1_src_install
373 else
374 apache2_src_install
375 fi
376}
377
378apache-module_pkg_postinst() {
379 debug-print-function $FUNCNAME $*
380
381 if [[ ${APACHE_VERSION} -eq "1" ]] ; then
382 apache1_pkg_postinst
383 else
384 apache2_pkg_postinst
385 fi
386}
387
388EXPORT_FUNCTIONS pkg_setup src_compile src_install pkg_postinst 237EXPORT_FUNCTIONS src_compile src_install pkg_postinst

Legend:
Removed from v.1.19  
changed lines
  Added in v.1.25

  ViewVC Help
Powered by ViewVC 1.1.20