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

Diff of /eclass/apache-2.eclass

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

Revision 1.11 Revision 1.41
1# Copyright 1999-2007 Gentoo Foundation 1# Copyright 1999-2015 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-2.eclass,v 1.11 2008/03/23 13:03:53 hollow Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/apache-2.eclass,v 1.41 2015/06/07 19:22:36 pacho Exp $
4 4
5# @ECLASS: apache-2.eclass 5# @ECLASS: apache-2.eclass
6# @MAINTAINER: 6# @MAINTAINER:
7# apache-devs@gentoo.org 7# polynomial-c@gentoo.org
8# @BLURB: Provides a common set of functions for apache-2.x ebuilds 8# @BLURB: Provides a common set of functions for apache-2.x ebuilds
9# @DESCRIPTION: 9# @DESCRIPTION:
10# This eclass handles apache-2.x ebuild functions such as LoadModule generation 10# This eclass handles apache-2.x ebuild functions such as LoadModule generation
11# and inter-module dependency checking. 11# and inter-module dependency checking.
12 12
13inherit autotools confutils eutils flag-o-matic multilib 13inherit autotools eutils flag-o-matic multilib ssl-cert user toolchain-funcs versionator
14
15[[ ${CATEGORY}/${PN} != www-servers/apache ]] \
16 && die "Do not use this eclass with anything else than www-servers/apache ebuilds!"
17
18case ${EAPI:-0} in
19 0|1|2|3)
20 die "This eclass requires >=EAPI-4"
21 ;;
22esac
23
24# settings which are version specific go in here:
25case $(get_version_component_range 1-2) in
26 2.4)
27 DEFAULT_MPM_THREADED="event" #509922
28 RDEPEND=">=dev-libs/apr-1.5.1
29 !www-apache/mod_macro" #492578 #477702
30 ;;
31 *)
32 DEFAULT_MPM_THREADED="worker"
33 RDEPEND=">=dev-libs/apr-1.4.5" #368651
34 ;;
35esac
14 36
15# ============================================================================== 37# ==============================================================================
16# INTERNAL VARIABLES 38# INTERNAL VARIABLES
17# ============================================================================== 39# ==============================================================================
18 40
19# @ECLASS-VARIABLE: GENTOO_PATCHNAME 41# @ECLASS-VARIABLE: GENTOO_PATCHNAME
20# @DESCRIPTION: 42# @DESCRIPTION:
21# This internal variable contains the prefix for the patch tarball 43# This internal variable contains the prefix for the patch tarball.
22GENTOO_PATCHNAME="gentoo-${PF}" 44# Defaults to the full name and version (including revision) of the package.
45# If you want to override this in an ebuild, use:
46# ORIG_PR="(revision of Gentoo stuff you want)"
47# GENTOO_PATCHNAME="gentoo-${PN}-${PV}${ORIG_PR:+-${ORIG_PR}}"
48[[ -n "$GENTOO_PATCHNAME" ]] || GENTOO_PATCHNAME="gentoo-${PF}"
23 49
24# @ECLASS-VARIABLE: GENTOO_PATCHDIR 50# @ECLASS-VARIABLE: GENTOO_PATCHDIR
25# @DESCRIPTION: 51# @DESCRIPTION:
26# This internal variable contains the working directory where patches and config 52# This internal variable contains the working directory where patches and config
27# files are located 53# files are located.
54# Defaults to the patchset name appended to the working directory.
28GENTOO_PATCHDIR="${WORKDIR}/${GENTOO_PATCHNAME}" 55[[ -n "$GENTOO_PATCHDIR" ]] || GENTOO_PATCHDIR="${WORKDIR}/${GENTOO_PATCHNAME}"
29 56
30# @VARIABLE: GENTOO_DEVELOPER 57# @VARIABLE: GENTOO_DEVELOPER
31# @DESCRIPTION: 58# @DESCRIPTION:
32# This variable needs to be set in the ebuild and contains the name of the 59# This variable needs to be set in the ebuild and contains the name of the
33# gentoo developer who created the patch tarball 60# gentoo developer who created the patch tarball
35# @VARIABLE: GENTOO_PATCHSTAMP 62# @VARIABLE: GENTOO_PATCHSTAMP
36# @DESCRIPTION: 63# @DESCRIPTION:
37# This variable needs to be set in the ebuild and contains the date the patch 64# This variable needs to be set in the ebuild and contains the date the patch
38# tarball was created at in YYYYMMDD format 65# tarball was created at in YYYYMMDD format
39 66
67# @VARIABLE: GENTOO_PATCH_A
68# @DESCRIPTION:
69# This variable should contain the entire filename of patch tarball.
70# Defaults to the name of the patchset, with a datestamp.
71[[ -n "$GENTOO_PATCH_A" ]] || GENTOO_PATCH_A="${GENTOO_PATCHNAME}-${GENTOO_PATCHSTAMP}.tar.bz2"
72
40SRC_URI="mirror://apache/httpd/httpd-${PV}.tar.bz2 73SRC_URI="mirror://apache/httpd/httpd-${PV}.tar.bz2
41 http://dev.gentoo.org/~${GENTOO_DEVELOPER}/dist/apache/${GENTOO_PATCHNAME}-${GENTOO_PATCHSTAMP}.tar.bz2" 74 http://dev.gentoo.org/~${GENTOO_DEVELOPER}/dist/apache/${GENTOO_PATCH_A}"
42 75
43# @VARIABLE: IUSE_MPMS_FORK 76# @VARIABLE: IUSE_MPMS_FORK
44# @DESCRIPTION: 77# @DESCRIPTION:
45# This variable needs to be set in the ebuild and contains a list of forking 78# This variable needs to be set in the ebuild and contains a list of forking
46# (i.e. non-threaded) MPMs 79# (i.e. non-threaded) MPMs
66 IUSE="${IUSE} apache2_mpms_${mpm}" 99 IUSE="${IUSE} apache2_mpms_${mpm}"
67done 100done
68 101
69DEPEND="dev-lang/perl 102DEPEND="dev-lang/perl
70 =dev-libs/apr-1* 103 =dev-libs/apr-1*
71 =dev-libs/apr-util-1* 104 =dev-libs/apr-util-1*[ldap?]
72 dev-libs/libpcre 105 dev-libs/libpcre
106 apache2_modules_deflate? ( sys-libs/zlib )
107 apache2_modules_mime? ( app-misc/mime-types )
73 ldap? ( =net-nds/openldap-2* ) 108 ldap? ( =net-nds/openldap-2* )
74 selinux? ( sec-policy/selinux-apache )
75 ssl? ( >=dev-libs/openssl-0.9.8f ) 109 ssl? ( >=dev-libs/openssl-0.9.8m )
76 !=www-servers/apache-1*" 110 !=www-servers/apache-1*"
77RDEPEND="${DEPEND}" 111RDEPEND+=" ${DEPEND}
112 selinux? ( sec-policy/selinux-apache )"
78PDEPEND="~app-admin/apache-tools-${PV}" 113PDEPEND="~app-admin/apache-tools-${PV}"
79 114
80S="${WORKDIR}/httpd-${PV}" 115S="${WORKDIR}/httpd-${PV}"
81 116
82# ============================================================================== 117# ==============================================================================
108 fi 143 fi
109 done 144 done
110 145
111 if [[ -z "${MY_MPM}" ]] ; then 146 if [[ -z "${MY_MPM}" ]] ; then
112 if use threads ; then 147 if use threads ; then
113 MY_MPM=worker 148 MY_MPM=${DEFAULT_MPM_THREADED}
114 elog 149 elog
115 elog "Selected default threaded MPM: ${MY_MPM}" 150 elog "Selected default threaded MPM: ${MY_MPM}"
116 elog 151 elog
117 else 152 else
118 MY_MPM=prefork 153 MY_MPM=prefork
145# apache configuration. 180# apache configuration.
146check_module_critical() { 181check_module_critical() {
147 local unsupported=0 182 local unsupported=0
148 183
149 for m in ${MODULE_CRITICAL} ; do 184 for m in ${MODULE_CRITICAL} ; do
150 if ! has ${m} ${MY_MODS} ; then 185 if ! has ${m} ${MY_MODS[@]} ; then
151 ewarn "Module '${m}' is required in the default apache configuration." 186 ewarn "Module '${m}' is required in the default apache configuration."
152 unsupported=1 187 unsupported=1
153 fi 188 fi
154 done 189 done
155 190
158 ewarn "You have disabled one or more required modules" 193 ewarn "You have disabled one or more required modules"
159 ewarn "for the default apache configuration." 194 ewarn "for the default apache configuration."
160 ewarn "Although this is not an error, please be" 195 ewarn "Although this is not an error, please be"
161 ewarn "aware that this setup is UNSUPPORTED." 196 ewarn "aware that this setup is UNSUPPORTED."
162 ewarn 197 ewarn
163 ebeep 10
164 fi 198 fi
165} 199}
166 200
167# @VARIABLE: MODULE_DEPENDS 201# @VARIABLE: MODULE_DEPENDS
168# @DESCRIPTION: 202# @DESCRIPTION:
175# This internal function makes sure that all inter-module dependencies are 209# This internal function makes sure that all inter-module dependencies are
176# satisfied with the current module selection 210# satisfied with the current module selection
177check_module_depends() { 211check_module_depends() {
178 local err=0 212 local err=0
179 213
180 for m in ${MY_MODS} ; do 214 for m in ${MY_MODS[@]} ; do
181 for dep in ${MODULE_DEPENDS} ; do 215 for dep in ${MODULE_DEPENDS} ; do
182 if [[ "${m}" == "${dep%:*}" ]] ; then 216 if [[ "${m}" == "${dep%:*}" ]] ; then
183 if ! use apache2_modules_${dep#*:} ; then 217 if ! use apache2_modules_${dep#*:} ; then
184 eerror "Module '${m}' depends on '${dep#*:}'" 218 eerror "Module '${m}' depends on '${dep#*:}'"
185 err=1 219 err=1
214 mod_type="static" 248 mod_type="static"
215 else 249 else
216 mod_type="shared" 250 mod_type="shared"
217 fi 251 fi
218 252
219 MY_CONF="--enable-so=static" 253 MY_CONF=( --enable-so=static )
254 MY_MODS=()
220 255
221 if use ldap ; then 256 if use ldap ; then
222 confutils_use_depend_built_with_all ldap dev-libs/apr-util ldap
223 MY_CONF="${MY_CONF} --enable-authnz_ldap=${mod_type} --enable-ldap=${mod_type}" 257 MY_CONF+=( --enable-authnz_ldap=${mod_type} --enable-ldap=${mod_type} )
224 MY_MODS="${MY_MODS} ldap authnz_ldap" 258 MY_MODS+=( ldap authnz_ldap )
225 else 259 else
226 MY_CONF="${MY_CONF} --disable-authnz_ldap --disable-ldap" 260 MY_CONF+=( --disable-authnz_ldap --disable-ldap )
227 fi 261 fi
228 262
229 if use ssl ; then 263 if use ssl ; then
230 MY_CONF="${MY_CONF} --with-ssl=/usr --enable-ssl=${mod_type}" 264 MY_CONF+=( --with-ssl="${EPREFIX}"/usr --enable-ssl=${mod_type} )
231 MY_MODS="${MY_MODS} ssl" 265 MY_MODS+=( ssl )
232 else 266 else
233 MY_CONF="${MY_CONF} --without-ssl --disable-ssl" 267 MY_CONF+=( --without-ssl --disable-ssl )
234 fi
235
236 if use threads || has ${MY_MPM} ${IUSE_MPMS_THREAD} ; then
237 MY_CONF="${MY_CONF} --enable-cgid=${mod_type}"
238 MY_MODS="${MY_MODS} cgid"
239 else
240 MY_CONF="${MY_CONF} --enable-cgi=${mod_type}"
241 MY_MODS="${MY_MODS} cgi"
242 fi 268 fi
243 269
244 if use suexec ; then 270 if use suexec ; then
245 elog "You can manipulate several configure options of suexec" 271 elog "You can manipulate several configure options of suexec"
246 elog "through the following environment variables:" 272 elog "through the following environment variables:"
247 elog 273 elog
248 elog " SUEXEC_SAFEPATH: Default PATH for suexec (default: /usr/local/bin:/usr/bin:/bin)" 274 elog " SUEXEC_SAFEPATH: Default PATH for suexec (default: '${EPREFIX}/usr/local/bin:${EPREFIX}/usr/bin:${EPREFIX}/bin')"
249 elog " SUEXEC_LOGFILE: Path to the suexec logfile (default: /var/log/apache2/suexec_log)" 275 elog " SUEXEC_LOGFILE: Path to the suexec logfile (default: '${EPREFIX}/var/log/apache2/suexec_log')"
250 elog " SUEXEC_CALLER: Name of the user Apache is running as (default: apache)" 276 elog " SUEXEC_CALLER: Name of the user Apache is running as (default: apache)"
251 elog " SUEXEC_DOCROOT: Directory in which suexec will run scripts (default: /var/www)" 277 elog " SUEXEC_DOCROOT: Directory in which suexec will run scripts (default: '${EPREFIX}/var/www')"
252 elog " SUEXEC_MINUID: Minimum UID, which is allowed to run scripts via suexec (default: 1000)" 278 elog " SUEXEC_MINUID: Minimum UID, which is allowed to run scripts via suexec (default: 1000)"
253 elog " SUEXEC_MINGID: Minimum GID, which is allowed to run scripts via suexec (default: 100)" 279 elog " SUEXEC_MINGID: Minimum GID, which is allowed to run scripts via suexec (default: 100)"
254 elog " SUEXEC_USERDIR: User subdirectories (like /home/user/html) (default: public_html)" 280 elog " SUEXEC_USERDIR: User subdirectories (like /home/user/html) (default: public_html)"
255 elog " SUEXEC_UMASK: Umask for the suexec process (default: 077)" 281 elog " SUEXEC_UMASK: Umask for the suexec process (default: 077)"
256 elog 282 elog
257 283
258 MY_CONF="${MY_CONF} --with-suexec-safepath=${SUEXEC_SAFEPATH:-/usr/local/bin:/usr/bin:/bin}" 284 MY_CONF+=( --with-suexec-safepath="${SUEXEC_SAFEPATH:-${EPREFIX}/usr/local/bin:${EPREFIX}/usr/bin:${EPREFIX}/bin}" )
259 MY_CONF="${MY_CONF} --with-suexec-logfile=${SUEXEC_LOGFILE:-/var/log/apache2/suexec_log}" 285 MY_CONF+=( --with-suexec-logfile="${SUEXEC_LOGFILE:-${EPREFIX}/var/log/apache2/suexec_log}" )
260 MY_CONF="${MY_CONF} --with-suexec-bin=/usr/sbin/suexec" 286 MY_CONF+=( --with-suexec-bin="${EPREFIX}/usr/sbin/suexec" )
261 MY_CONF="${MY_CONF} --with-suexec-userdir=${SUEXEC_USERDIR:-public_html}" 287 MY_CONF+=( --with-suexec-userdir=${SUEXEC_USERDIR:-public_html} )
262 MY_CONF="${MY_CONF} --with-suexec-caller=${SUEXEC_CALLER:-apache}" 288 MY_CONF+=( --with-suexec-caller=${SUEXEC_CALLER:-apache} )
263 MY_CONF="${MY_CONF} --with-suexec-docroot=${SUEXEC_DOCROOT:-/var/www}" 289 MY_CONF+=( --with-suexec-docroot="${SUEXEC_DOCROOT:-${EPREFIX}/var/www}" )
264 MY_CONF="${MY_CONF} --with-suexec-uidmin=${SUEXEC_MINUID:-1000}" 290 MY_CONF+=( --with-suexec-uidmin=${SUEXEC_MINUID:-1000} )
265 MY_CONF="${MY_CONF} --with-suexec-gidmin=${SUEXEC_MINGID:-100}" 291 MY_CONF+=( --with-suexec-gidmin=${SUEXEC_MINGID:-100} )
266 MY_CONF="${MY_CONF} --with-suexec-umask=${SUEXEC_UMASK:-077}" 292 MY_CONF+=( --with-suexec-umask=${SUEXEC_UMASK:-077} )
267 MY_CONF="${MY_CONF} --enable-suexec=${mod_type}" 293 MY_CONF+=( --enable-suexec=${mod_type} )
268 MY_MODS="${MY_MODS} suexec" 294 MY_MODS+=( suexec )
269 else 295 else
270 MY_CONF="${MY_CONF} --disable-suexec" 296 MY_CONF+=( --disable-suexec )
271 fi 297 fi
272 298
273 for x in ${IUSE_MODULES} ; do 299 for x in ${IUSE_MODULES} ; do
274 if use apache2_modules_${x} ; then 300 if use apache2_modules_${x} ; then
275 MY_CONF="${MY_CONF} --enable-${x}=${mod_type}" 301 MY_CONF+=( --enable-${x}=${mod_type} )
276 MY_MODS="${MY_MODS} ${x}" 302 MY_MODS+=( ${x} )
277 else 303 else
278 MY_CONF="${MY_CONF} --disable-${x}" 304 MY_CONF+=( --disable-${x} )
279 fi 305 fi
280 done 306 done
281 307
282 # sort and uniquify MY_MODS 308 # sort and uniquify MY_MODS
283 MY_MODS=$(echo ${MY_MODS} | tr ' ' '\n' | sort -u) 309 MY_MODS=( $(echo ${MY_MODS[@]} | tr ' ' '\n' | sort -u) )
284 check_module_depends 310 check_module_depends
285 check_module_critical 311 check_module_critical
286} 312}
287 313
288# @VARIABLE: MODULE_DEFINES 314# @VARIABLE: MODULE_DEFINES
295# @FUNCTION: generate_load_module 321# @FUNCTION: generate_load_module
296# @DESCRIPTION: 322# @DESCRIPTION:
297# This internal function generates the LoadModule lines for httpd.conf based on 323# This internal function generates the LoadModule lines for httpd.conf based on
298# the current module selection and MODULE_DEFINES 324# the current module selection and MODULE_DEFINES
299generate_load_module() { 325generate_load_module() {
300 local endit=0 mod_lines= mod_dir="${D}/usr/$(get_libdir)/apache2/modules" 326 local endit=0 mod_lines= mod_dir="${ED}/usr/$(get_libdir)/apache2/modules"
301 327
302 if use static; then 328 if use static; then
303 sed -i -e "/%%LOAD_MODULE%%/d" \ 329 sed -i -e "/%%LOAD_MODULE%%/d" \
304 "${GENTOO_PATCHDIR}"/conf/httpd.conf 330 "${GENTOO_PATCHDIR}"/conf/httpd.conf
305 return 331 return
306 fi 332 fi
307 333
308 for m in ${MY_MODS} ; do 334 for m in ${MY_MODS[@]} ; do
309 if [[ -e "${mod_dir}/mod_${m}.so" ]] ; then 335 if [[ -e "${mod_dir}/mod_${m}.so" ]] ; then
310 for def in ${MODULE_DEFINES} ; do 336 for def in ${MODULE_DEFINES} ; do
311 if [[ "${m}" == "${def%:*}" ]] ; then 337 if [[ "${m}" == "${def%:*}" ]] ; then
312 mod_lines="${mod_lines}\n<IfDefine ${def#*:}>" 338 mod_lines="${mod_lines}\n<IfDefine ${def#*:}>"
313 endit=1 339 endit=1
332# This internal function checks if the previous configuration file for built-in 358# This internal function checks if the previous configuration file for built-in
333# modules exists in ROOT and prevents upgrade in this case. Users are supposed 359# modules exists in ROOT and prevents upgrade in this case. Users are supposed
334# to convert this file to the new APACHE2_MODULES USE_EXPAND variable and remove 360# to convert this file to the new APACHE2_MODULES USE_EXPAND variable and remove
335# it afterwards. 361# it afterwards.
336check_upgrade() { 362check_upgrade() {
337 if [[ -e "${ROOT}"etc/apache2/apache2-builtin-mods ]]; then 363 if [[ -e "${EROOT}"etc/apache2/apache2-builtin-mods ]]; then
338 eerror "The previous configuration file for built-in modules" 364 eerror "The previous configuration file for built-in modules"
339 eerror "(${ROOT}etc/apache2/apache2-builtin-mods) exists on your" 365 eerror "(${EROOT}etc/apache2/apache2-builtin-mods) exists on your"
340 eerror "system." 366 eerror "system."
341 eerror 367 eerror
342 eerror "Please read http://www.gentoo.org/doc/en/apache-upgrading.xml" 368 eerror "Please read http://www.gentoo.org/doc/en/apache-upgrading.xml"
343 eerror "for detailed information how to convert this file to the new" 369 eerror "for detailed information how to convert this file to the new"
344 eerror "APACHE2_MODULES USE_EXPAND variable." 370 eerror "APACHE2_MODULES USE_EXPAND variable."
365 391
366 setup_mpm 392 setup_mpm
367 setup_modules 393 setup_modules
368 394
369 if use debug; then 395 if use debug; then
370 MY_CONF="${MY_CONF} --enable-maintainer-mode --enable-exception-hook" 396 MY_CONF+=( --enable-maintainer-mode --enable-exception-hook )
371 fi 397 fi
372 398
373 elog "Please note that you need SysV IPC support in your kernel." 399 elog "Please note that you need SysV IPC support in your kernel."
374 elog "Make sure CONFIG_SYSVIPC=y is set." 400 elog "Make sure CONFIG_SYSVIPC=y is set."
375 elog 401 elog
376}
377 402
403 if use userland_BSD; then
404 elog "On BSD systems you need to add the following line to /boot/loader.conf:"
405 elog " accf_http_load=\"YES\""
406 elog
407 fi
408}
409
378# @FUNCTION: apache-2_src_unpack 410# @FUNCTION: apache-2_src_prepare
379# @DESCRIPTION: 411# @DESCRIPTION:
380# This function applies patches, configures a custom file-system layout and 412# This function applies patches, configures a custom file-system layout and
381# rebuilds the configure scripts. 413# rebuilds the configure scripts.
382apache-2_src_unpack() { 414apache-2_src_prepare() {
383 unpack ${A} 415 #fix prefix in conf files etc (bug #433736)
384 cd "${S}" 416 use !prefix || sed -e "s@/\(usr\|var\|etc\|run\)/@${EPREFIX}&@g" \
417 -i "${GENTOO_PATCHDIR}"/conf/httpd.conf "${GENTOO_PATCHDIR}"/scripts/* \
418 "${GENTOO_PATCHDIR}"/docs/*.example "${GENTOO_PATCHDIR}"/patches/*.layout \
419 "${GENTOO_PATCHDIR}"/init/* "${GENTOO_PATCHDIR}"/conf/vhosts.d/* \
420 "${GENTOO_PATCHDIR}"/conf/modules.d/* || die
421
422 # 03_all_gentoo-apache-tools.patch injects -Wl,-z,now, which is not a good
423 # idea for everyone
424 case ${CHOST} in
425 *-linux-gnu|*-solaris*|*-freebsd*)
426 # do nothing, these use GNU binutils
427 :
428 ;;
429 *-darwin*)
430 sed -i -e 's/-Wl,-z,now/-Wl,-bind_at_load/g' \
431 "${GENTOO_PATCHDIR}"/patches/03_all_gentoo_apache-tools.patch
432 ;;
433 *)
434 # patch it out to be like upstream
435 sed -i -e 's/-Wl,-z,now//g' \
436 "${GENTOO_PATCHDIR}"/patches/03_all_gentoo_apache-tools.patch
437 ;;
438 esac
385 439
386 # Use correct multilib libdir in gentoo patches 440 # Use correct multilib libdir in gentoo patches
387 sed -i -e "s:/usr/lib:/usr/$(get_libdir):g" \ 441 sed -i -e "s:/usr/lib:/usr/$(get_libdir):g" \
388 "${GENTOO_PATCHDIR}"/{conf/httpd.conf,init/*,patches/config.layout} \ 442 "${GENTOO_PATCHDIR}"/{conf/httpd.conf,init/*,patches/config.layout} \
389 || die "libdir sed failed" 443 || die "libdir sed failed"
399 mv docs/man/{httpd,apache2}.8 453 mv docs/man/{httpd,apache2}.8
400 sed -i -e 's/httpd\.8/apache2.8/g' Makefile.in 454 sed -i -e 's/httpd\.8/apache2.8/g' Makefile.in
401 455
402 # patched-in MPMs need the build environment rebuilt 456 # patched-in MPMs need the build environment rebuilt
403 sed -i -e '/sinclude/d' configure.in 457 sed -i -e '/sinclude/d' configure.in
404 AT_GNUCONF_UPDATE=yes AT_M4DIR=build eautoreconf 458 AT_M4DIR=build eautoreconf
405}
406 459
460 # ${T} must be not group-writable, else grsec TPE will block it
461 chmod g-w "${T}"
462
463 # This package really should upgrade to using pcre's .pc file.
464 cat <<-\EOF >"${T}"/pcre-config
465 #!/bin/sh
466 [ "${flag}" = "--version" ] && set -- --modversion
467 exec ${PKG_CONFIG} libpcre "$@"
468 EOF
469 chmod a+x "${T}"/pcre-config
470}
471
407# @FUNCTION: apache-2_src_compile 472# @FUNCTION: apache-2_src_configure
408# @DESCRIPTION: 473# @DESCRIPTION:
409# This function adds compiler flags and runs econf and emake based on MY_MPM and 474# This function adds compiler flags and runs econf and emake based on MY_MPM and
410# MY_CONF 475# MY_CONF
411apache-2_src_compile() { 476apache-2_src_configure() {
477 tc-export PKG_CONFIG
478
479 # Sanity check in case people have bad mounts/TPE settings. #500928
480 if ! "${T}"/pcre-config --help >/dev/null ; then
481 eerror "Could not execute ${T}/pcre-config; do you have bad mount"
482 eerror "permissions in ${T} or have TPE turned on in your kernel?"
483 die "check your runtime settings #500928"
484 fi
485
412 # Instead of filtering --as-needed (bug #128505), append --no-as-needed 486 # Instead of filtering --as-needed (bug #128505), append --no-as-needed
413 # Thanks to Harald van Dijk 487 # Thanks to Harald van Dijk
414 append-ldflags -Wl,--no-as-needed 488 append-ldflags $(no-as-needed)
415 489
416 # peruser MPM debugging with -X is nearly impossible 490 # peruser MPM debugging with -X is nearly impossible
417 if has peruser ${IUSE_MPMS} && use apache2_mpms_peruser ; then 491 if has peruser ${IUSE_MPMS} && use apache2_mpms_peruser ; then
418 use debug && append-flags -DMPM_PERUSER_DEBUG 492 use debug && append-flags -DMPM_PERUSER_DEBUG
419 fi 493 fi
420 494
421 # econf overwrites the stuff from config.layout, so we have to put them into 495 # econf overwrites the stuff from config.layout, so we have to put them into
422 # our myconf line too 496 # our myconf line too
497 ac_cv_path_PKGCONFIG=${PKG_CONFIG} \
423 econf \ 498 econf \
424 --includedir=/usr/include/apache2 \ 499 --includedir="${EPREFIX}"/usr/include/apache2 \
425 --libexecdir=/usr/$(get_libdir)/apache2/modules \ 500 --libexecdir="${EPREFIX}"/usr/$(get_libdir)/apache2/modules \
426 --datadir=/var/www/localhost \ 501 --datadir="${EPREFIX}"/var/www/localhost \
427 --sysconfdir=/etc/apache2 \ 502 --sysconfdir="${EPREFIX}"/etc/apache2 \
428 --localstatedir=/var \ 503 --localstatedir="${EPREFIX}"/var \
429 --with-mpm=${MY_MPM} \ 504 --with-mpm=${MY_MPM} \
430 --with-perl=/usr/bin/perl \ 505 --with-apr="${SYSROOT}${EPREFIX}"/usr \
431 --with-apr=/usr \ 506 --with-apr-util="${SYSROOT}${EPREFIX}"/usr \
432 --with-apr-util=/usr \ 507 --with-pcre="${T}"/pcre-config \
433 --with-pcre=/usr \ 508 --with-z="${EPREFIX}"/usr \
434 --with-z=/usr \
435 --with-port=80 \ 509 --with-port=80 \
436 --with-program-name=apache2 \ 510 --with-program-name=apache2 \
437 --enable-layout=Gentoo \ 511 --enable-layout=Gentoo \
438 ${MY_CONF} || die "econf failed!" 512 "${MY_CONF[@]}"
439 513
440 sed -i -e 's:apache2\.conf:httpd.conf:' include/ap_config_auto.h 514 sed -i -e 's:apache2\.conf:httpd.conf:' include/ap_config_auto.h
441
442 emake || die "emake failed"
443} 515}
444 516
445# @FUNCTION: apache-2_src_install 517# @FUNCTION: apache-2_src_install
446# @DESCRIPTION: 518# @DESCRIPTION:
447# This function runs `emake install' and generates, installs and adapts the gentoo 519# This function runs `emake install' and generates, installs and adapts the gentoo
448# specific configuration files found in the tarball 520# specific configuration files found in the tarball
449apache-2_src_install() { 521apache-2_src_install() {
450 make DESTDIR="${D}" install || die "make install failed" 522 emake DESTDIR="${D}" MKINSTALLDIRS="mkdir -p" install
451 523
452 # install our configuration files 524 # install our configuration files
453 keepdir /etc/apache2/vhosts.d 525 keepdir /etc/apache2/vhosts.d
454 keepdir /etc/apache2/modules.d 526 keepdir /etc/apache2/modules.d
455 527
456 generate_load_module 528 generate_load_module
457 insinto /etc/apache2 529 insinto /etc/apache2
458 doins -r "${GENTOO_PATCHDIR}"/conf/* 530 doins -r "${GENTOO_PATCHDIR}"/conf/*
459 doins docs/conf/magic 531 use apache2_modules_mime_magic && doins docs/conf/magic
460 532
461 insinto /etc/logrotate.d 533 insinto /etc/logrotate.d
462 newins "${GENTOO_PATCHDIR}"/scripts/apache2-logrotate apache2 534 newins "${GENTOO_PATCHDIR}"/scripts/apache2-logrotate apache2
463 535
464 # generate a sane default APACHE2_OPTS 536 # generate a sane default APACHE2_OPTS
465 APACHE2_OPTS="-D DEFAULT_VHOST -D INFO -D LANGUAGE" 537 APACHE2_OPTS="-D DEFAULT_VHOST -D INFO"
466 use doc && APACHE2_OPTS="${APACHE2_OPTS} -D MANUAL" 538 use doc && APACHE2_OPTS="${APACHE2_OPTS} -D MANUAL"
467 use ssl && APACHE2_OPTS="${APACHE2_OPTS} -D SSL -D SSL_DEFAULT_VHOST" 539 use ssl && APACHE2_OPTS="${APACHE2_OPTS} -D SSL -D SSL_DEFAULT_VHOST"
468 use suexec && APACHE2_OPTS="${APACHE2_OPTS} -D SUEXEC" 540 use suexec && APACHE2_OPTS="${APACHE2_OPTS} -D SUEXEC"
541 if has negotiation ${APACHE2_MODULES} && use apache2_modules_negotiation; then
542 APACHE2_OPTS="${APACHE2_OPTS} -D LANGUAGE"
543 fi
469 544
470 sed -i -e "s:APACHE2_OPTS=\".*\":APACHE2_OPTS=\"${APACHE2_OPTS}\":" \ 545 sed -i -e "s:APACHE2_OPTS=\".*\":APACHE2_OPTS=\"${APACHE2_OPTS}\":" \
471 "${GENTOO_PATCHDIR}"/init/apache2.confd || die "sed failed" 546 "${GENTOO_PATCHDIR}"/init/apache2.confd || die "sed failed"
472 547
473 newconfd "${GENTOO_PATCHDIR}"/init/apache2.confd apache2 548 newconfd "${GENTOO_PATCHDIR}"/init/apache2.confd apache2
474 newinitd "${GENTOO_PATCHDIR}"/init/apache2.initd apache2 549 newinitd "${GENTOO_PATCHDIR}"/init/apache2.initd apache2
475 550
476 # link apache2ctl to the init script 551 # install apache2ctl wrapper for our init script if available
552 if test -e "${GENTOO_PATCHDIR}"/scripts/apache2ctl; then
553 exeinto /usr/sbin
554 doexe "${GENTOO_PATCHDIR}"/scripts/apache2ctl
555 else
477 dosym /etc/init.d/apache2 /usr/sbin/apache2ctl 556 dosym /etc/init.d/apache2 /usr/sbin/apache2ctl
557 fi
478 558
479 # provide legacy symlink for apxs, bug 177697 559 # provide legacy symlink for apxs, bug 177697
480 dosym /usr/sbin/apxs /usr/sbin/apxs2 560 dosym apxs /usr/sbin/apxs2
481
482 # install some thirdparty scripts
483 exeinto /usr/sbin
484 use ssl && doexe "${GENTOO_PATCHDIR}"/scripts/gentestcrt.sh
485 561
486 # install some documentation 562 # install some documentation
487 dodoc ABOUT_APACHE CHANGES LAYOUT README README.platforms VERSIONING 563 dodoc ABOUT_APACHE CHANGES LAYOUT README README.platforms VERSIONING
488 dodoc "${GENTOO_PATCHDIR}"/docs/* 564 dodoc "${GENTOO_PATCHDIR}"/docs/*
489 565
490 # drop in a convenient link to the manual 566 # drop in a convenient link to the manual
491 if use doc ; then 567 if use doc ; then
492 sed -i -e "s:VERSION:${PVR}:" "${D}/etc/apache2/modules.d/00_apache_manual.conf" 568 sed -i -e "s:VERSION:${PVR}:" "${ED}/etc/apache2/modules.d/00_apache_manual.conf"
569 docompress -x /usr/share/doc/${PF}/manual # 503640
493 else 570 else
494 rm -f "${D}/etc/apache2/modules.d/00_apache_manual.conf" 571 rm -f "${ED}/etc/apache2/modules.d/00_apache_manual.conf"
495 rm -Rf "${D}/usr/share/doc/${PF}/manual" 572 rm -Rf "${ED}/usr/share/doc/${PF}/manual"
496 fi 573 fi
497 574
498 # the default webroot gets stored in /usr/share/${PF}/webroot 575 # the default icons and error pages get stored in
499 ebegin "Installing default webroot to /usr/share/${PF}/webroot" 576 # /usr/share/apache2/{error,icons}
500 dodir /usr/share/${PF} 577 dodir /usr/share/apache2
501 mv -f "${D}/var/www/localhost" "${D}/usr/share/${PF}/webroot" 578 mv -f "${ED}/var/www/localhost/error" "${ED}/usr/share/apache2/error"
579 mv -f "${ED}/var/www/localhost/icons" "${ED}/usr/share/apache2/icons"
580 rm -rf "${ED}/var/www/localhost/"
502 eend $? 581 eend $?
503 582
504 # set some sane permissions for suexec 583 # set some sane permissions for suexec
505 if use suexec ; then 584 if use suexec ; then
506 fowners 0:apache /usr/sbin/suexec 585 fowners 0:${SUEXEC_CALLER:-apache} /usr/sbin/suexec
507 fperms 4710 /usr/sbin/suexec 586 fperms 4710 /usr/sbin/suexec
508 # provide legacy symlink for suexec, bug 177697 587 # provide legacy symlink for suexec, bug 177697
509 dosym /usr/sbin/suexec /usr/sbin/suexec2 588 dosym /usr/sbin/suexec /usr/sbin/suexec2
510 fi 589 fi
511 590
512 # empty dirs 591 # empty dirs
513 for i in /var/lib/dav /var/log/apache2 /var/cache/apache2 ; do 592 for i in /var/lib/dav /var/log/apache2 /var/cache/apache2 ; do
514 keepdir ${i} 593 keepdir ${i}
515 fowners apache:apache ${i} 594 fowners apache:apache ${i}
516 fperms 0755 ${i} 595 fperms 0750 ${i}
517 done 596 done
518
519 # we need /etc/apache2/ssl if USE=ssl
520 use ssl && keepdir /etc/apache2/ssl
521} 597}
522 598
523# @FUNCTION: apache-2_pkg_postinst 599# @FUNCTION: apache-2_pkg_postinst
524# @DESCRIPTION: 600# @DESCRIPTION:
525# This function creates test certificates if SSL is enabled and installs the 601# This function creates test certificates if SSL is enabled and installs the
526# default webroot to /var/www/localhost if it does not exist. We do this here 602# default index.html to /var/www/localhost if it does not exist. We do this here
527# because the default webroot is a copy of the files that exist elsewhere and we 603# because the default webroot is a copy of the files that exist elsewhere and we
528# don't want them to be managed/removed by portage when apache is upgraded. 604# don't want them to be managed/removed by portage when apache is upgraded.
529apache-2_pkg_postinst() { 605apache-2_pkg_postinst() {
530 einfo
531
532 if use ssl && [[ ! -e "${ROOT}/etc/apache2/ssl/server.crt" ]] ; then 606 if use ssl && [[ ! -e "${EROOT}/etc/ssl/apache2/server.pem" ]]; then
533 cd "${ROOT}"/etc/apache2/ssl 607 SSL_ORGANIZATION="${SSL_ORGANIZATION:-Apache HTTP Server}"
534 einfo "Generating self-signed test certificate in ${ROOT}etc/apache2/ssl ..." 608 install_cert /etc/ssl/apache2/server
535 yes "" 2>/dev/null | \ 609 ewarn
536 "${ROOT}"/usr/sbin/gentestcrt.sh >/dev/null 2>&1 || \ 610 ewarn "The location of SSL certificates has changed. If you are"
537 die "gentestcrt.sh failed" 611 ewarn "upgrading from ${CATEGORY}/${PN}-2.2.13 or earlier (or remerged"
538 einfo 612 ewarn "*any* apache version), you might want to move your old"
613 ewarn "certificates from /etc/apache2/ssl/ to /etc/ssl/apache2/ and"
614 ewarn "update your config files."
615 ewarn
539 fi 616 fi
540 617
541 if [[ -e "${ROOT}/var/www/localhost" ]] ; then 618 if [[ ! -e "${EROOT}/var/www/localhost" ]] ; then
542 elog "The default webroot has not been installed into"
543 elog "${ROOT}var/www/localhost because the directory already exists"
544 elog "and we do not want to overwrite any files you have put there."
545 elog
546 elog "If you would like to install the latest webroot, please run"
547 elog "emerge --config =${PF}"
548 elog
549 else
550 einfo "Installing default webroot to ${ROOT}var/www/localhost"
551 mkdir -p "${ROOT}"/var/www/localhost 619 mkdir -p "${EROOT}/var/www/localhost/htdocs"
552 cp -R "${ROOT}"/usr/share/${PF}/webroot/* "${ROOT}"/var/www/localhost/ 620 echo "<html><body><h1>It works!</h1></body></html>" > "${EROOT}/var/www/localhost/htdocs/index.html"
553 einfo
554 fi 621 fi
555}
556 622
557# @FUNCTION: apache-2_pkg_config 623 echo
558# @DESCRIPTION: 624 elog "Attention: cgi and cgid modules are now handled via APACHE2_MODULES flags"
559# This function installs -- and overwrites -- the default webroot to 625 elog "in make.conf. Make sure to enable those in order to compile them."
560# /var/www/localhost 626 elog "In general, you should use 'cgid' with threaded MPMs and 'cgi' otherwise."
561apache-2_pkg_config() { 627 echo
562 einfo "Installing default webroot to ${ROOT}var/www/localhost"
563 mkdir -p "${ROOT}"/var/www/localhost
564 cp -R "${ROOT}"/usr/share/${PF}/webroot/* "${ROOT}"/var/www/localhost/
565}
566 628
629}
630
567EXPORT_FUNCTIONS pkg_setup src_unpack src_compile src_install pkg_postinst pkg_config 631EXPORT_FUNCTIONS pkg_setup src_prepare src_configure src_install pkg_postinst

Legend:
Removed from v.1.11  
changed lines
  Added in v.1.41

  ViewVC Help
Powered by ViewVC 1.1.20