fc3e335d52c83c64cb7244cc5a2660ff4da31291
[gentoo.git] / net-proxy / privoxy / privoxy-3.0.28.ebuild
1 # Copyright 1999-2020 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
3
4 EAPI=7
5
6 inherit autotools systemd toolchain-funcs user
7
8 [ "${PV##*_}" = "beta" ] &&
9         PRIVOXY_STATUS="beta" ||
10         PRIVOXY_STATUS="stable"
11
12 HOMEPAGE="http://www.privoxy.org https://sourceforge.net/projects/ijbswa/"
13 DESCRIPTION="A web proxy with advanced filtering capabilities for enhancing privacy"
14 SRC_URI="mirror://sourceforge/ijbswa/${P%_*}-${PRIVOXY_STATUS}-src.tar.gz"
15
16 IUSE="+acl client-tags compression editor extended-host-patterns
17 external-filters +fast-redirects +force fuzz graceful-termination
18 +image-blocking ipv6 lfs png-images selinux +stats +threads toggle
19 tools whitelists +zlib"
20 SLOT="0"
21 KEYWORDS="~alpha ~amd64 ~arm ~ppc ~ppc64 ~sparc ~x86"
22 LICENSE="GPL-2"
23
24 DEPEND="
25         dev-libs/libpcre
26         zlib? ( sys-libs/zlib )
27 "
28 RDEPEND="${DEPEND}
29         extended-host-patterns? ( dev-lang/perl )
30         selinux? ( sec-policy/selinux-privoxy )
31         tools? (
32                 net-misc/curl
33                 dev-lang/perl
34         )
35 "
36 REQUIRED_USE="
37         compression? ( zlib )
38         toggle? ( editor )
39 "
40
41 S="${WORKDIR}/${P%_*}-${PRIVOXY_STATUS}"
42
43 PATCHES=( "${FILESDIR}"/${PN}-3.0.19-gentoo.patch )
44
45 pkg_pretend() {
46         if ! use threads; then
47                 ewarn
48                 ewarn "Privoxy may be very slow without threads support, consider to enable them."
49                 ewarn "See also http://www.privoxy.org/faq/trouble.html#GENTOO-RICERS"
50                 ewarn
51         fi
52 }
53
54 pkg_setup() {
55         enewgroup privoxy
56         enewuser privoxy -1 -1 /etc/privoxy privoxy
57 }
58
59 src_prepare() {
60         default
61         mv configure.in configure.ac || die
62         sed -i "s|/p\.p/|/config.privoxy.org/|g" tools/privoxy-regression-test.pl || die
63
64         # autoreconf needs to be called even if we don't modify any autotools source files
65         # See main makefile
66         eautoreconf
67 }
68
69 src_configure() {
70         # --with-debug only enables debug CFLAGS
71         # --with-docbook and --with-db2html and their deps are useless,
72         #       since docs are already pregenerated in the source tarball
73         econf \
74                 --docdir=/usr/share/doc/${PF} \
75                 --sysconfdir=/etc/privoxy \
76                 --enable-dynamic-pcre \
77                 --with-user=privoxy \
78                 --with-group=privoxy \
79                 $(use_enable acl acl-support) \
80                 $(use_enable compression) \
81                 $(use_enable client-tags) \
82                 $(use_enable editor) \
83                 $(use_enable extended-host-patterns) \
84                 $(use_enable fast-redirects) \
85                 $(use_enable force) \
86                 $(use_enable fuzz) \
87                 $(use_enable graceful-termination) \
88                 $(use_enable image-blocking) \
89                 $(use_enable ipv6 ipv6-support) \
90                 $(use_enable kernel_FreeBSD accept-filter) \
91                 $(use_enable lfs large-file-support) \
92                 $(use_enable png-images no-gifs) \
93                 $(use_enable stats) \
94                 $(use_enable threads pthread) \
95                 $(use_enable toggle) \
96                 $(use_enable whitelists trust-files) \
97                 $(use_enable zlib)
98 }
99
100 src_install() {
101         default
102
103         newinitd "${FILESDIR}/privoxy.initd-3" privoxy
104         systemd_dounit "${FILESDIR}"/${PN}.service
105
106         insinto /etc/logrotate.d
107         newins "${FILESDIR}/privoxy.logrotate" privoxy
108
109         diropts -m 0750 -g privoxy -o privoxy
110         keepdir /var/log/privoxy
111
112         use extended-host-patterns && newbin tools/url-pattern-translator.pl privoxy-url-pattern-translator.pl
113         if use tools; then
114                 dobin tools/{privoxy-log-parser.pl,privoxy-regression-test.pl}
115                 newbin tools/uagen.pl privoxy-uagen.pl
116         fi
117 }
118
119 pkg_postinst() {
120         if use extended-host-patterns; then
121                 ewarn
122                 ewarn "You enabled extended-host-patterns, now you *must* convert all action files in"
123                 ewarn "PCRE-compatible format, or privoxy will fail to start. Helper tool"
124                 ewarn "privoxy-url-pattern-translator.pl is available."
125                 ewarn
126         fi
127 }