aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2017-12-12 22:51:47 +0100
committerJason A. Donenfeld <Jason@zx2c4.com>2017-12-12 22:52:58 +0100
commitd78204a1b18f62ea9b1fb00ae68c5c91fd9ed981 (patch)
treec0d807332a1b06c36fafdcf12111638dfed4451b
parentDo not install addon.d if no directory (diff)
downloadandroid_kernel_wireguard-d78204a1b18f62ea9b1fb00ae68c5c91fd9ed981.tar.xz
android_kernel_wireguard-d78204a1b18f62ea9b1fb00ae68c5c91fd9ed981.zip
standalone-kernel: auto-commit and better .gitignore
-rwxr-xr-xstandalone-kernel/patch-kernel.sh26
1 files changed, 17 insertions, 9 deletions
diff --git a/standalone-kernel/patch-kernel.sh b/standalone-kernel/patch-kernel.sh
index e42ed6c..888d94a 100755
--- a/standalone-kernel/patch-kernel.sh
+++ b/standalone-kernel/patch-kernel.sh
@@ -1,18 +1,26 @@
#!/bin/bash
-cd "$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")"
-K="$1"
+FETCH_SCRIPT="$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")/fetch.sh"
+if ! cd "$1"; then
+ echo "$1 does not exist." >&2
+ exit 1
+fi
-if [[ ! -e $K/net/Kconfig ]]; then
+if [[ ! -e net/Kconfig ]]; then
echo "You must specify the location of kernel sources as the first argument." >&2
exit 1
fi
-[[ $(< "$K/net/Makefile") == *wireguard* ]] || sed -i "/^obj-\\\$(CONFIG_NETFILTER).*+=/a obj-\$(CONFIG_WIREGUARD) += wireguard/" "$K/net/Makefile"
-[[ $(< "$K/net/Kconfig") == *wireguard* ]] || sed -i "/^if INET\$/a source \"net/wireguard/Kconfig\"" "$K/net/Kconfig"
-[[ $(< "$K/.gitignore") == *wireguard* ]] || echo "net/wireguard/" >> "$K/.gitignore"
+[[ $(< 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
+
+cp "$FETCH_SCRIPT" scripts/fetch-latest-wireguard.sh
+chmod +x scripts/fetch-latest-wireguard.sh
-cp fetch.sh "$K/scripts/fetch-latest-wireguard.sh"
-chmod +x "$K/scripts/fetch-latest-wireguard.sh"
+[[ $(< scripts/Kbuild.include) == *fetch-latest-wireguard.sh* ]] || echo '$(shell cd "$(srctree)" && ./scripts/fetch-latest-wireguard.sh)' >> scripts/Kbuild.include
-[[ $(< "$K/scripts/Kbuild.include") == *fetch-latest-wireguard.sh* ]] || echo '$(shell cd "$(srctree)" && ./scripts/fetch-latest-wireguard.sh)' >> "$K/scripts/Kbuild.include"
+if [[ -d .git ]]; then
+ git add scripts/Kbuild.include scripts/fetch-latest-wireguard.sh net/.gitignore net/Kconfig net/Makefile
+ git commit -s -m "net/wireguard: add wireguard importer" scripts/Kbuild.include scripts/fetch-latest-wireguard.sh net/.gitignore net/Kconfig net/Makefile
+fi