From 4472d4ff70c85a6b76bc1f9998e3124098d4a2be Mon Sep 17 00:00:00 2001 From: Sushrut1101 Date: Thu, 12 May 2022 16:47:37 +0530 Subject: [PATCH] Add OF_USE_LATEST_MAGISK Signed-off-by: Sushrut1101 --- config.sh | 4 ++++ scripts/build.sh | 6 ++++++ scripts/sync.sh | 14 ++++++++++++++ 3 files changed, 24 insertions(+) diff --git a/config.sh b/config.sh index e3d8df93..7fed1f48 100644 --- a/config.sh +++ b/config.sh @@ -23,6 +23,10 @@ export OUTPUT="OrangeFox*.zip" # Extra Command export EXTRA_CMD="git clone https://github.com/OrangeFoxRecovery/Avatar.git misc" +# Magisk +## Use the Latest Release of Magisk for the OrangeFox addon +OF_USE_LATEST_MAGISK=true + # Not Recommended to Change export SYNC_PATH="$HOME/work" # Full (absolute) path. export USE_CCACHE=1 diff --git a/scripts/build.sh b/scripts/build.sh index 98daab36..5cd22ade 100644 --- a/scripts/build.sh +++ b/scripts/build.sh @@ -72,6 +72,12 @@ fi # Set BRANCH_INT variable for future use BRANCH_INT=$(echo $SYNC_BRANCH | cut -d. -f1) +# Magisk +if [[ $OF_USE_LATEST_MAGISK = "true" || $OF_USE_LATEST_MAGISK = "1" ]]; then + echo "Using the Latest Release of Magisk..." + export FOX_USE_SPECIFIC_MAGISK_ZIP="~/Magisk/$(ls ~/Magisk/Magisk*.zip)" +fi + # Legacy Build Systems if [ $BRANCH_INT -le 6 ]; then export OF_DISABLE_KEYMASTER2=1 # Disable Keymaster2 diff --git a/scripts/sync.sh b/scripts/sync.sh index f364a6f7..ca0a08a4 100644 --- a/scripts/sync.sh +++ b/scripts/sync.sh @@ -55,5 +55,19 @@ git clone $DT_LINK $DT_PATH || { echo "ERROR: Failed to Clone the Device Trees!" # only if the Kernel Source is Specified in the Config [ ! -z "$KERNEL_SOURCE" ] && git clone --depth=1 --single-branch $KERNEL_SOURCE $KERNEL_PATH +# Magisk +if [[ $OF_USE_LATEST_MAGISK = "true" || $OF_USE_LATEST_MAGISK = "1" ]]; then + echo "Downloading the Latest Release of Magisk..." + LATEST_MAGISK_URL="$(curl -sL https://api.github.com/repos/topjohnwu/Magisk/releases/latest | jq -r . | grep browser_download_url | grep Magisk- | cut -d : -f 2,3 | sed 's/"//g')" + mkdir -p ~/Magisk + cd ~/Magisk + aria2c $LATEST_MAGISK_URL 2>&1 || wget $LATEST_MAGISK_URL 2>&1 + echo "Magisk Downloaded Successfully" + echo "Renaming .apk to .zip ..." + rename 's/.apk/.zip/' Magisk* + cd $SYNC_PATH >/dev/null + echo "Done!" +fi + # Exit exit 0