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

Contents of /eclass/apache-module.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.20 - (show annotations) (download)
Sun Nov 25 14:27:52 2007 UTC (6 years, 11 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 # 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.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
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_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 APACHE2_MOD_DEFINE=""
49
50 # @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 DOCFILES=""
56
57 # ==============================================================================
58 # PUBLIC FUNCTIONS
59 # ==============================================================================
60
61 # @FUNCTION: apache_cd_dir
62 # @DESCRIPTION:
63 # Return the path to our temporary build dir
64 apache_cd_dir() {
65 debug-print-function $FUNCNAME $*
66
67 [[ -n "${APXS2_S}" ]] && CD_DIR="${APXS2_S}"
68
69 if [[ -z "${CD_DIR}" ]] ; then
70 if [[ -d "${S}/src" ]] ; then
71 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 echo "${CD_DIR}"
79 }
80
81 # @FUNCTION: apache_mod_file
82 # @DESCRIPTION:
83 # Return the path to the module file
84 apache_mod_file() {
85 debug-print-function $FUNCNAME $*
86
87 [[ -n "${APACHE2_MOD_FILE}" ]] && MOD_FILE="${APACHE2_MOD_FILE}"
88 [[ -z "${MOD_FILE}" ]] && MOD_FILE="$(apache_cd_dir)/.libs/${PN}.so"
89
90 debug-print apache_mod_file: "MOD_FILE=${MOD_FILE}"
91 echo "${MOD_FILE}"
92 }
93
94 # @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 apache_doc_magic() {
100 debug-print-function $FUNCNAME $*
101
102 if [[ -n "${DOCFILES}" ]] ; then
103 if [[ "x$1" == "xhtml" ]] ; then
104 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 debug-print apache_doc_magic: "DOCS=${DOCS}"
110 echo "${DOCS}"
111 fi
112 }
113
114 # @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 debug-print-function $FUNCNAME $*
120
121 if [[ -n "${APACHE2_SAFE_MPMS}" ]] ; then
122 INSTALLED_MPM="$(${ROOT}/usr/sbin/apxs2 -q MPM_NAME)"
123
124 if hasq ${INSTALLED_MPM} ${APACHE2_SAFE_MPMS} ; then
125 INSTALLED_MPM_SAFE="yes"
126 fi
127
128 if [[ -z "${INSTALLED_MPM_SAFE}" ]] ; then
129 eerror "The module you are trying to install (${PN})"
130 eerror "will only work with one of the following MPMs:"
131 eerror " ${APACHE2_SAFE_MPMS}"
132 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 fi
136 fi
137 }
138
139 # @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 debug-print-function $FUNCNAME $*
146
147 CD_DIR=$(apache_cd_dir)
148 cd "${CD_DIR}" || die "cd ${CD_DIR} failed"
149 APXS2_ARGS="${APXS2_ARGS:--c ${PN}.c}"
150 ${APXS2} ${APXS2_ARGS} || die "${APXS2} ${APXS2_ARGS} failed"
151 }
152
153 # @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 debug-print-function $FUNCNAME $*
164
165 CD_DIR=$(apache_cd_dir)
166 cd "${CD_DIR}" || die "cd ${CD_DIR} failed"
167
168 MOD_FILE=$(apache_mod_file)
169
170 exeinto "${APACHE2_MODULESDIR}"
171 doexe ${MOD_FILE} || die "internal ebuild error: '${MOD_FILE}' not found"
172 [[ -n "${APACHE2_EXECFILES}" ]] && doexe ${APACHE2_EXECFILES}
173
174 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 fi
178
179 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 fi
183
184 cd "${S}"
185
186 if [[ -n "${DOCFILES}" ]] ; then
187 OTHER_DOCS=$(apache_doc_magic)
188 HTML_DOCS=$(apache_doc_magic html)
189
190 [[ -n "${OTHER_DOCS}" ]] && dodoc ${OTHER_DOCS}
191 [[ -n "${HTML_DOCS}" ]] && dohtml ${HTML_DOCS}
192 fi
193 }
194
195 # @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 debug-print-function $FUNCNAME $*
200
201 if [[ -n "${APACHE2_MOD_DEFINE}" ]] ; then
202 local my_opts="-D ${APACHE2_MOD_DEFINE// / -D }"
203
204 einfo
205 einfo "To enable ${PN}, you need to edit your /etc/conf.d/apache2 file and"
206 einfo "add '${my_opts}' to APACHE2_OPTS."
207 einfo
208 fi
209
210 if [[ -n "${APACHE2_MOD_CONF}" ]] ; then
211 einfo
212 einfo "Configuration file installed as"
213 einfo " ${APACHE2_MODULES_CONFDIR}/$(basename ${APACHE2_MOD_CONF}).conf"
214 einfo "You may want to edit it before turning the module on in /etc/conf.d/apache2"
215 einfo
216 fi
217
218 if [[ -n "${APACHE2_SAFE_MPMS}" ]] ; then
219 INSTALLED_MPM="$(${ROOT}/usr/sbin/apxs2 -q MPM_NAME)"
220
221 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
227 if [[ -n "${INSTALLED_MPM_UNSAFE}" ]] ; then
228 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 ewarn " ${INSTALLED_MPM_SAFE}"
232 fi
233 fi
234 }
235
236 EXPORT_FUNCTIONS pkg_setup src_compile src_install pkg_postinst

  ViewVC Help
Powered by ViewVC 1.1.20