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

Diff of /eclass/apache-module.eclass

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

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

Legend:
Removed from v.1.20  
changed lines
  Added in v.1.25

  ViewVC Help
Powered by ViewVC 1.1.20