summaryrefslogtreecommitdiff
blob: 7f2726da7badfc6513d61bd40a67b9da34b61a7a (plain)
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
# Copyright 1999-2002 Gentoo Technologies, Inc.
# Distributed under the terms of the GNU General Public License, v2 or later
# $Header: /var/cvsroot/gentoo-x86/net-www/apache/apache-1.3.24-r2.ebuild,v 1.5 2002/07/14 20:25:23 aliz Exp $

mod_ssl_ver=2.8.8-${PV}
HARD_SERVER_LIMIT=512

S=${WORKDIR}/apache_${PV}
DESCRIPTION="The Apache Web Server"
HOMEPAGE="http://www.apache.org http://www.modssl.org"
KEYWORDS="x86"
SRC_URI="http://httpd.apache.org/dist/httpd/apache_${PV}.tar.gz
	ftp://ftp.modssl.org/source/mod_ssl-${mod_ssl_ver}.tar.gz"
# The mod_ssl archive is only for providing the EAPI patch in here.
# You should install the net-www/mod_ssl package for the actual DSO.

RDEPEND="virtual/glibc
	=sys-libs/db-1*
	=sys-libs/db-3*
	>=dev-libs/mm-1.1.3
	>=sys-libs/gdbm-1.8
	>=dev-libs/expat-1.95.2"
DEPEND="${RDEPEND} sys-devel/perl"
LICENSE="Apache-1.1"
SLOT="1"

pkg_setup() {
	# these are in baselayout now; it will not hurt to leave them here though..
	if ! grep -q ^apache: /etc/group ; then
		groupadd -g 81 apache || die "problem adding group apache"
	fi

	if ! grep -q ^apache: /etc/passwd ; then
		useradd -u 81 -g apache -s /bin/false -d /home/httpd -c "apache" apache
		assert "problem adding user apache"
	fi

	select_modules_config || \
	die "couldn't find apache-builtin-mods config file"
}

