/[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.18 Revision 1.19
1# Copyright 2004 Gentoo Foundation 1# Copyright 1999-2007 Gentoo Foundation
2# Distributed under the terms of the GNU General Public License, v2 or later 2# Distributed under the terms of the GNU General Public License v2
3# Author Michael Tindal <urilith@gentoo.org>
4# $Header: /var/cvsroot/gentoo-x86/eclass/apache-module.eclass,v 1.18 2006/11/26 21:25:28 vericgar Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/apache-module.eclass,v 1.19 2007/05/12 02:28:51 chtekk Exp $
5 4
6inherit depend.apache 5inherit depend.apache
7 6
8# This eclass provides a common set of functions for Apache modules. 7# This eclass provides a common set of functions for Apache modules.
9 8
10# NOTE: If you use this, be sure you use the need_* call after you have 9# NOTE: If you use this, be sure you use the need_* call after you have
11# defined DEPEND and RDEPEND. Also note that you can not rely on the 10# defined DEPEND and RDEPEND. Also note that you can not rely on the
12# automatic RDEPEND=DEPEND that portage does if you use this eclass. 11# automatic RDEPEND=DEPEND that Portage does if you use this eclass.
13# See bug 107127 for more information. 12# See bug 107127 for more information.
14 13
15###### 14######
16## Common ebuild variables 15## Common ebuild variables
17###### 16######
76## Return the path to our temporary build dir 75## Return the path to our temporary build dir
77#### 76####
78apache_cd_dir() { 77apache_cd_dir() {
79 debug-print-function $FUNCNAME $* 78 debug-print-function $FUNCNAME $*
80 79
81 if [ "${APACHE_VERSION}" == "1" ]; then 80 if [[ "${APACHE_VERSION}" == "1" ]] ; then
82 [ -n "${APXS1_S}" ] && CD_DIR="${APXS1_S}" 81 [[ -n "${APXS1_S}" ]] && CD_DIR="${APXS1_S}"
83 else 82 else
84 [ -n "${APXS2_S}" ] && CD_DIR="${APXS2_S}" 83 [[ -n "${APXS2_S}" ]] && CD_DIR="${APXS2_S}"
85 fi 84 fi
86 85
87 # XXX - is this really needed? can't we just return ${S}? 86 # XXX - Is this really needed? Can't we just return ${S}?
88 if [ -z "${CD_DIR}" ]; then 87 if [[ -z "${CD_DIR}" ]] ; then
89 if [ -d ${S}/src ] ; then 88 if [[ -d "${S}/src" ]] ; then
90 CD_DIR="${S}/src" 89 CD_DIR="${S}/src"
91 else 90 else
92 CD_DIR="${S}" 91 CD_DIR="${S}"
93 fi 92 fi
94 fi 93 fi
95 94
96 debug-print apache_cd_dir: "CD_DIR=${CD_DIR}" 95 debug-print apache_cd_dir: "CD_DIR=${CD_DIR}"
97 echo ${CD_DIR} 96 echo "${CD_DIR}"
98} 97}
99 98
100#### 99####
101## apache_mod_file 100## apache_mod_file
102## 101##
103## Return the path to the module file 102## Return the path to the module file
104#### 103####
105apache_mod_file() { 104apache_mod_file() {
106 debug-print-function $FUNCNAME $* 105 debug-print-function $FUNCNAME $*
107 106
108 if [ "${APACHE_VERSION}" == "1" ]; then 107 if [[ "${APACHE_VERSION}" == "1" ]] ; then
109 [ -n "${APACHE1_MOD_FILE}" ] && MOD_FILE="${APACHE1_MOD_FILE}" 108 [[ -n "${APACHE1_MOD_FILE}" ]] && MOD_FILE="${APACHE1_MOD_FILE}"
110 [ -z "${MOD_FILE}" ] && MOD_FILE="$(apache_cd_dir)/${PN}.so" 109 [[ -z "${MOD_FILE}" ]] && MOD_FILE="$(apache_cd_dir)/${PN}.so"
111 else 110 else
112 [ -n "${APACHE2_MOD_FILE}" ] && MOD_FILE="${APACHE2_MOD_FILE}" 111 [[ -n "${APACHE2_MOD_FILE}" ]] && MOD_FILE="${APACHE2_MOD_FILE}"
113 [ -z "${MOD_FILE}" ] && MOD_FILE="$(apache_cd_dir)/.libs/${PN}.so" 112 [[ -z "${MOD_FILE}" ]] && MOD_FILE="$(apache_cd_dir)/.libs/${PN}.so"
114 fi 113 fi
115 114
116 debug-print apache_mod_file: MOD_FILE=${MOD_FILE} 115 debug-print apache_mod_file: "MOD_FILE=${MOD_FILE}"
117 echo ${MOD_FILE} 116 echo "${MOD_FILE}"
118} 117}
119 118
120#### 119####
121## apache_doc_magic 120## apache_doc_magic
122## 121##
123## Some magic for picking out html files from ${DOCFILES}. It takes 122## Some magic for picking out html files from ${DOCFILES}. It takes
124## an optional first argument `html'; if the first argument is equals 123## an optional first argument `html'; if the first argument is equals
125## `html', only html files are returned, otherwise normal (non-html) 124## `html', only html files are returned, otherwise normal (non-html)
126## docs are returned. 125## docs are returned.
127#### 126####
128apache_doc_magic() { 127apache_doc_magic() {
129 debug-print-function $FUNCNAME $* 128 debug-print-function $FUNCNAME $*
130 129
131 if [ -n "${DOCFILES}" ]; then 130 if [[ -n "${DOCFILES}" ]] ; then
132 if [ "x$1" == "xhtml" ]; then 131 if [[ "x$1" == "xhtml" ]] ; then
133 DOCS="`echo ${DOCFILES} | sed -e 's/ /\n/g' | sed -e '/^[^ ]*.html$/ !d'`" 132 DOCS="`echo ${DOCFILES} | sed -e 's/ /\n/g' | sed -e '/^[^ ]*.html$/ !d'`"
134 else 133 else
135 DOCS="`echo ${DOCFILES} | sed 's, *[^ ]*\+.html, ,g'`" 134 DOCS="`echo ${DOCFILES} | sed 's, *[^ ]*\+.html, ,g'`"
136 fi 135 fi
137 136
138 debug-print apache_doc_magic: DOCS=${DOCS} 137 debug-print apache_doc_magic: "DOCS=${DOCS}"
139 echo ${DOCS} 138 echo "${DOCS}"
140 fi 139 fi
141} 140}
142 141
143######
144## Apache 1.x ebuild functions
145######
146
147#### 142######
148## apache1_src_compile 143## Apache 1.x ebuild functions - !!! DEPRECATED !!!
149## The default action is to call ${APXS11} with the value of 144######
150## ${APXS1_ARGS}. If a module requires a different build setup 145
151## than this, use ${APXS1} in your own src_compile routine. 146####
147## apache1_src_compile - !!! DEPRECATED !!!
152#### 148####
153apache1_src_compile() { 149apache1_src_compile() {
154 debug-print-function $FUNCNAME $* 150 debug-print-function $FUNCNAME $*
155 151
156 CD_DIR=$(apache_cd_dir) 152 CD_DIR=$(apache_cd_dir)
158 APXS1_ARGS="${APXS1_ARGS:--c ${PN}.c}" 154 APXS1_ARGS="${APXS1_ARGS:--c ${PN}.c}"
159 ${APXS1} ${APXS1_ARGS} || die "${APXS1} ${APXS1_ARGS} failed" 155 ${APXS1} ${APXS1_ARGS} || die "${APXS1} ${APXS1_ARGS} failed"
160} 156}
161 157
162#### 158####
163## apache1_src_install 159## apache1_src_install - !!! DEPRECATED !!!
164##
165## This installs the files into apache's directories. The module is installed
166## from a directory chosen as above (APXS2_S or ${S}/src). In addition,
167## this function can also set the executable permission on files listed in EXECFILES.
168## The configuration file name is listed in APACHE1_MOD_CONF without the .conf extensions,
169## so if you configuration is 55_mod_foo.conf, APACHE1_MOD_CONF would be 55_mod_foo.
170## DOCFILES contains the list of files you want filed as documentation. The name of the
171## module can also be specified using the APACHE1_MOD_FILE or defaults to
172## .libs/${PN}.so.
173#### 160####
174apache1_src_install() { 161apache1_src_install() {
175 debug-print-function $FUNCNAME $* 162 debug-print-function $FUNCNAME $*
176 163
177 CD_DIR=$(apache_cd_dir) 164 CD_DIR=$(apache_cd_dir)
198 [ -n "${HTML_DOCS}" ] && dohtml ${HTML_DOCS} 185 [ -n "${HTML_DOCS}" ] && dohtml ${HTML_DOCS}
199 fi 186 fi
200} 187}
201 188
202#### 189####
203## apache1_pkg_postinst 190## apache1_pkg_postinst - !!! DEPRECATED !!!
204##
205## Prints the standard config message, unless APACHE1_NO_CONFIG is set to yes.
206#### 191####
207apache1_pkg_postinst() { 192apache1_pkg_postinst() {
208 debug-print-function $FUNCNAME $* 193 debug-print-function $FUNCNAME $*
209 194
210 if [ -n "${APACHE1_MOD_DEFINE}" ]; then 195 if [ -n "${APACHE1_MOD_DEFINE}" ]; then
216 einfo 201 einfo
217 fi 202 fi
218 if [ -n "${APACHE1_MOD_CONF}" ] ; then 203 if [ -n "${APACHE1_MOD_CONF}" ] ; then
219 einfo 204 einfo
220 einfo "Configuration file installed as" 205 einfo "Configuration file installed as"
221 einfo " ${APACHE1_MODULES_CONFDIR}/$(basename ${APACHE1_MOD_CONF}).conf" 206 einfo " ${APACHE1_MODULES_CONFDIR}/$(basename ${APACHE1_MOD_CONF}).conf"
222 einfo "You may want to edit it before turning the module on in /etc/conf.d/apache" 207 einfo "You may want to edit it before turning the module on in /etc/conf.d/apache"
223 einfo 208 einfo
224 fi 209 fi
225} 210}
226 211
229###### 214######
230 215
231#### 216####
232## apache2_pkg_setup 217## apache2_pkg_setup
233## 218##
234## Checks to see if APACHE2_MT_UNSAFE is set to anything other than "no". If it is, then 219## Checks to see if APACHE2_MT_UNSAFE is set to anything other than "no". If it is, then
235## we check what the MPM style used by Apache is, if it isnt prefork, we let the user 220## we check what the MPM style used by Apache is, if it isnt prefork, we let the user
236## know they need prefork, and then exit the build. 221## know they need prefork, and then exit the build.
237#### 222####
238apache2_pkg_setup() { 223apache2_pkg_setup() {
239 debug-print-function $FUNCNAME $* 224 debug-print-function $FUNCNAME $*
240 225
241 if [ -n "${APACHE2_SAFE_MPMS}" ]; then 226 if [[ -n "${APACHE2_SAFE_MPMS}" ]] ; then
242
243 INSTALLED_MPM="$(${ROOT}/usr/sbin/apxs2 -q MPM_NAME)" 227 INSTALLED_MPM="$(${ROOT}/usr/sbin/apxs2 -q MPM_NAME)"
244 228
245 if hasq ${INSTALLED_MPM} ${APACHE2_SAFE_MPMS} ; then 229 if hasq ${INSTALLED_MPM} ${APACHE2_SAFE_MPMS} ; then
246 INSTALLED_MPM_SAFE="yes" 230 INSTALLED_MPM_SAFE="yes"
247 fi 231 fi
248 232
249 if [ -z "${INSTALLED_MPM_SAFE}" ] ; then 233 if [[ -z "${INSTALLED_MPM_SAFE}" ]] ; then
250 eerror "The module you are trying to install (${PN})" 234 eerror "The module you are trying to install (${PN})"
251 eerror "will only work with one of the following MPMs:" 235 eerror "will only work with one of the following MPMs:"
252 eerror " ${APACHE2_SAFE_MPMS}" 236 eerror " ${APACHE2_SAFE_MPMS}"
253 eerror "You do not currently have any of these MPMs installed." 237 eerror "You do not currently have any of these MPMs installed."
254 eerror "Please re-install apache with the correct mpm-* USE flag set." 238 eerror "Please re-install apache with the correct mpm-* USE flag set."
255 die "No safe MPM installed." 239 die "No safe MPM installed."
256 fi 240 fi
257
258 fi 241 fi
259
260} 242}
261 243
262#### 244####
263## apache2_src_compile 245## apache2_src_compile
264## 246##
265## The default action is to call ${APXS2} with the value of 247## The default action is to call ${APXS2} with the value of
266## ${APXS2_ARGS}. If a module requires a different build setup 248## ${APXS2_ARGS}. If a module requires a different build setup
267## than this, use ${APXS2} in your own src_compile routine. 249## than this, use ${APXS2} in your own src_compile routine.
268#### 250####
269apache2_src_compile() { 251apache2_src_compile() {
270 debug-print-function $FUNCNAME $* 252 debug-print-function $FUNCNAME $*
271 253
272 CD_DIR=$(apache_cd_dir) 254 CD_DIR=$(apache_cd_dir)
273 cd ${CD_DIR} || die "cd ${CD_DIR} failed" 255 cd "${CD_DIR}" || die "cd ${CD_DIR} failed"
274 APXS2_ARGS="${APXS2_ARGS:--c ${PN}.c}" 256 APXS2_ARGS="${APXS2_ARGS:--c ${PN}.c}"
275 ${APXS2} ${APXS2_ARGS} || die "${APXS2} ${APXS2_ARGS} failed" 257 ${APXS2} ${APXS2_ARGS} || die "${APXS2} ${APXS2_ARGS} failed"
276} 258}
277 259
278#### 260####
279## apache2_src_install 261## apache2_src_install
280## 262##
281## This installs the files into apache's directories. The module is installed 263## This installs the files into apache's directories. The module is installed
282## from a directory chosen as above (APXS2_S or ${S}/src). In addition, 264## from a directory chosen as above (APXS2_S or ${S}/src). In addition,
283## this function can also set the executable permission on files listed in EXECFILES. 265## this function can also set the executable permission on files listed in EXECFILES.
284## The configuration file name is listed in CONFFILE without the .conf extensions, 266## The configuration file name is listed in CONFFILE without the .conf extensions,
285## so if you configuration is 55_mod_foo.conf, CONFFILE would be 55_mod_foo. 267## so if you configuration is 55_mod_foo.conf, CONFFILE would be 55_mod_foo.
286## DOCFILES contains the list of files you want filed as documentation. 268## DOCFILES contains the list of files you want filed as documentation.
287#### 269####
288apache2_src_install() { 270apache2_src_install() {
289 debug-print-function $FUNCNAME $* 271 debug-print-function $FUNCNAME $*
290 272
291 CD_DIR=$(apache_cd_dir) 273 CD_DIR=$(apache_cd_dir)
292 cd ${CD_DIR} || die "cd ${CD_DIR} failed" 274 cd "${CD_DIR}" || die "cd ${CD_DIR} failed"
293 275
294 MOD_FILE=$(apache_mod_file) 276 MOD_FILE=$(apache_mod_file)
295 277
296 exeinto ${APACHE2_MODULESDIR} 278 exeinto "${APACHE2_MODULESDIR}"
297 doexe ${MOD_FILE} || die "internal ebuild error: '${MOD_FILE}' not found" 279 doexe ${MOD_FILE} || die "internal ebuild error: '${MOD_FILE}' not found"
298 [ -n "${APACHE2_EXECFILES}" ] && doexe ${APACHE2_EXECFILES} 280 [[ -n "${APACHE2_EXECFILES}" ]] && doexe ${APACHE2_EXECFILES}
299 281
300 if [ -n "${APACHE2_MOD_CONF}" ] ; then 282 if [[ -n "${APACHE2_MOD_CONF}" ]] ; then
301 insinto ${APACHE2_MODULES_CONFDIR} 283 insinto "${APACHE2_MODULES_CONFDIR}"
302 doins ${FILESDIR}/${APACHE2_MOD_CONF}.conf || die "internal ebuild error: '${FILESDIR}/${APACHE2_MOD_CONF}.conf' not found." 284 doins "${FILESDIR}/${APACHE2_MOD_CONF}.conf" || die "internal ebuild error: '${FILESDIR}/${APACHE2_MOD_CONF}.conf' not found"
303 fi 285 fi
304 286
305 if [ -n "${APACHE2_VHOSTFILE}" ]; then 287 if [[ -n "${APACHE2_VHOSTFILE}" ]] ; then
306 insinto ${APACHE2_VHOSTDIR} 288 insinto "${APACHE2_VHOSTDIR}"
307 doins ${FILESDIR}/${APACHE2_VHOSTFILE}.conf 289 doins "${FILESDIR}/${APACHE2_VHOSTFILE}.conf" || die "internal ebuild error: '${FILESDIR}/${APACHE2_VHOSTFILE}.conf' not found"
308 fi 290 fi
309 291
310 cd ${S} 292 cd "${S}"
311 293
312 if [ -n "${DOCFILES}" ] ; then 294 if [[ -n "${DOCFILES}" ]] ; then
313 OTHER_DOCS=$(apache_doc_magic) 295 OTHER_DOCS=$(apache_doc_magic)
314 HTML_DOCS=$(apache_doc_magic html) 296 HTML_DOCS=$(apache_doc_magic html)
315 297
316 [ -n "${OTHER_DOCS}" ] && dodoc ${OTHER_DOCS} 298 [[ -n "${OTHER_DOCS}" ]] && dodoc ${OTHER_DOCS}
317 [ -n "${HTML_DOCS}" ] && dohtml ${HTML_DOCS} 299 [[ -n "${HTML_DOCS}" ]] && dohtml ${HTML_DOCS}
318 fi 300 fi
319} 301}
320 302
321apache2_pkg_postinst() { 303apache2_pkg_postinst() {
322 debug-print-function $FUNCNAME $* 304 debug-print-function $FUNCNAME $*
323 305
324 if [ -n "${APACHE2_MOD_DEFINE}" ]; then 306 if [[ -n "${APACHE2_MOD_DEFINE}" ]] ; then
325 local my_opts="-D ${APACHE2_MOD_DEFINE// / -D }" 307 local my_opts="-D ${APACHE2_MOD_DEFINE// / -D }"
326 308
327 einfo 309 einfo
328 einfo "To enable ${PN}, you need to edit your /etc/conf.d/apache2 file and" 310 einfo "To enable ${PN}, you need to edit your /etc/conf.d/apache2 file and"
329 einfo "add '${my_opts}' to APACHE2_OPTS." 311 einfo "add '${my_opts}' to APACHE2_OPTS."
330 einfo 312 einfo
331 fi 313 fi
314
332 if [ -n "${APACHE2_MOD_CONF}" ] ; then 315 if [[ -n "${APACHE2_MOD_CONF}" ]] ; then
333 einfo 316 einfo
334 einfo "Configuration file installed as" 317 einfo "Configuration file installed as"
335 einfo " ${APACHE2_MODULES_CONFDIR}/$(basename ${APACHE2_MOD_CONF}).conf" 318 einfo " ${APACHE2_MODULES_CONFDIR}/$(basename ${APACHE2_MOD_CONF}).conf"
336 einfo "You may want to edit it before turning the module on in /etc/conf.d/apache2" 319 einfo "You may want to edit it before turning the module on in /etc/conf.d/apache2"
337 einfo 320 einfo
338 fi 321 fi
339 322
340 if [ -n "${APACHE2_SAFE_MPMS}" ]; then 323 if [[ -n "${APACHE2_SAFE_MPMS}" ]] ; then
341
342 INSTALLED_MPM="$(${ROOT}/usr/sbin/apxs2 -q MPM_NAME)" 324 INSTALLED_MPM="$(${ROOT}/usr/sbin/apxs2 -q MPM_NAME)"
343 325
344 if ! hasq ${INSTALLED_MPM} ${APACHE2_SAFE_MPMS} ; then 326 if ! hasq ${INSTALLED_MPM} ${APACHE2_SAFE_MPMS} ; then
345 INSTALLED_MPM_UNSAFE="${INSTALLED_MPM_UNSAFE} ${mpm}" 327 INSTALLED_MPM_UNSAFE="${INSTALLED_MPM_UNSAFE} ${mpm}"
346 else 328 else
347 INSTALLED_MPM_SAFE="${INSTALLED_MPM_SAFE} ${mpm}" 329 INSTALLED_MPM_SAFE="${INSTALLED_MPM_SAFE} ${mpm}"
348 fi 330 fi
349 331
350 if [ -n "${INSTALLED_MPM_UNSAFE}" ] ; then 332 if [[ -n "${INSTALLED_MPM_UNSAFE}" ]] ; then
351 ewarn "You have one or more MPMs installed that will not work with" 333 ewarn "You have one or more MPMs installed that will not work with"
352 ewarn "this module (${PN}). Please make sure that you only enable" 334 ewarn "this module (${PN}). Please make sure that you only enable"
353 ewarn "this module if you are using one of the following MPMs:" 335 ewarn "this module if you are using one of the following MPMs:"
354 ewarn " ${INSTALLED_MPM_SAFE}" 336 ewarn " ${INSTALLED_MPM_SAFE}"
355 fi
356
357 fi 337 fi
358 338 fi
359} 339}
360 340
361###### 341######
362## Apache dual (1.x or 2.x) ebuild functions 342## Apache dual (1.x or 2.x) ebuild functions - Apache 1.X DEPRECATED!
363## 343##
364## This is where the magic happens. We provide dummy routines of all of the functions 344## This is where the magic happens. We provide dummy routines of all of the functions
365## provided by all of the specifics. We use APACHE_ECLASS_VER_* to see which versions 345## provided by all of the specifics. We use APACHE_ECLASS_VER_* to see which versions
366## to call. If a function is provided by a given section (ie pkg_postinst in Apache 2.x) 346## to call. If a function is provided by a given section (ie pkg_postinst in Apache 2.x)
367## the exported routine simply does nothing. 347## the exported routine simply does nothing.
368###### 348######
369 349
370apache-module_pkg_setup() { 350apache-module_pkg_setup() {
371 debug-print-function $FUNCNAME $* 351 debug-print-function $FUNCNAME $*
372 352
373 if [ ${APACHE_VERSION} -eq '2' ]; then 353 if [[ ${APACHE_VERSION} -eq "2" ]] ; then
374 apache2_pkg_setup 354 apache2_pkg_setup
375 fi 355 fi
376} 356}
377 357
378apache-module_src_compile() { 358apache-module_src_compile() {
379 debug-print-function $FUNCNAME $* 359 debug-print-function $FUNCNAME $*
380 360
381 if [ ${APACHE_VERSION} -eq '1' ]; then 361 if [[ ${APACHE_VERSION} -eq "1" ]] ; then
382 apache1_src_compile 362 apache1_src_compile
383 else 363 else
384 apache2_src_compile 364 apache2_src_compile
385 fi 365 fi
386} 366}
387 367
388apache-module_src_install() { 368apache-module_src_install() {
389 debug-print-function $FUNCNAME $* 369 debug-print-function $FUNCNAME $*
390 370
391 if [ ${APACHE_VERSION} -eq '1' ]; then 371 if [[ ${APACHE_VERSION} -eq "1" ]] ; then
392 apache1_src_install 372 apache1_src_install
393 else 373 else
394 apache2_src_install 374 apache2_src_install
395 fi 375 fi
396} 376}
397 377
398apache-module_pkg_postinst() { 378apache-module_pkg_postinst() {
399 debug-print-function $FUNCNAME $* 379 debug-print-function $FUNCNAME $*
400 380
401 if [ ${APACHE_VERSION} -eq '1' ]; then 381 if [[ ${APACHE_VERSION} -eq "1" ]] ; then
402 apache1_pkg_postinst 382 apache1_pkg_postinst
403 else 383 else
404 apache2_pkg_postinst 384 apache2_pkg_postinst
405 fi 385 fi
406} 386}
407 387
408EXPORT_FUNCTIONS pkg_setup src_compile src_install pkg_postinst 388EXPORT_FUNCTIONS pkg_setup src_compile src_install pkg_postinst
409
410# vim:ts=4

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

  ViewVC Help
Powered by ViewVC 1.1.20