1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
|
# Copyright 1999-2007 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/net-www/apache/apache-2.2.4.ebuild,v 1.4 2007/05/07 18:47:34 kloeri Exp $
inherit eutils flag-o-matic gnuconfig multilib autotools
# latest gentoo apache files
GENTOO_PATCHNAME="gentoo-apache-${PV}"
GENTOO_PATCHSTAMP="20070121"
GENTOO_DEVSPACE="phreak"
GENTOO_PATCHDIR="${WORKDIR}/${GENTOO_PATCHNAME}"
DESCRIPTION="The Apache Web Server."
HOMEPAGE="http://httpd.apache.org/"
SRC_URI="mirror://apache/httpd/httpd-${PV}.tar.bz2
http://dev.gentoo.org/~${GENTOO_DEVSPACE}/dist/apache/${GENTOO_PATCHNAME}-${GENTOO_PATCHSTAMP}.tar.bz2"
# some helper scripts are apache-1.1, thus both are here
LICENSE="Apache-2.0 Apache-1.1"
SLOT="2"
KEYWORDS="~alpha ~amd64 ~arm ~hppa ~ia64 ~mips ~ppc ~ppc64 ~s390 ~sh ~sparc ~x86 ~x86-fbsd"
IUSE="debug doc ldap mpm-event mpm-peruser mpm-prefork mpm-worker no-suexec selinux ssl static-modules threads"
DEPEND="dev-lang/perl
=dev-libs/apr-1*
=dev-libs/apr-util-1*
dev-libs/expat
dev-libs/libpcre
sys-libs/zlib
ldap? ( =net-nds/openldap-2* )
selinux? ( sec-policy/selinux-apache )
ssl? ( dev-libs/openssl )
!=net-www/apache-1*"
RDEPEND="${DEPEND}
app-misc/mime-types"
PDEPEND="~app-admin/apache-tools-${PV}"
S="${WORKDIR}/httpd-${PV}"
pkg_setup() {
if use ldap && ! built_with_use 'dev-libs/apr-util' ldap ; then
eerror "dev-libs/apr-util is missing LDAP support. For apache to have"
eerror "ldap support, apr-util must be built with the ldap USE-flag"
eerror "enabled."
die "ldap USE-flag enabled while not supported in apr-util"
fi
# select our MPM
MPM_LIST="event peruser prefork worker"
for x in ${MPM_LIST} ; do
if use mpm-${x} ; then
if [[ "x${mpm}" == "x" ]] ; then
mpm=${x}
einfo "Selected MPM: ${mpm}"
else
eerror "You have selected more then one mpm USE-flag."
eerror "Only one MPM is supported."
die "more then one mpm was specified"
fi
fi
done
if [[ "x${mpm}" == "x" ]] ; then
if use threads ; then
mpm=worker
einfo "Selected default threaded MPM: ${mpm}";
else
mpm=prefork
einfo "Selected default MPM: ${mpm}";
fi
fi
# setup apache user and group
enewgroup apache 81
enewuser apache 81 -1 /var/www apache
}
src_unpack() {
unpack ${A}
cd "${S}"
# Use correct multilib libdir in gentoo patches
sed -i -e "s:/usr/lib:/usr/$(get_libdir):g" \
"${GENTOO_PATCHDIR}"/{conf/httpd.conf,init/*,patches/config.layout,scripts/Makefile.suexec,scripts/suexec2-config} \
|| die "libdir sed failed"
#### Patch Organization
# 00-19 Gentoo specific (00_all_some-title.patch)
# 20-39 Additional MPMs (20_all_${MPM}_some-title.patch)
# 40-59 USE-flag based (40_all_${USE}_some-title.patch)
# 60-79 Version specific (60_all_${PV}_some-title.patch)
# 80-99 Security patches (80_all_${PV}_cve-####-####.patch)
EPATCH_SUFFIX="patch"
epatch "${GENTOO_PATCHDIR}"/patches/[0-1]*
if $(ls "${GENTOO_PATCHDIR}"/patches/[2-3]?_*_${mpm}_* &>/dev/null) ; then
epatch "${GENTOO_PATCHDIR}"/patches/[2-3]?_*_${mpm}_*
fi
for uf in ${IUSE} ; do
if use ${uf} && $(ls "${GENTOO_PATCHDIR}"/patches/[4-5]?_*_${uf}_* &>/dev/null) ; then
epatch "${GENTOO_PATCHDIR}"/patches/[4-5]?_*_${uf}_*
fi
done
if $(ls "${GENTOO_PATCHDIR}"/patches/[6-9]?_*_${PV}_* &>/dev/null) ; then
epatch "${GENTOO_PATCHDIR}"/patches/[6-9]?_*_${PV}_*
fi
# setup the filesystem layout config
cat "${GENTOO_PATCHDIR}"/patches/config.layout >> "${S}"/config.layout
sed -i -e "s:version:${PF}:g" "${S}"/config.layout
# patched-in MPMs need the build environment rebuilt
sed -i -e '/sinclude/d' configure.in
AT_GNUCONF_UPDATE=yes AT_M4DIR=build eautoreconf
}
src_compile() {
local modtype="shared" myconf=""
cd "${S}"
# Instead of filtering --as-needed (bug #128505), append --no-as-needed
# Thanks to Harald van Dijk
append-ldflags -Wl,--no-as-needed
use static-modules && modtype="static"
select_modules_config || die "determining modules failed"
if use ldap ; then
mods="${mods} ldap authnz_ldap"
myconf="${myconf} --enable-authnz-ldap=${modtype} --enable-ldap=${modtype}"
fi
if use ssl; then
mods="${mods} ssl"
myconf="${myconf} --with-ssl=/usr --enable-ssl=${modtype}"
fi
# Fix for bug #24215 - robbat2@gentoo.org, 30 Oct 2003
# We pre-load the cache with the correct answer! This avoids
# it violating the sandbox. This may have to be changed for
# non-Linux systems or if sem_open changes on Linux. This
# hack is built around documentation in /usr/include/semaphore.h
# and the glibc (pthread) source.
echo 'ac_cv_func_sem_open=${ac_cv_func_sem_open=no}' >> config.cache
if use no-suexec ; then
myconf="${myconf} --disable-suexec"
else
mods="${mods} suexec"
myconf="${myconf} $(${GENTOO_PATCHDIR}/scripts/suexec2-config --config)"
myconf="${myconf} \
--with-suexec-bin=/usr/sbin/suexec2 \
--enable-suexec=${modtype}"
fi
# econf overwrites the stuff from config.layout, so we have to put them into
# our myconf line too
econf \
--includedir=/usr/include/apache2 \
--libexecdir=/usr/$(get_libdir)/apache2/modules \
--datadir=/var/www/localhost \
--sysconfdir=/etc/apache2 \
--localstatedir=/var \
--cache-file="${S}/config.cache" \
--with-mpm=${mpm} \
--with-perl=/usr/bin/perl \
--with-expat=/usr \
--with-z=/usr \
--with-apr=/usr \
--with-apr-util=/usr \
--with-pcre=/usr \
--with-port=80 \
--with-program-name=apache2 \
--enable-layout=Gentoo \
$( use_enable debug maintainer-mode ) \
${myconf} ${MY_BUILTINS} || die "econf failed!"
sed -i -e 's:apache2\.conf:httpd.conf:' include/ap_config_auto.h
emake || die "emake failed"
}
src_install () {
emake DESTDIR="${D}" install || die "emake install failed"
# Remove some of the default files installed by `make install'
# and those binaries/manpages, that belong to app-admin/apache-tools now
rm -Rf "${D}"/etc \
"${D}"/usr/sbin/{envvars*,apachectl} \
"${D}"/usr/sbin/{htdigest,htpasswd,ab,htdbm} \
"${D}"/usr/share/man/man1/{htdigest,htpasswd,htdbm}.1* \
"${D}"/usr/share/man/man8/ab.8*
# This is a mapping of module names to the -D options in APACHE2_OPTS
# Used for creating optional LoadModule lines
mod_defines="info:INFO status:INFO
ldap:LDAP authnz_ldap:AUTH_LDAP
proxy:PROXY proxy_connect:PROXY proxy_http:PROXY
proxy_ajp:PROXY proxy_balancer:PROXY
ssl:SSL
suexec:SUEXEC
userdir:USERDIR"
# create our LoadModule lines
if ! use static-modules ; then
load_module=""
moddir="${D}/usr/$(get_libdir)/apache2/modules"
for m in ${mods} ; do
endid="no"
if [[ -e "${moddir}/mod_${m}.so" ]] ; then
for def in ${mod_defines} ; do
if [[ "${m}" == "${def%:*}" ]] ; then
load_module="${load_module}\n<IfDefine ${def#*:}>"
endid="yes"
fi
done
load_module="${load_module}\nLoadModule ${m}_module modules/mod_${m}.so"
if [[ "${endid}" == "yes" ]] ; then
load_module="${load_module}\n</IfDefine>"
fi
fi
done
fi
sed -i -e "s:%%LOAD_MODULE%%:${load_module}:" \
"${GENTOO_PATCHDIR}"/conf/httpd.conf || die "sed failed"
# Install our configuration files
insinto /etc/apache2
doins docs/conf/magic
doins -r "${GENTOO_PATCHDIR}"/conf/*
insinto /etc/logrotate.d
newins "${GENTOO_PATCHDIR}"/scripts/apache2-logrotate apache2
# generate a sane default APACHE2_OPTS
APACHE2_OPTS="-D DEFAULT_VHOST -D INFO -D LANGUAGE"
use doc && APACHE2_OPTS="${APACHE2_OPTS} -D MANUAL"
use ssl && APACHE2_OPTS="${APACHE2_OPTS} -D SSL -D SSL_DEFAULT_VHOST"
use no-suexec || APACHE2_OPTS="${APACHE2_OPTS} -D SUEXEC"
sed -i -e "s:APACHE2_OPTS=\".*\":APACHE2_OPTS=\"${APACHE2_OPTS}\":" \
"${GENTOO_PATCHDIR}"/init/apache2.confd || die "sed failed"
newconfd "${GENTOO_PATCHDIR}"/init/apache2.confd apache2
newinitd "${GENTOO_PATCHDIR}"/init/apache2.initd apache2
# link apache2ctl to the init script
dosym /etc/init.d/apache2 /usr/sbin/apache2ctl
# Install some thirdparty scripts
exeinto /usr/sbin
for i in apache2logserverstatus apache2splitlogfile suexec2-config ; do
doexe "${GENTOO_PATCHDIR}"/scripts/${i}
done
use ssl && doexe "${GENTOO_PATCHDIR}"/scripts/gentestcrt.sh
for i in logresolve.pl split-logfile log_server_status ; do
doexe support/${i}
done
# needed for suexec2-config
insinto /usr/$(get_libdir)/apache2/build
doins "${GENTOO_PATCHDIR}"/scripts/Makefile.suexec
doins support/suexec.c
# we don't use apachectl anymore, it's symlinked to the init script now
rm -f usr/share/man/man8/apachectl.8
# Install some documentation
dodoc ABOUT_APACHE CHANGES LAYOUT README README.platforms VERSIONING
# drop in a convenient link to the manual
if use doc ; then
sed -i -e "s:VERSION:${PVR}:" "${D}/etc/apache2/modules.d/00_apache_manual.conf"
else
rm -f "${D}/etc/apache2/modules.d/00_apache_manual.conf"
rm -Rf "${D}/usr/share/doc/${PF}/manual"
fi
# the default webroot gets stored in /usr/share/doc
ebegin "Installing default webroot to /usr/share/doc/${PF}"
mv -f "${D}/var/www/localhost" "${D}/usr/share/doc/${PF}/webroot"
eend $?
# Set up some sane permissions
if ! use no-suexec ; then
fowners 0:apache /usr/sbin/suexec
fperms 4710 /usr/sbin/suexec
fi
keepdir /etc/apache2/vhosts.d
keepdir /etc/apache2/modules.d
# empty dirs
for i in /var/lib/dav /var/log/apache2 /var/cache/apache2 ; do
keepdir ${i}
fowners apache:apache ${i}
fperms 0755 ${i}
done
# We'll be needing /etc/apache2/ssl if USE=ssl
use ssl && keepdir /etc/apache2/ssl
fperms 0755 /usr/sbin/apache2logserverstatus
fperms 0755 /usr/sbin/apache2splitlogfile
}
pkg_postinst() {
# Automatically generate test certificates if ssl USE flag is being set
if use ssl && [[ ! -e "${ROOT}/etc/apache2/ssl/server.crt" ]] ; then
cd "${ROOT}"/etc/apache2/ssl
einfo
einfo "Generating self-signed test certificate in ${ROOT}/etc/apache2/ssl ..."
yes "" 2>/dev/null | \
"${ROOT}"/usr/sbin/gentestcrt.sh >/dev/null 2>&1 || \
die "gentestcrt.sh failed"
einfo
fi
# we do this here because the default webroot is a copy of the files
# that exist elsewhere and we don't want them managed/removed by portage
# when apache is upgraded.
if [[ -e "${ROOT}/var/www/localhost" ]] ; then
elog "The default webroot has not been installed into"
elog "${ROOT}/var/www/localhost because the directory already exists"
elog "and we do not want to overwrite any files you have put there."
elog
elog "If you would like to install the latest webroot, please run"
elog "emerge --config =${PF}"
else
einfo "Installing default webroot to ${ROOT}/var/www/localhost"
mkdir -p "${ROOT}"/var/www/localhost
cp -R "${ROOT}"/usr/share/doc/${PF}/webroot/* "${ROOT}"/var/www/localhost
chown -R apache:0 "${ROOT}"/var/www/localhost
fi
# Check for dual/upgrade install
# The hasq is a hack so we don't throw QA warnings for not putting
# apache2 in IUSE - the only use of the flag is this warning
if has_version '<net-www/apache-2.2.0' ; then
elog
elog "When upgrading from versions below 2.2.0 to this version, you"
elog "need to rebuild all your modules. Please do so for your modules"
elog "to continue working correctly."
elog
elog "Also note that some configuration directives have been"
elog "split into their own files under ${ROOT}/etc/apache2/modules.d"
elog
elog "For more information on what you may need to change, please"
elog "see the overview of changes at:"
elog "http://httpd.apache.org/docs/2.2/new_features_2_2.html"
elog
elog "Some modules do not yet work with Apache 2.2."
elog "To keep from accidentally downgrading to Apache 2.0, you should"
elog "add the following to ${ROOT}/etc/portage/package.mask:"
elog
elog " <net-www/apache-2.2.0"
elog
fi
}
pkg_config() {
einfo "Installing default webroot to ${ROOT}/var/www/localhost"
mkdir -p "${ROOT}"/var/www/localhost
cp -R "${ROOT}"/usr/share/doc/${PF}/webroot/* "${ROOT}"/var/www/localhost
chown -R apache:0 "${ROOT}"/var/www/localhost
}
parse_modules_config() {
local name=""
local disable=""
local version="undef"
MY_BUILTINS=""
mods=""
[[ -f "${1}" ]] || return 1
for i in $(sed 's/#.*//' < $1) ; do
if [[ "$i" == "VERSION:" ]] ; then
version="select"
elif [[ "${version}" == "select" ]] ; then
version="$i"
# start with - option for backwards compatibility only
elif [[ "$i" == "-" ]] ; then
disable="true"
elif [[ -z "${name}" ]] && [[ "$i" != "${i/mod_/}" ]] ; then
name="${i/mod_/}"
elif [[ -n "${disable}" ]] || [[ "$i" == "disabled" ]] ; then
MY_BUILTINS="${MY_BUILTINS} --disable-${name}"
name="" ; disable=""
elif [[ "$i" == "static" ]] || use static-modules ; then
MY_BUILTINS="${MY_BUILTINS} --enable-${name}=static"
name="" ; disable=""
elif [[ "$i" == "shared" ]] ; then
MY_BUILTINS="${MY_BUILTINS} --enable-${name}=shared"
mods="${mods} ${name}"
name="" ; disable=""
else
ewarn "Parse error in ${1} - unknown option: $i"
fi
done
# reject the file if it's unversioned or doesn't match our
# package major.minor. This is to make upgrading work smoothly.
if [[ "${version}" != "${PV%.*}" ]] ; then
mods=""
MY_BUILTINS=""
return 1
fi
einfo "Using ${1}"
einfo "options: ${MY_BUILTINS}"
einfo "LoadModules: ${mods}"
}
select_modules_config() {
parse_modules_config "${ROOT}"/etc/apache2/apache2-builtin-mods || \
parse_modules_config "${GENTOO_PATCHDIR}"/conf/apache2-builtin-mods || \
return 1
}
|