summaryrefslogtreecommitdiff
path: root/user/netifrc
diff options
context:
space:
mode:
authorLee Starnes <lee@canned-death.us>2020-09-13 20:55:31 +0000
committerA. Wilcox <awilcox@wilcox-tech.com>2020-09-13 20:55:31 +0000
commitcf7e1ee8ae9060afb6d124712cc740fc9485acdd (patch)
treea6bd5a4605ad6047eee562615a7a7cef57336c7f /user/netifrc
parent1a1558f77106adeb93d6bcd8eea552b678e93f89 (diff)
downloadpackages-cf7e1ee8ae9060afb6d124712cc740fc9485acdd.tar.gz
packages-cf7e1ee8ae9060afb6d124712cc740fc9485acdd.tar.bz2
packages-cf7e1ee8ae9060afb6d124712cc740fc9485acdd.tar.xz
packages-cf7e1ee8ae9060afb6d124712cc740fc9485acdd.zip
user/netifrc: bump to 0.7.1; replace gawk w/ perl
net/l2tp.sh depends on the 3-argument match() provided by GNU awk, which mawk doesn't implement. Rather than rewrite this in mawk, which would be very hard, instead translate it to perl, which is in system. Also upgrade to 0.7.1.
Diffstat (limited to 'user/netifrc')
-rw-r--r--user/netifrc/APKBUILD11
-rw-r--r--user/netifrc/switch-l2tp-gawk-to-perl.patch92
2 files changed, 99 insertions, 4 deletions
diff --git a/user/netifrc/APKBUILD b/user/netifrc/APKBUILD
index 6749f98c7..01bd4ec96 100644
--- a/user/netifrc/APKBUILD
+++ b/user/netifrc/APKBUILD
@@ -1,17 +1,19 @@
# Contributor: A. Wilcox <awilfox@adelielinux.org>
+# Contrinutor: Lee Starnes <lee@canned-death.us>
# Maintainer: A. Wilcox <awilfox@adelielinux.org>
pkgname=netifrc
-pkgver=0.6.1
+pkgver=0.7.1
pkgrel=0
pkgdesc="User-friendly network interface management scripts for OpenRC"
url="https://www.gentoo.org/proj/en/base/openrc/"
arch="noarch"
options="!check" # No test suite.
license="BSD-2-Clause"
-depends="eudev openrc"
+depends="eudev openrc perl"
makedepends="eudev-dev pkgconf"
subpackages="$pkgname-doc $pkgname-openrc"
-source="https://gitweb.gentoo.org/proj/$pkgname.git/snapshot/$pkgname-$pkgver.tar.gz"
+source="https://gitweb.gentoo.org/proj/$pkgname.git/snapshot/$pkgname-$pkgver.tar.gz
+ switch-l2tp-gawk-to-perl.patch"
build() {
make UDEVDIR=/lib/udev LIBEXECDIR=/lib/$pkgname PF="$pkgname-$pkgver"
@@ -24,4 +26,5 @@ package() {
done
}
-sha512sums="798a882f87f153c31b415d77a06a2beca94a958ea982aca20bbc2cf6a7d800aedbd99a577734ea41d6a75807b13d640dd7fa5a51aa5a27055e9c552634ac7bdb netifrc-0.6.1.tar.gz"
+sha512sums="407071f8f58b7788703a62193677673ddd18114b69142894674337410473e620cf3895bb014cff133f719ac1a7191ac3bedfd969c9a11bf2f1c4b04d39683057 netifrc-0.7.1.tar.gz
+5fdd2d2c16dd0ba0ba629dfda50133d132b81afcd8e566c8b81cd3aee8e4a86f063d8ac7bc451fff31f77186a7b790a2e642acac8b44c51934f8332a9dc0bfbd switch-l2tp-gawk-to-perl.patch"
diff --git a/user/netifrc/switch-l2tp-gawk-to-perl.patch b/user/netifrc/switch-l2tp-gawk-to-perl.patch
new file mode 100644
index 000000000..9c8bc7e0c
--- /dev/null
+++ b/user/netifrc/switch-l2tp-gawk-to-perl.patch
@@ -0,0 +1,92 @@
+diff --git a/net/l2tp.sh b/net/l2tp.sh
+index 9644e32..24b081c 100644
+--- a/net/l2tp.sh
++++ b/net/l2tp.sh
+@@ -37,9 +37,20 @@ _is_l2tp() {
+ ip l2tp show session &>/dev/null
+ [ $? -ne 0 ] && return 1
+
+- eval "$(ip l2tp show session | \
+- awk "match(\$0, /^Session ([0-9]+) in tunnel ([0-9]+)\$/, ret) {sid=ret[1]; tid=ret[2]}
+- match(\$0, /^[ ]*interface name: ${IFACE}\$/) {print \"session_id=\"sid\";tunnel_id=\"tid; exit}")"
++ eval "$(ip l2tp show session | perl -E '
++my $sid;
++my $tid;
++my $IFACE=$ARGV[0];
++while (<STDIN>) {
++ if($_ =~ /^Session ([0-9]+) in tunnel ([0-9+])\$/) {
++ $sid = $1;
++ $tid = $2;
++ }
++ if ($_ =~ /^[ ]*interface name: $IFACE$/) {
++ say "session_id=" . $sid . ";" . "tunnel_id=" . $tid;
++ exit;
++ }
++}' $IFACE)"
+ test -n "$session_id"
+ }
+
+@@ -49,33 +60,36 @@ _is_l2tp() {
+ _l2tp_get_tunnel_info() {
+ local found
+ eval "$(ip l2tp show tunnel | \
+- awk -v id=$2 -v prefix=$1 '
+- match($0, /^Tunnel ([0-9]+), encap (IP|UDP)$/, ret) {
+- if (found == "1") exit;
+- if (ret[1] == id) {
+- print "found=1;"
+- print prefix "tunnel_id=" ret[1] ";"
+- print prefix "encap=" ret[2] ";";
+- found="1"
+- }
+- }
+- match($0, /^[ ]*From ([^ ]+) to ([^ ]+)$/, ret) {
+- if (found == "1") {
+- print prefix "local=" ret[1] ";";
+- print prefix "remote=" ret[2] ";";
+- }
+- }
+- match($0, /^[ ]*Peer tunnel ([0-9]+)$/, ret) {
+- if (found == "1") {
+- print prefix "peer_tunnel_id=" ret[1] ";";
+- }
+- }
+- match($0, /^[ ]*UDP source \/ dest ports: ([0-9]+)\/([0-9]+)$/, ret) {
+- if (found == "1") {
+- print prefix "udp_sport=" ret[1] ";";
+- print prefix "udp_dport=" ret[2] ";";
+- }
+- }')"
++ perl -E '
++my ($prefix, $id) = @ARGV;
++my $found = 0;
++while(<STDIN>) {
++ if ($_ =~ /^Tunnel ([0-9]+), encap (IP|UDP)$/) {
++ if ($found) {
++ exit;
++ }
++ elsif ($1 == $id) {
++ say "found=1;";
++ say $prefix . "tunnel_id=" . $1 . ";";
++ say $prefix . "encap=" . $2 . ";";
++ $found = 1;
++ }
++ }
++ elsif ($found) {
++ if ($_ =~ /^[ ]*From ([^ ]+) to ([^ \n]+)$/) {
++ say $prefix . "local=" . $1 . ";";
++ say $prefix . "remote=" . $2 . ";";
++ }
++ elsif ($_ =~ /^[ ]*Peer tunnel ([0-9]+)$/) {
++ say $prefix . "peer_tunnel_id=" . $1 . ";";
++ }
++ elsif ($_ =~ /^[ ]*UDP source \/ dest ports: ([0-9]+)\/([0-9]+)$/) {
++ say $prefix . "udp_sport=" . $1 . ";";
++ say $prefix . "udp_dport=" . $2 . ";";
++ }
++ }
++}
++ ' "$1" "$2")"
+ test -n "$found"
+ }
+