src_unpack() {
	local myssl
	unpack ${A} ; cd ${S}

	# some nice patches..
	patch -p1 < ${FILESDIR}/${PV}/mdk/apache_1.3.11-apxs.patch || die m1
	patch -p1 < ${FILESDIR}/${PV}/mdk/apache_1.3.22-srvroot.patch || die m2
	patch -p1 < ${FILESDIR}/${PV}/mdk/apache-1.3.14-mkstemp.patch || die m3
	patch -p0 < ${FILESDIR}/${PV}/mdk/apache-1.3.20.manpage.patch || die m4
	patch -p1 < ${FILESDIR}/${PV}/deb/apxs_wrong_prefix || die d1
	patch -p1 < ${FILESDIR}/${PV}/deb/custom_response_segfaults || die d2
	patch -p1 < ${FILESDIR}/${PV}/deb/mime_type_fix || die d3
	patch -p1 < ${FILESDIR}/${PV}/deb/regex_must_conform_to_posix_for_LFS_to_work || die d4
	patch -p1 < ${FILESDIR}/${PV}/deb/suexec_combined || die d5
	patch -p1 < ${FILESDIR}/${PV}/deb/suexec_of_death || die d6
	patch -p1 < ${FILESDIR}/${PV}/deb/usr_bin_perl_owns_you || die d7

	# yet another perl path fix..
	cp htdocs/manual/search/manual-index.cgi \
		htdocs/manual/search/manual-index.cgi.orig
	sed -e "s:/usr/local/bin/perl5:/usr/bin/perl:" \
		htdocs/manual/search/manual-index.cgi.orig \
		> htdocs/manual/search/manual-index.cgi
	rm -f htdocs/manual/search/manual-index.cgi.orig

	# setup eapi..
	myssl=${S}/../mod_ssl-${mod_ssl_ver}
	cp ${myssl}/pkg.eapi/*.h src/include
	cp ${myssl}/pkg.eapi/*.c src/ap
	patch -p0 < ${myssl}/pkg.eapi/eapi.patch || die eapi

	# set a reasonable MM_CORE_PATH location..
	mv src/include/httpd.h src/include/httpd.h.orig
	sed -e 's:logs/mm:/var/cache/apache-mm/mm:' \
		src/include/httpd.h.orig > src/include/httpd.h

	# fix this silly script so it finds a db lib..
	mv src/helpers/find-dbm-lib src/helpers/find-dbm-lib.orig
	cp ${FILESDIR}/find-dbm-lib src/helpers
}

src_compile() {
	local myconf mycflags
	mycflags="${CFLAGS}"
	unset CFLAGS ; unset CXXFLAGS

	#-DBUFFERED_LOGS
	OPTIM="${mycflags} -DHARD_SERVER_LIMIT=${HARD_SERVER_LIMIT} \
		-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64" \
	LIBS="-lgdbm -lpthread" \
	EAPI_MM=SYSTEM \
	./configure \
		--prefix=/usr \
		--exec-prefix=/usr \
		--bindir=/usr/bin \
		--sbindir=/usr/sbin \
		--libexecdir=/usr/lib/apache \
		--mandir=/usr/share/man \
		--sysconfdir=/etc/apache/conf \
		--datadir=/home/httpd \
		--iconsdir=/home/httpd/icons \
		--htdocsdir=/home/httpd/htdocs \
		--manualdir=/usr/share/doc/${PF}/manual \
		--cgidir=/home/httpd/cgi-bin \
		--includedir=/usr/include/apache \
		--localstatedir=/var \
		--runtimedir=/var/run \
		--logfiledir=/var/log/apache \
		--proxycachedir=/var/cache/apache \
		--serverroot=/etc/apache \
		\
		--target=apache \
		--server-uid=apache \
		--server-gid=apache \
		--enable-rule=EAPI \
		--enable-rule=SHARED_CHAIN \
		--with-perl=/usr/bin/perl \
		\
		${MY_BUILTINS} \
		\
		--enable-suexec \
		--suexec-uidmin=1000 \
		--suexec-gidmin=100 \
		--suexec-caller=apache \
		--suexec-userdir=public_html \
		--suexec-docroot=/home/httpd/htdocs \
		--suexec-safepath="/bin:/usr/bin" \
		--suexec-logfile=/var/log/apache/suexec_log \
		\
		${myconf} || die "bad ./configure"

	emake || die "compile problem"
}

src_install() {
	local myfile
	make install-quiet root=${D} || die
	dodoc ABOUT_APACHE Announcement INSTALL* LICENSE* README* WARNING*

	fowners root.apache /usr/sbin/suexec
	fperms 4710 /usr/sbin/suexec
	#fowners apache.apache /home/httpd
	#fowners apache.apache /home/httpd/htdocs

	# nice support scripts..    # apachefixconf
	for myfile in apacheaddmod apachedelmod \
		apachelogserverstatus apachesplitlogfile
	do
		exeinto /usr/sbin
		doexe ${FILESDIR}/$myfile
	done

	# setup links in /etc/apache..
	cd ${D}/etc/apache
	ln -sf ../../usr/lib/apache modules
	# apxs needs this to pickup the right lib for install..
	ln -sf ../../usr/lib lib
	ln -sf ../../var/log/apache logs
	ln -sf ../../usr/lib/apache-extramodules extramodules

	# drop in a convenient link to the manual
	dosym /usr/share/doc/${PF}/manual /home/httpd/htdocs/manual

	# deprecated config files, empty dirs..
	rm -f ${D}/etc/apache/conf/access.conf*
	rm -f ${D}/etc/apache/conf/srm.conf*
	rm -rf ${D}/var

	# now the config files..
	insinto /etc/apache/conf
	doins ${FILESDIR}/conf/commonapache.conf
	doins ${FILESDIR}/conf/apache.conf
	insinto /etc/apache/conf/vhosts
	doins ${FILESDIR}/conf/VirtualHomePages.conf
	doins ${FILESDIR}/conf/DynamicVhosts.conf
	doins ${FILESDIR}/conf/Vhosts.conf

	exeinto /etc/init.d ; newexe ${FILESDIR}/apache.rc6 apache
	insinto /etc/conf.d ; newins ${FILESDIR}/apache.confd apache
	insinto /etc/apache ; doins ${FILESDIR}/apache-builtin-mods
}

pkg_postinst() {
	# empty dirs..
	install -d -o apache -g apache ${ROOT}/var/cache/apache
	install -d -o apache -g apache -m1333 ${ROOT}/var/cache/apache-mm
	install -d -o root -g root -m0755 ${ROOT}/usr/lib/apache-extramodules
	install -d -o root -g root -m0755 ${ROOT}/etc/apache/conf/addon-modules
	install -d -o root -g root -m0755 ${ROOT}/var/log/apache
}

parse_modules_config() {
	local filename=$1
	local name=""
	local dso=""
	local disable=""
	[ -f ${filename} ] || return 1
	einfo ">>> using ${filename} for builtins..."
	for i in `cat $filename | sed "s/^#.*//"` ; do
		if [ $i == "-" ] ; then
			disable="true"
		elif [ -z "$name" ] && [ ! -z "`echo $i | grep "mod_"`" ] ; then
			name=`echo $i | sed "s/mod_//"`
		elif [ "$disable" ] && ( [ $i == "static" ] || [ $i == "shared" ] ) ; then
			MY_BUILTINS="${MY_BUILTINS} --disable-module=$name"
			name="" ; disable=""
		elif [ $i == "static" ] ; then
			MY_BUILTINS="${MY_BUILTINS} --enable-module=$name --disable-shared=$name"
			name="" ; disable=""
		elif [ $i == "shared" ] ; then
			MY_BUILTINS="${MY_BUILTINS} --enable-module=$name --enable-shared=$name"
			name="" ; disable=""
		fi
	done
}

select_modules_config() {
	parse_modules_config /etc/apache/apache-builtin-mods || \
	parse_modules_config ${FILESDIR}/apache-builtin-mods || \
	return 1
}