/[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.21 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.21 2008/01/27 20:09:17 hollow Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/apache-module.eclass,v 1.25 2011/12/27 17:55:12 fauli Exp $
4 4
5# @ECLASS: apache-module 5# @ECLASS: apache-module.eclass
6# @MAINTAINER:
6# @MAINTAINER: apache-devs@gentoo.org 7# apache-devs@gentoo.org
7# @BLURB: Provides a common set of functions for apache modules 8# @BLURB: Provides a common set of functions for apache modules
8# @DESCRIPTION: 9# @DESCRIPTION:
9# This eclass handles apache modules in a sane way and providing information 10# This eclass handles apache modules in a sane way.
10# about where certain interfaces 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 in depend.apache.eclass. Make sure you use the need/want_apache call
13# DEPEND and RDEPEND. Also note that you can not rely on the automatic 14# after you have defined DEPEND and RDEPEND. Also note that you can not rely on
14# RDEPEND=DEPEND that Portage does if you use this eclass. 15# the automatic 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 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
17 47
18inherit depend.apache 48inherit depend.apache
19 49
20# ============================================================================== 50# ==============================================================================
21# INTERNAL VARIABLES 51# PUBLIC VARIABLES
22# ============================================================================== 52# ==============================================================================
23 53
24# @ECLASS-VARIABLE: APXS2_S 54# @VARIABLE: APXS2_S
25# @DESCRIPTION: 55# @DESCRIPTION:
26# Path to temporary build directory 56# Path to temporary build directory. (Defaults to `${S}/src' if it exists,
27APXS2_S="" 57# `${S}' otherwise)
28 58
29# @ECLASS-VARIABLE: APXS2_ARGS 59# @VARIABLE: APXS2_ARGS
30# @DESCRIPTION: 60# @DESCRIPTION:
31# Arguments to pass to the apxs tool 61# Arguments to pass to the apxs tool. (Defaults to `-c ${PN}.c')
32APXS2_ARGS=""
33 62
34# @ECLASS-VARIABLE: APACHE2_MOD_FILE 63# @VARIABLE: APACHE2_EXECFILES
35# @DESCRIPTION: 64# @DESCRIPTION:
36# Name of the module that src_install installs (minus the .so) 65# List of files that will be installed into ${APACHE_MODULE_DIR} beside
37APACHE2_MOD_FILE="" 66# ${APACHE2_MOD_FILE}. In addition, this function also sets the executable
67# permission on those files.
38 68
39# @ECLASS-VARIABLE: APACHE2_MOD_CONF 69# @VARIABLE: APACHE2_MOD_CONF
40# @DESCRIPTION: 70# @DESCRIPTION:
41# Configuration file installed by src_install 71# Module configuration file installed by src_install (minus the .conf suffix and
42APACHE2_MOD_CONF="" 72# relative to ${FILESDIR}).
43 73
44# @ECLASS-VARIABLE: APACHE2_VHOSTFILE
45# @DESCRIPTION:
46# Virtual host configuration file installed by src_install
47APACHE2_VHOSTFILE=""
48
49# @ECLASS-VARIABLE: APACHE2_MOD_DEFINE 74# @VARIABLE: APACHE2_MOD_DEFINE
50# @DESCRIPTION: 75# @DESCRIPTION:
51# 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
52# module/it's config file, multiple defines should be space separated 77# module/its config file, multiple defines should be space separated.
53APACHE2_MOD_DEFINE=""
54 78
79# @VARIABLE: APACHE2_MOD_FILE
80# @DESCRIPTION:
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
55# @ECLASS-VARIABLE: DOCFILES 89# @VARIABLE: DOCFILES
56# @DESCRIPTION: 90# @DESCRIPTION:
57# If the exported src_install() is being used, and ${DOCFILES} is non-zero, some 91# If the exported src_install() is being used, and ${DOCFILES} is non-zero, some
58# 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
59# documentation, and dodoc'd or dohtml'd 93# documentation, and dodoc'd or dohtml'd.
60DOCFILES=""
61 94
62# ============================================================================== 95# ==============================================================================
63# PUBLIC FUNCTIONS 96# INTERNAL FUNCTIONS
64# ============================================================================== 97# ==============================================================================
65 98
66# @FUNCTION: apache_cd_dir 99# Internal function to construct the default ${APXS2_S} path if required.
67# @DESCRIPTION:
68# Return the path to our temporary build dir
69apache_cd_dir() { 100apache_cd_dir() {
70 debug-print-function $FUNCNAME $* 101 debug-print-function $FUNCNAME $*
71 102
72 [[ -n "${APXS2_S}" ]] && CD_DIR="${APXS2_S}" 103 local CD_DIR="${APXS2_S}"
73 104
74 if [[ -z "${CD_DIR}" ]] ; then 105 if [[ -z "${CD_DIR}" ]] ; then
75 if [[ -d "${S}/src" ]] ; then 106 if [[ -d "${S}/src" ]] ; then
76 CD_DIR="${S}/src" 107 CD_DIR="${S}/src"
77 else 108 else
78 CD_DIR="${S}" 109 CD_DIR="${S}"
79 fi 110 fi
80 fi 111 fi
81 112
82 debug-print apache_cd_dir: "CD_DIR=${CD_DIR}" 113 debug-print $FUNCNAME "CD_DIR=${CD_DIR}"
83 echo "${CD_DIR}" 114 echo "${CD_DIR}"
84} 115}
85 116
86# @FUNCTION: apache_mod_file 117# Internal function to construct the default ${APACHE2_MOD_FILE} if required.
87# @DESCRIPTION:
88# Return the path to the module file
89apache_mod_file() { 118apache_mod_file() {
90 debug-print-function $FUNCNAME $* 119 debug-print-function $FUNCNAME $*
91 120
92 [[ -n "${APACHE2_MOD_FILE}" ]] && MOD_FILE="${APACHE2_MOD_FILE}" 121 local MOD_FILE="${APACHE2_MOD_FILE:-$(apache_cd_dir)/.libs/${PN}.so}"
93 [[ -z "${MOD_FILE}" ]] && MOD_FILE="$(apache_cd_dir)/.libs/${PN}.so"
94 122
95 debug-print apache_mod_file: "MOD_FILE=${MOD_FILE}" 123 debug-print $FUNCNAME "MOD_FILE=${MOD_FILE}"
96 echo "${MOD_FILE}" 124 echo "${MOD_FILE}"
97} 125}
98 126
99# @FUNCTION: apache_doc_magic
100# @DESCRIPTION:
101# Some magic for picking out html files from ${DOCFILES}. It takes an optional 127# Internal function for picking out html files from ${DOCFILES}. It takes an
102# first argument `html'; if the first argument is equals `html', only html files 128# optional first argument `html'; if the first argument is equals `html', only
103# are returned, otherwise normal (non-html) docs are returned. 129# html files are returned, otherwise normal (non-html) docs are returned.
104apache_doc_magic() { 130apache_doc_magic() {
105 debug-print-function $FUNCNAME $* 131 debug-print-function $FUNCNAME $*
132
133 local DOCS=
106 134
107 if [[ -n "${DOCFILES}" ]] ; then 135 if [[ -n "${DOCFILES}" ]] ; then
108 if [[ "x$1" == "xhtml" ]] ; then 136 if [[ "x$1" == "xhtml" ]] ; then
109 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'`"
110 else 138 else
111 DOCS="`echo ${DOCFILES} | sed 's, *[^ ]*\+.html, ,g'`" 139 DOCS="`echo ${DOCFILES} | sed 's, *[^ ]*\+.html, ,g'`"
112 fi 140 fi
141 fi
113 142
114 debug-print apache_doc_magic: "DOCS=${DOCS}" 143 debug-print $FUNCNAME "DOCS=${DOCS}"
115 echo "${DOCS}" 144 echo "${DOCS}"
116 fi
117} 145}
118 146
119# @FUNCTION: apache-module_pkg_setup 147# ==============================================================================
120# @DESCRIPTION: 148# EXPORTED FUNCTIONS
121# Checks to see if APACHE2_SAFE_MPMS is set and if the currently installed MPM 149# ==============================================================================
122# does appear in the list.
123apache-module_pkg_setup() {
124 debug-print-function $FUNCNAME $*
125
126 if [[ -n "${APACHE2_SAFE_MPMS}" ]] ; then
127 INSTALLED_MPM="$(${ROOT}/usr/sbin/apxs2 -q MPM_NAME)"
128
129 if hasq ${INSTALLED_MPM} ${APACHE2_SAFE_MPMS} ; then
130 INSTALLED_MPM_SAFE="yes"
131 fi
132
133 if [[ -z "${INSTALLED_MPM_SAFE}" ]] ; then
134 eerror "The module you are trying to install (${PN})"
135 eerror "will only work with one of the following MPMs:"
136 eerror " ${APACHE2_SAFE_MPMS}"
137 eerror "You do not currently have any of these MPMs installed."
138 eerror "Please re-install apache with the correct mpm-* USE flag set."
139 die "No safe MPM installed."
140 fi
141 fi
142}
143 150
144# @FUNCTION: apache-module_src_compile 151# @FUNCTION: apache-module_src_compile
145# @DESCRIPTION: 152# @DESCRIPTION:
146# The default action is to call ${APXS2} with the value of ${APXS2_ARGS}. If a 153# The default action is to call ${APXS} with the value of ${APXS2_ARGS}. If a
147# module requires a different build setup than this, use ${APXS2} in your own 154# module requires a different build setup than this, use ${APXS} in your own
148# src_compile routine. 155# src_compile routine.
149apache-module_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" 160 cd "${CD_DIR}" || die "cd ${CD_DIR} failed"
161
154 APXS2_ARGS="${APXS2_ARGS:--c ${PN}.c}" 162 APXS2_ARGS="${APXS2_ARGS:--c ${PN}.c}"
155 ${APXS2} ${APXS2_ARGS} || die "${APXS2} ${APXS2_ARGS} failed" 163 ${APXS} ${APXS2_ARGS} || die "${APXS} ${APXS2_ARGS} failed"
156} 164}
157 165
158# @FUNCTION: apache-module_src_install 166# @FUNCTION: apache-module_src_install
159# @DESCRIPTION: 167# @DESCRIPTION:
160# 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
161# from a directory chosen as above (APXS2_S or ${S}/src). In addition, this 169# from a directory chosen as above (apache_cd_dir). In addition, this function
162# function can also set the executable permission on files listed in 170# can also set the executable permission on files listed in
163# APACHE2_EXECFILES. The configuration file name is listed in APACHE2_MOD_CONF 171# ${APACHE2_EXECFILES}. The configuration file name is listed in
164# without the .conf extensions, so if you configuration is 55_mod_foo.conf, 172# ${APACHE2_MOD_CONF} without the .conf extensions, so if you configuration is
165# APACHE2_MOD_CONF would be 55_mod_foo. DOCFILES contains the list of files you 173# 55_mod_foo.conf, APACHE2_MOD_CONF would be 55_mod_foo. ${DOCFILES} contains
166# want filed as documentation. 174# the list of files you want filed as documentation.
167apache-module_src_install() { 175apache-module_src_install() {
168 debug-print-function $FUNCNAME $* 176 debug-print-function $FUNCNAME $*
169 177
170 CD_DIR=$(apache_cd_dir) 178 local CD_DIR=$(apache_cd_dir)
171 cd "${CD_DIR}" || die "cd ${CD_DIR} failed" 179 cd "${CD_DIR}" || die "cd ${CD_DIR} failed"
172 180
173 MOD_FILE=$(apache_mod_file) 181 local MOD_FILE=$(apache_mod_file)
174 182
175 exeinto "${APACHE2_MODULESDIR}" 183 exeinto "${APACHE_MODULESDIR}"
176 doexe ${MOD_FILE} || die "internal ebuild error: '${MOD_FILE}' not found" 184 doexe ${MOD_FILE} || die "internal ebuild error: '${MOD_FILE}' not found"
177 [[ -n "${APACHE2_EXECFILES}" ]] && doexe ${APACHE2_EXECFILES} 185 [[ -n "${APACHE2_EXECFILES}" ]] && doexe ${APACHE2_EXECFILES}
178 186
179 if [[ -n "${APACHE2_MOD_CONF}" ]] ; then 187 if [[ -n "${APACHE2_MOD_CONF}" ]] ; then
180 insinto "${APACHE2_MODULES_CONFDIR}" 188 insinto "${APACHE_MODULES_CONFDIR}"
181 set -- ${APACHE2_MOD_CONF} 189 set -- ${APACHE2_MOD_CONF}
182 newins "${FILESDIR}/${1}.conf" "$(basename ${2:-$1}).conf" \ 190 newins "${FILESDIR}/${1}.conf" "$(basename ${2:-$1}).conf" \
183 || die "internal ebuild error: '${FILESDIR}/${1}.conf' not found" 191 || die "internal ebuild error: '${FILESDIR}/${1}.conf' not found"
184 fi 192 fi
185 193
186 if [[ -n "${APACHE2_VHOSTFILE}" ]] ; then 194 if [[ -n "${APACHE2_VHOST_CONF}" ]] ; then
187 insinto "${APACHE2_VHOSTDIR}" 195 insinto "${APACHE_VHOSTS_CONFDIR}"
188 set -- ${APACHE2_VHOSTFILE} 196 set -- ${APACHE2_VHOST_CONF}
189 newins "${FILESDIR}/${1}.conf" "$(basename ${2:-$1}).conf " \ 197 newins "${FILESDIR}/${1}.conf" "$(basename ${2:-$1}).conf " \
190 || die "internal ebuild error: '${FILESDIR}/${1}.conf' not found" 198 || die "internal ebuild error: '${FILESDIR}/${1}.conf' not found"
191 fi 199 fi
192 200
193 cd "${S}" 201 cd "${S}"
194 202
195 if [[ -n "${DOCFILES}" ]] ; then 203 if [[ -n "${DOCFILES}" ]] ; then
196 OTHER_DOCS=$(apache_doc_magic) 204 local OTHER_DOCS=$(apache_doc_magic)
197 HTML_DOCS=$(apache_doc_magic html) 205 local HTML_DOCS=$(apache_doc_magic html)
198 206
199 [[ -n "${OTHER_DOCS}" ]] && dodoc ${OTHER_DOCS} 207 [[ -n "${OTHER_DOCS}" ]] && dodoc ${OTHER_DOCS}
200 [[ -n "${HTML_DOCS}" ]] && dohtml ${HTML_DOCS} 208 [[ -n "${HTML_DOCS}" ]] && dohtml ${HTML_DOCS}
201 fi 209 fi
202} 210}
218 226
219 if [[ -n "${APACHE2_MOD_CONF}" ]] ; then 227 if [[ -n "${APACHE2_MOD_CONF}" ]] ; then
220 set -- ${APACHE2_MOD_CONF} 228 set -- ${APACHE2_MOD_CONF}
221 einfo 229 einfo
222 einfo "Configuration file installed as" 230 einfo "Configuration file installed as"
223 einfo " ${APACHE2_MODULES_CONFDIR}/$(basename $1).conf" 231 einfo " ${APACHE_MODULES_CONFDIR}/$(basename ${2:-$1}).conf"
224 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"
225 einfo 233 einfo
226 fi 234 fi
227
228 if [[ -n "${APACHE2_SAFE_MPMS}" ]] ; then
229 INSTALLED_MPM="$(${ROOT}/usr/sbin/apxs2 -q MPM_NAME)"
230
231 if ! hasq ${INSTALLED_MPM} ${APACHE2_SAFE_MPMS} ; then
232 INSTALLED_MPM_UNSAFE="${INSTALLED_MPM_UNSAFE} ${mpm}"
233 else
234 INSTALLED_MPM_SAFE="${INSTALLED_MPM_SAFE} ${mpm}"
235 fi
236
237 if [[ -n "${INSTALLED_MPM_UNSAFE}" ]] ; then
238 ewarn "Your installed MPM will not work with this module (${PN})."
239 ewarn "Please make sure that you only enable this module"
240 ewarn "if you are using one of the following MPMs:"
241 ewarn " ${INSTALLED_MPM_SAFE}"
242 fi
243 fi
244} 235}
245 236
246EXPORT_FUNCTIONS pkg_setup src_compile src_install pkg_postinst 237EXPORT_FUNCTIONS src_compile src_install pkg_postinst

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

  ViewVC Help
Powered by ViewVC 1.1.20