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

Contents of /eclass/apache-module.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.20 - (hide annotations) (download)
Sun Nov 25 14:27:52 2007 UTC (6 years, 8 months ago) by hollow
Branch: MAIN
Changes since 1.19: +85 -237 lines
remove deprecated apache1 functions; remove bogus need_apache logic; convert to standardized documentation comments

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

  ViewVC Help
Powered by ViewVC 1.1.20