Gentoo Archives: gentoo-commits

From: Artemis Everfree <artemis@×××××××.sh>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/proj/guru:dev commit in: net-vpn/fastd/files/, net-vpn/fastd/
Date: Wed, 01 Feb 2023 00:10:42
Message-Id: 1675210216.024e170cd96c3e0e537109affbb591e8e11ab17b.artemis@gentoo
1 commit: 024e170cd96c3e0e537109affbb591e8e11ab17b
2 Author: Artemis Everfree <artemis <AT> artemis <DOT> sh>
3 AuthorDate: Wed Feb 1 00:04:08 2023 +0000
4 Commit: Artemis Everfree <artemis <AT> artemis <DOT> sh>
5 CommitDate: Wed Feb 1 00:10:16 2023 +0000
6 URL: https://gitweb.gentoo.org/repo/proj/guru.git/commit/?id=024e170c
7
8 net-vpn/fastd: new package, add 22
9
10 Signed-off-by: Artemis Everfree <artemis <AT> artemis.sh>
11
12 net-vpn/fastd/Manifest | 1 +
13 net-vpn/fastd/fastd-22.ebuild | 73 ++++++++++++++++++++++++++++++++++++++++++
14 net-vpn/fastd/files/fastd.init | 55 +++++++++++++++++++++++++++++++
15 net-vpn/fastd/metadata.xml | 16 +++++++++
16 4 files changed, 145 insertions(+)
17
18 diff --git a/net-vpn/fastd/Manifest b/net-vpn/fastd/Manifest
19 new file mode 100644
20 index 000000000..78d7a7b42
21 --- /dev/null
22 +++ b/net-vpn/fastd/Manifest
23 @@ -0,0 +1 @@
24 +DIST fastd-22.tar.xz 161288 BLAKE2B 25c741a0fe1ff4d8f02ee932301cc0bf58ff65cb95d4f53a49b2ef691d8531a917c1fea5b93f796dc0151ebeea3edd2b0c97e1ea5649ef2dfa4043b489c945eb SHA512 66196fa13c93b87b78b9e31bc267cf616dcfb4a964387c4a3f0f3176fa1529be335a6fac91379038d6a8b1a1be4fea547659551a8a9fa8d6939589d5f8a9a7aa
25
26 diff --git a/net-vpn/fastd/fastd-22.ebuild b/net-vpn/fastd/fastd-22.ebuild
27 new file mode 100644
28 index 000000000..789e8b99d
29 --- /dev/null
30 +++ b/net-vpn/fastd/fastd-22.ebuild
31 @@ -0,0 +1,73 @@
32 +# Copyright 1999-2023 Gentoo Authors
33 +#
34 +# Distributed under the terms of the GNU General Public License v2
35 +
36 +EAPI=8
37 +inherit linux-info meson systemd
38 +
39 +DESCRIPTION="A very small VPN daemon which tunnels IP packets and Ethernet frames over UDP."
40 +HOMEPAGE="https://fastd.readthedocs.io/"
41 +SRC_URI="https://github.com/NeoRaider/fastd/releases/download/v${PV}/${P}.tar.xz"
42 +
43 +# while source COPYRIGHT also mentions LGPLv2.1+, that only applies to
44 +# vendored libmnl. we are using system libmnl.
45 +LICENSE="BSD BSD-2"
46 +
47 +SLOT="0"
48 +KEYWORDS="~amd64 ~arm64"
49 +IUSE="+caps doc offload-l2tp systemd test"
50 +RESTRICT="!test? ( test )"
51 +
52 +RDEPEND="
53 +>=net-libs/libuecc-6
54 +dev-libs/json-c
55 +dev-libs/libsodium
56 +dev-libs/openssl
57 +offload-l2tp? ( net-libs/libmnl )
58 +caps? ( sys-libs/libcap )
59 +test? ( dev-util/cmocka )
60 +"
61 +DEPEND="${RDEPEND}"
62 +BDEPEND="
63 +sys-devel/bison
64 +doc? ( dev-python/sphinx )
65 +"
66 +IDEPEND=""
67 +
68 +pkg_setup() {
69 + if use offload-l2tp; then
70 + CONFIG_CHECK="~L2TP ~L2TP_V3 ~L2TP_ETH"
71 + declare -g ERROR_L2TP="CONFIG_L2TP isn't set. Offloading L2TP to kernel will not work."
72 + declare -g ERROR_L2TP_V3="CONFIG_L2TP_V3 isn't set. Offloading L2TP to kernel will not work."
73 + declare -g ERROR_L2TP_ETH="CONFIG_L2TP_ETH isn't set. Offloading L2TP to kernel will not work."
74 + linux-info_pkg_setup
75 + fi
76 +}
77 +
78 +src_configure() {
79 + local emesonargs=(
80 + $(meson_feature caps capabilities)
81 + $(meson_feature offload-l2tp offload_l2tp)
82 + $(meson_feature systemd)
83 + $(meson_use test build_tests)
84 + -Dlibmnl_builtin=false
85 + )
86 + meson_src_configure
87 +}
88 +
89 +src_compile() {
90 + meson_src_compile
91 + if use doc; then
92 + einfo "Building documentation ..."
93 + local doc_dir="${S}/doc"
94 + cd "${doc_dir}" || die "Cannot chdir into \"${doc_dir}\"!"
95 + emake man || die "Building documentation failed!"
96 + fi
97 +}
98 +
99 +src_install() {
100 + meson_src_install
101 + systemd_dounit "doc/examples/fastd@.service"
102 + newinitd "${FILESDIR}/fastd.init" fastd
103 + use doc && doman doc/build/man/*
104 +}
105
106 diff --git a/net-vpn/fastd/files/fastd.init b/net-vpn/fastd/files/fastd.init
107 new file mode 100644
108 index 000000000..9f93c7a81
109 --- /dev/null
110 +++ b/net-vpn/fastd/files/fastd.init
111 @@ -0,0 +1,55 @@
112 +#!/sbin/openrc-run
113 +# Copyright 2023 Gentoo Authors
114 +#
115 +# Distributed under the terms of the GNU General Public License v2
116 +
117 +name="fastd"
118 +description="fastd (Fast and Secure Tunnelling Daemon)"
119 +
120 +# usage would be i.e. fastd.my_vpn
121 +IFACE="${RC_SVCNAME#*.}"
122 +
123 +command="/usr/bin/fastd"
124 +command_args="--syslog-level info --syslog-ident fastd.${IFACE} --config /etc/fastd/${IFACE}/fastd.conf"
125 +pidfile="/run/${RC_SVCNAME}.pid"
126 +command_args_background="--daemon --pid-file ${pidfile}"
127 +
128 +depend() {
129 + need net
130 + use dns
131 +}
132 +
133 +extra_commands="checkconfig"
134 +checkconfig() {
135 + if [ "${IFACE}" = "${RC_SVCNAME}" ]; then
136 + eerror "You cannot call this init script directly. You must create a symbolic link to it with the configuration name:"
137 + eerror " mkdir -p /etc/fastd/my_vpn"
138 + eerror " nano /etc/fastd/my_vpn/fastd.conf"
139 + eerror " ln -s /etc/init.d/fastd /etc/init.d/fastd.my_vpn"
140 + eerror "And then call it instead:"
141 + eerror " /etc/init.d/fastd.my_vpn start"
142 + return 1
143 + fi
144 + fastd --config "/etc/fastd/${IFACE}/fastd.conf" --verify-config
145 +}
146 +
147 +start_pre() {
148 + # If this isn't a restart, make sure that the user's config isn't
149 + # busted before we try to start the daemon (this will produce
150 + # better error messages than if we just try to start it blindly).
151 + #
152 + # If, on the other hand, this *is* a restart, then the stop_pre
153 + # action will have ensured that the config is usable and we don't
154 + # need to do that again.
155 + if [ "${RC_CMD}" != "restart" ] ; then
156 + checkconfig || return $?
157 + fi
158 +}
159 +
160 +stop_pre() {
161 + # If this is a restart, check to make sure the user's config
162 + # isn't busted before we stop the running daemon.
163 + if [ "${RC_CMD}" = "restart" ] ; then
164 + checkconfig || return $?
165 + fi
166 +}
167
168 diff --git a/net-vpn/fastd/metadata.xml b/net-vpn/fastd/metadata.xml
169 new file mode 100644
170 index 000000000..e549fbf6f
171 --- /dev/null
172 +++ b/net-vpn/fastd/metadata.xml
173 @@ -0,0 +1,16 @@
174 +<?xml version="1.0" encoding="UTF-8"?>
175 +<!DOCTYPE pkgmetadata SYSTEM "https://www.gentoo.org/dtd/metadata.dtd">
176 +<pkgmetadata>
177 + <maintainer type="person">
178 + <email>artemis@×××××××.sh</email>
179 + <description>Primary maintainer</description>
180 + <name>Artemis Everfree</name>
181 + </maintainer>
182 + <upstream>
183 + <remote-id type="github">NeoRaider/fastd</remote-id>
184 + </upstream>
185 + <use>
186 + <flag name="offload-l2tp">Offload L2TP traffic to the kernel when using the null@l2tp transport method</flag>
187 + <flag name="doc">Build and install manpages</flag>
188 + </use>
189 +</pkgmetadata>