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

Contents of /eclass/apache-module.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.21 - (show annotations) (download)
Sun Jan 27 20:09:17 2008 UTC (6 years, 5 months ago) by hollow
Branch: MAIN
Changes since 1.20: +14 -4 lines
make apache modules configurations newins-able

1 # Copyright 1999-2007 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3 # $Header: /var/cvsroot/gentoo-x86/eclass/apache-module.eclass,v 1.20 2007/11/25 14:27:52 hollow 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
18 inherit depend.apache
19
20 # ==============================================================================
21 # INTERNAL VARIABLES
22 # ==============================================================================
23
24 # @ECLASS-VARIABLE: APXS2_S
25 # @DESCRIPTION:
26 # Path to temporary build directory
27 APXS2_S=""
28
29 # @ECLASS-VARIABLE: APXS2_ARGS
30 # @DESCRIPTION:
31 # Arguments to pass to the apxs tool
32 APXS2_ARGS=""
33
34 # @ECLASS-VARIABLE: APACHE2_MOD_FILE
35 # @DESCRIPTION:
36 # Name of the module that src_install installs (minus the .so)
37 APACHE2_MOD_FILE=""
38
39 # @ECLASS-VARIABLE: APACHE2_MOD_CONF
40 # @DESCRIPTION:
41 # Configuration file installed by src_install
42 APACHE2_MOD_CONF=""
43
44 # @ECLASS-VARIABLE: APACHE2_VHOSTFILE
45 # @DESCRIPTION:
46 # Virtual host configuration file installed by src_install
47 APACHE2_VHOSTFILE=""
48
49 # @ECLASS-VARIABLE: APACHE2_MOD_DEFINE
50 # @DESCRIPTION:
51 # Name of define (eg FOO) to use in conditional loading of the installed
52 # module/it's config file, multiple defines should be space separated
53 APACHE2_MOD_DEFINE=""
54
55 # @ECLASS-VARIABLE: DOCFILES
56 # @DESCRIPTION:
57 # 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
59 # documentation, and dodoc'd or dohtml'd
60 DOCFILES=""
61
62 # ==============================================================================
63 # PUBLIC FUNCTIONS
64 # ==============================================================================
65
66 # @FUNCTION: apache_cd_dir
67 # @DESCRIPTION:
68 # Return the path to our temporary build dir
69 apache_cd_dir() {
70 debug-print-function $FUNCNAME $*
71
72 [[ -n "${APXS2_S}" ]] && CD_DIR="${APXS2_S}"
73
74 if [[ -z "${CD_DIR}" ]] ; then
75 if [[ -d "${S}/src" ]] ; then
76 CD_DIR="${S}/src"
77 else
78 CD_DIR="${S}"
79 fi
80 fi
81
82 debug-print apache_cd_dir: "CD_DIR=${CD_DIR}"
83 echo "${CD_DIR}"
84 }
85
86 # @FUNCTION: apache_mod_file
87 # @DESCRIPTION:
88 # Return the path to the module file
89 apache_mod_file() {
90 debug-print-function $FUNCNAME $*
91
92 [[ -n "${APACHE2_MOD_FILE}" ]] && MOD_FILE="${APACHE2_MOD_FILE}"
93 [[ -z "${MOD_FILE}" ]] && MOD_FILE="$(apache_cd_dir)/.libs/${PN}.so"
94
95 debug-print apache_mod_file: "MOD_FILE=${MOD_FILE}"
96 echo "${MOD_FILE}"
97 }
98
99 # @FUNCTION: apache_doc_magic
100 # @DESCRIPTION:
101 # Some magic for picking out html files from ${DOCFILES}. It takes an optional
102 # first argument `html'; if the first argument is equals `html', only html files
103 # are returned, otherwise normal (non-html) docs are returned.
104 apache_doc_magic() {
105 debug-print-function $FUNCNAME $*
106
107 if [[ -n "${DOCFILES}" ]] ; then
108 if [[ "x$1" == "xhtml" ]] ; then
109 DOCS="`echo ${DOCFILES} | sed -e 's/ /\n/g' | sed -e '/^[^ ]*.html$/ !d'`"
110 else
111 DOCS="`echo ${DOCFILES} | sed 's, *[^ ]*\+.html, ,g'`"
112 fi
113
114 debug-print apache_doc_magic: "DOCS=${DOCS}"
115 echo "${DOCS}"
116 fi
117 }
118
119 # @FUNCTION: apache-module_pkg_setup
120 # @DESCRIPTION:
121 # Checks to see if APACHE2_SAFE_MPMS is set and if the currently installed MPM
122 # does appear in the list.
123 apache-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
144 # @FUNCTION: apache-module_src_compile
145 # @DESCRIPTION:
146 # The default action is to call ${APXS2} with the value of ${APXS2_ARGS}. If a
147 # module requires a different build setup than this, use ${APXS2} in your own
148 # src_compile routine.
149 apache-module_src_compile() {
150 debug-print-function $FUNCNAME $*
151
152 CD_DIR=$(apache_cd_dir)
153 cd "${CD_DIR}" || die "cd ${CD_DIR} failed"
154 APXS2_ARGS="${APXS2_ARGS:--c ${PN}.c}"
155 ${APXS2} ${APXS2_ARGS} || die "${APXS2} ${APXS2_ARGS} failed"
156 }
157
158 # @FUNCTION: apache-module_src_install
159 # @DESCRIPTION:
160 # 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
162 # function can also set the executable permission on files listed in
163 # APACHE2_EXECFILES. The configuration file name is listed in APACHE2_MOD_CONF
164 # without the .conf extensions, so if you configuration is 55_mod_foo.conf,
165 # APACHE2_MOD_CONF would be 55_mod_foo. DOCFILES contains the list of files you
166 # want filed as documentation.
167 apache-module_src_install() {
168 debug-print-function $FUNCNAME $*
169
170 CD_DIR=$(apache_cd_dir)
171 cd "${CD_DIR}" || die "cd ${CD_DIR} failed"
172
173 MOD_FILE=$(apache_mod_file)
174
175 exeinto "${APACHE2_MODULESDIR}"
176 doexe ${MOD_FILE} || die "internal ebuild error: '${MOD_FILE}' not found"
177 [[ -n "${APACHE2_EXECFILES}" ]] && doexe ${APACHE2_EXECFILES}
178
179 if [[ -n "${APACHE2_MOD_CONF}" ]] ; then
180 insinto "${APACHE2_MODULES_CONFDIR}"
181 set -- ${APACHE2_MOD_CONF}
182 newins "${FILESDIR}/${1}.conf" "$(basename ${2:-$1}).conf" \
183 || die "internal ebuild error: '${FILESDIR}/${1}.conf' not found"
184 fi
185
186 if [[ -n "${APACHE2_VHOSTFILE}" ]] ; then
187 insinto "${APACHE2_VHOSTDIR}"
188 set -- ${APACHE2_VHOSTFILE}
189 newins "${FILESDIR}/${1}.conf" "$(basename ${2:-$1}).conf " \
190 || die "internal ebuild error: '${FILESDIR}/${1}.conf' not found"
191 fi
192
193 cd "${S}"
194
195 if [[ -n "${DOCFILES}" ]] ; then
196 OTHER_DOCS=$(apache_doc_magic)
197 HTML_DOCS=$(apache_doc_magic html)
198
199 [[ -n "${OTHER_DOCS}" ]] && dodoc ${OTHER_DOCS}
200 [[ -n "${HTML_DOCS}" ]] && dohtml ${HTML_DOCS}
201 fi
202 }
203
204 # @FUNCTION: apache-module_pkg_postinst
205 # @DESCRIPTION:
206 # This prints out information about the installed module and how to enable it.
207 apache-module_pkg_postinst() {
208 debug-print-function $FUNCNAME $*
209
210 if [[ -n "${APACHE2_MOD_DEFINE}" ]] ; then
211 local my_opts="-D ${APACHE2_MOD_DEFINE// / -D }"
212
213 einfo
214 einfo "To enable ${PN}, you need to edit your /etc/conf.d/apache2 file and"
215 einfo "add '${my_opts}' to APACHE2_OPTS."
216 einfo
217 fi
218
219 if [[ -n "${APACHE2_MOD_CONF}" ]] ; then
220 set -- ${APACHE2_MOD_CONF}
221 einfo
222 einfo "Configuration file installed as"
223 einfo " ${APACHE2_MODULES_CONFDIR}/$(basename $1).conf"
224 einfo "You may want to edit it before turning the module on in /etc/conf.d/apache2"
225 einfo
226 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 }
245
246 EXPORT_FUNCTIONS pkg_setup src_compile src_install pkg_postinst

  ViewVC Help
Powered by ViewVC 1.1.20