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

Contents of /eclass/apache-2.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.14 - (hide annotations) (download)
Wed Dec 10 01:06:12 2008 UTC (6 years ago) by robbat2
Branch: MAIN
Changes since 1.13: +14 -6 lines
Allow overriding of $GENTOO_PATCHNAME and $GENTOO_PATCHDIR for easier testing in overlays with other revision numbers. Use GENTOO_PATCHNAME="gentoo-${PV}${ORIG_PR:+-${ORIG_PR}}" in the ebuild.

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

  ViewVC Help
Powered by ViewVC 1.1.20