2022-08-25 18:20:49 +02:00
#!/bin/bash
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-23 10:32:34 +02:00
if [ ! " $BASH_VERSION " ] ; then
echo "Please do not use sh to run this script, just execute it directly" 1>& 2
exit 1
fi
HOST_ARCH = $( uname -m)
if [ " $HOST_ARCH " != "x86_64" ] && [ " $HOST_ARCH " != "aarch64" ] ; then
echo " Unsupported architectures: $HOST_ARCH "
exit 1
fi
cd " $( dirname " $0 " ) " || exit 1
2022-08-25 18:20:49 +02:00
trap umount_clean EXIT
2022-08-23 08:03:56 +02:00
WORK_DIR = $( mktemp -d -t wsa-build-XXXXXXXXXX_) || exit 1
2022-08-17 12:43:34 +02:00
DOWNLOAD_DIR = ../download
2022-08-23 19:54:24 +02:00
DOWNLOAD_CONF_NAME = download.list
2022-08-17 12:43:34 +02:00
OUTPUT_DIR = ../output
2022-08-17 20:02:29 +02:00
MOUNT_DIR = " $WORK_DIR " /system
2022-08-25 18:20:49 +02:00
umount_clean( ) {
echo "Cleanup Work Directory"
if [ -d " $MOUNT_DIR " ] ; then
if [ -d " $MOUNT_DIR /vendor " ] ; then
sudo umount " $MOUNT_DIR " /vendor
fi
if [ -d " $MOUNT_DIR /product " ] ; then
sudo umount " $MOUNT_DIR " /product
fi
if [ -d " $MOUNT_DIR /system_ext " ] ; then
sudo umount " $MOUNT_DIR " /system_ext
fi
sudo umount " $MOUNT_DIR "
fi
sudo rm -rf " ${ WORK_DIR : ? } "
}
2022-08-25 20:33:27 +02:00
clean_download( ) {
if [ -d " $DOWNLOAD_DIR " ] ; then
echo "Cleanup Download Directory"
if [ " $CLEAN_DOWNLOAD_WSA " = "1" ] ; then
rm -f " ${ WSA_ZIP_PATH : ? } "
fi
if [ " $CLEAN_DOWNLOAD_MAGISK " = "1" ] ; then
rm -f " ${ MAGISK_PATH : ? } "
fi
if [ " $CLEAN_DOWNLOAD_GAPPS " = "1" ] ; then
rm -f " ${ GAPPS_PATH : ? } "
fi
fi
}
2022-08-17 12:43:34 +02:00
abort( ) {
2022-08-23 11:12:53 +02:00
echo "An error has occurred, exit"
2022-08-17 12:43:34 +02:00
if [ -d " $WORK_DIR " ] ; then
2022-08-25 18:20:49 +02:00
umount_clean
2022-08-17 12:43:34 +02:00
fi
2022-08-25 20:33:27 +02:00
clean_download
2022-08-17 12:43:34 +02:00
exit 1
}
2022-08-23 09:52:26 +02:00
trap abort INT TERM
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
}
2022-08-15 12:51:24 +02:00
function Gen_Rand_Str {
2022-08-17 20:02:29 +02:00
tr -dc 'a-zA-Z0-9' < /dev/urandom | fold -w " $1 " | head -n 1
2022-08-15 12:51:24 +02:00
}
2022-08-14 04:43:35 +02:00
echo "Dependencies"
2022-08-23 19:54:24 +02:00
sudo apt update && sudo apt -y install setools lzip wine winetricks patchelf whiptail e2fsprogs python3-pip aria2
2022-08-25 18:20:49 +02:00
python3 -m pip install requests
2022-08-14 04:43:35 +02:00
cp -r ../wine/.cache/* ~/.cache
2022-08-17 12:43:34 +02:00
winetricks msxml6 || abort
2022-08-14 04:43:35 +02: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'
)
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'
)
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-08-25 20:33:27 +02:00
if [ -f " $DOWNLOAD_DIR " /MindTheGapps-" $ARCH " .zip ] ; then
2022-08-14 06:48:47 +02:00
GAPPS_BRAND = $(
2022-08-24 20:16:13 +02:00
Radiolist ' ( [ title] = "Which GApps do you want to install?"
2022-08-24 20:32:55 +02:00
[ default] = "OpenGApps" ) ' \
2022-08-14 06:48:47 +02:00
\
2022-08-24 20:16:13 +02:00
'OpenGApps' "" 'on' \
2022-08-14 06:48:47 +02:00
'MindTheGapps' "" 'off'
)
else
2022-08-24 20:16:13 +02:00
GAPPS_BRAND = "OpenGApps"
2022-08-14 06:48:47 +02:00
fi
else
GAPPS_VARIANT = "none"
fi
2022-08-24 20:16:13 +02:00
if [ $GAPPS_BRAND = "OpenGApps" ] ; 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'
)
else
2022-08-14 06:48:47 +02:00
GAPPS_VARIANT = $GAPPS_BRAND
2022-08-14 04:43:35 +02:00
fi
2022-08-24 20:16:13 +02:00
if ( YesNoBox '([title]="Remove Amazon AppStore" [text]="Do you want to keep Amazon AppStore?")' ) ; then
2022-08-14 04:43:35 +02:00
REMOVE_AMAZON = "keep"
2022-08-14 09:03:17 +02:00
else
REMOVE_AMAZON = "remove"
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
COMPRESS_OUTPUT = "yes"
else
COMPRESS_OUTPUT = "no"
fi
2022-08-14 04:43:35 +02:00
clear
2022-08-23 07:04:16 +02:00
echo -e " ARCH= $ARCH \nRELEASE_TYPE= $RELEASE_TYPE \nMAGISK_VER= $MAGISK_VER \nGAPPS_VARIANT= $GAPPS_VARIANT \nREMOVE_AMAZON= $REMOVE_AMAZON \nROOT_SOL= $ROOT_SOL \nCOMPRESS_OUTPUT= $COMPRESS_OUTPUT "
2022-08-25 20:33:27 +02:00
declare -A RELEASE_TYPE_MAP = ( [ "retail" ] = "Retail" [ "release preview" ] = "RP" [ "insider slow" ] = "WIS" [ "insider fast" ] = "WIF" )
trap 'rm -f -- "${DOWNLOAD_DIR:?}/${DOWNLOAD_CONF_NAME}"' EXIT
2022-08-23 19:54:24 +02:00
echo "Generate Download Links"
python3 generateWSALinks.py " $ARCH " " $RELEASE_TYPE " " $DOWNLOAD_DIR " " $DOWNLOAD_CONF_NAME " || abort
python3 generateMagiskLink.py " $MAGISK_VER " " $DOWNLOAD_DIR " " $DOWNLOAD_CONF_NAME " || abort
if [ $GAPPS_VARIANT != 'none' ] && [ $GAPPS_VARIANT != '' ] ; then
2022-08-24 20:32:55 +02:00
if [ $GAPPS_BRAND = "OpenGApps" ] ; then
2022-08-23 19:54:24 +02:00
# TODO: Keep it pico since other variants of opengapps are unable to boot successfully
python3 generateGappsLink.py " $ARCH " "pico" " $DOWNLOAD_DIR " " $DOWNLOAD_CONF_NAME " || abort
# python3 generateGappsLink.py "$ARCH" "$GAPPS_VARIANT" "$DOWNLOAD_DIR" "$DOWNLOAD_CONF_NAME" || abort
fi
fi
echo "Download Artifacts"
2022-08-25 20:33:27 +02:00
if ! aria2c --no-conf --log-level= info --log= " $DOWNLOAD_DIR /aria2_download.log " -x16 -s16 -j5 -c -R -m0 --allow-overwrite= true --conditional-get= true -d" $DOWNLOAD_DIR " -i" $DOWNLOAD_DIR " /" $DOWNLOAD_CONF_NAME " ; then
2022-08-25 18:20:49 +02:00
echo "We have encountered an error while downloading files."
exit 1
2022-08-23 19:54:24 +02:00
fi
2022-08-25 20:33:27 +02:00
WSA_ZIP_PATH = $DOWNLOAD_DIR /wsa-$ARCH -${ RELEASE_TYPE_MAP [ $RELEASE_TYPE ] } .zip
MAGISK_PATH = $DOWNLOAD_DIR /magisk-$MAGISK_VER .zip
GAPPS_PATH = " $DOWNLOAD_DIR " /OpenGApps-$ARCH -$GAPPS_VARIANT .zip
2022-08-14 04:43:35 +02:00
2022-08-17 12:43:34 +02:00
echo "Extract WSA"
2022-08-25 20:33:27 +02:00
if [ -f " $WSA_ZIP_PATH " ] ; then
WSA_WORK_ENV = " ${ WORK_DIR : ? } " /ENV
if [ -f " $WSA_WORK_ENV " ] ; then rm -f " ${ WSA_WORK_ENV : ? } " ; fi
export WSA_WORK_ENV
if ! python3 extractWSA.py " $ARCH " " $WSA_ZIP_PATH " " $WORK_DIR " ; then
echo "Unzip WSA failed, is the download incomplete?"
CLEAN_DOWNLOAD_WSA = 1
abort
fi
echo -e "Extract done\n"
source " ${ WORK_DIR : ? } /ENV " || abort
else
echo "The WSA zip package does not exist, is the download incomplete?"
exit 1
fi
2022-08-23 19:54:24 +02:00
echo "Extract Magisk"
2022-08-25 20:33:27 +02:00
if [ -f " $MAGISK_PATH " ] ; then
if ! python3 extractMagisk.py " $ARCH " " $MAGISK_PATH " " $WORK_DIR " ; then
echo "Unzip Magisk failed, is the download incomplete?"
CLEAN_DOWNLOAD_MAGISK = 1
abort
fi
else
echo "The Magisk zip package does not exist, is the download incomplete?"
exit 1
fi
2022-08-17 12:43:34 +02:00
echo -e "done\n"
2022-08-14 04:43:35 +02:00
if [ $GAPPS_VARIANT != 'none' ] && [ $GAPPS_VARIANT != '' ] ; then
2022-08-14 06:48:47 +02:00
echo "Extract GApps"
2022-08-17 12:43:34 +02:00
mkdir -p " $WORK_DIR " /gapps || abort
2022-08-24 20:16:13 +02:00
if [ $GAPPS_BRAND = "OpenGApps" ] ; then
2022-08-25 20:33:27 +02:00
if [ -f " $GAPPS_PATH " ] ; then
if ! unzip -p " $GAPPS_PATH " { Core,GApps} /'*.lz' | tar --lzip -C " $WORK_DIR " /gapps -xf - -i --strip-components= 2 --exclude= 'setupwizardtablet-x86_64' --exclude= 'packageinstallergoogle-all' --exclude= 'speech-common' --exclude= 'markup-lib-arm' --exclude= 'markup-lib-arm64' --exclude= 'markup-all' --exclude= 'setupwizarddefault-x86_64' --exclude= 'pixellauncher-all' --exclude= 'pixellauncher-common' ; then
echo "Unzip GApps failed, is the download incomplete?"
CLEAN_DOWNLOAD_GAPPS = 1
abort
fi
else
echo "The WSA zip package does not exist, is the download incomplete?"
exit 1
fi
2022-08-14 06:48:47 +02:00
else
2022-08-25 20:33:27 +02:00
if ! unzip " $DOWNLOAD_DIR " /MindTheGapps-" $ARCH " .zip "system/*" -x "system/addon.d/*" "system/system_ext/priv-app/SetupWizard/*" -d " $WORK_DIR " /gapps; then
echo "Unzip MindTheGapps failed, package is corrupted?"
abort
fi
2022-08-17 12:43:34 +02:00
mv " $WORK_DIR " /gapps/system/* " $WORK_DIR " /gapps || abort
2022-08-25 18:20:49 +02:00
rm -rf " ${ WORK_DIR : ? } " /gapps/system || abort
fi
cp -r ../" $ARCH " /gapps/* " $WORK_DIR " /gapps || abort
if [ $GAPPS_BRAND = "MindTheGapps" ] ; then
mv " $WORK_DIR " /gapps/priv-app/* " $WORK_DIR " /gapps/system_ext/priv-app || abort
rm -rf " ${ WORK_DIR : ? } " /gapps/priv-app || abort
2022-08-14 06:48:47 +02:00
fi
2022-08-17 12:43:34 +02:00
echo -e "Extract done\n"
2022-08-14 04:43:35 +02:00
fi
echo "Expand images"
2022-08-17 12:43:34 +02:00
e2fsck -yf " $WORK_DIR " /wsa/" $ARCH " /system_ext.img || abort
2022-08-23 07:04:16 +02:00
SYSTEM_EXT_SIZE = $(( $( du --apparent-size -sB512 " $WORK_DIR " /wsa/" $ARCH " /system_ext.img | cut -f1) + 20000 ))
2022-08-17 12:43:34 +02:00
if [ -d " $WORK_DIR " /gapps/system_ext ] ; then
2022-08-23 07:04:16 +02:00
SYSTEM_EXT_SIZE = $(( SYSTEM_EXT_SIZE + $( du --apparent-size -sB512 " $WORK_DIR " /gapps/system_ext | cut -f1) ))
2022-08-14 06:48:47 +02:00
fi
2022-08-17 12:43:34 +02:00
resize2fs " $WORK_DIR " /wsa/" $ARCH " /system_ext.img " $SYSTEM_EXT_SIZE " s || abort
2022-08-14 04:43:35 +02:00
2022-08-17 12:43:34 +02:00
e2fsck -yf " $WORK_DIR " /wsa/" $ARCH " /product.img || abort
2022-08-23 07:04:16 +02:00
PRODUCT_SIZE = $(( $( du --apparent-size -sB512 " $WORK_DIR " /wsa/" $ARCH " /product.img | cut -f1) + 20000 ))
2022-08-17 12:43:34 +02:00
if [ -d " $WORK_DIR " /gapps/product ] ; then
2022-08-23 07:04:16 +02:00
PRODUCT_SIZE = $(( PRODUCT_SIZE + $( du --apparent-size -sB512 " $WORK_DIR " /gapps/product | cut -f1) ))
2022-08-14 04:43:35 +02:00
fi
2022-08-17 12:43:34 +02:00
resize2fs " $WORK_DIR " /wsa/" $ARCH " /product.img " $PRODUCT_SIZE " s || abort
e2fsck -yf " $WORK_DIR " /wsa/" $ARCH " /system.img || abort
2022-08-23 07:04:16 +02:00
SYSTEM_SIZE = $(( $( du --apparent-size -sB512 " $WORK_DIR " /wsa/" $ARCH " /system.img | cut -f1) + 20000 ))
2022-08-17 12:43:34 +02:00
if [ -d " $WORK_DIR " /gapps ] ; then
2022-08-23 07:04:16 +02:00
SYSTEM_SIZE = $(( SYSTEM_SIZE + $( du --apparent-size -sB512 " $WORK_DIR " /gapps | cut -f1) - $( du --apparent-size -sB512 " $WORK_DIR " /gapps/product | cut -f1) ))
2022-08-17 12:43:34 +02:00
if [ -d " $WORK_DIR " /gapps/system_ext ] ; then
2022-08-23 07:04:16 +02:00
SYSTEM_SIZE = $(( SYSTEM_SIZE - $( du --apparent-size -sB512 " $WORK_DIR " /gapps/system_ext | cut -f1) ))
2022-08-14 06:48:47 +02:00
fi
2022-08-14 04:43:35 +02:00
fi
2022-08-17 12:43:34 +02:00
if [ -d " $WORK_DIR " /magisk ] ; then
2022-08-23 07:04:16 +02:00
SYSTEM_SIZE = $(( SYSTEM_SIZE + $( du --apparent-size -sB512 " $WORK_DIR " /magisk/magisk | cut -f1) ))
2022-08-14 04:43:35 +02:00
fi
2022-08-17 12:43:34 +02:00
if [ -f " $DOWNLOAD_DIR " /magisk.zip ] ; then
2022-08-23 07:04:16 +02:00
SYSTEM_SIZE = $(( SYSTEM_SIZE + $( du --apparent-size -sB512 " $DOWNLOAD_DIR " /magisk.zip | cut -f1) ))
2022-08-14 04:43:35 +02:00
fi
2022-08-25 18:20:49 +02:00
if [ -d " ../ $ARCH /system " ] ; then
SYSTEM_SIZE = $(( SYSTEM_SIZE + $( du --apparent-size -sB512 " ../ $ARCH /system " | cut -f1) ))
fi
2022-08-17 12:43:34 +02:00
resize2fs " $WORK_DIR " /wsa/" $ARCH " /system.img " $SYSTEM_SIZE " s || abort
2022-08-14 04:43:35 +02:00
2022-08-17 12:43:34 +02:00
e2fsck -yf " $WORK_DIR " /wsa/" $ARCH " /vendor.img || abort
2022-08-23 07:04:16 +02:00
VENDOR_SIZE = $(( $( du --apparent-size -sB512 " $WORK_DIR " /wsa/" $ARCH " /vendor.img | cut -f1) + 20000 ))
2022-08-17 12:43:34 +02:00
resize2fs " $WORK_DIR " /wsa/" $ARCH " /vendor.img " $VENDOR_SIZE " s || abort
echo -e "Expand images done\n"
2022-08-14 04:43:35 +02:00
echo "Mount images"
2022-08-17 20:02:29 +02:00
sudo mkdir " $MOUNT_DIR " || abort
sudo mount -o loop " $WORK_DIR " /wsa/" $ARCH " /system.img " $MOUNT_DIR " || abort
sudo mount -o loop " $WORK_DIR " /wsa/" $ARCH " /vendor.img " $MOUNT_DIR " /vendor || abort
sudo mount -o loop " $WORK_DIR " /wsa/" $ARCH " /product.img " $MOUNT_DIR " /product || abort
sudo mount -o loop " $WORK_DIR " /wsa/" $ARCH " /system_ext.img " $MOUNT_DIR " /system_ext || abort
2022-08-17 12:43:34 +02:00
echo -e "done\n"
2022-08-14 04:43:35 +02:00
if [ $REMOVE_AMAZON = 'remove' ] ; then
2022-08-14 06:48:47 +02:00
echo "Remove Amazon AppStore"
2022-08-23 10:32:34 +02:00
find " ${ MOUNT_DIR : ? } " /product/{ etc/permissions,etc/sysconfig,framework,priv-app} | grep -e amazon -e venezia | sudo xargs rm -rf
2022-08-17 12:43:34 +02:00
echo -e "done\n"
2022-08-14 04:43:35 +02:00
fi
2022-08-14 14:05:43 +02:00
if [ " $ROOT_SOL " = 'magisk' ] || [ " $ROOT_SOL " = '' ] ; then
2022-08-14 06:48:47 +02:00
echo "Integrate Magisk"
2022-08-17 20:02:29 +02:00
sudo mkdir " $MOUNT_DIR " /sbin
sudo chcon --reference " $MOUNT_DIR " /init.environ.rc " $MOUNT_DIR " /sbin
sudo chown root:root " $MOUNT_DIR " /sbin
sudo chmod 0700 " $MOUNT_DIR " /sbin
sudo cp " $WORK_DIR " /magisk/magisk/* " $MOUNT_DIR " /sbin/
sudo cp " $DOWNLOAD_DIR " /magisk.zip " $MOUNT_DIR " /sbin/magisk.apk
sudo tee -a " $MOUNT_DIR " /sbin/loadpolicy.sh <<EOF
2022-08-14 04:43:35 +02:00
#!/system/bin/sh
mkdir -p /data/adb/magisk
cp /sbin/* /data/adb/magisk/
chmod -R 755 /data/adb/magisk
restorecon -R /data/adb/magisk
for module in \$ ( ls /data/adb/modules) ; do
if ! [ -f "/data/adb/modules/\$module/disable" ] && [ -f "/data/adb/modules/\$module/sepolicy.rule" ] ; then
/sbin/magiskpolicy --live --apply "/data/adb/modules/\$module/sepolicy.rule"
fi
done
EOF
2022-08-17 20:02:29 +02:00
sudo find " $MOUNT_DIR " /sbin -type f -exec chmod 0755 { } \;
sudo find " $MOUNT_DIR " /sbin -type f -exec chown root:root { } \;
sudo find " $MOUNT_DIR " /sbin -type f -exec chcon --reference " $MOUNT_DIR " /product { } \;
2022-08-23 10:32:34 +02:00
sudo patchelf --replace-needed libc.so " ../linker/ $HOST_ARCH /libc.so " " $WORK_DIR " /magisk/magiskpolicy || abort
sudo patchelf --replace-needed libm.so " ../linker/ $HOST_ARCH /libm.so " " $WORK_DIR " /magisk/magiskpolicy || abort
sudo patchelf --replace-needed libdl.so " ../linker/ $HOST_ARCH /libdl.so " " $WORK_DIR " /magisk/magiskpolicy || abort
sudo patchelf --set-interpreter " ../linker/ $HOST_ARCH /linker64 " " $WORK_DIR " /magisk/magiskpolicy || abort
chmod +x " $WORK_DIR " /magisk/magiskpolicy || abort
2022-08-15 12:51:24 +02:00
TMP_PATH = $( Gen_Rand_Str 8)
2022-08-17 20:02:29 +02:00
echo " /dev/ $TMP_PATH (/.*)? u:object_r:magisk_file:s0 " | sudo tee -a " $MOUNT_DIR " /vendor/etc/selinux/vendor_file_contexts
echo '/data/adb/magisk(/.*)? u:object_r:magisk_file:s0' | sudo tee -a " $MOUNT_DIR " /vendor/etc/selinux/vendor_file_contexts
2022-08-23 10:32:34 +02:00
sudo " $WORK_DIR " /magisk/magiskpolicy --load " $MOUNT_DIR " /vendor/etc/selinux/precompiled_sepolicy --save " $MOUNT_DIR " /vendor/etc/selinux/precompiled_sepolicy --magisk "allow * magisk_file lnk_file *" || abort
2022-08-15 12:51:24 +02:00
SERVER_NAME1 = $( Gen_Rand_Str 12)
SERVER_NAME2 = $( Gen_Rand_Str 12)
SERVER_NAME3 = $( Gen_Rand_Str 12)
SERVER_NAME4 = $( Gen_Rand_Str 12)
2022-08-17 20:02:29 +02:00
sudo tee -a " $MOUNT_DIR " /system/etc/init/hw/init.rc <<EOF
2022-08-14 04:43:35 +02:00
on post-fs-data
start adbd
2022-08-15 12:51:24 +02:00
mkdir /dev/$TMP_PATH
mount tmpfs tmpfs /dev/$TMP_PATH mode = 0755
copy /sbin/magisk64 /dev/$TMP_PATH /magisk64
chmod 0755 /dev/$TMP_PATH /magisk64
symlink ./magisk64 /dev/$TMP_PATH /magisk
symlink ./magisk64 /dev/$TMP_PATH /su
symlink ./magisk64 /dev/$TMP_PATH /resetprop
copy /sbin/magisk32 /dev/$TMP_PATH /magisk32
chmod 0755 /dev/$TMP_PATH /magisk32
copy /sbin/magiskinit /dev/$TMP_PATH /magiskinit
chmod 0755 /dev/$TMP_PATH /magiskinit
copy /sbin/magiskpolicy /dev/$TMP_PATH /magiskpolicy
chmod 0755 /dev/$TMP_PATH /magiskpolicy
mkdir /dev/$TMP_PATH /.magisk 700
mkdir /dev/$TMP_PATH /.magisk/mirror 700
mkdir /dev/$TMP_PATH /.magisk/block 700
copy /sbin/magisk.apk /dev/$TMP_PATH /stub.apk
2022-08-14 04:43:35 +02:00
rm /dev/.magisk_unblock
2022-08-15 12:51:24 +02:00
start $SERVER_NAME1
start $SERVER_NAME2
2022-08-14 04:43:35 +02:00
wait /dev/.magisk_unblock 40
rm /dev/.magisk_unblock
2022-08-15 12:51:24 +02:00
service $SERVER_NAME1 /system/bin/sh /sbin/loadpolicy.sh
2022-08-14 04:43:35 +02:00
user root
seclabel u:r:magisk:s0
oneshot
2022-08-15 12:51:24 +02:00
service $SERVER_NAME2 /dev/$TMP_PATH /magisk --post-fs-data
2022-08-14 04:43:35 +02:00
user root
seclabel u:r:magisk:s0
oneshot
2022-08-15 12:51:24 +02:00
service $SERVER_NAME3 /dev/$TMP_PATH /magisk --service
2022-08-14 04:43:35 +02:00
class late_start
user root
seclabel u:r:magisk:s0
oneshot
on property:sys.boot_completed= 1
mkdir /data/adb/magisk 755
copy /sbin/magisk.apk /data/adb/magisk/magisk.apk
2022-08-15 12:51:24 +02:00
start $SERVER_NAME4
2022-08-14 04:43:35 +02:00
2022-08-15 12:51:24 +02:00
service $SERVER_NAME4 /dev/$TMP_PATH /magisk --boot-complete
2022-08-14 04:43:35 +02:00
user root
seclabel u:r:magisk:s0
oneshot
EOF
2022-08-17 12:43:34 +02:00
echo -e "Integrate Magisk done\n"
2022-08-14 04:43:35 +02:00
fi
echo "Merge Language Resources"
2022-08-17 12:43:34 +02:00
cp " $WORK_DIR " /wsa/" $ARCH " /resources.pri " $WORK_DIR " /wsa/pri/en-us.pri
cp " $WORK_DIR " /wsa/" $ARCH " /AppxManifest.xml " $WORK_DIR " /wsa/xml/en-us.xml
tee " $WORK_DIR " /wsa/priconfig.xml <<EOF
2022-08-14 04:43:35 +02:00
<?xml version = "1.0" encoding = "UTF-8" standalone = "yes" ?>
<resources targetOsVersion = "10.0.0" majorVersion = "1" >
<index root = "\" startIndexAt=" \" >
<indexer-config type = "folder" foldernameAsQualifier = "true" filenameAsQualifier = "true" qualifierDelimiter = "." />
<indexer-config type = "PRI" />
</index>
</resources>
EOF
2022-08-23 10:32:34 +02:00
wine64 ../wine/" $HOST_ARCH " /makepri.exe new /pr " $WORK_DIR " /wsa/pri /in MicrosoftCorporationII.WindowsSubsystemForAndroid /cf " $WORK_DIR " /wsa/priconfig.xml /of " $WORK_DIR " /wsa/" $ARCH " /resources.pri /o
2022-08-17 12:43:34 +02:00
sed -i -zE " s/<Resources.*Resources>/<Resources>\n $( cat " $WORK_DIR " /wsa/xml/* | grep -Po '<Resource [^>]*/>' | sed ':a;N;$!ba;s/\n/\\n/g' | sed 's/\$/\\$/g' | sed 's/\//\\\//g' ) \n<\/Resources>/g " " $WORK_DIR " /wsa/" $ARCH " /AppxManifest.xml
echo -e "Merge Language Resources done\n"
2022-08-14 04:43:35 +02:00
echo "Add extra packages"
2022-08-25 18:20:49 +02:00
sudo cp -r ../" $ARCH " /system/* " $MOUNT_DIR " || abort
find ../" $ARCH " /system/system/priv-app/ -maxdepth 1 -mindepth 1 -printf '%P\n' | xargs -I dir sudo find " $MOUNT_DIR " /system/priv-app/dir -type d -exec chmod 0755 { } \;
find ../" $ARCH " /system/system/priv-app/ -maxdepth 1 -mindepth 1 -printf '%P\n' | xargs -I dir sudo find " $MOUNT_DIR " /system/priv-app/dir -type f -exec chmod 0644 { } \;
find ../" $ARCH " /system/system/priv-app/ -maxdepth 1 -mindepth 1 -printf '%P\n' | xargs -I dir sudo find " $MOUNT_DIR " /system/priv-app/dir -exec chown root:root { } \;
find ../" $ARCH " /system/system/priv-app/ -maxdepth 1 -mindepth 1 -printf '%P\n' | xargs -I dir sudo find " $MOUNT_DIR " /system/priv-app/dir -exec chcon --reference= " $MOUNT_DIR " /system/priv-app { } \;
find ../" $ARCH " /system/system/etc/permissions/ -maxdepth 1 -mindepth 1 -printf '%P\n' | xargs -I file sudo find " $MOUNT_DIR " /system/etc/permissions/file -type f -exec chmod 0644 { } \;
find ../" $ARCH " /system/system/etc/permissions/ -maxdepth 1 -mindepth 1 -printf '%P\n' | xargs -I file sudo find " $MOUNT_DIR " /system/etc/permissions/file -exec chown root:root { } \;
find ../" $ARCH " /system/system/etc/permissions/ -maxdepth 1 -mindepth 1 -printf '%P\n' | xargs -I file sudo find " $MOUNT_DIR " /system/etc/permissions/file -type f -exec chcon --reference= " $MOUNT_DIR " /system/etc/permissions/platform.xml { } \;
2022-08-17 12:43:34 +02:00
echo -e "Add extra packages done\n"
2022-08-14 04:43:35 +02:00
if [ $GAPPS_VARIANT != 'none' ] && [ $GAPPS_VARIANT != '' ] ; then
2022-08-14 06:48:47 +02:00
echo "Integrate GApps"
2022-08-25 18:20:49 +02:00
find " $WORK_DIR /gapps/ " -mindepth 1 -type d -exec sudo chmod 0755 { } \;
find " $WORK_DIR /gapps/ " -mindepth 1 -type d -exec sudo chown root:root { } \;
file_list = " $( find " $WORK_DIR /gapps/ " -mindepth 1 -type f | cut -d/ -f5-) "
for file in $file_list ; do
sudo chown root:root " $WORK_DIR /gapps/ ${ file } "
sudo chmod 0644 " $WORK_DIR /gapps/ ${ file } "
2022-08-14 06:48:47 +02:00
done
2022-08-25 08:05:05 +02:00
2022-08-25 08:38:44 +02:00
if [ $GAPPS_BRAND = "OpenGApps" ] ; then
2022-08-25 18:20:49 +02:00
find " $WORK_DIR " /gapps/ -maxdepth 1 -mindepth 1 -type d -not -path '*product' -exec sudo cp --preserve= all -r { } " $MOUNT_DIR " /system \; || abort
elif [ $GAPPS_BRAND = "MindTheGapps" ] ; then
sudo cp --preserve= all -r " $WORK_DIR " /gapps/system_ext/* " $MOUNT_DIR " /system_ext/ || abort
2022-08-17 20:02:29 +02:00
if [ -e " $MOUNT_DIR " /system_ext/priv-app/SetupWizard ] ; then
2022-08-23 10:32:34 +02:00
rm -rf " ${ MOUNT_DIR : ? } /system_ext/priv-app/Provision "
2022-08-17 20:02:29 +02:00
fi
2022-08-14 06:48:47 +02:00
fi
2022-08-25 18:20:49 +02:00
sudo cp --preserve= all -r " $WORK_DIR " /gapps/product/* " $MOUNT_DIR " /product || abort
2022-08-14 04:43:35 +02:00
2022-08-25 18:20:49 +02:00
find " $WORK_DIR " /gapps/product/overlay -maxdepth 1 -mindepth 1 -printf '%P\n' | xargs -I file sudo find " $MOUNT_DIR " /product/overlay/file -type f -exec chcon --reference= " $MOUNT_DIR " /product/overlay/FontNotoSerifSource/FontNotoSerifSourceOverlay.apk { } \;
2022-08-14 06:48:47 +02:00
2022-08-24 20:16:13 +02:00
if [ $GAPPS_BRAND = "OpenGApps" ] ; then
2022-08-25 18:20:49 +02:00
find " $WORK_DIR " /gapps/app/ -maxdepth 1 -mindepth 1 -printf '%P\n' | xargs -I dir sudo find " $MOUNT_DIR " /system/app/dir -type d -exec chcon --reference= " $MOUNT_DIR " /system/app { } \;
find " $WORK_DIR " /gapps/framework/ -maxdepth 1 -mindepth 1 -printf '%P\n' | xargs -I dir sudo find " $MOUNT_DIR " /system/framework/dir -type d -exec chcon --reference= " $MOUNT_DIR " /system/framework { } \;
find " $WORK_DIR " /gapps/priv-app/ -maxdepth 1 -mindepth 1 -printf '%P\n' | xargs -I dir sudo find " $MOUNT_DIR " /system/priv-app/dir -type d -exec chcon --reference= " $MOUNT_DIR " /system/priv-app { } \;
find " $WORK_DIR " /gapps/app/ -maxdepth 1 -mindepth 1 -printf '%P\n' | xargs -I file sudo find " $MOUNT_DIR " /system/app/file -type f -exec chcon --reference= " $MOUNT_DIR " /system/app/KeyChain/KeyChain.apk { } \;
find " $WORK_DIR " /gapps/framework/ -maxdepth 1 -mindepth 1 -printf '%P\n' | xargs -I file sudo find " $MOUNT_DIR " /system/framework/file -type f -exec chcon --reference= " $MOUNT_DIR " /system/framework/ext.jar { } \;
find " $WORK_DIR " /gapps/priv-app/ -maxdepth 1 -mindepth 1 -printf '%P\n' | xargs -I file sudo find " $MOUNT_DIR " /system/priv-app/file -type f -exec chcon --reference= " $MOUNT_DIR " /system/priv-app/Shell/Shell.apk { } \;
find " $WORK_DIR " /gapps/etc/ -maxdepth 1 -mindepth 1 -printf '%P\n' | xargs -I dir sudo find " $MOUNT_DIR " /system/etc/dir -type d -exec chcon --reference= " $MOUNT_DIR " /system/etc/permissions { } \;
find " $WORK_DIR " /gapps/etc/ -maxdepth 1 -mindepth 1 -printf '%P\n' | xargs -I dir sudo find " $MOUNT_DIR " /system/etc/dir -type f -exec chcon --reference= " $MOUNT_DIR " /system/etc/permissions { } \;
2022-08-14 09:03:17 +02:00
else
2022-08-25 18:20:49 +02:00
find " $WORK_DIR " /gapps/product/app/ -maxdepth 1 -mindepth 1 -printf '%P\n' | xargs -I item sudo find " $MOUNT_DIR " /product/app/item -type d -exec chcon --reference= " $MOUNT_DIR " /product/app { } \;
find " $WORK_DIR " /gapps/product/etc/ -maxdepth 1 -mindepth 1 -printf '%P\n' | xargs -I item sudo find " $MOUNT_DIR " /product/etc/item -type d -exec chcon --reference= " $MOUNT_DIR " /product/etc { } \;
find " $WORK_DIR " /gapps/product/priv-app/ -maxdepth 1 -mindepth 1 -printf '%P\n' | xargs -I item sudo find " $MOUNT_DIR " /product/priv-app/item -type d -exec chcon --reference= " $MOUNT_DIR " /product/priv-app { } \;
find " $WORK_DIR " /gapps/product/framework/ -maxdepth 1 -mindepth 1 -printf '%P\n' | xargs -I item sudo find " $MOUNT_DIR " /product/framework/item -type d -exec chcon --reference= " $MOUNT_DIR " /product/framework { } \;
find " $WORK_DIR " /gapps/product/app/ -maxdepth 1 -mindepth 1 -printf '%P\n' | xargs -I item sudo find " $MOUNT_DIR " /product/app/item -type f -exec chcon --reference= " $MOUNT_DIR " /product/app/HomeApp/HomeApp.apk { } \;
find " $WORK_DIR " /gapps/product/etc/ -maxdepth 1 -mindepth 1 -printf '%P\n' | xargs -I item sudo find " $MOUNT_DIR " /product/etc/item -type f -exec chcon --reference= " $MOUNT_DIR " /product/etc/permissions/com.android.settings.intelligence.xml { } \;
find " $WORK_DIR " /gapps/product/priv-app/ -maxdepth 1 -mindepth 1 -printf '%P\n' | xargs -I item sudo find " $MOUNT_DIR " /product/priv-app/item -type f -exec chcon --reference= " $MOUNT_DIR " /product/priv-app/SettingsIntelligence/SettingsIntelligence.apk { } \;
find " $WORK_DIR " /gapps/product/framework/ -maxdepth 1 -mindepth 1 -printf '%P\n' | xargs -I item sudo find " $MOUNT_DIR " /product/framework/item -type f -exec chcon --reference= " $MOUNT_DIR " /product/etc/permissions/com.android.settings.intelligence.xml { } \;
find " $WORK_DIR " /gapps/system_ext/etc/permissions/ -maxdepth 1 -mindepth 1 -printf '%P\n' | xargs -I file sudo find " $MOUNT_DIR " /system_ext/etc/permissions/file -type f -exec chcon --reference= " $MOUNT_DIR " /system_ext/etc/permissions/com.android.systemui.xml { } \;
2022-08-25 20:33:27 +02:00
sudo chcon --reference= " $MOUNT_DIR " /product/lib64/libjni_eglfence.so " $MOUNT_DIR " /product/lib
2022-08-25 18:20:49 +02:00
find " $WORK_DIR " /gapps/product/lib/ -maxdepth 1 -mindepth 1 -printf '%P\n' | xargs -I file sudo find " $MOUNT_DIR " /product/lib/file -exec chcon --reference= " $MOUNT_DIR " /product/lib64/libjni_eglfence.so { } \;
find " $WORK_DIR " /gapps/product/lib64/ -maxdepth 1 -mindepth 1 -printf '%P\n' | xargs -I file sudo find " $MOUNT_DIR " /product/lib64/file -type f -exec chcon --reference= " $MOUNT_DIR " /product/lib64/libjni_eglfence.so { } \;
find " $WORK_DIR " /gapps/system_ext/priv-app/ -maxdepth 1 -mindepth 1 -printf '%P\n' | xargs -I dir sudo find " $MOUNT_DIR " /system_ext/priv-app/dir -type d -exec chcon --reference= " $MOUNT_DIR " /system_ext/priv-app { } \;
find " $WORK_DIR " /gapps/system_ext/etc/ -maxdepth 1 -mindepth 1 -printf '%P\n' | xargs -I dir sudo find " $MOUNT_DIR " /system_ext/etc/dir -type d -exec chcon --reference= " $MOUNT_DIR " /system_ext/etc { } \;
find " $WORK_DIR " /gapps/system_ext/priv-app/ -maxdepth 1 -mindepth 1 -printf '%P\n' | xargs -I dir sudo find " $MOUNT_DIR " /system_ext/priv-app/dir -type f -exec chcon --reference= " $MOUNT_DIR " /system_ext/priv-app/Settings/Settings.apk { } \;
2022-08-14 06:48:47 +02:00
fi
2022-08-23 10:32:34 +02:00
sudo patchelf --replace-needed libc.so " ../linker/ $HOST_ARCH /libc.so " " $WORK_DIR " /magisk/magiskpolicy || abort
sudo patchelf --replace-needed libm.so " ../linker/ $HOST_ARCH /libm.so " " $WORK_DIR " /magisk/magiskpolicy || abort
sudo patchelf --replace-needed libdl.so " ../linker/ $HOST_ARCH /libdl.so " " $WORK_DIR " /magisk/magiskpolicy || abort
sudo patchelf --set-interpreter " ../linker/ $HOST_ARCH /linker64 " " $WORK_DIR " /magisk/magiskpolicy || abort
2022-08-17 12:43:34 +02:00
chmod +x " $WORK_DIR " /magisk/magiskpolicy || abort
2022-08-17 20:02:29 +02:00
sudo " $WORK_DIR " /magisk/magiskpolicy --load " $MOUNT_DIR " /vendor/etc/selinux/precompiled_sepolicy --save " $MOUNT_DIR " /vendor/etc/selinux/precompiled_sepolicy "allow gmscore_app gmscore_app vsock_socket { create connect write read }" "allow gmscore_app device_config_runtime_native_boot_prop file read" "allow gmscore_app system_server_tmpfs dir search" "allow gmscore_app system_server_tmpfs file open" || abort
2022-08-17 12:43:34 +02:00
echo -e "Integrate GApps done\n"
2022-08-14 04:43:35 +02:00
fi
2022-08-14 06:48:47 +02:00
2022-08-14 04:43:35 +02:00
if [ $GAPPS_VARIANT != 'none' ] && [ $GAPPS_VARIANT != '' ] ; then
2022-08-14 06:48:47 +02:00
echo "Fix GApps prop"
2022-08-17 20:02:29 +02:00
sudo python3 fixGappsProp.py " $MOUNT_DIR " || abort
2022-08-17 12:43:34 +02:00
echo -e "done\n"
2022-08-14 04:43:35 +02:00
fi
echo "Umount images"
2022-08-17 20:02:29 +02:00
sudo find " $MOUNT_DIR " -exec touch -amt 200901010000.00 { } \; >/dev/null 2>& 1
sudo umount " $MOUNT_DIR " /vendor
sudo umount " $MOUNT_DIR " /product
sudo umount " $MOUNT_DIR " /system_ext
sudo umount " $MOUNT_DIR "
2022-08-17 12:43:34 +02:00
echo -e "done\n"
2022-08-14 04:43:35 +02:00
echo "Shrink images"
2022-08-17 12:43:34 +02:00
e2fsck -yf " $WORK_DIR " /wsa/" $ARCH " /system.img || abort
resize2fs -M " $WORK_DIR " /wsa/" $ARCH " /system.img || abort
e2fsck -yf " $WORK_DIR " /wsa/" $ARCH " /vendor.img || abort
resize2fs -M " $WORK_DIR " /wsa/" $ARCH " /vendor.img || abort
e2fsck -yf " $WORK_DIR " /wsa/" $ARCH " /product.img || abort
resize2fs -M " $WORK_DIR " /wsa/" $ARCH " /product.img || abort
e2fsck -yf " $WORK_DIR " /wsa/" $ARCH " /system_ext.img || abort
resize2fs -M " $WORK_DIR " /wsa/" $ARCH " /system_ext.img || abort
echo -e "Shrink images done\n"
2022-08-14 04:43:35 +02:00
echo "Remove signature and add scripts"
2022-08-23 10:32:34 +02:00
sudo rm -rf " ${ WORK_DIR : ? } " /wsa/" $ARCH " /\[ Content_Types\] .xml " $WORK_DIR " /wsa/" $ARCH " /AppxBlockMap.xml " $WORK_DIR " /wsa/" $ARCH " /AppxSignature.p7x " $WORK_DIR " /wsa/" $ARCH " /AppxMetadata || abort
2022-08-25 20:33:27 +02:00
cp " $DOWNLOAD_DIR " /vclibs-" $ARCH " .appx " $DOWNLOAD_DIR " /xaml-" $ARCH " .appx " $WORK_DIR " /wsa/" $ARCH " || abort
2022-08-17 12:43:34 +02:00
tee " $WORK_DIR " /wsa/" $ARCH " /Install.ps1 <<EOF
# Automated Install script by Midonei
# http://github.com/doneibcn
2022-08-14 04:43:35 +02:00
function Test-Administrator {
[ OutputType( [ bool] ) ]
param( )
process {
[ Security.Principal.WindowsPrincipal] \$ user = [ Security.Principal.WindowsIdentity] ::GetCurrent( ) ;
return \$ user.IsInRole( [ Security.Principal.WindowsBuiltinRole] ::Administrator) ;
}
}
function Finish {
Clear-Host
Start-Process "wsa://com.topjohnwu.magisk"
Start-Process "wsa://com.android.vending"
}
if ( -not ( Test-Administrator) ) {
Set-ExecutionPolicy -Scope CurrentUser -ExecutionPolicy Bypass -Force
\$ proc = Start-Process -PassThru -WindowStyle Hidden -Verb RunAs powershell.exe -Args "-executionpolicy bypass -command Set-Location '\$PSScriptRoot'; &'\$PSCommandPath' EVAL"
\$ proc.WaitForExit( )
if ( \$ proc.ExitCode -ne 0) {
Clear-Host
Write-Warning "Failed to launch start as Administrator\`r\`nPress any key to exit"
\$ null = \$ Host.UI.RawUI.ReadKey( 'NoEcho,IncludeKeyDown' ) ;
}
exit
}
elseif ( ( \$ args.Count -eq 1) -and ( \$ args[ 0] -eq "EVAL" ) ) {
Start-Process powershell.exe -Args "-executionpolicy bypass -command Set-Location '\$PSScriptRoot'; &'\$PSCommandPath'"
exit
}
2022-08-25 18:20:49 +02:00
if ( ( ( Test-Path -Path $( find " $WORK_DIR " /wsa/" $ARCH " -maxdepth 1 -mindepth 1 -printf "\"%P\"\n" | paste -sd "," -) ) -eq \$ false ) .Count) {
2022-08-14 14:05:43 +02:00
Write-Error "Some files are missing in the folder. Please try to build again. Press any key to exist"
2022-08-14 04:43:35 +02:00
\$ null = \$ Host.UI.RawUI.ReadKey( 'NoEcho,IncludeKeyDown' )
exit 1
}
reg add "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\AppModelUnlock" /t REG_DWORD /f /v "AllowDevelopmentWithoutDevLicense" /d "1"
\$ VMP = Get-WindowsOptionalFeature -Online -FeatureName 'VirtualMachinePlatform'
if ( \$ VMP.State -ne "Enabled" ) {
Enable-WindowsOptionalFeature -Online -NoRestart -FeatureName 'VirtualMachinePlatform'
Clear-Host
Write-Warning "Need restart to enable virtual machine platform\`r\`nPress y to restart or press any key to exit"
\$ key = \$ Host.UI.RawUI.ReadKey( 'NoEcho,IncludeKeyDown' )
If ( "y" -eq \$ key.Character) {
Restart-Computer -Confirm
}
Else {
exit 1
}
}
2022-08-25 20:33:27 +02:00
Add-AppxPackage -ForceApplicationShutdown -ForceUpdateFromAnyVersion -Path vclibs-$ARCH .appx
Add-AppxPackage -ForceApplicationShutdown -ForceUpdateFromAnyVersion -Path xaml-$ARCH .appx
2022-08-14 04:43:35 +02:00
\$ Installed = \$ null
\$ Installed = Get-AppxPackage -Name 'MicrosoftCorporationII.WindowsSubsystemForAndroid'
If ( ( \$ null -ne \$ Installed) -and ( -not ( \$ Installed.IsDevelopmentMode) ) ) {
Clear-Host
Write-Warning "There is already one installed WSA. Please uninstall it first.\`r\`nPress y to uninstall existing WSA or press any key to exit"
\$ key = \$ Host.UI.RawUI.ReadKey( 'NoEcho,IncludeKeyDown' )
If ( "y" -eq \$ key.Character) {
Remove-AppxPackage -Package \$ Installed.PackageFullName
}
Else {
exit 1
}
}
Clear-Host
Write-Host "Installing MagiskOnWSA..."
Stop-Process -Name "wsaclient" -ErrorAction "silentlycontinue"
Add-AppxPackage -ForceApplicationShutdown -ForceUpdateFromAnyVersion -Register .\A ppxManifest.xml
if ( \$ ?) {
Finish
}
Elseif ( \$ null -ne \$ Installed) {
Clear-Host
Write-Host "Failed to update, try to uninstall existing installation while preserving userdata..."
Remove-AppxPackage -PreserveApplicationData -Package \$ Installed.PackageFullName
Add-AppxPackage -ForceApplicationShutdown -ForceUpdateFromAnyVersion -Register .\A ppxManifest.xml
if ( \$ ?) {
Finish
}
}
Write-Host "All Done\`r\`nPress any key to exit"
\$ null = \$ Host.UI.RawUI.ReadKey( 'NoEcho,IncludeKeyDown' )
EOF
2022-08-17 12:43:34 +02:00
echo -e "Remove signature and add scripts done\n"
2022-08-14 04:43:35 +02:00
echo "Generate info"
2022-08-23 14:34:26 +02:00
2022-08-14 04:43:35 +02:00
if [ [ " $ROOT_SOL " = "none" ] ] ; then
name1 = ""
elif [ [ " $ROOT_SOL " = "" ] ] ; then
2022-08-25 20:33:27 +02:00
name1 = " -with-magisk- $MAGISK_VER "
2022-08-14 04:43:35 +02:00
else
2022-08-25 20:33:27 +02:00
name1 = " -with- $ROOT_SOL - $MAGISK_VER "
2022-08-14 04:43:35 +02:00
fi
if [ [ " $GAPPS_VARIANT " = "none" || " $GAPPS_VARIANT " = "" ] ] ; then
name2 = "-NoGApps"
else
2022-08-24 20:32:55 +02:00
if [ " $GAPPS_VARIANT " != "pico" ] && [ $GAPPS_BRAND = "OpenGApps" ] ; then
echo ":warning: Since OpenGApps doesn't officially support Android 12.1 yet, lock the variant to pico!"
2022-08-14 04:43:35 +02:00
fi
name2 = " -GApps- ${ GAPPS_VARIANT } "
fi
2022-08-23 07:04:16 +02:00
artifact_name = " WSA ${ name1 } ${ name2 } _ ${ WSA_VER } _ ${ ARCH } _ ${ WSA_REL } "
echo " $artifact_name "
2022-08-17 20:02:29 +02:00
echo -e "\nFinishing building...."
2022-08-25 08:38:44 +02:00
if [ -f " $OUTPUT_DIR " ] ; then
sudo rm -rf " ${ OUTPUT_DIR : ? } "
fi
2022-08-21 22:33:07 +02:00
if [ ! -d " $OUTPUT_DIR " ] ; then
2022-08-25 08:38:44 +02:00
mkdir -p " $OUTPUT_DIR "
2022-08-21 22:33:07 +02:00
fi
if [ " $COMPRESS_OUTPUT " = "yes" ] ; then
2022-08-23 10:32:34 +02:00
rm -f " ${ OUTPUT_DIR : ? } " /" $artifact_name .7z " || abort
2022-08-23 07:04:16 +02:00
7z a " $OUTPUT_DIR " /" $artifact_name .7z " " $WORK_DIR /wsa/ $ARCH / " || abort
2022-08-21 22:33:07 +02:00
elif [ " $COMPRESS_OUTPUT " = "no" ] ; then
2022-08-23 10:32:34 +02:00
rm -rf " ${ OUTPUT_DIR : ? } / ${ artifact_name } " || abort
mv " $WORK_DIR " /wsa/" $ARCH " " $OUTPUT_DIR / $artifact_name " || abort
2022-08-21 22:33:07 +02:00
fi
2022-08-17 12:43:34 +02:00
echo -e "done\n"
echo "Cleanup Work Directory"
2022-08-23 10:32:34 +02:00
sudo rm -rf " ${ WORK_DIR : ? } "
2022-08-17 12:43:34 +02:00
echo "done"