summaryrefslogtreecommitdiff
blob: 7b0cb05105bac31cd82021c18dc4dabb002160b4 (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-2011 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/net-proxy/tinyproxy/tinyproxy-1.8.2.ebuild,v 1.3 2011/03/10 17:16:23 jer Exp $

EAPI="2"

inherit autotools eutils

DESCRIPTION="A lightweight HTTP/SSL proxy"
HOMEPAGE="http://www.banu.com/tinyproxy/"
SRC_URI="http://www.banu.com/pub/${PN}/1.8/${P}.tar.bz2"

LICENSE="GPL-2"
SLOT="0"
KEYWORDS="~alpha ~amd64 ~ia64 ~ppc ~sparc ~x86"
IUSE="debug +filter-proxy minimal reverse-proxy transparent-proxy
	+upstream-proxy +xtinyproxy-header"

DEPEND="!minimal? ( app-text/asciidoc )"
RDEPEND=""

pkg_setup() {
	enewgroup ${PN}
	enewuser ${PN} "" "" "" ${PN}
}

src_prepare() {
	epatch "${FILESDIR}"/${PN}-1.8.1-ldflags.patch
	use minimal && epatch "${FILESDIR}/${PN}-1.8.1-minimal.patch"
	sed -i etc/${PN}.conf.in -e "s|nobody|${PN}|g" || die "sed failed"
	sed \
		-e "/CONFFILE/s:${PN}/::g" \
		"${FILESDIR}/${PN}.initd" \
		> "${WORKDIR}"/${PN}.initd \
		|| die "sed failed"
	eautoreconf
}

src_configure() {
	if use minimal; then
		ln -s /bin/true "${T}"/a2x
		export PATH="${T}:${PATH}"
	fi
	econf \
		--localstatedir=/var \
		$(use_enable filter-proxy filter) \
		$(use_enable reverse-proxy reverse) \
		$(use_enable transparent-proxy transparent) \
		$(use_enable upstream-proxy upstream) \
		$(use_enable xtinyproxy-header xtinyproxy) \
		$(use_enable debug)
}

src_test() {
	emake test || die
}

src_install() {
	sed -i \
		-e 's:mkdir $(datadir)/tinyproxy:mkdir -p $(DESTDIR)$(datadir)/tinyproxy:' \
		Makefile
	emake DESTDIR="${D}" install || die "install failed"

	if ! use minimal; then
		dodoc AUTHORS ChangeLog NEWS README TODO || die "dodoc failed"
	fi

	diropts -m0775 -o ${PN} -g ${PN}
	keepdir /var/log/${PN}
	keepdir /var/run/${PN}

	newinitd "${WORKDIR}"/tinyproxy.initd tinyproxy
}

pkg_postinst() {
	einfo "For filtering domains and URLs, enable filter option in the configuration"
	einfo "file and add them to the filter file (one domain or URL per line)."
}