7dbd010efe27b32b3bf9019a00af38d7c240f3f2
[gentoo.git] / net-misc / stunnel / stunnel-5.20.ebuild
1 # Copyright 1999-2015 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3 # $Id$
4
5 EAPI="5"
6
7 inherit ssl-cert eutils multilib systemd user
8
9 DESCRIPTION="TLS/SSL - Port Wrapper"
10 HOMEPAGE="http://www.stunnel.org/index.html"
11 SRC_URI="ftp://ftp.stunnel.org/stunnel/archive/${PV%%.*}.x/${P}.tar.gz
12         http://www.usenix.org.uk/mirrors/stunnel/archive/${PV%%.*}.x/${P}.tar.gz
13         http://ftp.nluug.nl/pub/networking/stunnel/archive/${PV%%.*}.x/${P}.tar.gz
14         http://www.namesdir.com/mirrors/stunnel/archive/${PV%%.*}.x/${P}.tar.gz
15         http://stunnel.cybermirror.org/archive/${PV%%.*}.x/${P}.tar.gz
16         http://mirrors.zerg.biz/stunnel/archive/${PV%%.*}.x/${P}.tar.gz
17         ftp://mirrors.go-parts.com/stunnel/archive/${PV%%.*}.x/${P}.tar.gz"
18
19 LICENSE="GPL-2"
20 SLOT="0"
21 KEYWORDS="~alpha amd64 arm ~hppa ~ia64 ~mips ppc ppc64 ~s390 sparc x86 ~amd64-linux ~arm-linux ~x86-linux ~ppc-macos ~x86-macos"
22 IUSE="ipv6 selinux stunnel3 tcpd"
23
24 DEPEND="tcpd? ( sys-apps/tcp-wrappers )
25         dev-libs/openssl:="
26 RDEPEND="${DEPEND}
27         stunnel3? ( dev-lang/perl )
28         selinux? ( sec-policy/selinux-stunnel )"
29
30 RESTRICT="test"
31
32 pkg_setup() {
33         enewgroup stunnel
34         enewuser stunnel -1 -1 -1 stunnel
35 }
36
37 src_prepare() {
38         # Hack away generation of certificate
39         sed -i -e "s/^install-data-local:/do-not-run-this:/" \
40                 tools/Makefile.in || die "sed failed"
41
42         echo "CONFIG_PROTECT=\"/etc/stunnel/stunnel.conf\"" > "${T}"/20stunnel
43 }
44
45 src_configure() {
46         econf \
47                 --libdir="${EPREFIX}/usr/$(get_libdir)" \
48                 $(use_enable ipv6) \
49                 $(use_enable tcpd libwrap) \
50                 --with-ssl="${EPREFIX}"/usr \
51                 --disable-fips
52 }
53
54 src_install() {
55         emake DESTDIR="${D}" install
56         rm -rf "${ED}"/usr/share/doc/${PN}
57         rm -f "${ED}"/etc/stunnel/stunnel.conf-sample \
58                 "${ED}"/usr/share/man/man8/stunnel.{fr,pl}.8
59         use stunnel3 || rm -f "${ED}"/usr/bin/stunnel3
60
61         # The binary was moved to /usr/bin with 4.21,
62         # symlink for backwards compatibility
63         dosym ../bin/stunnel /usr/sbin/stunnel
64
65         dodoc AUTHORS BUGS CREDITS PORTS README TODO ChangeLog
66         dohtml doc/stunnel.html doc/en/VNC_StunnelHOWTO.html tools/ca.html \
67                 tools/importCA.html
68
69         insinto /etc/stunnel
70         doins "${FILESDIR}"/stunnel.conf
71         doinitd "${FILESDIR}"/stunnel
72
73         doenvd "${T}"/20stunnel
74
75         systemd_dounit "${S}/tools/stunnel.service"
76         systemd_newtmpfilesd "${FILESDIR}"/stunnel.tmpfiles.conf stunnel.conf
77 }
78
79 pkg_postinst() {
80         if [ ! -f "${EROOT}"/etc/stunnel/stunnel.key ]; then
81                 install_cert /etc/stunnel/stunnel
82                 chown stunnel:stunnel "${EROOT}"/etc/stunnel/stunnel.{crt,csr,key,pem}
83                 chmod 0640 "${EROOT}"/etc/stunnel/stunnel.{crt,csr,key,pem}
84         fi
85
86         einfo "If you want to run multiple instances of stunnel, create a new config"
87         einfo "file ending with .conf in /etc/stunnel/. **Make sure** you change "
88         einfo "\'pid= \' with a unique filename."
89 }