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

Contents of /eclass/apache-2.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.36 - (hide annotations) (download)
Thu May 22 13:58:46 2014 UTC (7 weeks, 1 day ago) by polynomial-c
Branch: MAIN
CVS Tags: HEAD
Changes since 1.35: +52 -28 lines
Eclass cleanup. Now requires >=EAPI-4 ebuilds. Fixed bugs #509922 and #503640

1 patrick 1.33 # Copyright 1999-2014 Gentoo Foundation
2 hollow 1.1 # Distributed under the terms of the GNU General Public License v2
3 polynomial-c 1.36 # $Header: /var/cvsroot/gentoo-x86/eclass/apache-2.eclass,v 1.35 2014/02/12 00:03:21 vapier Exp $
4 hollow 1.1
5 hollow 1.10 # @ECLASS: apache-2.eclass
6     # @MAINTAINER:
7     # apache-devs@gentoo.org
8 hollow 1.11 # @BLURB: Provides a common set of functions for apache-2.x ebuilds
9 hollow 1.1 # @DESCRIPTION:
10 hollow 1.11 # This eclass handles apache-2.x ebuild functions such as LoadModule generation
11     # and inter-module dependency checking.
12 hollow 1.1
13 polynomial-c 1.36 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 hollow 1.1
36     # ==============================================================================
37     # INTERNAL VARIABLES
38     # ==============================================================================
39    
40     # @ECLASS-VARIABLE: GENTOO_PATCHNAME
41     # @DESCRIPTION:
42 robbat2 1.14 # This internal variable contains the prefix for the patch tarball.
43 robbat2 1.15 # 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 robbat2 1.14 [[ -n "$GENTOO_PATCHNAME" ]] || GENTOO_PATCHNAME="gentoo-${PF}"
48 hollow 1.1
49     # @ECLASS-VARIABLE: GENTOO_PATCHDIR
50     # @DESCRIPTION:
51     # This internal variable contains the working directory where patches and config
52 robbat2 1.14 # files are located.
53     # Defaults to the patchset name appended to the working directory.
54     [[ -n "$GENTOO_PATCHDIR" ]] || GENTOO_PATCHDIR="${WORKDIR}/${GENTOO_PATCHNAME}"
55 hollow 1.1
56 hollow 1.9 # @VARIABLE: GENTOO_DEVELOPER
57 hollow 1.1 # @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 hollow 1.9 # @VARIABLE: GENTOO_PATCHSTAMP
62 hollow 1.1 # @DESCRIPTION:
63     # This variable needs to be set in the ebuild and contains the date the patch
64 hollow 1.7 # tarball was created at in YYYYMMDD format
65 hollow 1.1
66 robbat2 1.14 # @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 hollow 1.1 SRC_URI="mirror://apache/httpd/httpd-${PV}.tar.bz2
73 robbat2 1.14 http://dev.gentoo.org/~${GENTOO_DEVELOPER}/dist/apache/${GENTOO_PATCH_A}"
74 hollow 1.1
75 hollow 1.9 # @VARIABLE: IUSE_MPMS_FORK
76 hollow 1.1 # @DESCRIPTION:
77     # This variable needs to be set in the ebuild and contains a list of forking
78 hollow 1.11 # (i.e. non-threaded) MPMs
79 hollow 1.1
80 hollow 1.9 # @VARIABLE: IUSE_MPMS_THREAD
81 hollow 1.1 # @DESCRIPTION:
82     # This variable needs to be set in the ebuild and contains a list of threaded
83 hollow 1.11 # MPMs
84 hollow 1.1
85 hollow 1.9 # @VARIABLE: IUSE_MODULES
86 hollow 1.1 # @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 hollow 1.3 IUSE="${IUSE} debug doc ldap selinux ssl static suexec threads"
92 hollow 1.1
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 hollow 1.18 =dev-libs/apr-util-1*[ldap?]
104 hollow 1.1 dev-libs/libpcre
105 polynomial-c 1.36 apache2_modules_deflate? ( sys-libs/zlib )
106     apache2_modules_mime? ( app-misc/mime-types )
107 hollow 1.1 ldap? ( =net-nds/openldap-2* )
108     selinux? ( sec-policy/selinux-apache )
109 polynomial-c 1.36 ssl? ( >=dev-libs/openssl-0.9.8m )
110 hollow 1.1 !=www-servers/apache-1*"
111 polynomial-c 1.36 RDEPEND+=" ${DEPEND}"
112 hollow 1.1 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 hollow 1.7 # @DESCRIPTION:
122 hollow 1.1 # 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 zmedico 1.4 MY_MPM=""
130 hollow 1.1 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 polynomial-c 1.36 MY_MPM=${DEFAULT_MPM_THREADED}
148 hollow 1.1 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 hollow 1.9 # @VARIABLE: MODULE_CRITICAL
171 hollow 1.3 # @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 hollow 1.9 # @VARIABLE: MODULE_DEPENDS
201 hollow 1.1 # @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 hollow 1.7 if [[ "${m}" == "${dep%:*}" ]] ; then
216 hollow 1.1 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 hollow 1.8 # @DESCRIPTION:
231 hollow 1.1 # 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 hollow 1.8 # @DESCRIPTION:
236 hollow 1.1 # 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    
254     if use ldap ; then
255 polynomial-c 1.36 MY_CONF+=" --enable-authnz_ldap=${mod_type} --enable-ldap=${mod_type}"
256     MY_MODS+=" ldap authnz_ldap"
257 hollow 1.1 else
258 polynomial-c 1.36 MY_CONF+=" --disable-authnz_ldap --disable-ldap"
259 hollow 1.1 fi
260    
261     if use ssl ; then
262 polynomial-c 1.36 MY_CONF+=" --with-ssl=/usr --enable-ssl=${mod_type}"
263     MY_MODS+=" ssl"
264 hollow 1.1 else
265 polynomial-c 1.36 MY_CONF+=" --without-ssl --disable-ssl"
266 hollow 1.1 fi
267    
268     if use suexec ; then
269     elog "You can manipulate several configure options of suexec"
270     elog "through the following environment variables:"
271     elog
272     elog " SUEXEC_SAFEPATH: Default PATH for suexec (default: /usr/local/bin:/usr/bin:/bin)"
273     elog " SUEXEC_LOGFILE: Path to the suexec logfile (default: /var/log/apache2/suexec_log)"
274     elog " SUEXEC_CALLER: Name of the user Apache is running as (default: apache)"
275     elog " SUEXEC_DOCROOT: Directory in which suexec will run scripts (default: /var/www)"
276     elog " SUEXEC_MINUID: Minimum UID, which is allowed to run scripts via suexec (default: 1000)"
277     elog " SUEXEC_MINGID: Minimum GID, which is allowed to run scripts via suexec (default: 100)"
278     elog " SUEXEC_USERDIR: User subdirectories (like /home/user/html) (default: public_html)"
279     elog " SUEXEC_UMASK: Umask for the suexec process (default: 077)"
280     elog
281    
282 polynomial-c 1.36 MY_CONF+=" --with-suexec-safepath=${SUEXEC_SAFEPATH:-/usr/local/bin:/usr/bin:/bin}"
283     MY_CONF+=" --with-suexec-logfile=${SUEXEC_LOGFILE:-/var/log/apache2/suexec_log}"
284     MY_CONF+=" --with-suexec-bin=/usr/sbin/suexec"
285     MY_CONF+=" --with-suexec-userdir=${SUEXEC_USERDIR:-public_html}"
286     MY_CONF+=" --with-suexec-caller=${SUEXEC_CALLER:-apache}"
287     MY_CONF+=" --with-suexec-docroot=${SUEXEC_DOCROOT:-/var/www}"
288     MY_CONF+=" --with-suexec-uidmin=${SUEXEC_MINUID:-1000}"
289     MY_CONF+=" --with-suexec-gidmin=${SUEXEC_MINGID:-100}"
290     MY_CONF+=" --with-suexec-umask=${SUEXEC_UMASK:-077}"
291     MY_CONF+=" --enable-suexec=${mod_type}"
292     MY_MODS+=" suexec"
293 hollow 1.1 else
294 polynomial-c 1.36 MY_CONF+=" --disable-suexec"
295 hollow 1.1 fi
296    
297     for x in ${IUSE_MODULES} ; do
298     if use apache2_modules_${x} ; then
299 polynomial-c 1.36 MY_CONF+=" --enable-${x}=${mod_type}"
300     MY_MODS+=" ${x}"
301 hollow 1.1 else
302 polynomial-c 1.36 MY_CONF+=" --disable-${x}"
303 hollow 1.1 fi
304     done
305    
306     # sort and uniquify MY_MODS
307     MY_MODS=$(echo ${MY_MODS} | tr ' ' '\n' | sort -u)
308     check_module_depends
309 hollow 1.3 check_module_critical
310 hollow 1.1 }
311    
312 hollow 1.9 # @VARIABLE: MODULE_DEFINES
313 hollow 1.1 # @DESCRIPTION:
314     # This variable needs to be set in the ebuild and contains a space-separated
315     # list of tokens each mapping a module to a runtime define which can be
316     # specified in APACHE2_OPTS in /etc/conf.d/apache2 to enable this particular
317     # module.
318    
319     # @FUNCTION: generate_load_module
320     # @DESCRIPTION:
321     # This internal function generates the LoadModule lines for httpd.conf based on
322     # the current module selection and MODULE_DEFINES
323     generate_load_module() {
324 hollow 1.8 local endit=0 mod_lines= mod_dir="${D}/usr/$(get_libdir)/apache2/modules"
325 hollow 1.1
326     if use static; then
327     sed -i -e "/%%LOAD_MODULE%%/d" \
328     "${GENTOO_PATCHDIR}"/conf/httpd.conf
329     return
330     fi
331    
332     for m in ${MY_MODS} ; do
333     if [[ -e "${mod_dir}/mod_${m}.so" ]] ; then
334     for def in ${MODULE_DEFINES} ; do
335     if [[ "${m}" == "${def%:*}" ]] ; then
336     mod_lines="${mod_lines}\n<IfDefine ${def#*:}>"
337     endit=1
338     fi
339     done
340    
341     mod_lines="${mod_lines}\nLoadModule ${m}_module modules/mod_${m}.so"
342    
343     if [[ ${endit} -ne 0 ]] ; then
344     mod_lines="${mod_lines}\n</IfDefine>"
345     endit=0
346     fi
347     fi
348     done
349    
350     sed -i -e "s:%%LOAD_MODULE%%:${mod_lines}:" \
351     "${GENTOO_PATCHDIR}"/conf/httpd.conf
352     }
353    
354     # @FUNCTION: check_upgrade
355     # @DESCRIPTION:
356     # This internal function checks if the previous configuration file for built-in
357     # modules exists in ROOT and prevents upgrade in this case. Users are supposed
358     # to convert this file to the new APACHE2_MODULES USE_EXPAND variable and remove
359     # it afterwards.
360     check_upgrade() {
361     if [[ -e "${ROOT}"etc/apache2/apache2-builtin-mods ]]; then
362     eerror "The previous configuration file for built-in modules"
363     eerror "(${ROOT}etc/apache2/apache2-builtin-mods) exists on your"
364     eerror "system."
365     eerror
366 hollow 1.2 eerror "Please read http://www.gentoo.org/doc/en/apache-upgrading.xml"
367 hollow 1.1 eerror "for detailed information how to convert this file to the new"
368     eerror "APACHE2_MODULES USE_EXPAND variable."
369     eerror
370     die "upgrade not possible with existing ${ROOT}etc/apache2/apache2-builtin-mods"
371     fi
372     }
373    
374     # ==============================================================================
375     # EXPORTED FUNCTIONS
376     # ==============================================================================
377    
378     # @FUNCTION: apache-2_pkg_setup
379     # @DESCRIPTION:
380     # This function selects built-in modules, the MPM and other configure options,
381     # creates the apache user and group and informs about CONFIG_SYSVIPC being
382     # needed (we don't depend on kernel sources and therefore cannot check).
383     apache-2_pkg_setup() {
384     check_upgrade
385    
386 hollow 1.11 # setup apache user and group
387     enewgroup apache 81
388     enewuser apache 81 -1 /var/www apache
389    
390 hollow 1.1 setup_mpm
391     setup_modules
392    
393     if use debug; then
394 polynomial-c 1.36 MY_CONF+=" --enable-maintainer-mode --enable-exception-hook"
395 hollow 1.1 fi
396    
397     elog "Please note that you need SysV IPC support in your kernel."
398     elog "Make sure CONFIG_SYSVIPC=y is set."
399     elog
400 hollow 1.12
401     if use userland_BSD; then
402     elog "On BSD systems you need to add the following line to /boot/loader.conf:"
403     elog " accf_http_load=\"YES\""
404     elog
405     fi
406 hollow 1.1 }
407    
408 hollow 1.18 # @FUNCTION: apache-2_src_prepare
409 hollow 1.1 # @DESCRIPTION:
410     # This function applies patches, configures a custom file-system layout and
411 hollow 1.3 # rebuilds the configure scripts.
412 hollow 1.18 apache-2_src_prepare() {
413 grobian 1.16 # 03_all_gentoo-apache-tools.patch injects -Wl,-z,now, which is not a good
414     # idea for everyone
415     case ${CHOST} in
416     *-linux-gnu|*-solaris*|*-freebsd*)
417     # do nothing, these use GNU binutils
418     :
419     ;;
420     *-darwin*)
421     sed -i -e 's/-Wl,-z,now/-Wl,-bind_at_load/g' \
422     "${GENTOO_PATCHDIR}"/patches/03_all_gentoo_apache-tools.patch
423     ;;
424     *)
425     # patch it out to be like upstream
426     sed -i -e 's/-Wl,-z,now//g' \
427     "${GENTOO_PATCHDIR}"/patches/03_all_gentoo_apache-tools.patch
428     ;;
429     esac
430    
431 hollow 1.1 # Use correct multilib libdir in gentoo patches
432     sed -i -e "s:/usr/lib:/usr/$(get_libdir):g" \
433     "${GENTOO_PATCHDIR}"/{conf/httpd.conf,init/*,patches/config.layout} \
434     || die "libdir sed failed"
435    
436     epatch "${GENTOO_PATCHDIR}"/patches/*.patch
437    
438     # setup the filesystem layout config
439     cat "${GENTOO_PATCHDIR}"/patches/config.layout >> "${S}"/config.layout || \
440     die "Failed preparing config.layout!"
441     sed -i -e "s:version:${PF}:g" "${S}"/config.layout
442    
443 hollow 1.3 # apache2.8 instead of httpd.8 (bug #194828)
444     mv docs/man/{httpd,apache2}.8
445     sed -i -e 's/httpd\.8/apache2.8/g' Makefile.in
446    
447 hollow 1.1 # patched-in MPMs need the build environment rebuilt
448     sed -i -e '/sinclude/d' configure.in
449 vapier 1.22 AT_M4DIR=build eautoreconf
450 vapier 1.34
451     # This package really should upgrade to using pcre's .pc file.
452     cat <<-\EOF >"${T}"/pcre-config
453     #!/bin/sh
454     [ "${flag}" = "--version" ] && set -- --modversion
455     exec ${PKG_CONFIG} libpcre "$@"
456     EOF
457     chmod a+x "${T}"/pcre-config
458 hollow 1.1 }
459    
460 hollow 1.18 # @FUNCTION: apache-2_src_configure
461 hollow 1.1 # @DESCRIPTION:
462     # This function adds compiler flags and runs econf and emake based on MY_MPM and
463     # MY_CONF
464 hollow 1.18 apache-2_src_configure() {
465 vapier 1.34 tc-export PKG_CONFIG
466    
467 vapier 1.35 # Sanity check in case people have bad mounts/TPE settings. #500928
468     if ! "${T}"/pcre-config --help >/dev/null ; then
469     eerror "Could not execute ${T}/pcre-config; do you have bad mount"
470     eerror "permissions in ${T} or have TPE turned on in your kernel?"
471     die "check your runtime settings #500928"
472     fi
473    
474 hollow 1.1 # Instead of filtering --as-needed (bug #128505), append --no-as-needed
475     # Thanks to Harald van Dijk
476 ssuominen 1.19 append-ldflags $(no-as-needed)
477 hollow 1.1
478     # peruser MPM debugging with -X is nearly impossible
479     if has peruser ${IUSE_MPMS} && use apache2_mpms_peruser ; then
480     use debug && append-flags -DMPM_PERUSER_DEBUG
481     fi
482    
483     # econf overwrites the stuff from config.layout, so we have to put them into
484     # our myconf line too
485 vapier 1.34 ac_cv_path_PKGCONFIG=${PKG_CONFIG} \
486 hollow 1.1 econf \
487     --includedir=/usr/include/apache2 \
488     --libexecdir=/usr/$(get_libdir)/apache2/modules \
489     --datadir=/var/www/localhost \
490     --sysconfdir=/etc/apache2 \
491     --localstatedir=/var \
492     --with-mpm=${MY_MPM} \
493 vapier 1.34 --with-apr="${SYSROOT}"/usr \
494     --with-apr-util="${SYSROOT}"/usr \
495     --with-pcre="${T}"/pcre-config \
496 hollow 1.1 --with-z=/usr \
497     --with-port=80 \
498     --with-program-name=apache2 \
499     --enable-layout=Gentoo \
500     ${MY_CONF} || die "econf failed!"
501    
502     sed -i -e 's:apache2\.conf:httpd.conf:' include/ap_config_auto.h
503     }
504    
505     # @FUNCTION: apache-2_src_install
506     # @DESCRIPTION:
507 hollow 1.11 # This function runs `emake install' and generates, installs and adapts the gentoo
508 hollow 1.1 # specific configuration files found in the tarball
509     apache-2_src_install() {
510 flameeyes 1.29 emake DESTDIR="${D}" MKINSTALLDIRS="mkdir -p" install || die "make install failed"
511 hollow 1.1
512     # install our configuration files
513     keepdir /etc/apache2/vhosts.d
514     keepdir /etc/apache2/modules.d
515    
516     generate_load_module
517     insinto /etc/apache2
518     doins -r "${GENTOO_PATCHDIR}"/conf/*
519 hollow 1.20 use apache2_modules_mime_magic && doins docs/conf/magic
520 hollow 1.1
521     insinto /etc/logrotate.d
522     newins "${GENTOO_PATCHDIR}"/scripts/apache2-logrotate apache2
523    
524     # generate a sane default APACHE2_OPTS
525 hollow 1.18 APACHE2_OPTS="-D DEFAULT_VHOST -D INFO"
526 hollow 1.1 use doc && APACHE2_OPTS="${APACHE2_OPTS} -D MANUAL"
527     use ssl && APACHE2_OPTS="${APACHE2_OPTS} -D SSL -D SSL_DEFAULT_VHOST"
528     use suexec && APACHE2_OPTS="${APACHE2_OPTS} -D SUEXEC"
529 ssuominen 1.25 if has negotiation ${APACHE2_MODULES} && use apache2_modules_negotiation; then
530 hollow 1.18 APACHE2_OPTS="${APACHE2_OPTS} -D LANGUAGE"
531     fi
532 hollow 1.1
533     sed -i -e "s:APACHE2_OPTS=\".*\":APACHE2_OPTS=\"${APACHE2_OPTS}\":" \
534     "${GENTOO_PATCHDIR}"/init/apache2.confd || die "sed failed"
535    
536     newconfd "${GENTOO_PATCHDIR}"/init/apache2.confd apache2
537     newinitd "${GENTOO_PATCHDIR}"/init/apache2.initd apache2
538    
539 hollow 1.13 # install apache2ctl wrapper for our init script if available
540     if test -e "${GENTOO_PATCHDIR}"/scripts/apache2ctl; then
541     exeinto /usr/sbin
542     doexe "${GENTOO_PATCHDIR}"/scripts/apache2ctl
543     else
544     dosym /etc/init.d/apache2 /usr/sbin/apache2ctl
545     fi
546 hollow 1.1
547 hollow 1.6 # provide legacy symlink for apxs, bug 177697
548 polynomial-c 1.36 dosym apxs /usr/sbin/apxs2
549 hollow 1.1
550     # install some documentation
551     dodoc ABOUT_APACHE CHANGES LAYOUT README README.platforms VERSIONING
552     dodoc "${GENTOO_PATCHDIR}"/docs/*
553    
554     # drop in a convenient link to the manual
555     if use doc ; then
556     sed -i -e "s:VERSION:${PVR}:" "${D}/etc/apache2/modules.d/00_apache_manual.conf"
557 polynomial-c 1.36 docompress -x /usr/share/doc/${PF}/manual # 503640
558 hollow 1.1 else
559     rm -f "${D}/etc/apache2/modules.d/00_apache_manual.conf"
560     rm -Rf "${D}/usr/share/doc/${PF}/manual"
561     fi
562    
563 hollow 1.18 # the default icons and error pages get stored in
564     # /usr/share/apache2/{error,icons}
565     dodir /usr/share/apache2
566     mv -f "${D}/var/www/localhost/error" "${D}/usr/share/apache2/error"
567     mv -f "${D}/var/www/localhost/icons" "${D}/usr/share/apache2/icons"
568     rm -rf "${D}/var/www/localhost/"
569 hollow 1.1 eend $?
570    
571     # set some sane permissions for suexec
572     if use suexec ; then
573 hollow 1.17 fowners 0:${SUEXEC_CALLER:-apache} /usr/sbin/suexec
574 hollow 1.1 fperms 4710 /usr/sbin/suexec
575 hollow 1.6 # provide legacy symlink for suexec, bug 177697
576     dosym /usr/sbin/suexec /usr/sbin/suexec2
577 hollow 1.1 fi
578    
579     # empty dirs
580     for i in /var/lib/dav /var/log/apache2 /var/cache/apache2 ; do
581     keepdir ${i}
582     fowners apache:apache ${i}
583 patrick 1.28 fperms 0750 ${i}
584 hollow 1.1 done
585     }
586    
587     # @FUNCTION: apache-2_pkg_postinst
588     # @DESCRIPTION:
589     # This function creates test certificates if SSL is enabled and installs the
590 hollow 1.18 # default index.html to /var/www/localhost if it does not exist. We do this here
591 hollow 1.11 # because the default webroot is a copy of the files that exist elsewhere and we
592     # don't want them to be managed/removed by portage when apache is upgraded.
593 hollow 1.1 apache-2_pkg_postinst() {
594 hollow 1.18 if use ssl && [[ ! -e "${ROOT}/etc/ssl/apache2/server.pem" ]]; then
595     SSL_ORGANIZATION="${SSL_ORGANIZATION:-Apache HTTP Server}"
596     install_cert /etc/ssl/apache2/server
597     ewarn
598     ewarn "The location of SSL certificates has changed. If you are"
599     ewarn "upgrading from ${CATEGORY}/${PN}-2.2.13 or earlier (or remerged"
600     ewarn "*any* apache version), you might want to move your old"
601     ewarn "certificates from /etc/apache2/ssl/ to /etc/ssl/apache2/ and"
602     ewarn "update your config files."
603     ewarn
604 hollow 1.1 fi
605    
606 hollow 1.18 if [[ ! -e "${ROOT}/var/www/localhost" ]] ; then
607     mkdir -p "${ROOT}/var/www/localhost/htdocs"
608     echo "<html><body><h1>It works!</h1></body></html>" > "${ROOT}/var/www/localhost/htdocs/index.html"
609 hollow 1.1 fi
610 lxnay 1.21
611     echo
612     elog "Attention: cgi and cgid modules are now handled via APACHE2_MODULES flags"
613 zmedico 1.31 elog "in make.conf. Make sure to enable those in order to compile them."
614 hollow 1.24 elog "In general, you should use 'cgid' with threaded MPMs and 'cgi' otherwise."
615 lxnay 1.21 echo
616    
617 hollow 1.1 }
618    
619 hollow 1.18 EXPORT_FUNCTIONS pkg_setup src_prepare src_configure src_install pkg_postinst

  ViewVC Help
Powered by ViewVC 1.1.20