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

Contents of /eclass/apache-module.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.22 - (hide annotations) (download)
Sat Feb 2 12:31:00 2008 UTC (6 years, 5 months ago) by hollow
Branch: MAIN
Changes since 1.21: +20 -20 lines
fix depend.apache usage wrt #208033

1 chtekk 1.19 # Copyright 1999-2007 Gentoo Foundation
2     # Distributed under the terms of the GNU General Public License v2
3 hollow 1.22 # $Header: /var/cvsroot/gentoo-x86/eclass/apache-module.eclass,v 1.21 2008/01/27 20:09:17 hollow Exp $
4 hollow 1.20
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_CONF
35     # @DESCRIPTION:
36     # Configuration file installed by src_install
37 urilith 1.1 APACHE2_MOD_CONF=""
38    
39 hollow 1.20 # @ECLASS-VARIABLE: APACHE2_MOD_DEFINE
40     # @DESCRIPTION:
41     # Name of define (eg FOO) to use in conditional loading of the installed
42     # module/it's config file, multiple defines should be space separated
43 urilith 1.1 APACHE2_MOD_DEFINE=""
44    
45 hollow 1.22 # @ECLASS-VARIABLE: APACHE2_MOD_FILE
46     # @DESCRIPTION:
47     # Name of the module that src_install installs (minus the .so)
48     APACHE2_MOD_FILE=""
49    
50     # @ECLASS-VARIABLE: APACHE2_VHOST_CONF
51     # @DESCRIPTION:
52     # Virtual host configuration file installed by src_install
53     APACHE2_VHOST_CONF=""
54    
55 hollow 1.20 # @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 urilith 1.1 DOCFILES=""
61    
62 hollow 1.20 # ==============================================================================
63     # PUBLIC FUNCTIONS
64     # ==============================================================================
65    
66     # @FUNCTION: apache_cd_dir
67     # @DESCRIPTION:
68     # Return the path to our temporary build dir
69 urilith 1.1 apache_cd_dir() {
70 vericgar 1.18 debug-print-function $FUNCNAME $*
71 urilith 1.1
72 hollow 1.20 [[ -n "${APXS2_S}" ]] && CD_DIR="${APXS2_S}"
73 urilith 1.1
74 chtekk 1.19 if [[ -z "${CD_DIR}" ]] ; then
75     if [[ -d "${S}/src" ]] ; then
76 urilith 1.1 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 chtekk 1.19 echo "${CD_DIR}"
84 urilith 1.1 }
85    
86 hollow 1.20 # @FUNCTION: apache_mod_file
87     # @DESCRIPTION:
88     # Return the path to the module file
89 urilith 1.1 apache_mod_file() {
90 vericgar 1.18 debug-print-function $FUNCNAME $*
91 urilith 1.1
92 hollow 1.20 [[ -n "${APACHE2_MOD_FILE}" ]] && MOD_FILE="${APACHE2_MOD_FILE}"
93     [[ -z "${MOD_FILE}" ]] && MOD_FILE="$(apache_cd_dir)/.libs/${PN}.so"
94 urilith 1.1
95 chtekk 1.19 debug-print apache_mod_file: "MOD_FILE=${MOD_FILE}"
96     echo "${MOD_FILE}"
97 urilith 1.1 }
98    
99 hollow 1.20 # @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 urilith 1.1 apache_doc_magic() {
105 vericgar 1.18 debug-print-function $FUNCNAME $*
106 urilith 1.1
107 chtekk 1.19 if [[ -n "${DOCFILES}" ]] ; then
108     if [[ "x$1" == "xhtml" ]] ; then
109 urilith 1.1 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 chtekk 1.19 debug-print apache_doc_magic: "DOCS=${DOCS}"
115     echo "${DOCS}"
116 urilith 1.1 fi
117     }
118    
119 hollow 1.20 # @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 vericgar 1.18 debug-print-function $FUNCNAME $*
125 urilith 1.1
126 chtekk 1.19 if [[ -n "${APACHE2_SAFE_MPMS}" ]] ; then
127 vericgar 1.9 INSTALLED_MPM="$(${ROOT}/usr/sbin/apxs2 -q MPM_NAME)"
128 urilith 1.8
129 vericgar 1.9 if hasq ${INSTALLED_MPM} ${APACHE2_SAFE_MPMS} ; then
130     INSTALLED_MPM_SAFE="yes"
131     fi
132 vericgar 1.4
133 chtekk 1.19 if [[ -z "${INSTALLED_MPM_SAFE}" ]] ; then
134 vericgar 1.4 eerror "The module you are trying to install (${PN})"
135     eerror "will only work with one of the following MPMs:"
136 chtekk 1.19 eerror " ${APACHE2_SAFE_MPMS}"
137 vericgar 1.4 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 urilith 1.1 fi
141     fi
142     }
143 swegener 1.12
144 hollow 1.20 # @FUNCTION: apache-module_src_compile
145     # @DESCRIPTION:
146 hollow 1.22 # The default action is to call ${APXS} with the value of ${APXS2_ARGS}. If a
147     # module requires a different build setup than this, use ${APXS} in your own
148 hollow 1.20 # src_compile routine.
149     apache-module_src_compile() {
150 vericgar 1.18 debug-print-function $FUNCNAME $*
151 urilith 1.1
152     CD_DIR=$(apache_cd_dir)
153 chtekk 1.19 cd "${CD_DIR}" || die "cd ${CD_DIR} failed"
154 urilith 1.1 APXS2_ARGS="${APXS2_ARGS:--c ${PN}.c}"
155 hollow 1.22 ${APXS} ${APXS2_ARGS} || die "${APXS} ${APXS2_ARGS} failed"
156 urilith 1.1 }
157    
158 hollow 1.20 # @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 vericgar 1.18 debug-print-function $FUNCNAME $*
169 urilith 1.1
170     CD_DIR=$(apache_cd_dir)
171 chtekk 1.19 cd "${CD_DIR}" || die "cd ${CD_DIR} failed"
172 urilith 1.1
173     MOD_FILE=$(apache_mod_file)
174    
175 hollow 1.22 exeinto "${APACHE_MODULESDIR}"
176 vericgar 1.5 doexe ${MOD_FILE} || die "internal ebuild error: '${MOD_FILE}' not found"
177 chtekk 1.19 [[ -n "${APACHE2_EXECFILES}" ]] && doexe ${APACHE2_EXECFILES}
178 urilith 1.1
179 chtekk 1.19 if [[ -n "${APACHE2_MOD_CONF}" ]] ; then
180 hollow 1.22 insinto "${APACHE_MODULES_CONFDIR}"
181 hollow 1.21 set -- ${APACHE2_MOD_CONF}
182     newins "${FILESDIR}/${1}.conf" "$(basename ${2:-$1}).conf" \
183     || die "internal ebuild error: '${FILESDIR}/${1}.conf' not found"
184 urilith 1.1 fi
185    
186 hollow 1.22 if [[ -n "${APACHE2_VHOST_CONF}" ]] ; then
187     insinto "${APACHE_VHOSTS_CONFDIR}"
188     set -- ${APACHE2_VHOST_CONF}
189 hollow 1.21 newins "${FILESDIR}/${1}.conf" "$(basename ${2:-$1}).conf " \
190     || die "internal ebuild error: '${FILESDIR}/${1}.conf' not found"
191 urilith 1.1 fi
192    
193 chtekk 1.19 cd "${S}"
194 urilith 1.1
195 chtekk 1.19 if [[ -n "${DOCFILES}" ]] ; then
196 urilith 1.1 OTHER_DOCS=$(apache_doc_magic)
197     HTML_DOCS=$(apache_doc_magic html)
198    
199 chtekk 1.19 [[ -n "${OTHER_DOCS}" ]] && dodoc ${OTHER_DOCS}
200     [[ -n "${HTML_DOCS}" ]] && dohtml ${HTML_DOCS}
201 urilith 1.1 fi
202     }
203    
204 hollow 1.20 # @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 vericgar 1.18 debug-print-function $FUNCNAME $*
209 urilith 1.1
210 chtekk 1.19 if [[ -n "${APACHE2_MOD_DEFINE}" ]] ; then
211 tomk 1.16 local my_opts="-D ${APACHE2_MOD_DEFINE// / -D }"
212    
213 urilith 1.1 einfo
214     einfo "To enable ${PN}, you need to edit your /etc/conf.d/apache2 file and"
215 tomk 1.16 einfo "add '${my_opts}' to APACHE2_OPTS."
216 urilith 1.1 einfo
217     fi
218 chtekk 1.19
219     if [[ -n "${APACHE2_MOD_CONF}" ]] ; then
220 hollow 1.21 set -- ${APACHE2_MOD_CONF}
221 vericgar 1.2 einfo
222 vericgar 1.3 einfo "Configuration file installed as"
223 hollow 1.22 einfo " ${APACHE_MODULES_CONFDIR}/$(basename $1).conf"
224 vericgar 1.2 einfo "You may want to edit it before turning the module on in /etc/conf.d/apache2"
225     einfo
226     fi
227 vericgar 1.4
228 chtekk 1.19 if [[ -n "${APACHE2_SAFE_MPMS}" ]] ; then
229 vericgar 1.9 INSTALLED_MPM="$(${ROOT}/usr/sbin/apxs2 -q MPM_NAME)"
230 vericgar 1.4
231 urilith 1.7 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 swegener 1.12
237 chtekk 1.19 if [[ -n "${INSTALLED_MPM_UNSAFE}" ]] ; then
238 hollow 1.20 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 chtekk 1.19 ewarn " ${INSTALLED_MPM_SAFE}"
242 vericgar 1.4 fi
243     fi
244 urilith 1.1 }
245    
246     EXPORT_FUNCTIONS pkg_setup src_compile src_install pkg_postinst

  ViewVC Help
Powered by ViewVC 1.1.20