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