Gentoo Archives: gentoo-commits

From: Jason Donenfeld <zx2c4@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: net-misc/wireguard/
Date: Wed, 02 Nov 2016 11:32:25
Message-Id: 1478086339.2eacdb091f9a5d84db6413d83e9a1a9a35f88dbf.zx2c4@gentoo
1 commit: 2eacdb091f9a5d84db6413d83e9a1a9a35f88dbf
2 Author: Jason A. Donenfeld <zx2c4 <AT> gentoo <DOT> org>
3 AuthorDate: Wed Nov 2 11:31:36 2016 +0000
4 Commit: Jason Donenfeld <zx2c4 <AT> gentoo <DOT> org>
5 CommitDate: Wed Nov 2 11:32:19 2016 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=2eacdb09
7
8 net-misc/wireguard: add kmod-src option
9
10 Package-Manager: portage-2.3.2
11
12 net-misc/wireguard/metadata.xml | 4 ++++
13 net-misc/wireguard/wireguard-0.0.20161102.ebuild | 24 ++++++++++++++++++++----
14 net-misc/wireguard/wireguard-9999.ebuild | 24 ++++++++++++++++++++----
15 3 files changed, 44 insertions(+), 8 deletions(-)
16
17 diff --git a/net-misc/wireguard/metadata.xml b/net-misc/wireguard/metadata.xml
18 index 915f002..aa8747f 100644
19 --- a/net-misc/wireguard/metadata.xml
20 +++ b/net-misc/wireguard/metadata.xml
21 @@ -5,4 +5,8 @@
22 <email>zx2c4@g.o</email>
23 <name>Jason A. Donenfeld</name>
24 </maintainer>
25 + <use>
26 + <flag name="kmod-src">Do not compile the kernel module. Instead install the kernel module source code to /usr/src/wireguard.</flag>
27 + <flag name="debug">Enable verbose debug reporting in dmesg of various WireGuard peer and device information.</flag>
28 + </use>
29 </pkgmetadata>
30
31 diff --git a/net-misc/wireguard/wireguard-0.0.20161102.ebuild b/net-misc/wireguard/wireguard-0.0.20161102.ebuild
32 index 642325b..b6e88c4 100644
33 --- a/net-misc/wireguard/wireguard-0.0.20161102.ebuild
34 +++ b/net-misc/wireguard/wireguard-0.0.20161102.ebuild
35 @@ -21,7 +21,7 @@ fi
36
37 LICENSE="GPL-2"
38 SLOT="0"
39 -IUSE="debug"
40 +IUSE="debug kmod-src"
41
42 DEPEND="net-libs/libmnl"
43 RDEPEND="${DEPEND}"
44 @@ -33,27 +33,43 @@ WARNING_PADATA="If you're running a multicore system you likely should enable CO
45 WARNING_IP6_NF_IPTABLES="If your kernel has CONFIG_IPV6, you need CONFIG_IP6_NF_IPTABLES; otherwise WireGuard will not insert."
46
47 pkg_setup() {
48 + use kmod-src && return
49 linux-mod_pkg_setup
50 kernel_is -lt 4 1 0 && die "This version of ${PN} requires Linux >= 4.1"
51 }
52
53 src_compile() {
54 use debug && BUILD_PARAMS="CONFIG_WIREGUARD_DEBUG=y ${BUILD_PARAMS}"
55 - linux-mod_src_compile
56 + use kmod-src || linux-mod_src_compile
57 emake RUNSTATEDIR="${EPREFIX}/run" -C src/tools
58 }
59
60 src_install() {
61 dodoc README.md
62 dodoc -r contrib/examples
63 - linux-mod_src_install
64 emake DESTDIR="${D}" PREFIX="${EPREFIX}/usr" -C src/tools install
65 + if use kmod-src; then
66 + dodir /usr/src
67 + rm -r "${WORKDIR}"/*/src/tools || die
68 + mv "${WORKDIR}"/*/src "${ED}"usr/src/wireguard || die
69 + else
70 + linux-mod_src_install
71 + fi
72 insinto /$(get_libdir)/netifrc/net
73 newins "${FILESDIR}"/wireguard-openrc.sh wireguard.sh
74 }
75
76 pkg_postinst() {
77 - linux-mod_pkg_postinst
78 + if use kmod-src; then
79 + einfo
80 + einfo "You have enabled the kmod-src USE flag. This means that sources"
81 + einfo "are installed to ${ROOT}usr/src/wireguard instead of having the"
82 + einfo "kernel module compiled. You will need to compile the module"
83 + einfo "yourself. Most likely, you don't want this USE flag."
84 + einfo
85 + else
86 + linux-mod_pkg_postinst
87 + fi
88 ewarn
89 ewarn "This software is experimental and has not yet been released."
90 ewarn "As such, it may contain significant issues. Please do not file"
91
92 diff --git a/net-misc/wireguard/wireguard-9999.ebuild b/net-misc/wireguard/wireguard-9999.ebuild
93 index 642325b..b6e88c4 100644
94 --- a/net-misc/wireguard/wireguard-9999.ebuild
95 +++ b/net-misc/wireguard/wireguard-9999.ebuild
96 @@ -21,7 +21,7 @@ fi
97
98 LICENSE="GPL-2"
99 SLOT="0"
100 -IUSE="debug"
101 +IUSE="debug kmod-src"
102
103 DEPEND="net-libs/libmnl"
104 RDEPEND="${DEPEND}"
105 @@ -33,27 +33,43 @@ WARNING_PADATA="If you're running a multicore system you likely should enable CO
106 WARNING_IP6_NF_IPTABLES="If your kernel has CONFIG_IPV6, you need CONFIG_IP6_NF_IPTABLES; otherwise WireGuard will not insert."
107
108 pkg_setup() {
109 + use kmod-src && return
110 linux-mod_pkg_setup
111 kernel_is -lt 4 1 0 && die "This version of ${PN} requires Linux >= 4.1"
112 }
113
114 src_compile() {
115 use debug && BUILD_PARAMS="CONFIG_WIREGUARD_DEBUG=y ${BUILD_PARAMS}"
116 - linux-mod_src_compile
117 + use kmod-src || linux-mod_src_compile
118 emake RUNSTATEDIR="${EPREFIX}/run" -C src/tools
119 }
120
121 src_install() {
122 dodoc README.md
123 dodoc -r contrib/examples
124 - linux-mod_src_install
125 emake DESTDIR="${D}" PREFIX="${EPREFIX}/usr" -C src/tools install
126 + if use kmod-src; then
127 + dodir /usr/src
128 + rm -r "${WORKDIR}"/*/src/tools || die
129 + mv "${WORKDIR}"/*/src "${ED}"usr/src/wireguard || die
130 + else
131 + linux-mod_src_install
132 + fi
133 insinto /$(get_libdir)/netifrc/net
134 newins "${FILESDIR}"/wireguard-openrc.sh wireguard.sh
135 }
136
137 pkg_postinst() {
138 - linux-mod_pkg_postinst
139 + if use kmod-src; then
140 + einfo
141 + einfo "You have enabled the kmod-src USE flag. This means that sources"
142 + einfo "are installed to ${ROOT}usr/src/wireguard instead of having the"
143 + einfo "kernel module compiled. You will need to compile the module"
144 + einfo "yourself. Most likely, you don't want this USE flag."
145 + einfo
146 + else
147 + linux-mod_pkg_postinst
148 + fi
149 ewarn
150 ewarn "This software is experimental and has not yet been released."
151 ewarn "As such, it may contain significant issues. Please do not file"