| 1 |
# Copyright 2004 Gentoo Foundation
|
| 2 |
# Distributed under the terms of the GNU General Public License, v2 or later
|
| 3 |
# Author Michael Tindal <urilith@gentoo.org>
|
| 4 |
# $Header: /var/cvsroot/gentoo-x86/eclass/apache-module.eclass,v 1.5 2005/02/26 18:17:42 vericgar Exp $
|
| 5 |
ECLASS=apache-module
|
| 6 |
INHERITED="$INHERITED $ECLASS"
|
| 7 |
|
| 8 |
inherit depend.apache
|
| 9 |
|
| 10 |
# This eclass provides a common set of functions for Apache modules.
|
| 11 |
|
| 12 |
######
|
| 13 |
## Common ebuild variables
|
| 14 |
######
|
| 15 |
|
| 16 |
####
|
| 17 |
## APXS1_S, APXS2_S
|
| 18 |
##
|
| 19 |
## Paths to temporary build directories
|
| 20 |
####
|
| 21 |
APXS1_S=""
|
| 22 |
APXS2_S=""
|
| 23 |
|
| 24 |
####
|
| 25 |
## APXS1_ARGS, APXS2_ARGS
|
| 26 |
##
|
| 27 |
## Arguments to pass to the apxs tool
|
| 28 |
####
|
| 29 |
APXS1_ARGS=""
|
| 30 |
APXS2_ARGS=""
|
| 31 |
|
| 32 |
####
|
| 33 |
## APACHE1_MOD_FILE, APACHE2_MOD_FILE
|
| 34 |
##
|
| 35 |
## Name of the module that src_install installs (only, minus the .so)
|
| 36 |
####
|
| 37 |
APACHE1_MOD_FILE=""
|
| 38 |
APACHE2_MOD_FILE=""
|
| 39 |
|
| 40 |
####
|
| 41 |
## APACHE1_MOD_CONF, APACHE2_MOD_CONF
|
| 42 |
##
|
| 43 |
## Configuration file installed by src_install
|
| 44 |
####
|
| 45 |
APACHE1_MOD_CONF=""
|
| 46 |
APACHE2_MOD_CONF=""
|
| 47 |
|
| 48 |
####
|
| 49 |
## APACHE1_MOD_DEFINE, APACHE2_MOD_DEFINE
|
| 50 |
##
|
| 51 |
## Name of define (eg FOO) to use in conditional loading of the installed
|
| 52 |
## module/it's config file
|
| 53 |
####
|
| 54 |
APACHE1_MOD_DEFINE=""
|
| 55 |
APACHE2_MOD_DEFINE=""
|
| 56 |
|
| 57 |
####
|
| 58 |
## DOCFILES
|
| 59 |
##
|
| 60 |
## If the exported src_install() is being used, and ${DOCFILES} is non-zero,
|
| 61 |
## some sed-fu is applied to split out html documentation (if any) from normal
|
| 62 |
## documentation, and dodoc'd or dohtml'd
|
| 63 |
####
|
| 64 |
DOCFILES=""
|
| 65 |
|
| 66 |
######
|
| 67 |
## Utility functions
|
| 68 |
######
|
| 69 |
|
| 70 |
####
|
| 71 |
## apache_cd_dir
|
| 72 |
##
|
| 73 |
## Return the path to our temporary build dir
|
| 74 |
####
|
| 75 |
apache_cd_dir() {
|
| 76 |
debug-print-function apache_cd_dir
|
| 77 |
|
| 78 |
if [ "${APACHE_VERSION}" == "1" ]; then
|
| 79 |
[ -n "${APXS1_S}" ] && CD_DIR="${APXS1_S}"
|
| 80 |
else
|
| 81 |
[ -n "${APXS2_S}" ] && CD_DIR="${APXS2_S}"
|
| 82 |
fi
|
| 83 |
|
| 84 |
# XXX - is this really needed? can't we just return ${S}?
|
| 85 |
if [ -z "${CD_DIR}" ]; then
|
| 86 |
if [ -d ${S}/src ] ; then
|
| 87 |
CD_DIR="${S}/src"
|
| 88 |
else
|
| 89 |
CD_DIR="${S}"
|
| 90 |
fi
|
| 91 |
fi
|
| 92 |
|
| 93 |
debug-print apache_cd_dir: "CD_DIR=${CD_DIR}"
|
| 94 |
echo ${CD_DIR}
|
| 95 |
}
|
| 96 |
|
| 97 |
####
|
| 98 |
## apache_mod_file
|
| 99 |
##
|
| 100 |
## Return the path to the module file
|
| 101 |
####
|
| 102 |
apache_mod_file() {
|
| 103 |
debug-print-function apache_mod_file
|
| 104 |
|
| 105 |
if [ "${APACHE_VERSION}" == "1" ]; then
|
| 106 |
[ -n "${APACHE1_MOD_FILE}" ] && MOD_FILE="${APACHE1_MOD_FILE}"
|
| 107 |
[ -z "${MOD_FILE}" ] && MOD_FILE="$(apache_cd_dir)/${PN}.so"
|
| 108 |
else
|
| 109 |
[ -n "${APACHE2_MOD_FILE}" ] && MOD_FILE="${APACHE2_MOD_FILE}"
|
| 110 |
[ -z "${MOD_FILE}" ] && MOD_FILE="$(apache_cd_dir)/.libs/${PN}.so"
|
| 111 |
fi
|
| 112 |
|
| 113 |
debug-print apache_mod_file: MOD_FILE=${MOD_FILE}
|
| 114 |
echo ${MOD_FILE}
|
| 115 |
}
|
| 116 |
|
| 117 |
####
|
| 118 |
## apache_doc_magic
|
| 119 |
##
|
| 120 |
## Some magic for picking out html files from ${DOCFILES}. It takes
|
| 121 |
## an optional first argument `html'; if the first argument is equals
|
| 122 |
## `html', only html files are returned, otherwise normal (non-html)
|
| 123 |
## docs are returned.
|
| 124 |
####
|
| 125 |
apache_doc_magic() {
|
| 126 |
debug-print-function apache_doc_magic $*
|
| 127 |
|
| 128 |
if [ -n "${DOCFILES}" ]; then
|
| 129 |
if [ "x$1" == "xhtml" ]; then
|
| 130 |
DOCS="`echo ${DOCFILES} | sed -e 's/ /\n/g' | sed -e '/^[^ ]*.html$/ !d'`"
|
| 131 |
else
|
| 132 |
DOCS="`echo ${DOCFILES} | sed 's, *[^ ]*\+.html, ,g'`"
|
| 133 |
fi
|
| 134 |
|
| 135 |
debug-print apache_doc_magic: DOCS=${DOCS}
|
| 136 |
echo ${DOCS}
|
| 137 |
fi
|
| 138 |
}
|
| 139 |
|
| 140 |
######
|
| 141 |
## Apache 1.x ebuild functions
|
| 142 |
######
|
| 143 |
|
| 144 |
####
|
| 145 |
## apache1_src_compile
|
| 146 |
## The default action is to call ${APXS11} with the value of
|
| 147 |
## ${APXS1_ARGS}. If a module requires a different build setup
|
| 148 |
## than this, use ${APXS1} in your own src_compile routine.
|
| 149 |
####
|
| 150 |
apache1_src_compile() {
|
| 151 |
debug-print-function apache1_src_compile
|
| 152 |
|
| 153 |
CD_DIR=$(apache_cd_dir)
|
| 154 |
cd ${CD_DIR} || die "cd ${CD_DIR} failed"
|
| 155 |
APXS1_ARGS="${APXS1_ARGS:--c ${PN}.c}"
|
| 156 |
${APXS1} ${APXS1_ARGS} || die "${APXS1} ${APXS1_ARGS} failed"
|
| 157 |
}
|
| 158 |
|
| 159 |
####
|
| 160 |
## apache1_src_install
|
| 161 |
##
|
| 162 |
## This installs the files into apache's directories. The module is installed
|
| 163 |
## from a directory chosen as above (APXS2_S or ${S}/src). In addition,
|
| 164 |
## this function can also set the executable permission on files listed in EXECFILES.
|
| 165 |
## The configuration file name is listed in APACHE1_MOD_CONF without the .conf extensions,
|
| 166 |
## so if you configuration is 55_mod_foo.conf, APACHE1_MOD_CONF would be 55_mod_foo.
|
| 167 |
## DOCFILES contains the list of files you want filed as documentation. The name of the
|
| 168 |
## module can also be specified using the APACHE1_MOD_FILE or defaults to
|
| 169 |
## .libs/${PN}.so.
|
| 170 |
####
|
| 171 |
apache1_src_install() {
|
| 172 |
debug-print-function apache1_src_install
|
| 173 |
|
| 174 |
CD_DIR=$(apache_cd_dir)
|
| 175 |
cd ${CD_DIR} || die "cd ${CD_DIR} failed"
|
| 176 |
|
| 177 |
MOD_FILE=$(apache_mod_file)
|
| 178 |
|
| 179 |
exeinto ${APACHE1_MODULESDIR}
|
| 180 |
doexe ${MOD_FILE} || die "internal ebuild error: '${MOD_FILE}' not found"
|
| 181 |
[ -n "${APACHE1_EXECFILES}" ] && doexe ${APACHE1_EXECFILES}
|
| 182 |
|
| 183 |
if [ -n "${APACHE1_MOD_CONF}" ] ; then
|
| 184 |
insinto ${APACHE1_MODULES_CONFDIR}
|
| 185 |
doins ${FILESDIR}/${APACHE1_MOD_CONF}.conf || die "internal ebuild error: '${FILESDIR}/${APACHE1_MOD_CONF}.conf' not found."
|
| 186 |
fi
|
| 187 |
|
| 188 |
cd ${S}
|
| 189 |
|
| 190 |
if [ -n "${DOCFILES}" ] ; then
|
| 191 |
OTHER_DOCS=$(apache_doc_magic)
|
| 192 |
HTML_DOCS=$(apache_doc_magic html)
|
| 193 |
|
| 194 |
[ -n "${OTHER_DOCS}" ] && dodoc ${OTHER_DOCS}
|
| 195 |
[ -n "${HTML_DOCS}" ] && dohtml ${HTML_DOCS}
|
| 196 |
fi
|
| 197 |
}
|
| 198 |
|
| 199 |
####
|
| 200 |
## apache1_pkg_postinst
|
| 201 |
##
|
| 202 |
## Prints the standard config message, unless APACHE1_NO_CONFIG is set to yes.
|
| 203 |
####
|
| 204 |
apache1_pkg_postinst() {
|
| 205 |
debug-print-function apache1_pkg_postinst
|
| 206 |
|
| 207 |
if [ -n "${APACHE1_MOD_DEFINE}" ]; then
|
| 208 |
einfo
|
| 209 |
einfo "To enable ${PN}, you need to edit your /etc/conf.d/apache file and"
|
| 210 |
einfo "add '-D ${APACHE1_MOD_DEFINE}' to APACHE_OPTS."
|
| 211 |
einfo
|
| 212 |
fi
|
| 213 |
if [ -n "${APACHE1_MOD_CONF}" ] ; then
|
| 214 |
einfo
|
| 215 |
einfo "Configuration file installed as"
|
| 216 |
einfo " ${APACHE1_MODULES_CONFDIR}/$(basename ${APACHE1_MOD_CONF}).conf"
|
| 217 |
einfo "You may want to edit it before turning the module on in /etc/conf.d/apache"
|
| 218 |
einfo
|
| 219 |
fi
|
| 220 |
}
|
| 221 |
|
| 222 |
######
|
| 223 |
## Apache 2.x ebuild functions
|
| 224 |
######
|
| 225 |
|
| 226 |
####
|
| 227 |
## apache2_pkg_setup
|
| 228 |
##
|
| 229 |
## Checks to see if APACHE2_MT_UNSAFE is set to anything other than "no". If it is, then
|
| 230 |
## we check what the MPM style used by Apache is, if it isnt prefork, we let the user
|
| 231 |
## know they need prefork, and then exit the build.
|
| 232 |
####
|
| 233 |
apache2_pkg_setup() {
|
| 234 |
debug-print-function apache2_pkg_setup
|
| 235 |
|
| 236 |
if [ -n "${APACHE2_SAFE_MPMS}" ]; then
|
| 237 |
|
| 238 |
for mpm in ${APACHE2_SAFE_MPMS}; do
|
| 239 |
MPM_USE="mpm-${mpm}"
|
| 240 |
if built_with_use apache ${MPM_USE}; then
|
| 241 |
INSTALLED_MPM_SAFE="yes"
|
| 242 |
fi
|
| 243 |
done
|
| 244 |
|
| 245 |
if [ -z "${INSTALLED_MPM_SAFE}" ] ; then
|
| 246 |
eerror "The module you are trying to install (${PN})"
|
| 247 |
eerror "will only work with one of the following MPMs:"
|
| 248 |
eerror " ${APACHE2_SAFE_MPMS}"
|
| 249 |
eerror "You do not currently have any of these MPMs installed."
|
| 250 |
eerror "Please re-install apache with the correct mpm-* USE flag set."
|
| 251 |
die "No safe MPM installed."
|
| 252 |
fi
|
| 253 |
|
| 254 |
fi
|
| 255 |
|
| 256 |
}
|
| 257 |
|
| 258 |
####
|
| 259 |
## apache2_src_compile
|
| 260 |
##
|
| 261 |
## The default action is to call ${APXS2} with the value of
|
| 262 |
## ${APXS2_ARGS}. If a module requires a different build setup
|
| 263 |
## than this, use ${APXS2} in your own src_compile routine.
|
| 264 |
####
|
| 265 |
apache2_src_compile() {
|
| 266 |
debug-print-function apache2_src_compile
|
| 267 |
|
| 268 |
CD_DIR=$(apache_cd_dir)
|
| 269 |
cd ${CD_DIR} || die "cd ${CD_DIR} failed"
|
| 270 |
APXS2_ARGS="${APXS2_ARGS:--c ${PN}.c}"
|
| 271 |
${APXS2} ${APXS2_ARGS} || die "${APXS2} ${APXS2_ARGS} failed"
|
| 272 |
}
|
| 273 |
|
| 274 |
####
|
| 275 |
## apache2_src_install
|
| 276 |
##
|
| 277 |
## This installs the files into apache's directories. The module is installed
|
| 278 |
## from a directory chosen as above (APXS2_S or ${S}/src). In addition,
|
| 279 |
## this function can also set the executable permission on files listed in EXECFILES.
|
| 280 |
## The configuration file name is listed in CONFFILE without the .conf extensions,
|
| 281 |
## so if you configuration is 55_mod_foo.conf, CONFFILE would be 55_mod_foo.
|
| 282 |
## DOCFILES contains the list of files you want filed as documentation.
|
| 283 |
####
|
| 284 |
apache2_src_install() {
|
| 285 |
debug-print-function apache2_src_install
|
| 286 |
|
| 287 |
CD_DIR=$(apache_cd_dir)
|
| 288 |
cd ${CD_DIR} || die "cd ${CD_DIR} failed"
|
| 289 |
|
| 290 |
MOD_FILE=$(apache_mod_file)
|
| 291 |
|
| 292 |
exeinto ${APACHE2_MODULESDIR}
|
| 293 |
doexe ${MOD_FILE} || die "internal ebuild error: '${MOD_FILE}' not found"
|
| 294 |
[ -n "${APACHE2_EXECFILES}" ] && doexe ${APACHE2_EXECFILES}
|
| 295 |
|
| 296 |
if [ -n "${APACHE2_MOD_CONF}" ] ; then
|
| 297 |
insinto ${APACHE2_MODULES_CONFDIR}
|
| 298 |
doins ${FILESDIR}/${APACHE2_MOD_CONF}.conf || die "internal ebuild error: '${FILESDIR}/${APACHE2_MOD_CONF}.conf' not found."
|
| 299 |
fi
|
| 300 |
|
| 301 |
if [ -n "${APACHE2_VHOSTFILE}" ]; then
|
| 302 |
insinto ${APACHE2_MODULES_VHOSTDIR}
|
| 303 |
doins ${FILESDIR}/${APACHE2_VHOSTFILE}.conf
|
| 304 |
fi
|
| 305 |
|
| 306 |
cd ${S}
|
| 307 |
|
| 308 |
if [ -n "${DOCFILES}" ] ; then
|
| 309 |
OTHER_DOCS=$(apache_doc_magic)
|
| 310 |
HTML_DOCS=$(apache_doc_magic html)
|
| 311 |
|
| 312 |
[ -n "${OTHER_DOCS}" ] && dodoc ${OTHER_DOCS}
|
| 313 |
[ -n "${HTML_DOCS}" ] && dohtml ${HTML_DOCS}
|
| 314 |
fi
|
| 315 |
}
|
| 316 |
|
| 317 |
apache2_pkg_postinst() {
|
| 318 |
debug-print-function apache2_pkg_postinst
|
| 319 |
|
| 320 |
if [ -n "${APACHE2_MOD_DEFINE}" ]; then
|
| 321 |
einfo
|
| 322 |
einfo "To enable ${PN}, you need to edit your /etc/conf.d/apache2 file and"
|
| 323 |
einfo "add '-D ${APACHE2_MOD_DEFINE}' to APACHE2_OPTS."
|
| 324 |
einfo
|
| 325 |
fi
|
| 326 |
if [ -n "${APACHE2_MOD_CONF}" ] ; then
|
| 327 |
einfo
|
| 328 |
einfo "Configuration file installed as"
|
| 329 |
einfo " ${APACHE2_MODULES_CONFDIR}/$(basename ${APACHE2_MOD_CONF}).conf"
|
| 330 |
einfo "You may want to edit it before turning the module on in /etc/conf.d/apache2"
|
| 331 |
einfo
|
| 332 |
fi
|
| 333 |
|
| 334 |
if [ -n "${APACHE2_SAFE_MPMS}" ]; then
|
| 335 |
|
| 336 |
INSTALLED_MPMS=$(ls ${ROOT}/usr/sbin/apache2.*)
|
| 337 |
|
| 338 |
for mpm in ${INSTALLED_MPMS}; do
|
| 339 |
# strip everything up to and including 'apache2.' from ${mpm}
|
| 340 |
mpm=${mpm#*apache2.}
|
| 341 |
|
| 342 |
if ! hasq ${mpm} ${APACHE2_SAFE_MPMS} ; then
|
| 343 |
INSTALLED_MPM_UNSAFE="${INSTALLED_MPM_UNSAFE} ${mpm}"
|
| 344 |
else
|
| 345 |
INSTALLED_MPM_SAFE="${INSTALLED_MPM_SAFE} ${mpm}"
|
| 346 |
fi
|
| 347 |
done
|
| 348 |
|
| 349 |
if [ -n "${INSTALLED_MPM_UNSAFE}" ] ; then
|
| 350 |
ewarn "You have one or more MPMs installed that will not work with"
|
| 351 |
ewarn "this module (${PN}). Please make sure that you only enable"
|
| 352 |
ewarn "this module if you are using one of the following MPMs:"
|
| 353 |
ewarn " ${INSTALLED_MPM_SAFE}"
|
| 354 |
fi
|
| 355 |
|
| 356 |
fi
|
| 357 |
|
| 358 |
|
| 359 |
}
|
| 360 |
|
| 361 |
######
|
| 362 |
## Apache dual (1.x or 2.x) ebuild functions
|
| 363 |
##
|
| 364 |
## This is where the magic happens. We provide dummy routines of all of the functions
|
| 365 |
## provided by all of the specifics. We use APACHE_ECLASS_VER_* to see which versions
|
| 366 |
## to call. If a function is provided by a given section (ie pkg_postinst in Apache 2.x)
|
| 367 |
## the exported routine simply does nothing.
|
| 368 |
######
|
| 369 |
|
| 370 |
apache-module_pkg_setup() {
|
| 371 |
debug-print-function apache-module_pkg_setup
|
| 372 |
|
| 373 |
if [ ${APACHE_VERSION} -eq '2' ]; then
|
| 374 |
apache2_pkg_setup
|
| 375 |
fi
|
| 376 |
}
|
| 377 |
|
| 378 |
apache-module_src_compile() {
|
| 379 |
debug-print-function apache-module_src_compile
|
| 380 |
|
| 381 |
if [ ${APACHE_VERSION} -eq '1' ]; then
|
| 382 |
apache1_src_compile
|
| 383 |
else
|
| 384 |
apache2_src_compile
|
| 385 |
fi
|
| 386 |
}
|
| 387 |
|
| 388 |
apache-module_src_install() {
|
| 389 |
debug-print-function apache-module_src_install
|
| 390 |
|
| 391 |
if [ ${APACHE_VERSION} -eq '1' ]; then
|
| 392 |
apache1_src_install
|
| 393 |
else
|
| 394 |
apache2_src_install
|
| 395 |
fi
|
| 396 |
}
|
| 397 |
|
| 398 |
apache-module_pkg_postinst() {
|
| 399 |
debug-print-function apache-module_pkg_postinst
|
| 400 |
|
| 401 |
if [ ${APACHE_VERSION} -eq '1' ]; then
|
| 402 |
apache1_pkg_postinst
|
| 403 |
else
|
| 404 |
apache2_pkg_postinst
|
| 405 |
fi
|
| 406 |
}
|
| 407 |
|
| 408 |
EXPORT_FUNCTIONS pkg_setup src_compile src_install pkg_postinst
|
| 409 |
|
| 410 |
# vim:ts=4
|