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

Contents of /eclass/apache-module.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.23 - (show annotations) (download)
Sun Mar 23 12:11:52 2008 UTC (6 years, 8 months ago) by hollow
Branch: MAIN
Changes since 1.22: +96 -105 lines
remove obsolete apache-module_pkg_setup; update documentation

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.22 2008/02/02 12:31:00 hollow Exp $
4
5 # @ECLASS: apache-module.eclass
6 # @MAINTAINER:
7 # apache-devs@gentoo.org
8 # @BLURB: Provides a common set of functions for apache modules
9 # @DESCRIPTION:
10 # This eclass handles apache modules in a sane way.
11 #
12 # To make use of this eclass simply call one of the need/want_apache functions
13 # described in depend.apache.eclass. Make sure you use the need/want_apache call
14 # after you have defined DEPEND and RDEPEND. Also note that you can not rely on
15 # the automatic RDEPEND=DEPEND that portage does if you use this eclass.
16 #
17 # See Bug 107127 for more information.
18 #
19 # @EXAMPLE:
20 #
21 # Here is a simple example of an ebuild for mod_foo:
22 #
23 # @CODE
24 # APACHE2_MOD_CONF="42_mod_foo"
25 # APACHE2_MOD_DEFINE="FOO"
26 # need_apache2
27 # @CODE
28 #
29 # A more complicated example for a module with non-standard locations:
30 #
31 # @CODE
32 # APXS2_S="${S}/apache22/src"
33 # APACHE2_MOD_FILE="${APXS2_S}/${PN}.so"
34 # APACHE2_MOD_CONF="42_${PN}"
35 # APACHE2_MOD_DEFINE="FOO"
36 # DOCFILES="docs/*.html"
37 # need_apache2_2
38 # @CODE
39 #
40 # A basic module configuration which just loads the module into apache:
41 #
42 # @CODE
43 # <IfDefine FOO>
44 # LoadModule foo_module modules/mod_foo.so
45 # </IfDefine>
46 # @CODE
47
48 inherit depend.apache
49
50 # ==============================================================================
51 # PUBLIC VARIABLES
52 # ==============================================================================
53
54 # @VARIABLE: APXS2_S
55 # @DESCRIPTION:
56 # Path to temporary build directory. (Defaults to `${S}/src' if it exists,
57 # `${S}' otherwise)
58
59 # @VARIABLE: APXS2_ARGS
60 # @DESCRIPTION:
61 # Arguments to pass to the apxs tool. (Defaults to `-c ${PN}.c')
62
63 # @VARIABLE: APACHE2_EXECFILES
64 # @DESCRIPTION:
65 # List of files that will be installed into ${APACHE_MODULE_DIR} beside
66 # ${APACHE2_MOD_FILE}. In addition, this function also sets the executable
67 # permission on those files.
68
69 # @VARIABLE: APACHE2_MOD_CONF
70 # @DESCRIPTION:
71 # Module configuration file installed by src_install (minus the .conf suffix and
72 # relative to ${FILESDIR}).
73
74 # @VARIABLE: APACHE2_MOD_DEFINE
75 # @DESCRIPTION:
76 # Name of define (e.g. FOO) to use in conditional loading of the installed
77 # module/its config file, multiple defines should be space separated.
78
79 # @VARIABLE: APACHE2_MOD_FILE
80 # @DESCRIPTION:
81 # Name of the module that src_install installs minus the .so suffix. (Defaults
82 # to `${APXS2_S}/.libs/${PN}.so')
83
84 # @VARIABLE: APACHE2_VHOST_CONF
85 # @DESCRIPTION:
86 # Virtual host configuration file installed by src_install (minus the .conf
87 # suffix and relative to ${FILESDIR}).
88
89 # @VARIABLE: DOCFILES
90 # @DESCRIPTION:
91 # If the exported src_install() is being used, and ${DOCFILES} is non-zero, some
92 # sed-fu is applied to split out html documentation (if any) from normal
93 # documentation, and dodoc'd or dohtml'd.
94
95 # ==============================================================================
96 # INTERNAL FUNCTIONS
97 # ==============================================================================
98
99 # Internal function to construct the default ${APXS2_S} path if required.
100 apache_cd_dir() {
101 debug-print-function $FUNCNAME $*
102
103 local CD_DIR="${APXS2_S}"
104
105 if [[ -z "${CD_DIR}" ]] ; then
106 if [[ -d "${S}/src" ]] ; then
107 CD_DIR="${S}/src"
108 else
109 CD_DIR="${S}"
110 fi
111 fi
112
113 debug-print $FUNCNAME "CD_DIR=${CD_DIR}"
114 echo "${CD_DIR}"
115 }
116
117 # Internal function to construct the default ${APACHE2_MOD_FILE} if required.
118 apache_mod_file() {
119 debug-print-function $FUNCNAME $*
120
121 local MOD_FILE="${APACHE2_MOD_FILE:-$(apache_cd_dir)/.libs/${PN}.so}"
122
123 debug-print $FUNCNAME "MOD_FILE=${MOD_FILE}"
124 echo "${MOD_FILE}"
125 }
126
127 # Internal function for picking out html files from ${DOCFILES}. It takes an
128 # optional first argument `html'; if the first argument is equals `html', only
129 # html files are returned, otherwise normal (non-html) docs are returned.
130 apache_doc_magic() {
131 debug-print-function $FUNCNAME $*
132
133 local DOCS=
134
135 if [[ -n "${DOCFILES}" ]] ; then
136 if [[ "x$1" == "xhtml" ]] ; then
137 DOCS="`echo ${DOCFILES} | sed -e 's/ /\n/g' | sed -e '/^[^ ]*.html$/ !d'`"
138 else
139 DOCS="`echo ${DOCFILES} | sed 's, *[^ ]*\+.html, ,g'`"
140 fi
141 fi
142
143 debug-print $FUNCNAME "DOCS=${DOCS}"
144 echo "${DOCS}"
145 }
146
147 # ==============================================================================
148 # EXPORTED FUNCTIONS
149 # ==============================================================================
150
151 # @FUNCTION: apache-module_src_compile
152 # @DESCRIPTION:
153 # The default action is to call ${APXS} with the value of ${APXS2_ARGS}. If a
154 # module requires a different build setup than this, use ${APXS} in your own
155 # src_compile routine.
156 apache-module_src_compile() {
157 debug-print-function $FUNCNAME $*
158
159 local CD_DIR=$(apache_cd_dir)
160 cd "${CD_DIR}" || die "cd ${CD_DIR} failed"
161
162 APXS2_ARGS="${APXS2_ARGS:--c ${PN}.c}"
163 ${APXS} ${APXS2_ARGS} || die "${APXS} ${APXS2_ARGS} failed"
164 }
165
166 # @FUNCTION: apache-module_src_install
167 # @DESCRIPTION:
168 # This installs the files into apache's directories. The module is installed
169 # from a directory chosen as above (apache_cd_dir). In addition, this function
170 # can also set the executable permission on files listed in
171 # ${APACHE2_EXECFILES}. The configuration file name is listed in
172 # ${APACHE2_MOD_CONF} without the .conf extensions, so if you configuration is
173 # 55_mod_foo.conf, APACHE2_MOD_CONF would be 55_mod_foo. ${DOCFILES} contains
174 # the list of files you want filed as documentation.
175 apache-module_src_install() {
176 debug-print-function $FUNCNAME $*
177
178 local CD_DIR=$(apache_cd_dir)
179 cd "${CD_DIR}" || die "cd ${CD_DIR} failed"
180
181 local MOD_FILE=$(apache_mod_file)
182
183 exeinto "${APACHE_MODULESDIR}"
184 doexe ${MOD_FILE} || die "internal ebuild error: '${MOD_FILE}' not found"
185 [[ -n "${APACHE2_EXECFILES}" ]] && doexe ${APACHE2_EXECFILES}
186
187 if [[ -n "${APACHE2_MOD_CONF}" ]] ; then
188 insinto "${APACHE_MODULES_CONFDIR}"
189 set -- ${APACHE2_MOD_CONF}
190 newins "${FILESDIR}/${1}.conf" "$(basename ${2:-$1}).conf" \
191 || die "internal ebuild error: '${FILESDIR}/${1}.conf' not found"
192 fi
193
194 if [[ -n "${APACHE2_VHOST_CONF}" ]] ; then
195 insinto "${APACHE_VHOSTS_CONFDIR}"
196 set -- ${APACHE2_VHOST_CONF}
197 newins "${FILESDIR}/${1}.conf" "$(basename ${2:-$1}).conf " \
198 || die "internal ebuild error: '${FILESDIR}/${1}.conf' not found"
199 fi
200
201 cd "${S}"
202
203 if [[ -n "${DOCFILES}" ]] ; then
204 local OTHER_DOCS=$(apache_doc_magic)
205 local HTML_DOCS=$(apache_doc_magic html)
206
207 [[ -n "${OTHER_DOCS}" ]] && dodoc ${OTHER_DOCS}
208 [[ -n "${HTML_DOCS}" ]] && dohtml ${HTML_DOCS}
209 fi
210 }
211
212 # @FUNCTION: apache-module_pkg_postinst
213 # @DESCRIPTION:
214 # This prints out information about the installed module and how to enable it.
215 apache-module_pkg_postinst() {
216 debug-print-function $FUNCNAME $*
217
218 if [[ -n "${APACHE2_MOD_DEFINE}" ]] ; then
219 local my_opts="-D ${APACHE2_MOD_DEFINE// / -D }"
220
221 einfo
222 einfo "To enable ${PN}, you need to edit your /etc/conf.d/apache2 file and"
223 einfo "add '${my_opts}' to APACHE2_OPTS."
224 einfo
225 fi
226
227 if [[ -n "${APACHE2_MOD_CONF}" ]] ; then
228 set -- ${APACHE2_MOD_CONF}
229 einfo
230 einfo "Configuration file installed as"
231 einfo " ${APACHE_MODULES_CONFDIR}/$(basename $1).conf"
232 einfo "You may want to edit it before turning the module on in /etc/conf.d/apache2"
233 einfo
234 fi
235 }
236
237 EXPORT_FUNCTIONS src_compile src_install pkg_postinst

  ViewVC Help
Powered by ViewVC 1.1.20