2022-08-26 00:20:49 +08:00
|
|
|
#!/bin/bash
|
2022-08-29 16:29:54 +08:00
|
|
|
#
|
2022-08-24 01:54:24 +08:00
|
|
|
# This file is part of MagiskOnWSALocal.
|
|
|
|
#
|
|
|
|
# MagiskOnWSALocal is free software: you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU Affero General Public License as
|
|
|
|
# published by the Free Software Foundation, either version 3 of the
|
|
|
|
# License, or (at your option) any later version.
|
|
|
|
#
|
|
|
|
# MagiskOnWSALocal is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU Affero General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU Affero General Public License
|
|
|
|
# along with MagiskOnWSALocal. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
#
|
2023-01-11 09:49:14 +01:00
|
|
|
# Copyright (C) 2023 LSPosed Contributors
|
2022-08-24 01:54:24 +08:00
|
|
|
#
|
2022-08-29 16:29:54 +08:00
|
|
|
|
|
|
|
# DEBUG=--debug
|
|
|
|
# CUSTOM_MAGISK=--magisk-custom
|
2022-09-04 00:43:31 +08:00
|
|
|
if [ ! "$BASH_VERSION" ]; then
|
2022-08-23 16:32:34 +08:00
|
|
|
echo "Please do not use sh to run this script, just execute it directly" 1>&2
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
cd "$(dirname "$0")" || exit 1
|
2022-09-05 13:41:13 +08:00
|
|
|
|
2023-04-12 15:13:57 +02:00
|
|
|
./install_deps.sh || exit 1
|
2022-09-05 13:41:13 +08:00
|
|
|
|
2022-09-23 16:31:12 +08:00
|
|
|
WHIPTAIL=$(command -v whiptail 2>/dev/null)
|
|
|
|
DIALOG=$(command -v dialog 2>/dev/null)
|
2022-09-23 16:43:50 +08:00
|
|
|
DIALOG=${WHIPTAIL:-$DIALOG}
|
2022-08-14 10:43:35 +08:00
|
|
|
function Radiolist {
|
|
|
|
declare -A o="$1"
|
|
|
|
shift
|
2022-09-23 16:31:12 +08:00
|
|
|
if ! $DIALOG --nocancel --radiolist "${o[title]}" 0 0 0 "$@" 3>&1 1>&2 2>&3; then
|
2022-08-14 10:43:35 +08:00
|
|
|
echo "${o[default]}"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
function YesNoBox {
|
|
|
|
declare -A o="$1"
|
|
|
|
shift
|
2022-09-23 16:31:12 +08:00
|
|
|
$DIALOG --title "${o[title]}" --yesno "${o[text]}" 0 0
|
2022-08-14 10:43:35 +08:00
|
|
|
}
|
|
|
|
|
2023-03-29 20:05:27 +08:00
|
|
|
function DialogBox {
|
|
|
|
declare -A o="$1"
|
|
|
|
shift
|
|
|
|
$DIALOG --title "${o[title]}" --msgbox "${o[text]}" 0 0
|
|
|
|
}
|
|
|
|
intro="Welcome to MagiskOnWSA!
|
|
|
|
|
|
|
|
With this utility, you can integrate Magisk for WSA easily.
|
|
|
|
Use arrow keys to navigate, and press space to select.
|
|
|
|
Press enter to confirm.
|
|
|
|
"
|
|
|
|
DialogBox "([title]='Intro to MagiskOnWSA' \
|
|
|
|
[text]='$intro')"
|
|
|
|
|
2022-08-14 10:43:35 +08:00
|
|
|
ARCH=$(
|
|
|
|
Radiolist '([title]="Build arch"
|
|
|
|
[default]="x64")' \
|
|
|
|
'x64' "X86_64" 'on' \
|
|
|
|
'arm64' "AArch64" 'off'
|
|
|
|
)
|
|
|
|
|
|
|
|
RELEASE_TYPE=$(
|
|
|
|
Radiolist '([title]="WSA release type"
|
|
|
|
[default]="retail")' \
|
|
|
|
'retail' "Stable Channel" 'on' \
|
|
|
|
'release preview' "Release Preview Channel" 'off' \
|
|
|
|
'insider slow' "Beta Channel" 'off' \
|
|
|
|
'insider fast' "Dev Channel" 'off'
|
|
|
|
)
|
2022-08-30 21:59:26 +08:00
|
|
|
|
2023-03-19 19:34:31 +08:00
|
|
|
if (YesNoBox '([title]="Root" [text]="Do you want to Root WSA?")'); then
|
|
|
|
ROOT_SOL=$(
|
|
|
|
Radiolist '([title]="Root solution"
|
|
|
|
[default]="magisk")' \
|
|
|
|
'magisk' "Magisk" 'on' \
|
|
|
|
'kernelsu' "KernelSU" 'off'
|
|
|
|
)
|
|
|
|
else
|
|
|
|
ROOT_SOL="none"
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ "$ROOT_SOL" = "magisk" ]; then
|
2022-08-26 03:54:13 +08:00
|
|
|
MAGISK_VER=$(
|
|
|
|
Radiolist '([title]="Magisk version"
|
2023-03-19 19:34:31 +08:00
|
|
|
[default]="stable")' \
|
2022-08-26 03:54:13 +08:00
|
|
|
'stable' "Stable Channel" 'on' \
|
|
|
|
'beta' "Beta Channel" 'off' \
|
|
|
|
'canary' "Canary Channel" 'off' \
|
|
|
|
'debug' "Canary Channel Debug Build" 'off'
|
|
|
|
)
|
|
|
|
else
|
2023-04-10 22:34:49 +08:00
|
|
|
MAGISK_VER=""
|
2022-08-26 03:54:13 +08:00
|
|
|
fi
|
2022-08-14 12:48:47 +08:00
|
|
|
|
2022-08-25 03:16:13 +09:00
|
|
|
if (YesNoBox '([title]="Install GApps" [text]="Do you want to install GApps?")'); then
|
2022-09-10 15:40:21 +09:00
|
|
|
GAPPS_BRAND=$(
|
|
|
|
Radiolist '([title]="Which GApps do you want to install?"
|
2023-03-19 19:34:31 +08:00
|
|
|
[default]="MindTheGapps")' \
|
|
|
|
'MindTheGapps' "Recommend" 'on' \
|
|
|
|
'OpenGApps' "This flavor may cause startup failure" 'off'
|
2022-09-10 15:40:21 +09:00
|
|
|
)
|
2022-08-14 12:48:47 +08:00
|
|
|
else
|
2022-09-01 10:40:35 +08:00
|
|
|
GAPPS_BRAND="none"
|
2022-08-14 12:48:47 +08:00
|
|
|
fi
|
2023-04-10 22:34:49 +08:00
|
|
|
|
2023-01-02 15:51:04 +08:00
|
|
|
if [ "$GAPPS_BRAND" = "OpenGApps" ]; then
|
2022-08-26 03:28:43 +08:00
|
|
|
# TODO: Keep it pico since other variants of opengapps are unable to boot successfully
|
|
|
|
if [ "$DEBUG" = "1" ]; then
|
2023-03-19 19:34:31 +08:00
|
|
|
GAPPS_VARIANT=$(
|
|
|
|
Radiolist '([title]="Variants of GApps"
|
|
|
|
[default]="pico")' \
|
|
|
|
'super' "" 'off' \
|
|
|
|
'stock' "" 'off' \
|
|
|
|
'full' "" 'off' \
|
|
|
|
'mini' "" 'off' \
|
|
|
|
'micro' "" 'off' \
|
|
|
|
'nano' "" 'off' \
|
|
|
|
'pico' "" 'on' \
|
|
|
|
'tvstock' "" 'off' \
|
|
|
|
'tvmini' "" 'off'
|
|
|
|
)
|
2022-08-26 03:28:43 +08:00
|
|
|
else
|
2023-04-10 22:34:49 +08:00
|
|
|
GAPPS_VARIANT=""
|
2022-08-26 03:28:43 +08:00
|
|
|
fi
|
2022-08-14 10:43:35 +08:00
|
|
|
else
|
2023-04-10 22:34:49 +08:00
|
|
|
GAPPS_VARIANT=""
|
2022-08-14 10:43:35 +08:00
|
|
|
fi
|
|
|
|
|
2022-09-03 13:32:52 +09:00
|
|
|
if (YesNoBox '([title]="Remove Amazon Appstore" [text]="Do you want to keep Amazon Appstore?")'); then
|
2022-08-29 16:29:54 +08:00
|
|
|
REMOVE_AMAZON=""
|
2022-08-14 15:03:17 +08:00
|
|
|
else
|
2022-08-29 16:29:54 +08:00
|
|
|
REMOVE_AMAZON="--remove-amazon"
|
2022-08-14 10:43:35 +08:00
|
|
|
fi
|
|
|
|
|
2022-08-21 22:33:07 +02:00
|
|
|
if (YesNoBox '([title]="Compress output" [text]="Do you want to compress the output?")'); then
|
2022-08-29 16:29:54 +08:00
|
|
|
COMPRESS_OUTPUT="--compress"
|
2022-08-21 22:33:07 +02:00
|
|
|
else
|
2022-08-29 16:29:54 +08:00
|
|
|
COMPRESS_OUTPUT=""
|
2022-08-21 22:33:07 +02:00
|
|
|
fi
|
2022-10-22 01:03:02 +08:00
|
|
|
if [ "$COMPRESS_OUTPUT" = "--compress" ]; then
|
|
|
|
COMPRESS_FORMAT=$(
|
|
|
|
Radiolist '([title]="Compress format"
|
2023-03-19 19:34:31 +08:00
|
|
|
[default]="7z")' \
|
2022-10-22 01:03:02 +08:00
|
|
|
'7z' "7-Zip" 'on' \
|
2023-03-26 22:44:33 +08:00
|
|
|
'zip' "Zip" 'off'
|
2023-03-19 19:34:31 +08:00
|
|
|
)
|
2022-10-22 01:03:02 +08:00
|
|
|
fi
|
2023-03-19 19:34:31 +08:00
|
|
|
|
2022-08-14 10:43:35 +08:00
|
|
|
clear
|
2022-08-30 23:57:26 +08:00
|
|
|
declare -A RELEASE_TYPE_MAP=(["retail"]="retail" ["release preview"]="RP" ["insider slow"]="WIS" ["insider fast"]="WIF")
|
2023-04-10 22:34:49 +08:00
|
|
|
COMMAND_LINE=(--arch "$ARCH" --release-type "${RELEASE_TYPE_MAP[$RELEASE_TYPE]}" --root-sol "$ROOT_SOL" --gapps-brand "$GAPPS_BRAND")
|
|
|
|
CHECK_NULL_LIST=("$REMOVE_AMAZON" "$COMPRESS_OUTPUT" "$OFFLINE" "$DEBUG" "$CUSTOM_MAGISK")
|
|
|
|
for i in "${CHECK_NULL_LIST[@]}"; do
|
|
|
|
if [ -n "$i" ]; then
|
|
|
|
COMMAND_LINE+=("$i")
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
|
|
|
if [ -n "$MAGISK_VER" ]; then
|
|
|
|
COMMAND_LINE+=(--magisk-ver "$MAGISK_VER")
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -n "$GAPPS_VARIANT" ]; then
|
|
|
|
COMMAND_LINE+=(--gapps-variant "$GAPPS_VARIANT")
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -n "$COMPRESS_FORMAT" ]; then
|
|
|
|
COMMAND_LINE+=(--compress-format "$COMPRESS_FORMAT")
|
|
|
|
fi
|
|
|
|
|
2022-08-29 16:29:54 +08:00
|
|
|
echo "COMMAND_LINE=${COMMAND_LINE[*]}"
|
2023-04-07 01:57:41 +08:00
|
|
|
chmod +x ./build.sh
|
2022-08-29 16:29:54 +08:00
|
|
|
./build.sh "${COMMAND_LINE[@]}"
|