]> Pileus Git - ~andy/sunrise/blob - net-misc/uanytun/uanytun-0.3.3.ebuild
app-admin/jailkit: Add ~amd64 keyword, EAPI bump
[~andy/sunrise] / net-misc / uanytun / uanytun-0.3.3.ebuild
1 # Copyright 1999-2012 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3 # $Header: $
4
5 inherit user
6
7 DESCRIPTION="Tiny VPN daemon using Secure Anycast Tunneling"
8 HOMEPAGE="http://anytun.org/"
9 SRC_URI="http://anytun.org/download/${P}.tar.gz"
10
11 LICENSE="GPL-3"
12 SLOT="0"
13 KEYWORDS="~amd64 ~x86"
14 IUSE="examples gcrypt"
15
16 RDEPEND="gcrypt? ( dev-libs/libgcrypt )
17         !gcrypt? ( dev-libs/openssl )"
18 DEPEND="${RDEPEND}
19         app-text/asciidoc"
20
21 S=${S}/src
22
23 src_compile() {
24         local myconf
25         use gcrypt || myconf="--use-ssl-crypto"
26         use examples\
27                 && myconf="${myconf} --examplesdir=/usr/share/doc/${PF}/examples/etc" \
28                 || myconf="${myconf} --no-examples"
29         econf --ebuild-compat ${myconf}
30
31         einfo "Building executables"
32         emake || die "make failed"
33
34         einfo "Building manpages"
35         emake manpage || die "failed building manpages"
36 }
37
38 src_install() {
39         emake DESTDIR="${D}" install || die "make install failed"
40         rm -Rf "${D}"/etc/init.d
41         #as long as README just contains path to examples, only install it with examples
42         use examples || rm -f "${D}"/etc/${PN}/README
43
44         newinitd "${FILESDIR}/${PN}-0.3.3.init" ${PN} || die "failed to copy/install initrd script"
45
46         cd ../
47         dodoc AUTHORS ChangeLog README || die "failed to install docs"
48
49         #patch any examples to use user "antun" instad of "uanytun"
50         find "${D}"/usr/share/doc/${PF}/examples/etc/ -name "config" \
51                 -exec sed -i 's/\(username\|groupname\) uanytun$/\1 anytun/' {} \;
52 }
53
54 pkg_config() {
55         [ ! -d "${ROOT}"/usr/share/doc/${PF}/examples/etc/${PN} ] && \
56                 die "can't copy example configs since examples were not installed (reemerge with USE='examples')"
57         for example in autostart client1 client2 client3 p2p-a p2p-b; do
58                 [ -e "${ROOT}"/etc/${PN}/${example} ] && die "${ROOT}/etc/${PN}/${example} already present, rm -R it first"
59         done
60         cp -rv "${ROOT}"/usr/share/doc/${PF}/examples/etc/${PN} "${ROOT}"/etc/ || die "failed to copy examples"
61 }
62
63 pkg_postinst() {
64         enewgroup anytun
65         enewuser anytun -1 -1 /var/run/ anytun
66         elog "Note that each VPN gets its own directory under /etc/${PN}/"
67         elog "(see examples provided with the package)"
68         elog "Use the following command to create gentoo-style"
69         elog "uanytun.{VPN} initrd scripts for each VPN"
70         elog "# ln -s /etc/init.d/${PN} /etc/init.d/${PN}.client1"
71 }