aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2017-12-14 00:17:26 +0100
committerJason A. Donenfeld <Jason@zx2c4.com>2017-12-14 00:17:26 +0100
commitd33d95dac67041d943f333144b59d7107be272f4 (patch)
treef56a3966750c31c2af84e939f531479eb7aba93f
parentstandalone-tools: more error handling (diff)
downloadandroid_kernel_wireguard-d33d95dac67041d943f333144b59d7107be272f4.tar.xz
android_kernel_wireguard-d33d95dac67041d943f333144b59d7107be272f4.zip
standalone-kernel: don't patch <3.10 kernels
-rwxr-xr-xstandalone-kernel/patch-kernel.sh9
1 files changed, 9 insertions, 0 deletions
diff --git a/standalone-kernel/patch-kernel.sh b/standalone-kernel/patch-kernel.sh
index 888d94a..206ea32 100755
--- a/standalone-kernel/patch-kernel.sh
+++ b/standalone-kernel/patch-kernel.sh
@@ -11,6 +11,15 @@ if [[ ! -e net/Kconfig ]]; then
exit 1
fi
+if ! [[ $(< Makefile) =~ VERSION[[:space:]]*=[[:space:]]*([0-9]+).*PATCHLEVEL[[:space:]]*=[[:space:]]*([0-9]+).*SUBLEVEL[[:space:]]*=[[:space:]]*([0-9]+) ]]; then
+ echo "Unable to parse kernel Makefile." >&2
+ exit 1
+fi
+if (( ((${BASH_REMATCH[1]} * 65536) + (${BASH_REMATCH[2]} * 256) + ${BASH_REMATCH[3]}) < ((3 * 65536) + (10 * 256) + 0) )); then
+ echo "WireGuard requires kernels >= 3.10. This is kernel ${BASH_REMATCH[1]}.${BASH_REMATCH[2]}.${BASH_REMATCH[3]}."
+ exit 1
+fi
+
[[ $(< net/Makefile) == *wireguard* ]] || sed -i "/^obj-\\\$(CONFIG_NETFILTER).*+=/a obj-\$(CONFIG_WIREGUARD) += wireguard/" net/Makefile
[[ $(< net/Kconfig) == *wireguard* ]] || sed -i "/^if INET\$/a source \"net/wireguard/Kconfig\"" net/Kconfig
[[ -f net/.gitignore && $(< net/.gitignore) == *wireguard* ]] || echo "wireguard/" >> net/.gitignore