summaryrefslogtreecommitdiff
blob: 816dc6a214b445fc1adbd9392f2400b2ac7f716c (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
# Copyright 1999-2005 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/www-servers/thttpd/thttpd-2.25b-r3.ebuild,v 1.1 2005/10/28 15:49:14 ka0ttic Exp $

PHPSAPI="thttpd"

MY_PHP_P="php-5.0.3"
MY_THTTPD_P="${P%[a-z]*}"

inherit php5-sapi-r2 flag-o-matic

DESCRIPTION="Small and fast multiplexing webserver."
HOMEPAGE="http://www.acme.com/software/thttpd/"
SRC_URI="http://www.acme.com/software/thttpd/${P}.tar.gz
		php? ( http://www.php.net/distributions/${MY_PHP_P}.tar.gz )"

LICENSE="BSD"
SLOT="0"
KEYWORDS="~ppc ~x86"
IUSE="static php"

PHP_S="${WORKDIR}/${MY_PHP_P}"

pkg_setup() {
	if useq php ; then
		php5-sapi-r2_pkg_setup
	fi
}

src_unpack() {
	unpack ${A}
	cd ${S}
	epatch ${FILESDIR}/${MY_THTTPD_P}/fix-insecure-tmp-creation-CVE-2005-3124.diff

	if useq php ; then
		cd ${WORKDIR}
		epatch ${FILESDIR}/${MY_THTTPD_P}/php-5.0.3-thttpd-2.25b.patch
		epatch ${FILESDIR}/php-5.0.3-IOV.patch
		php5-sapi-r2_src_unpack
	fi
}

src_compile() {
	# compile PHP5 first
	if useq php ; then
		my_conf="--with-thttpd=${S}"
		php5-sapi-r2_src_compile
		php5-sapi-r2_src_install
	fi

	cd ${S}

	## TODO: what to do with IPv6?

	append-ldflags -Wl,-z,now
	use static && append-ldflags -static

	econf || die "econf failed"
	emake || die "emake failed"
}

src_install () {
	if useq php ; then
		# we have to do the install again, because Portage wipes anything
		# put into $D during src_compile
		#
		# ideally, we need to improve the eclass
		php5-sapi-r2_src_install
	fi

	cd ${S}
	dodir /usr/share/man/man1
	make prefix=${D}/usr \
		MANDIR=${D}/usr/share/man \
		WEBGROUP=nogroup \
		WEBDIR=${D}/var/www/localhost \
		"$@" install || die "make install failed"

	mv ${D}/usr/sbin/{,th_}htpasswd
	mv ${D}/usr/share/man/man1/{,th_}htpasswd.1

	newinitd ${FILESDIR}/${MY_THTTPD_P}/thttpd.init thttpd
	newconfd ${FILESDIR}/${MY_THTTPD_P}/thttpd.confd thttpd

	dodoc README INSTALL TODO

	insinto /etc/thttpd
	doins ${FILESDIR}/${MY_THTTPD_P}/thttpd.conf.sample
}

pkg_postinst() {
	if useq php ; then
		php5-sapi-r2_pkg_postinst
	fi

	einfo "Adjust THTTPD_DOCROOT in /etc/conf.d/thttpd !"
}