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

Contents of /eclass/apache-module.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.14 - (hide annotations) (download)
Sun Jun 4 19:15:09 2006 UTC (8 years, 2 months ago) by vericgar
Branch: MAIN
Changes since 1.13: +6 -1 lines
Add comment warning about dependency issues. Refer to bug 107127.

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

  ViewVC Help
Powered by ViewVC 1.1.20