summaryrefslogtreecommitdiff
blob: e20072370fce529aad18730d0ecd55cf5eeb03f2 (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
# Copyright 1999-2012 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/www-servers/monkeyd/monkeyd-1.1.1.ebuild,v 1.3 2012/10/23 09:46:28 blueness Exp $

EAPI="4"

inherit toolchain-funcs depend.php multilib

MY_P="${PN/d}-${PV}"
DESCRIPTION="A small, fast, and scalable web server"
HOMEPAGE="http://www.monkey-project.com/"
SRC_URI="http://monkey-project.com/releases/${PV:0:3}/${MY_P}.tar.gz"

LICENSE="GPL-2"
SLOT="0"
KEYWORDS="~amd64 arm ~mips ppc ppc64 ~x86"
IUSE="php"

RDEPEND="php? ( virtual/httpd-php )"

S="${WORKDIR}/${MY_P}"

WEBROOT="/var/www/localhost"

pkg_setup() {
	use php && require_php_cgi
}

src_prepare() {
	# Don't install the banana script, we use ${FILESDIR}/monkeyd.initd
	sed -i '/install -m 755 bin\/banana/d' configure || die "sed banana"

	# Don't explicitly strip files
	sed -i -e '/$STRIP /d' -e 's/install -s -m 644/install -m 755/' configure || die
}

src_configure() {
	# Non-autotools configure
	./configure \
		--prefix=/usr \
		--bindir=/usr/bin \
		--datadir=${WEBROOT}/htdocs \
		--logdir=/var/log/${PN} \
		--mandir=/usr/share/man \
		--plugdir=/usr/$(get_libdir)/monkeyd/plugins \
		--sysconfdir=/etc/${PN} \
		|| die
}

src_compile() {
	emake CC="$(tc-getCC)" CFLAGS="${CFLAGS}"

	# Don't install the banana script man page
	rm "${S}"/man/banana.1
}

src_install() {
	default

	if use php ; then
		sed -i -e '/^#AddScript application\/x-httpd-php/s:^#::' "${D}"/etc/monkeyd/monkey.conf || die
		sed -i -e 's:/home/my_home/php/bin/php:/usr/bin/php-cgi:' "${D}"/etc/monkeyd/monkey.conf || die
	fi

	sed -i -e "s:/var/log/monkeyd/monkey.pid:/var/run/monkey.pid:" "${D}"/etc/monkeyd/monkey.conf || die
	newinitd "${FILESDIR}"/monkeyd.initd monkeyd
	newconfd "${FILESDIR}"/monkeyd.confd monkeyd

	#move htdocs to docdir, bug #429632
	docompress -x /usr/share/doc/"${PF}"/htdocs.dist
	mv "${D}"${WEBROOT}/htdocs \
		"${D}"/usr/share/doc/"${PF}"/htdocs.dist
	mkdir "${D}"${WEBROOT}/htdocs

	keepdir \
		/var/log/monkeyd \
		${WEBROOT}/htdocs
}