2022-08-25 18:20:49 +02:00
|
|
|
#!/bin/bash
|
2022-08-29 10:29:54 +02:00
|
|
|
#
|
2022-08-23 19:54:24 +02: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/>.
|
|
|
|
#
|
|
|
|
# Copyright (C) 2022 LSPosed Contributors
|
|
|
|
#
|
2022-08-29 10:29:54 +02:00
|
|
|
|
|
|
|
# DEBUG=--debug
|
|
|
|
# CUSTOM_MAGISK=--magisk-custom
|
2022-08-30 15:59:26 +02:00
|
|
|
|
2022-09-03 16:26:38 +02:00
|
|
|
DOWNLOAD_DIR=../download
|
|
|
|
|
2022-09-03 18:43:31 +02:00
|
|
|
if [ ! "$BASH_VERSION" ]; then
|
2022-08-23 10:32:34 +02: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-08-29 10:29:54 +02:00
|
|
|
|
2022-09-03 18:43:31 +02:00
|
|
|
abort() {
|
2022-08-29 10:29:54 +02:00
|
|
|
echo "Dependencies: an error has occurred, exit"
|
2022-08-17 12:43:34 +02:00
|
|
|
exit 1
|
|
|
|
}
|
2022-08-14 04:43:35 +02:00
|
|
|
|
2022-09-05 07:41:13 +02:00
|
|
|
echo "Checking and ensuring dependencies"
|
|
|
|
check_dependencies() {
|
|
|
|
command -v whiptail >/dev/null 2>&1 || NEED_INSTALL+=("whiptail")
|
|
|
|
command -v seinfo >/dev/null 2>&1 || NEED_INSTALL+=("setools")
|
|
|
|
command -v lzip >/dev/null 2>&1 || NEED_INSTALL+=("lzip")
|
|
|
|
command -v wine64 >/dev/null 2>&1 || NEED_INSTALL+=("wine")
|
|
|
|
command -v winetricks >/dev/null 2>&1 || NEED_INSTALL+=("winetricks")
|
|
|
|
command -v patchelf >/dev/null 2>&1 || NEED_INSTALL+=("patchelf")
|
|
|
|
command -v resize2fs >/dev/null 2>&1 || NEED_INSTALL+=("e2fsprogs")
|
|
|
|
command -v pip >/dev/null 2>&1 || NEED_INSTALL+=("python3-pip")
|
|
|
|
command -v aria2c >/dev/null 2>&1 || NEED_INSTALL+=("aria2")
|
|
|
|
}
|
|
|
|
check_dependencies
|
|
|
|
declare -A os_pm_install;
|
|
|
|
# os_pm_install["/etc/redhat-release"]=yum
|
|
|
|
# os_pm_install["/etc/arch-release"]=pacman
|
|
|
|
# os_pm_install["/etc/gentoo-release"]=emerge
|
|
|
|
# os_pm_install["/etc/SuSE-release"]=zypp
|
|
|
|
os_pm_install["/etc/debian_version"]=apt-get
|
|
|
|
# os_pm_install["/etc/alpine-release"]=apk
|
|
|
|
|
|
|
|
declare -A PM_UPDATE_MAP;
|
|
|
|
PM_UPDATE_MAP["yum"]="check-update"
|
|
|
|
PM_UPDATE_MAP["pacman"]="-Syu --noconfirm"
|
|
|
|
PM_UPDATE_MAP["emerge"]="-auDN @world"
|
|
|
|
PM_UPDATE_MAP["zypp"]="update -y"
|
|
|
|
PM_UPDATE_MAP["apt-get"]="update"
|
|
|
|
PM_UPDATE_MAP["apk"]="update"
|
|
|
|
|
|
|
|
declare -A PM_INSTALL_MAP;
|
|
|
|
PM_INSTALL_MAP["yum"]="install -y"
|
|
|
|
PM_INSTALL_MAP["pacman"]="-S --noconfirm --needed"
|
|
|
|
PM_INSTALL_MAP["emerge"]="-a"
|
|
|
|
PM_INSTALL_MAP["zypp"]="install -y"
|
|
|
|
PM_INSTALL_MAP["apt-get"]="install -y"
|
|
|
|
PM_INSTALL_MAP["apk"]="add"
|
|
|
|
|
|
|
|
check_package_manager() {
|
|
|
|
for f in "${!os_pm_install[@]}"; do
|
|
|
|
if [[ -f $f ]]; then
|
|
|
|
PM="${os_pm_install[$f]}"
|
|
|
|
readarray -td ' ' UPDATE_OPTION <<<"${PM_UPDATE_MAP[$PM]} "; unset 'UPDATE_OPTION[-1]';
|
|
|
|
readarray -td ' ' INSTALL_OPTION <<<"${PM_INSTALL_MAP[$PM]} "; unset 'INSTALL_OPTION[-1]';
|
|
|
|
break
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
|
|
|
check_package_manager
|
|
|
|
if [ -n "${NEED_INSTALL[*]}" ]; then
|
|
|
|
if [ -z "$PM" ]; then
|
|
|
|
echo "Unable to determine package manager: unknown distribution"
|
2022-09-06 10:14:54 +02:00
|
|
|
abort
|
2022-09-05 07:41:13 +02:00
|
|
|
else
|
2022-09-06 10:14:54 +02:00
|
|
|
if ! (sudo "$PM" "${UPDATE_OPTION[@]}" && sudo "$PM" "${INSTALL_OPTION[@]}" "${NEED_INSTALL[@]}") then abort; fi
|
2022-09-05 07:41:13 +02:00
|
|
|
fi
|
|
|
|
fi
|
|
|
|
pip list --disable-pip-version-check | grep -E "^requests " >/dev/null 2>&1 || python3 -m pip install requests
|
|
|
|
|
|
|
|
winetricks list-installed | grep -E "^msxml6" >/dev/null 2>&1 || {
|
|
|
|
cp -r ../wine/.cache/* ~/.cache
|
2022-09-08 04:21:50 +02:00
|
|
|
winetricks msxml6 || abort
|
2022-09-05 07:41:13 +02:00
|
|
|
}
|
|
|
|
|
2022-08-14 04:43:35 +02:00
|
|
|
function Radiolist {
|
|
|
|
declare -A o="$1"
|
|
|
|
shift
|
2022-08-17 20:02:29 +02:00
|
|
|
if ! whiptail --nocancel --radiolist "${o[title]}" 0 0 0 "$@" 3>&1 1>&2 2>&3; then
|
2022-08-14 04:43:35 +02:00
|
|
|
echo "${o[default]}"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
function YesNoBox {
|
|
|
|
declare -A o="$1"
|
|
|
|
shift
|
|
|
|
whiptail --title "${o[title]}" --yesno "${o[text]}" 0 0
|
|
|
|
}
|
|
|
|
|
|
|
|
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 15:59:26 +02:00
|
|
|
|
|
|
|
if [ -z "${CUSTOM_MAGISK+x}" ]; then
|
2022-08-25 21:54:13 +02:00
|
|
|
MAGISK_VER=$(
|
|
|
|
Radiolist '([title]="Magisk version"
|
|
|
|
[default]="stable")' \
|
|
|
|
\
|
|
|
|
'stable' "Stable Channel" 'on' \
|
|
|
|
'beta' "Beta Channel" 'off' \
|
|
|
|
'canary' "Canary Channel" 'off' \
|
|
|
|
'debug' "Canary Channel Debug Build" 'off'
|
|
|
|
)
|
|
|
|
else
|
|
|
|
MAGISK_VER=debug
|
|
|
|
fi
|
2022-08-14 06:48:47 +02:00
|
|
|
|
2022-08-24 20:16:13 +02:00
|
|
|
if (YesNoBox '([title]="Install GApps" [text]="Do you want to install GApps?")'); then
|
2022-09-10 08:40:21 +02:00
|
|
|
GAPPS_BRAND=$(
|
|
|
|
Radiolist '([title]="Which GApps do you want to install?"
|
|
|
|
[default]="OpenGApps")' \
|
|
|
|
\
|
|
|
|
'OpenGApps' "" 'on' \
|
|
|
|
'MindTheGapps' "" 'off'
|
|
|
|
)
|
2022-08-14 06:48:47 +02:00
|
|
|
else
|
2022-09-01 04:40:35 +02:00
|
|
|
GAPPS_BRAND="none"
|
2022-08-14 06:48:47 +02:00
|
|
|
fi
|
2022-08-24 20:16:13 +02:00
|
|
|
if [ $GAPPS_BRAND = "OpenGApps" ]; then
|
2022-08-25 21:28:43 +02:00
|
|
|
# TODO: Keep it pico since other variants of opengapps are unable to boot successfully
|
|
|
|
if [ "$DEBUG" = "1" ]; then
|
2022-08-14 04:43:35 +02:00
|
|
|
GAPPS_VARIANT=$(
|
2022-08-24 20:16:13 +02:00
|
|
|
Radiolist '([title]="Variants of GApps"
|
2022-08-14 04:43:35 +02:00
|
|
|
[default]="pico")' \
|
|
|
|
\
|
|
|
|
'super' "" 'off' \
|
|
|
|
'stock' "" 'off' \
|
|
|
|
'full' "" 'off' \
|
|
|
|
'mini' "" 'off' \
|
|
|
|
'micro' "" 'off' \
|
|
|
|
'nano' "" 'off' \
|
|
|
|
'pico' "" 'on' \
|
|
|
|
'tvstock' "" 'off' \
|
|
|
|
'tvmini' "" 'off'
|
|
|
|
)
|
2022-08-25 21:28:43 +02:00
|
|
|
else
|
|
|
|
GAPPS_VARIANT=pico
|
|
|
|
fi
|
2022-08-14 04:43:35 +02:00
|
|
|
else
|
2022-09-03 17:44:52 +02:00
|
|
|
GAPPS_VARIANT="pico"
|
2022-08-14 04:43:35 +02:00
|
|
|
fi
|
|
|
|
|
2022-09-03 06:32:52 +02:00
|
|
|
if (YesNoBox '([title]="Remove Amazon Appstore" [text]="Do you want to keep Amazon Appstore?")'); then
|
2022-08-29 10:29:54 +02:00
|
|
|
REMOVE_AMAZON=""
|
2022-08-14 09:03:17 +02:00
|
|
|
else
|
2022-08-29 10:29:54 +02:00
|
|
|
REMOVE_AMAZON="--remove-amazon"
|
2022-08-14 04:43:35 +02:00
|
|
|
fi
|
|
|
|
|
|
|
|
ROOT_SOL=$(
|
|
|
|
Radiolist '([title]="Root solution"
|
|
|
|
[default]="magisk")' \
|
|
|
|
\
|
|
|
|
'magisk' "" 'on' \
|
|
|
|
'none' "" 'off'
|
|
|
|
)
|
|
|
|
|
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 10:29:54 +02:00
|
|
|
COMPRESS_OUTPUT="--compress"
|
2022-08-21 22:33:07 +02:00
|
|
|
else
|
2022-08-29 10:29:54 +02:00
|
|
|
COMPRESS_OUTPUT=""
|
2022-08-21 22:33:07 +02:00
|
|
|
fi
|
|
|
|
|
2022-08-29 10:29:54 +02:00
|
|
|
# if ! (YesNoBox '([title]="Off line mode" [text]="Do you want to enable off line mode?")'); then
|
2022-08-29 10:47:59 +02:00
|
|
|
# OFFLINE="--offline"
|
2022-08-29 10:29:54 +02:00
|
|
|
# else
|
2022-08-29 10:47:59 +02:00
|
|
|
# OFFLINE=""
|
2022-08-29 10:29:54 +02:00
|
|
|
# fi
|
2022-08-29 10:47:59 +02:00
|
|
|
# OFFLINE="--offline"
|
2022-08-14 04:43:35 +02:00
|
|
|
clear
|
2022-08-30 17:57:26 +02:00
|
|
|
declare -A RELEASE_TYPE_MAP=(["retail"]="retail" ["release preview"]="RP" ["insider slow"]="WIS" ["insider fast"]="WIF")
|
|
|
|
COMMAND_LINE=(--arch "$ARCH" --release-type "${RELEASE_TYPE_MAP[$RELEASE_TYPE]}" --magisk-ver "$MAGISK_VER" --gapps-brand "$GAPPS_BRAND" --gapps-variant "$GAPPS_VARIANT" "$REMOVE_AMAZON" --root-sol "$ROOT_SOL" "$COMPRESS_OUTPUT" "$OFFLINE" "$DEBUG" "$CUSTOM_MAGISK")
|
2022-08-29 10:29:54 +02:00
|
|
|
echo "COMMAND_LINE=${COMMAND_LINE[*]}"
|
|
|
|
./build.sh "${COMMAND_LINE[@]}"
|