From 954e06bbcced365807cc23d8f1174ebfa193babb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=82=BB=E3=83=AA=E3=82=AB=E3=83=BB=E3=82=B7=E3=83=AB?= =?UTF-8?q?=E3=83=95=E3=82=A3=E3=83=AB?= <64072399+natsumerinchan@users.noreply.github.com> Date: Thu, 12 Jan 2023 17:09:55 +0800 Subject: [PATCH] Make setup script support non-GKI kernel (#47) --- kernel/setup.sh | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/kernel/setup.sh b/kernel/setup.sh index 70a4c9df..cc6d3fbf 100755 --- a/kernel/setup.sh +++ b/kernel/setup.sh @@ -2,18 +2,33 @@ set -x -git clone https://github.com/tiann/KernelSU - GKI_ROOT=$(pwd) echo "[+] GKI_ROOT: $GKI_ROOT" -echo "[+] Copy kernel su driver to $GKI_ROOT/common/drivers" -ln -sf $(pwd)/KernelSU/kernel $GKI_ROOT/common/drivers/kernelsu +if test -d "$GKI_ROOT/common/drivers"; then + DRIVER_DIR="$GKI_ROOT/common/drivers" +elif test -d "$GKI_ROOT/drivers"; then + DRIVER_DIR="$GKI_ROOT/drivers" +else + echo "[ERROR] "drivers/" directory is not found." + echo "[+] You should modify this scrpit by yourself." + exit 127 +fi + +test -d "$GKI_ROOT/KernelSU" || git clone https://github.com/tiann/KernelSU +cd "$GKI_ROOT/KernelSU" +git stash && git pull +cd "$GKI_ROOT" + +echo "[+] GKI_ROOT: $GKI_ROOT" +echo "[+] Copy kernel su driver to $DRIVER_DIR" + +test -e "$DRIVER_DIR/kernelsu" || ln -sf "$GKI_ROOT/KernelSU/kernel" "$DRIVER_DIR/kernelsu" echo "[+] Add kernel su driver to Makefile" -DRIVER_MAKEFILE=$GKI_ROOT/common/drivers/Makefile +DRIVER_MAKEFILE=$DRIVER_DIR/Makefile grep -q "kernelsu" $DRIVER_MAKEFILE || echo "obj-y += kernelsu/" >> $DRIVER_MAKEFILE echo "[+] Done."