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

Contents of /eclass/apache-module.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.10 - (hide annotations) (download)
Wed Jul 6 20:20:03 2005 UTC (9 years, 3 months ago) by agriffis
Branch: MAIN
Changes since 1.9: +1 -2 lines
Remove ECLASS= and INHERITED= which haven't been necessary for a long time now

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

  ViewVC Help
Powered by ViewVC 1.1.20