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

Contents of /eclass/apache-module.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.19 - (hide annotations) (download)
Sat May 12 02:28:51 2007 UTC (7 years, 2 months ago) by chtekk
Branch: MAIN
Changes since 1.18: +63 -85 lines
Update for Apache 1.X masking.

1 chtekk 1.19 # Copyright 1999-2007 Gentoo Foundation
2     # Distributed under the terms of the GNU General Public License v2
3     # $Header: $
4 urilith 1.1
5     inherit depend.apache
6    
7     # This eclass provides a common set of functions for Apache modules.
8    
9 vericgar 1.14 # NOTE: If you use this, be sure you use the need_* call after you have
10 swegener 1.15 # defined DEPEND and RDEPEND. Also note that you can not rely on the
11 chtekk 1.19 # automatic RDEPEND=DEPEND that Portage does if you use this eclass.
12 vericgar 1.14 # See bug 107127 for more information.
13    
14 urilith 1.1 ######
15     ## Common ebuild variables
16     ######
17    
18     ####
19     ## APXS1_S, APXS2_S
20     ##
21     ## Paths to temporary build directories
22     ####
23     APXS1_S=""
24     APXS2_S=""
25    
26     ####
27     ## APXS1_ARGS, APXS2_ARGS
28     ##
29     ## Arguments to pass to the apxs tool
30     ####
31     APXS1_ARGS=""
32     APXS2_ARGS=""
33    
34     ####
35     ## APACHE1_MOD_FILE, APACHE2_MOD_FILE
36     ##
37     ## Name of the module that src_install installs (only, minus the .so)
38     ####
39     APACHE1_MOD_FILE=""
40     APACHE2_MOD_FILE=""
41    
42     ####
43     ## APACHE1_MOD_CONF, APACHE2_MOD_CONF
44     ##
45     ## Configuration file installed by src_install
46     ####
47     APACHE1_MOD_CONF=""
48     APACHE2_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
54 tomk 1.16 ## module/it's config file, multiple defines should be space separated
55 urilith 1.1 ####
56     APACHE1_MOD_DEFINE=""
57     APACHE2_MOD_DEFINE=""
58    
59     ####
60     ## DOCFILES
61     ##
62     ## If the exported src_install() is being used, and ${DOCFILES} is non-zero,
63     ## some sed-fu is applied to split out html documentation (if any) from normal
64     ## documentation, and dodoc'd or dohtml'd
65     ####
66     DOCFILES=""
67    
68     ######
69     ## Utility functions
70     ######
71    
72     ####
73     ## apache_cd_dir
74     ##
75     ## Return the path to our temporary build dir
76     ####
77     apache_cd_dir() {
78 vericgar 1.18 debug-print-function $FUNCNAME $*
79 urilith 1.1
80 chtekk 1.19 if [[ "${APACHE_VERSION}" == "1" ]] ; then
81     [[ -n "${APXS1_S}" ]] && CD_DIR="${APXS1_S}"
82 urilith 1.1 else
83 chtekk 1.19 [[ -n "${APXS2_S}" ]] && CD_DIR="${APXS2_S}"
84 urilith 1.1 fi
85    
86 chtekk 1.19 # XXX - Is this really needed? Can't we just return ${S}?
87     if [[ -z "${CD_DIR}" ]] ; then
88     if [[ -d "${S}/src" ]] ; then
89 urilith 1.1 CD_DIR="${S}/src"
90     else
91     CD_DIR="${S}"
92     fi
93     fi
94    
95     debug-print apache_cd_dir: "CD_DIR=${CD_DIR}"
96 chtekk 1.19 echo "${CD_DIR}"
97 urilith 1.1 }
98    
99     ####
100     ## apache_mod_file
101     ##
102     ## Return the path to the module file
103     ####
104     apache_mod_file() {
105 vericgar 1.18 debug-print-function $FUNCNAME $*
106 urilith 1.1
107 chtekk 1.19 if [[ "${APACHE_VERSION}" == "1" ]] ; then
108     [[ -n "${APACHE1_MOD_FILE}" ]] && MOD_FILE="${APACHE1_MOD_FILE}"
109     [[ -z "${MOD_FILE}" ]] && MOD_FILE="$(apache_cd_dir)/${PN}.so"
110 urilith 1.1 else
111 chtekk 1.19 [[ -n "${APACHE2_MOD_FILE}" ]] && MOD_FILE="${APACHE2_MOD_FILE}"
112     [[ -z "${MOD_FILE}" ]] && MOD_FILE="$(apache_cd_dir)/.libs/${PN}.so"
113 urilith 1.1 fi
114    
115 chtekk 1.19 debug-print apache_mod_file: "MOD_FILE=${MOD_FILE}"
116     echo "${MOD_FILE}"
117 urilith 1.1 }
118    
119     ####
120     ## apache_doc_magic
121     ##
122 chtekk 1.19 ## Some magic for picking out html files from ${DOCFILES}. It takes
123 urilith 1.1 ## an optional first argument `html'; if the first argument is equals
124     ## `html', only html files are returned, otherwise normal (non-html)
125     ## docs are returned.
126     ####
127     apache_doc_magic() {
128 vericgar 1.18 debug-print-function $FUNCNAME $*
129 urilith 1.1
130 chtekk 1.19 if [[ -n "${DOCFILES}" ]] ; then
131     if [[ "x$1" == "xhtml" ]] ; then
132 urilith 1.1 DOCS="`echo ${DOCFILES} | sed -e 's/ /\n/g' | sed -e '/^[^ ]*.html$/ !d'`"
133     else
134     DOCS="`echo ${DOCFILES} | sed 's, *[^ ]*\+.html, ,g'`"
135     fi
136    
137 chtekk 1.19 debug-print apache_doc_magic: "DOCS=${DOCS}"
138     echo "${DOCS}"
139 urilith 1.1 fi
140     }
141    
142     ######
143 chtekk 1.19 ## Apache 1.x ebuild functions - !!! DEPRECATED !!!
144 urilith 1.1 ######
145    
146     ####
147 chtekk 1.19 ## apache1_src_compile - !!! DEPRECATED !!!
148 urilith 1.1 ####
149 vericgar 1.2 apache1_src_compile() {
150 vericgar 1.18 debug-print-function $FUNCNAME $*
151 urilith 1.1
152     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 chtekk 1.19 ## apache1_src_install - !!! DEPRECATED !!!
160 urilith 1.1 ####
161     apache1_src_install() {
162 vericgar 1.18 debug-print-function $FUNCNAME $*
163 urilith 1.1
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 vericgar 1.5 doexe ${MOD_FILE} || die "internal ebuild error: '${MOD_FILE}' not found"
171 urilith 1.1 [ -n "${APACHE1_EXECFILES}" ] && doexe ${APACHE1_EXECFILES}
172    
173     if [ -n "${APACHE1_MOD_CONF}" ] ; then
174     insinto ${APACHE1_MODULES_CONFDIR}
175 vericgar 1.5 doins ${FILESDIR}/${APACHE1_MOD_CONF}.conf || die "internal ebuild error: '${FILESDIR}/${APACHE1_MOD_CONF}.conf' not found."
176 urilith 1.1 fi
177 swegener 1.12
178 urilith 1.1 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 chtekk 1.19 ## apache1_pkg_postinst - !!! DEPRECATED !!!
191 urilith 1.1 ####
192     apache1_pkg_postinst() {
193 vericgar 1.18 debug-print-function $FUNCNAME $*
194 urilith 1.1
195     if [ -n "${APACHE1_MOD_DEFINE}" ]; then
196 tomk 1.16 local my_opts="-D ${APACHE1_MOD_DEFINE// / -D }"
197    
198 urilith 1.1 einfo
199     einfo "To enable ${PN}, you need to edit your /etc/conf.d/apache file and"
200 tomk 1.16 einfo "add '${my_opts}' to APACHE_OPTS."
201 urilith 1.1 einfo
202     fi
203 vericgar 1.2 if [ -n "${APACHE1_MOD_CONF}" ] ; then
204     einfo
205 vericgar 1.3 einfo "Configuration file installed as"
206 chtekk 1.19 einfo " ${APACHE1_MODULES_CONFDIR}/$(basename ${APACHE1_MOD_CONF}).conf"
207 vericgar 1.2 einfo "You may want to edit it before turning the module on in /etc/conf.d/apache"
208     einfo
209     fi
210 urilith 1.1 }
211    
212     ######
213     ## Apache 2.x ebuild functions
214     ######
215    
216     ####
217     ## apache2_pkg_setup
218     ##
219 chtekk 1.19 ## Checks to see if APACHE2_MT_UNSAFE is set to anything other than "no". If it is, then
220 urilith 1.1 ## 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     ####
223 vericgar 1.2 apache2_pkg_setup() {
224 vericgar 1.18 debug-print-function $FUNCNAME $*
225 urilith 1.1
226 chtekk 1.19 if [[ -n "${APACHE2_SAFE_MPMS}" ]] ; then
227 vericgar 1.9 INSTALLED_MPM="$(${ROOT}/usr/sbin/apxs2 -q MPM_NAME)"
228 urilith 1.8
229 vericgar 1.9 if hasq ${INSTALLED_MPM} ${APACHE2_SAFE_MPMS} ; then
230     INSTALLED_MPM_SAFE="yes"
231     fi
232 vericgar 1.4
233 chtekk 1.19 if [[ -z "${INSTALLED_MPM_SAFE}" ]] ; then
234 vericgar 1.4 eerror "The module you are trying to install (${PN})"
235     eerror "will only work with one of the following MPMs:"
236 chtekk 1.19 eerror " ${APACHE2_SAFE_MPMS}"
237 vericgar 1.4 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 urilith 1.1 fi
241     fi
242     }
243 swegener 1.12
244 urilith 1.1 ####
245     ## apache2_src_compile
246     ##
247     ## The default action is to call ${APXS2} with the value of
248 chtekk 1.19 ## ${APXS2_ARGS}. If a module requires a different build setup
249 urilith 1.1 ## than this, use ${APXS2} in your own src_compile routine.
250     ####
251 vericgar 1.2 apache2_src_compile() {
252 vericgar 1.18 debug-print-function $FUNCNAME $*
253 urilith 1.1
254     CD_DIR=$(apache_cd_dir)
255 chtekk 1.19 cd "${CD_DIR}" || die "cd ${CD_DIR} failed"
256 urilith 1.1 APXS2_ARGS="${APXS2_ARGS:--c ${PN}.c}"
257     ${APXS2} ${APXS2_ARGS} || die "${APXS2} ${APXS2_ARGS} failed"
258     }
259    
260     ####
261     ## apache2_src_install
262     ##
263 chtekk 1.19 ## 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,
265 urilith 1.1 ## this function can also set the executable permission on files listed in EXECFILES.
266     ## The configuration file name is listed in CONFFILE without the .conf extensions,
267     ## so if you configuration is 55_mod_foo.conf, CONFFILE would be 55_mod_foo.
268     ## DOCFILES contains the list of files you want filed as documentation.
269     ####
270     apache2_src_install() {
271 vericgar 1.18 debug-print-function $FUNCNAME $*
272 urilith 1.1
273     CD_DIR=$(apache_cd_dir)
274 chtekk 1.19 cd "${CD_DIR}" || die "cd ${CD_DIR} failed"
275 urilith 1.1
276     MOD_FILE=$(apache_mod_file)
277    
278 chtekk 1.19 exeinto "${APACHE2_MODULESDIR}"
279 vericgar 1.5 doexe ${MOD_FILE} || die "internal ebuild error: '${MOD_FILE}' not found"
280 chtekk 1.19 [[ -n "${APACHE2_EXECFILES}" ]] && doexe ${APACHE2_EXECFILES}
281 urilith 1.1
282 chtekk 1.19 if [[ -n "${APACHE2_MOD_CONF}" ]] ; then
283     insinto "${APACHE2_MODULES_CONFDIR}"
284     doins "${FILESDIR}/${APACHE2_MOD_CONF}.conf" || die "internal ebuild error: '${FILESDIR}/${APACHE2_MOD_CONF}.conf' not found"
285 urilith 1.1 fi
286    
287 chtekk 1.19 if [[ -n "${APACHE2_VHOSTFILE}" ]] ; then
288     insinto "${APACHE2_VHOSTDIR}"
289     doins "${FILESDIR}/${APACHE2_VHOSTFILE}.conf" || die "internal ebuild error: '${FILESDIR}/${APACHE2_VHOSTFILE}.conf' not found"
290 urilith 1.1 fi
291    
292 chtekk 1.19 cd "${S}"
293 urilith 1.1
294 chtekk 1.19 if [[ -n "${DOCFILES}" ]] ; then
295 urilith 1.1 OTHER_DOCS=$(apache_doc_magic)
296     HTML_DOCS=$(apache_doc_magic html)
297    
298 chtekk 1.19 [[ -n "${OTHER_DOCS}" ]] && dodoc ${OTHER_DOCS}
299     [[ -n "${HTML_DOCS}" ]] && dohtml ${HTML_DOCS}
300 urilith 1.1 fi
301     }
302    
303     apache2_pkg_postinst() {
304 vericgar 1.18 debug-print-function $FUNCNAME $*
305 urilith 1.1
306 chtekk 1.19 if [[ -n "${APACHE2_MOD_DEFINE}" ]] ; then
307 tomk 1.16 local my_opts="-D ${APACHE2_MOD_DEFINE// / -D }"
308    
309 urilith 1.1 einfo
310     einfo "To enable ${PN}, you need to edit your /etc/conf.d/apache2 file and"
311 tomk 1.16 einfo "add '${my_opts}' to APACHE2_OPTS."
312 urilith 1.1 einfo
313     fi
314 chtekk 1.19
315     if [[ -n "${APACHE2_MOD_CONF}" ]] ; then
316 vericgar 1.2 einfo
317 vericgar 1.3 einfo "Configuration file installed as"
318     einfo " ${APACHE2_MODULES_CONFDIR}/$(basename ${APACHE2_MOD_CONF}).conf"
319 vericgar 1.2 einfo "You may want to edit it before turning the module on in /etc/conf.d/apache2"
320     einfo
321     fi
322 vericgar 1.4
323 chtekk 1.19 if [[ -n "${APACHE2_SAFE_MPMS}" ]] ; then
324 vericgar 1.9 INSTALLED_MPM="$(${ROOT}/usr/sbin/apxs2 -q MPM_NAME)"
325 vericgar 1.4
326 urilith 1.7 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 swegener 1.12
332 chtekk 1.19 if [[ -n "${INSTALLED_MPM_UNSAFE}" ]] ; then
333 vericgar 1.4 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 chtekk 1.19 ewarn " ${INSTALLED_MPM_SAFE}"
337 vericgar 1.4 fi
338     fi
339 urilith 1.1 }
340    
341     ######
342 chtekk 1.19 ## Apache dual (1.x or 2.x) ebuild functions - Apache 1.X DEPRECATED!
343 urilith 1.1 ##
344 chtekk 1.19 ## 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 urilith 1.1 ## the exported routine simply does nothing.
348     ######
349    
350     apache-module_pkg_setup() {
351 vericgar 1.18 debug-print-function $FUNCNAME $*
352 urilith 1.1
353 chtekk 1.19 if [[ ${APACHE_VERSION} -eq "2" ]] ; then
354 urilith 1.1 apache2_pkg_setup
355     fi
356     }
357    
358     apache-module_src_compile() {
359 vericgar 1.18 debug-print-function $FUNCNAME $*
360 urilith 1.1
361 chtekk 1.19 if [[ ${APACHE_VERSION} -eq "1" ]] ; then
362 urilith 1.1 apache1_src_compile
363     else
364     apache2_src_compile
365     fi
366     }
367    
368     apache-module_src_install() {
369 vericgar 1.18 debug-print-function $FUNCNAME $*
370 urilith 1.1
371 chtekk 1.19 if [[ ${APACHE_VERSION} -eq "1" ]] ; then
372 urilith 1.1 apache1_src_install
373     else
374     apache2_src_install
375     fi
376     }
377    
378     apache-module_pkg_postinst() {
379 vericgar 1.18 debug-print-function $FUNCNAME $*
380 urilith 1.1
381 chtekk 1.19 if [[ ${APACHE_VERSION} -eq "1" ]] ; then
382 urilith 1.1 apache1_pkg_postinst
383     else
384     apache2_pkg_postinst
385     fi
386     }
387    
388     EXPORT_FUNCTIONS pkg_setup src_compile src_install pkg_postinst

  ViewVC Help
Powered by ViewVC 1.1.20