diff options
-rwxr-xr-x | standalone-kernel/patch-kernel.sh | 26 |
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 |