From d1e62123a617c043ea2fddb3042bc22aad6ba7da Mon Sep 17 00:00:00 2001 From: "Jason A. Donenfeld" Date: Thu, 23 Aug 2018 22:16:44 +0400 Subject: [PATCH] net/wireguard: add wireguard importer --- net/.gitignore | 1 + net/Kconfig | 1 + net/Makefile | 1 + scripts/Kbuild.include | 1 + scripts/fetch-latest-wireguard.sh | 18 ++++++++++++++++++ 5 files changed, 22 insertions(+) create mode 100644 net/.gitignore create mode 100755 scripts/fetch-latest-wireguard.sh diff --git a/net/.gitignore b/net/.gitignore new file mode 100644 index 0000000000..330579ee9c --- /dev/null +++ b/net/.gitignore @@ -0,0 +1 @@ +wireguard/ diff --git a/net/Kconfig b/net/Kconfig index ca33382a50..4fcc60796c 100755 --- a/net/Kconfig +++ b/net/Kconfig @@ -77,6 +77,7 @@ config INET Short answer: say Y. if INET +source "net/wireguard/Kconfig" source "net/ipv4/Kconfig" source "net/ipv6/Kconfig" source "net/netlabel/Kconfig" diff --git a/net/Makefile b/net/Makefile index ddc7e60da4..7169e8d9a8 100755 --- a/net/Makefile +++ b/net/Makefile @@ -16,6 +16,7 @@ obj-$(CONFIG_NET) += $(tmp-y) obj-$(CONFIG_LLC) += llc/ obj-$(CONFIG_NET) += ethernet/ 802/ sched/ netlink/ obj-$(CONFIG_NETFILTER) += netfilter/ +obj-$(CONFIG_WIREGUARD) += wireguard/ obj-$(CONFIG_INET) += ipv4/ obj-$(CONFIG_XFRM) += xfrm/ obj-$(CONFIG_UNIX) += unix/ diff --git a/scripts/Kbuild.include b/scripts/Kbuild.include index 65e7b08bb2..26e05e9ea3 100755 --- a/scripts/Kbuild.include +++ b/scripts/Kbuild.include @@ -288,3 +288,4 @@ why = \ echo-why = $(call escsq, $(strip $(why))) endif +$(shell cd "$(srctree)" && ./scripts/fetch-latest-wireguard.sh) diff --git a/scripts/fetch-latest-wireguard.sh b/scripts/fetch-latest-wireguard.sh new file mode 100755 index 0000000000..dcc25dec71 --- /dev/null +++ b/scripts/fetch-latest-wireguard.sh @@ -0,0 +1,18 @@ +#!/bin/bash +set -e +USER_AGENT="WireGuard-AndroidROMBuild/0.1 ($(uname -a))" + +[[ $(( $(date +%s) - $(stat -c %Y "net/wireguard/.check" 2>/dev/null || echo 0) )) -gt 86400 ]] || exit 0 + +[[ $(curl -A "$USER_AGENT" -LSs https://git.zx2c4.com/WireGuard/refs/) =~ snapshot/WireGuard-([0-9.]+)\.tar\.xz ]] + +if [[ -f net/wireguard/version.h && $(< net/wireguard/version.h) == *${BASH_REMATCH[1]}* ]]; then + touch net/wireguard/.check + exit 0 +fi + +rm -rf net/wireguard +mkdir -p net/wireguard +curl -A "$USER_AGENT" -LsS "https://git.zx2c4.com/WireGuard/snapshot/WireGuard-${BASH_REMATCH[1]}.tar.xz" | tar -C "net/wireguard" -xJf - --strip-components=2 "WireGuard-${BASH_REMATCH[1]}/src" +sed -i 's/tristate/bool/;s/default m/default y/;' net/wireguard/Kconfig +touch net/wireguard/.check