aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2018-06-26 01:13:58 +0200
committerJason A. Donenfeld <Jason@zx2c4.com>2018-06-26 01:13:58 +0200
commitfc9bd6fb9084b3e512c8497a62545cb69d191be7 (patch)
tree2ed04ecc32058436a2e0c633cb688d29bf3b1130
parentpatch-kernel: only allow one execution at a time, with others failing open (diff)
downloadandroid_kernel_wireguard-fc9bd6fb9084b3e512c8497a62545cb69d191be7.tar.xz
android_kernel_wireguard-fc9bd6fb9084b3e512c8497a62545cb69d191be7.zip
patch-kernel: more reliable version selection
-rw-r--r--fetch.sh15
1 files changed, 11 insertions, 4 deletions
diff --git a/fetch.sh b/fetch.sh
index 4b00f43..dd6ed4d 100644
--- a/fetch.sh
+++ b/fetch.sh
@@ -1,21 +1,28 @@
#!/bin/bash
set -e
-USER_AGENT="WireGuard-AndroidROMBuild/0.1 ($(uname -a))"
+USER_AGENT="WireGuard-AndroidROMBuild/0.2 ($(uname -a))"
exec 9>.wireguard-fetch-lock
flock -n 9 || exit 0
[[ $(( $(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 ]]
+while read -r distro package version _; do
+ if [[ $distro == upstream && $package == kmodtools ]]; then
+ VERSION="$version"
+ break
+ fi
+done < <(curl -A "$USER_AGENT" -LSs https://build.wireguard.com/distros.txt)
-if [[ -f net/wireguard/version.h && $(< net/wireguard/version.h) == *${BASH_REMATCH[1]}* ]]; then
+[[ -n $VERSION ]]
+
+if [[ -f net/wireguard/version.h && $(< net/wireguard/version.h) == *$VERSION* ]]; 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"
+curl -A "$USER_AGENT" -LsS "https://git.zx2c4.com/WireGuard/snapshot/WireGuard-$VERSION.tar.xz" | tar -C "net/wireguard" -xJf - --strip-components=2 "WireGuard-$VERSION/src"
sed -i 's/tristate/bool/;s/default m/default y/;' net/wireguard/Kconfig
touch net/wireguard/.check