| 1 |
fauli |
1.25 |
# Copyright 1999-2011 Gentoo Foundation |
| 2 |
chtekk |
1.19 |
# Distributed under the terms of the GNU General Public License v2 |
| 3 |
fauli |
1.25 |
# $Header: /var/cvsroot/gentoo-x86/eclass/apache-module.eclass,v 1.24 2010/08/08 18:46:46 hollow Exp $ |
| 4 |
hollow |
1.20 |
|
| 5 |
hollow |
1.23 |
# @ECLASS: apache-module.eclass |
| 6 |
|
|
# @MAINTAINER: |
| 7 |
|
|
# apache-devs@gentoo.org |
| 8 |
hollow |
1.20 |
# @BLURB: Provides a common set of functions for apache modules |
| 9 |
|
|
# @DESCRIPTION: |
| 10 |
hollow |
1.23 |
# This eclass handles apache modules in a sane way. |
| 11 |
hollow |
1.20 |
# |
| 12 |
hollow |
1.23 |
# 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 |
hollow |
1.20 |
# |
| 17 |
hollow |
1.23 |
# 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 |
urilith |
1.1 |
|
| 48 |
|
|
inherit depend.apache |
| 49 |
|
|
|
| 50 |
hollow |
1.20 |
# ============================================================================== |
| 51 |
hollow |
1.23 |
# PUBLIC VARIABLES |
| 52 |
hollow |
1.20 |
# ============================================================================== |
| 53 |
|
|
|
| 54 |
hollow |
1.23 |
# @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 |
hollow |
1.20 |
# @DESCRIPTION: |
| 61 |
hollow |
1.23 |
# Arguments to pass to the apxs tool. (Defaults to `-c ${PN}.c') |
| 62 |
urilith |
1.1 |
|
| 63 |
hollow |
1.23 |
# @VARIABLE: APACHE2_EXECFILES |
| 64 |
hollow |
1.20 |
# @DESCRIPTION: |
| 65 |
hollow |
1.23 |
# 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 |
urilith |
1.1 |
|
| 69 |
hollow |
1.23 |
# @VARIABLE: APACHE2_MOD_CONF |
| 70 |
hollow |
1.20 |
# @DESCRIPTION: |
| 71 |
hollow |
1.23 |
# Module configuration file installed by src_install (minus the .conf suffix and |
| 72 |
|
|
# relative to ${FILESDIR}). |
| 73 |
urilith |
1.1 |
|
| 74 |
hollow |
1.23 |
# @VARIABLE: APACHE2_MOD_DEFINE |
| 75 |
hollow |
1.20 |
# @DESCRIPTION: |
| 76 |
hollow |
1.23 |
# 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 |
urilith |
1.1 |
|
| 79 |
hollow |
1.23 |
# @VARIABLE: APACHE2_MOD_FILE |
| 80 |
hollow |
1.22 |
# @DESCRIPTION: |
| 81 |
hollow |
1.23 |
# Name of the module that src_install installs minus the .so suffix. (Defaults |
| 82 |
|
|
# to `${APXS2_S}/.libs/${PN}.so') |
| 83 |
hollow |
1.22 |
|
| 84 |
hollow |
1.23 |
# @VARIABLE: APACHE2_VHOST_CONF |
| 85 |
hollow |
1.22 |
# @DESCRIPTION: |
| 86 |
hollow |
1.23 |
# Virtual host configuration file installed by src_install (minus the .conf |
| 87 |
|
|
# suffix and relative to ${FILESDIR}). |
| 88 |
hollow |
1.22 |
|
| 89 |
hollow |
1.23 |
# @VARIABLE: DOCFILES |
| 90 |
hollow |
1.20 |
# @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 |
hollow |
1.23 |
# documentation, and dodoc'd or dohtml'd. |
| 94 |
urilith |
1.1 |
|
| 95 |
hollow |
1.20 |
# ============================================================================== |
| 96 |
hollow |
1.23 |
# INTERNAL FUNCTIONS |
| 97 |
hollow |
1.20 |
# ============================================================================== |
| 98 |
|
|
|
| 99 |
hollow |
1.23 |
# Internal function to construct the default ${APXS2_S} path if required. |
| 100 |
urilith |
1.1 |
apache_cd_dir() { |
| 101 |
vericgar |
1.18 |
debug-print-function $FUNCNAME $* |
| 102 |
urilith |
1.1 |
|
| 103 |
hollow |
1.23 |
local CD_DIR="${APXS2_S}" |
| 104 |
urilith |
1.1 |
|
| 105 |
chtekk |
1.19 |
if [[ -z "${CD_DIR}" ]] ; then |
| 106 |
|
|
if [[ -d "${S}/src" ]] ; then |
| 107 |
urilith |
1.1 |
CD_DIR="${S}/src" |
| 108 |
|
|
else |
| 109 |
|
|
CD_DIR="${S}" |
| 110 |
|
|
fi |
| 111 |
|
|
fi |
| 112 |
|
|
|
| 113 |
hollow |
1.23 |
debug-print $FUNCNAME "CD_DIR=${CD_DIR}" |
| 114 |
chtekk |
1.19 |
echo "${CD_DIR}" |
| 115 |
urilith |
1.1 |
} |
| 116 |
|
|
|
| 117 |
hollow |
1.23 |
# Internal function to construct the default ${APACHE2_MOD_FILE} if required. |
| 118 |
urilith |
1.1 |
apache_mod_file() { |
| 119 |
vericgar |
1.18 |
debug-print-function $FUNCNAME $* |
| 120 |
urilith |
1.1 |
|
| 121 |
hollow |
1.23 |
local MOD_FILE="${APACHE2_MOD_FILE:-$(apache_cd_dir)/.libs/${PN}.so}" |
| 122 |
urilith |
1.1 |
|
| 123 |
hollow |
1.23 |
debug-print $FUNCNAME "MOD_FILE=${MOD_FILE}" |
| 124 |
chtekk |
1.19 |
echo "${MOD_FILE}" |
| 125 |
urilith |
1.1 |
} |
| 126 |
|
|
|
| 127 |
hollow |
1.23 |
# 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 |
urilith |
1.1 |
apache_doc_magic() { |
| 131 |
vericgar |
1.18 |
debug-print-function $FUNCNAME $* |
| 132 |
urilith |
1.1 |
|
| 133 |
hollow |
1.23 |
local DOCS= |
| 134 |
|
|
|
| 135 |
chtekk |
1.19 |
if [[ -n "${DOCFILES}" ]] ; then |
| 136 |
|
|
if [[ "x$1" == "xhtml" ]] ; then |
| 137 |
urilith |
1.1 |
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 |
hollow |
1.23 |
fi |
| 142 |
urilith |
1.1 |
|
| 143 |
hollow |
1.23 |
debug-print $FUNCNAME "DOCS=${DOCS}" |
| 144 |
|
|
echo "${DOCS}" |
| 145 |
urilith |
1.1 |
} |
| 146 |
|
|
|
| 147 |
hollow |
1.23 |
# ============================================================================== |
| 148 |
|
|
# EXPORTED FUNCTIONS |
| 149 |
|
|
# ============================================================================== |
| 150 |
swegener |
1.12 |
|
| 151 |
hollow |
1.20 |
# @FUNCTION: apache-module_src_compile |
| 152 |
|
|
# @DESCRIPTION: |
| 153 |
hollow |
1.22 |
# 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 |
hollow |
1.20 |
# src_compile routine. |
| 156 |
|
|
apache-module_src_compile() { |
| 157 |
vericgar |
1.18 |
debug-print-function $FUNCNAME $* |
| 158 |
urilith |
1.1 |
|
| 159 |
hollow |
1.23 |
local CD_DIR=$(apache_cd_dir) |
| 160 |
chtekk |
1.19 |
cd "${CD_DIR}" || die "cd ${CD_DIR} failed" |
| 161 |
hollow |
1.23 |
|
| 162 |
urilith |
1.1 |
APXS2_ARGS="${APXS2_ARGS:--c ${PN}.c}" |
| 163 |
hollow |
1.22 |
${APXS} ${APXS2_ARGS} || die "${APXS} ${APXS2_ARGS} failed" |
| 164 |
urilith |
1.1 |
} |
| 165 |
|
|
|
| 166 |
hollow |
1.20 |
# @FUNCTION: apache-module_src_install |
| 167 |
|
|
# @DESCRIPTION: |
| 168 |
|
|
# This installs the files into apache's directories. The module is installed |
| 169 |
hollow |
1.23 |
# 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 |
hollow |
1.20 |
apache-module_src_install() { |
| 176 |
vericgar |
1.18 |
debug-print-function $FUNCNAME $* |
| 177 |
urilith |
1.1 |
|
| 178 |
hollow |
1.23 |
local CD_DIR=$(apache_cd_dir) |
| 179 |
chtekk |
1.19 |
cd "${CD_DIR}" || die "cd ${CD_DIR} failed" |
| 180 |
urilith |
1.1 |
|
| 181 |
hollow |
1.23 |
local MOD_FILE=$(apache_mod_file) |
| 182 |
urilith |
1.1 |
|
| 183 |
hollow |
1.22 |
exeinto "${APACHE_MODULESDIR}" |
| 184 |
vericgar |
1.5 |
doexe ${MOD_FILE} || die "internal ebuild error: '${MOD_FILE}' not found" |
| 185 |
chtekk |
1.19 |
[[ -n "${APACHE2_EXECFILES}" ]] && doexe ${APACHE2_EXECFILES} |
| 186 |
urilith |
1.1 |
|
| 187 |
chtekk |
1.19 |
if [[ -n "${APACHE2_MOD_CONF}" ]] ; then |
| 188 |
hollow |
1.22 |
insinto "${APACHE_MODULES_CONFDIR}" |
| 189 |
hollow |
1.21 |
set -- ${APACHE2_MOD_CONF} |
| 190 |
|
|
newins "${FILESDIR}/${1}.conf" "$(basename ${2:-$1}).conf" \ |
| 191 |
|
|
|| die "internal ebuild error: '${FILESDIR}/${1}.conf' not found" |
| 192 |
urilith |
1.1 |
fi |
| 193 |
|
|
|
| 194 |
hollow |
1.22 |
if [[ -n "${APACHE2_VHOST_CONF}" ]] ; then |
| 195 |
|
|
insinto "${APACHE_VHOSTS_CONFDIR}" |
| 196 |
|
|
set -- ${APACHE2_VHOST_CONF} |
| 197 |
hollow |
1.21 |
newins "${FILESDIR}/${1}.conf" "$(basename ${2:-$1}).conf " \ |
| 198 |
|
|
|| die "internal ebuild error: '${FILESDIR}/${1}.conf' not found" |
| 199 |
urilith |
1.1 |
fi |
| 200 |
|
|
|
| 201 |
chtekk |
1.19 |
cd "${S}" |
| 202 |
urilith |
1.1 |
|
| 203 |
chtekk |
1.19 |
if [[ -n "${DOCFILES}" ]] ; then |
| 204 |
hollow |
1.23 |
local OTHER_DOCS=$(apache_doc_magic) |
| 205 |
|
|
local HTML_DOCS=$(apache_doc_magic html) |
| 206 |
urilith |
1.1 |
|
| 207 |
chtekk |
1.19 |
[[ -n "${OTHER_DOCS}" ]] && dodoc ${OTHER_DOCS} |
| 208 |
|
|
[[ -n "${HTML_DOCS}" ]] && dohtml ${HTML_DOCS} |
| 209 |
urilith |
1.1 |
fi |
| 210 |
|
|
} |
| 211 |
|
|
|
| 212 |
hollow |
1.20 |
# @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 |
vericgar |
1.18 |
debug-print-function $FUNCNAME $* |
| 217 |
urilith |
1.1 |
|
| 218 |
chtekk |
1.19 |
if [[ -n "${APACHE2_MOD_DEFINE}" ]] ; then |
| 219 |
tomk |
1.16 |
local my_opts="-D ${APACHE2_MOD_DEFINE// / -D }" |
| 220 |
|
|
|
| 221 |
urilith |
1.1 |
einfo |
| 222 |
|
|
einfo "To enable ${PN}, you need to edit your /etc/conf.d/apache2 file and" |
| 223 |
tomk |
1.16 |
einfo "add '${my_opts}' to APACHE2_OPTS." |
| 224 |
urilith |
1.1 |
einfo |
| 225 |
|
|
fi |
| 226 |
chtekk |
1.19 |
|
| 227 |
|
|
if [[ -n "${APACHE2_MOD_CONF}" ]] ; then |
| 228 |
hollow |
1.21 |
set -- ${APACHE2_MOD_CONF} |
| 229 |
vericgar |
1.2 |
einfo |
| 230 |
vericgar |
1.3 |
einfo "Configuration file installed as" |
| 231 |
hollow |
1.24 |
einfo " ${APACHE_MODULES_CONFDIR}/$(basename ${2:-$1}).conf" |
| 232 |
vericgar |
1.2 |
einfo "You may want to edit it before turning the module on in /etc/conf.d/apache2" |
| 233 |
|
|
einfo |
| 234 |
|
|
fi |
| 235 |
urilith |
1.1 |
} |
| 236 |
|
|
|
| 237 |
hollow |
1.23 |
EXPORT_FUNCTIONS src_compile src_install pkg_postinst |