700f6f9b03e9faba07056039e158ec839f4a09a0
[gentoo.git] / net-vpn / wireguard-tools / wireguard-tools-1.0.20191226.ebuild
1 # Copyright 1999-2019 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
3
4 EAPI=6
5
6 inherit linux-mod bash-completion-r1
7
8 DESCRIPTION="Required tools for WireGuard, such as wg(8) and wg-quick(8)"
9 HOMEPAGE="https://www.wireguard.com/"
10
11 if [[ ${PV} == 9999 ]]; then
12         inherit git-r3
13         EGIT_REPO_URI="https://git.zx2c4.com/wireguard-tools"
14         KEYWORDS=""
15 else
16         SRC_URI="https://git.zx2c4.com/wireguard-tools/snapshot/wireguard-tools-${PV}.tar.xz"
17         KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~m68k ~mips ~ppc ~ppc64 ~s390 ~sh ~sparc ~x86"
18 fi
19
20 LICENSE="GPL-2"
21 SLOT="0"
22
23 DEPEND="net-libs/libmnl"
24 RDEPEND="${DEPEND}
25         || ( net-firewall/nftables net-firewall/iptables )
26         !<=net-vpn/wireguard-0.0.20191219
27 "
28
29 wg_quick_optional_config_nob() {
30         CONFIG_CHECK="$CONFIG_CHECK ~$1"
31         declare -g ERROR_$1="CONFIG_$1: This option is required for automatic routing of default routes inside of wg-quick(8), though it is not required for general WireGuard usage."
32 }
33
34 pkg_setup() {
35         wg_quick_optional_config_nob IP_ADVANCED_ROUTER
36         wg_quick_optional_config_nob IP_MULTIPLE_TABLES
37         wg_quick_optional_config_nob NETFILTER_XT_MARK
38         wg_quick_optional_config_nob NETFILTER_XT_CONNMARK
39         wg_quick_optional_config_nob IP6_NF_RAW
40         wg_quick_optional_config_nob IP_NF_RAW
41         linux-mod_pkg_setup
42 }
43
44 src_compile() {
45         emake RUNSTATEDIR="${EPREFIX}/run" -C src CC="$(tc-getCC)" LD="$(tc-getLD)"
46 }
47
48 src_install() {
49         dodoc README.md
50         dodoc -r contrib
51         emake \
52                 WITH_BASHCOMPLETION=yes \
53                 WITH_SYSTEMDUNITS=yes \
54                 WITH_WGQUICK=yes \
55                 DESTDIR="${D}" \
56                 BASHCOMPDIR="$(get_bashcompdir)" \
57                 PREFIX="${EPREFIX}/usr" \
58                 -C src install
59 }
60
61 pkg_postinst() {
62         einfo
63         einfo "After installing WireGuard, if you'd like to try sending some packets through"
64         einfo "WireGuard, you may use, for testing purposes only, the insecure client.sh"
65         einfo "test example script:"
66         einfo
67         einfo "  \$ bzcat ${ROOT}usr/share/doc/${PF}/contrib/ncat-client-server/client.sh.bz2 | sudo bash -"
68         einfo
69         einfo "This will automatically setup interface wg0, through a very insecure transport"
70         einfo "that is only suitable for demonstration purposes. You can then try loading the"
71         einfo "hidden website or sending pings:"
72         einfo
73         einfo "  \$ chromium http://192.168.4.1"
74         einfo "  \$ ping 192.168.4.1"
75         einfo
76         einfo "If you'd like to redirect your internet traffic, you can run it with the"
77         einfo "\"default-route\" argument. You may not use this server for any abusive or illegal"
78         einfo "purposes. It is for quick testing only."
79         einfo
80         einfo "More info on getting started can be found at: https://www.wireguard.com/quickstart/"
81         einfo
82 }