This commit is contained in:
Peter Njeim 2022-09-17 21:08:19 -03:00
commit 75b973630e
8 changed files with 55 additions and 39 deletions

View File

@ -18,7 +18,7 @@
5. Move the newly extracted folder to a suitable location (Documents folder is a good choice), as you will need to keep the folder on your PC to use MagiskOnWSA 5. Move the newly extracted folder to a suitable location (Documents folder is a good choice), as you will need to keep the folder on your PC to use MagiskOnWSA
> Note: If you're updating WSA, merge the folders and replace the files for all items when asked > Note: If you're updating WSA, merge the folders and replace the files for all items when asked
6. Open the WSA folder and right-click `Install.ps1`, then select `Run with PowerShell` 6. Open the WSA folder and double-click `Run.bat`
7. Once the installation process completes, WSA will launch (if this is a first-time install, a window asking for consent to diagnositic information will be shown instead. Sometimes two identical windows will show, this is fine and nothing bad happens if you click OK in both windows) 7. Once the installation process completes, WSA will launch (if this is a first-time install, a window asking for consent to diagnositic information will be shown instead. Sometimes two identical windows will show, this is fine and nothing bad happens if you click OK in both windows)
8. Click on the PowerShell window, then press any key on the keyboard, the PowerShell window should close 8. Click on the PowerShell window, then press any key on the keyboard, the PowerShell window should close
9. Close File Explorer 9. Close File Explorer
@ -58,7 +58,7 @@ Can I pass SafetyNet/Play Integrity?
What is virtualization? What is virtualization?
- Virtualization is required to run virtual machines like WSA. `Install.ps1` helps you enable it. After rebooting, re-run `Install.ps1` to install WSA. If it's still not working, you have to enable virtualization in your BIOS/UEFI. Instructions vary by PC vendor, look for help online - Virtualization is required to run virtual machines like WSA. `Run.bat` helps you enable it. After rebooting, re-run `Run.bat` to install WSA. If it's still not working, you have to enable virtualization in your BIOS/UEFI. Instructions vary by PC vendor, look for help online
Can I remount system partition as read-write? Can I remount system partition as read-write?

View File

@ -275,6 +275,12 @@ if [ "$DEBUG" ]; then
set -x set -x
fi fi
require_su() {
if [ "$(sudo whoami)" != "root" ]; then
sudo echo "sudo is required to run this script"
fi
}
declare -A RELEASE_NAME_MAP=(["retail"]="Retail" ["RP"]="Release Preview" ["WIS"]="Insider Slow" ["WIF"]="Insider Fast") declare -A RELEASE_NAME_MAP=(["retail"]="Retail" ["RP"]="Release Preview" ["WIS"]="Insider Slow" ["WIF"]="Insider Fast")
RELEASE_NAME=${RELEASE_NAME_MAP[$RELEASE_TYPE]} || abort RELEASE_NAME=${RELEASE_NAME_MAP[$RELEASE_TYPE]} || abort
@ -295,11 +301,10 @@ if [ "$GAPPS_BRAND" = "OpenGApps" ]; then
else else
GAPPS_PATH="$DOWNLOAD_DIR"/MindTheGapps-"$ARCH".zip GAPPS_PATH="$DOWNLOAD_DIR"/MindTheGapps-"$ARCH".zip
fi fi
if [ "$(sudo whoami)" != "root" ]; then
sudo echo "sudo is required to run this script"
fi
if [ -z "${OFFLINE+x}" ]; then if [ -z "${OFFLINE+x}" ]; then
trap 'rm -f -- "${DOWNLOAD_DIR:?}/${DOWNLOAD_CONF_NAME}"' EXIT trap 'rm -f -- "${DOWNLOAD_DIR:?}/${DOWNLOAD_CONF_NAME}"' EXIT
require_su
echo "Generate Download Links" echo "Generate Download Links"
python3 generateWSALinks.py "$ARCH" "$RELEASE_TYPE" "$DOWNLOAD_DIR" "$DOWNLOAD_CONF_NAME" || abort python3 generateWSALinks.py "$ARCH" "$RELEASE_TYPE" "$DOWNLOAD_DIR" "$DOWNLOAD_CONF_NAME" || abort
if [ -z "${CUSTOM_MAGISK+x}" ]; then if [ -z "${CUSTOM_MAGISK+x}" ]; then
@ -332,12 +337,14 @@ else
echo "Offline mode: Some files are missing, please disable offline mode." echo "Offline mode: Some files are missing, please disable offline mode."
exit 1 exit 1
fi fi
require_su
fi fi
echo "Extract WSA" echo "Extract WSA"
if [ -f "$WSA_ZIP_PATH" ]; then if [ -f "$WSA_ZIP_PATH" ]; then
WSA_WORK_ENV="${WORK_DIR:?}"/ENV WSA_WORK_ENV="${WORK_DIR:?}"/ENV
if [ -f "$WSA_WORK_ENV" ]; then rm -f "${WSA_WORK_ENV:?}"; fi if [ -f "$WSA_WORK_ENV" ]; then rm -f "${WSA_WORK_ENV:?}"; fi
touch "$WSA_WORK_ENV"
export WSA_WORK_ENV export WSA_WORK_ENV
if ! python3 extractWSA.py "$ARCH" "$WSA_ZIP_PATH" "$WORK_DIR"; then if ! python3 extractWSA.py "$ARCH" "$WSA_ZIP_PATH" "$WORK_DIR"; then
echo "Unzip WSA failed, is the download incomplete?" echo "Unzip WSA failed, is the download incomplete?"
@ -351,8 +358,8 @@ else
echo "The WSA zip package does not exist, is the download incomplete?" echo "The WSA zip package does not exist, is the download incomplete?"
exit 1 exit 1
fi fi
echo "Extract Magisk"
echo "Extract Magisk"
if [ -f "$MAGISK_PATH" ]; then if [ -f "$MAGISK_PATH" ]; then
if ! python3 extractMagisk.py "$ARCH" "$MAGISK_PATH" "$WORK_DIR"; then if ! python3 extractMagisk.py "$ARCH" "$MAGISK_PATH" "$WORK_DIR"; then
echo "Unzip Magisk failed, is the download incomplete?" echo "Unzip Magisk failed, is the download incomplete?"
@ -658,7 +665,7 @@ sudo rm -rf "${WORK_DIR:?}"/wsa/"$ARCH"/\[Content_Types\].xml "$WORK_DIR"/wsa/"$
cp "$vclibs_PATH" "$xaml_PATH" "$WORK_DIR"/wsa/"$ARCH" || abort cp "$vclibs_PATH" "$xaml_PATH" "$WORK_DIR"/wsa/"$ARCH" || abort
tee "$WORK_DIR"/wsa/"$ARCH"/Install.ps1 <<EOF tee "$WORK_DIR"/wsa/"$ARCH"/Install.ps1 <<EOF
# Automated Install script by Midonei # Automated Install script by Midonei
# http://github.com/doneibcn \$Host.UI.RawUI.WindowTitle = "Installing MagiskOnWSA..."
function Test-Administrator { function Test-Administrator {
[OutputType([bool])] [OutputType([bool])]
param() param()
@ -674,23 +681,23 @@ function Finish {
Start-Process "wsa://com.android.vending" Start-Process "wsa://com.android.vending"
} }
if (-not (Test-Administrator)) { If (-Not (Test-Administrator)) {
Set-ExecutionPolicy -Scope CurrentUser -ExecutionPolicy Bypass -Force 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 = Start-Process -PassThru -WindowStyle Hidden -Verb RunAs powershell.exe -Args "-ExecutionPolicy Bypass -Command Set-Location '\$PSScriptRoot'; &'\$PSCommandPath' EVAL"
\$proc.WaitForExit() \$proc.WaitForExit()
if (\$proc.ExitCode -ne 0) { If (\$proc.ExitCode -Ne 0) {
Clear-Host Clear-Host
Write-Warning "Failed to launch start as Administrator\`r\`nPress any key to exit" Write-Warning "Failed to launch start as Administrator\`r\`nPress any key to exit"
\$null = \$Host.UI.RawUI.ReadKey('NoEcho,IncludeKeyDown'); \$null = \$Host.UI.RawUI.ReadKey('NoEcho,IncludeKeyDown');
} }
exit exit
} }
elseif ((\$args.Count -eq 1) -and (\$args[0] -eq "EVAL")) { ElseIf ((\$args.Count -Eq 1) -And (\$args[0] -Eq "EVAL")) {
Start-Process powershell.exe -Args "-executionpolicy bypass -command Set-Location '\$PSScriptRoot'; &'\$PSCommandPath'" Start-Process powershell.exe -Args "-ExecutionPolicy Bypass -Command Set-Location '\$PSScriptRoot'; &'\$PSCommandPath'"
exit exit
} }
if (((Test-Path -Path $(find "$WORK_DIR"/wsa/"$ARCH" -maxdepth 1 -mindepth 1 -printf "\"%P\"\n" | paste -sd "," -)) -eq \$false).Count) { If (((Test-Path -Path $(find "$WORK_DIR"/wsa/"$ARCH" -maxdepth 1 -mindepth 1 -printf "\"%P\"\n" | paste -sd "," -)) -Eq \$false).Count) {
Write-Error "Some files are missing in the folder. Please try to build again. Press any key to exist" Write-Error "Some files are missing in the folder. Please try to build again. Press any key to exist"
\$null = \$Host.UI.RawUI.ReadKey('NoEcho,IncludeKeyDown') \$null = \$Host.UI.RawUI.ReadKey('NoEcho,IncludeKeyDown')
exit 1 exit 1
@ -698,13 +705,12 @@ if (((Test-Path -Path $(find "$WORK_DIR"/wsa/"$ARCH" -maxdepth 1 -mindepth 1 -pr
reg add "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\AppModelUnlock" /t REG_DWORD /f /v "AllowDevelopmentWithoutDevLicense" /d "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 (\$(Get-WindowsOptionalFeature -Online -FeatureName 'VirtualMachinePlatform').State -Ne "Enabled") {
if (\$VMP.State -ne "Enabled") {
Enable-WindowsOptionalFeature -Online -NoRestart -FeatureName 'VirtualMachinePlatform' Enable-WindowsOptionalFeature -Online -NoRestart -FeatureName 'VirtualMachinePlatform'
Clear-Host Clear-Host
Write-Warning "Need restart to enable virtual machine platform\`r\`nPress y to restart or press any key to exit" 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') \$key = \$Host.UI.RawUI.ReadKey('NoEcho,IncludeKeyDown')
If ("y" -eq \$key.Character) { If ("y" -Eq \$key.Character) {
Restart-Computer -Confirm Restart-Computer -Confirm
} }
Else { Else {
@ -718,11 +724,11 @@ Add-AppxPackage -ForceApplicationShutdown -ForceUpdateFromAnyVersion -Path xaml-
\$Installed = \$null \$Installed = \$null
\$Installed = Get-AppxPackage -Name 'MicrosoftCorporationII.WindowsSubsystemForAndroid' \$Installed = Get-AppxPackage -Name 'MicrosoftCorporationII.WindowsSubsystemForAndroid'
If ((\$null -ne \$Installed) -and (-not (\$Installed.IsDevelopmentMode))) { If ((\$null -Ne \$Installed) -And (-Not (\$Installed.IsDevelopmentMode))) {
Clear-Host 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" 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') \$key = \$Host.UI.RawUI.ReadKey('NoEcho,IncludeKeyDown')
If ("y" -eq \$key.Character) { If ("y" -Eq \$key.Character) {
Remove-AppxPackage -Package \$Installed.PackageFullName Remove-AppxPackage -Package \$Installed.PackageFullName
} }
Else { Else {
@ -731,23 +737,37 @@ If ((\$null -ne \$Installed) -and (-not (\$Installed.IsDevelopmentMode))) {
} }
Clear-Host Clear-Host
Write-Host "Installing MagiskOnWSA..." Write-Host "Installing MagiskOnWSA..."
Stop-Process -Name "wsaclient" -ErrorAction "silentlycontinue" Stop-Process -Name "WsaClient" -ErrorAction SilentlyContinue
Add-AppxPackage -ForceApplicationShutdown -ForceUpdateFromAnyVersion -Register .\AppxManifest.xml Add-AppxPackage -ForceApplicationShutdown -ForceUpdateFromAnyVersion -Register .\AppxManifest.xml
if (\$?) { If (\$?) {
Finish Finish
} }
Elseif (\$null -ne \$Installed) { ElseIf (\$null -Ne \$Installed) {
Clear-Host Clear-Host
Write-Host "Failed to update, try to uninstall existing installation while preserving userdata..." Write-Host "Failed to update, try to uninstall existing installation while preserving userdata..."
Remove-AppxPackage -PreserveApplicationData -Package \$Installed.PackageFullName Remove-AppxPackage -PreserveApplicationData -Package \$Installed.PackageFullName
Add-AppxPackage -ForceApplicationShutdown -ForceUpdateFromAnyVersion -Register .\AppxManifest.xml Add-AppxPackage -ForceApplicationShutdown -ForceUpdateFromAnyVersion -Register .\AppxManifest.xml
if (\$?) { If (\$?) {
Finish Finish
} }
} }
Write-Host "All Done\`r\`nPress any key to exit" Write-Host "All Done!\`r\`nPress any key to exit"
\$null = \$Host.UI.RawUI.ReadKey('NoEcho,IncludeKeyDown') \$null = \$Host.UI.RawUI.ReadKey('NoEcho,IncludeKeyDown')
EOF EOF
tee "$WORK_DIR"/wsa/"$ARCH"/Run.bat <<EOF
:: Automated Install batch script by Syuugo
@echo off
if not exist Install.ps1 (
echo "Install.ps1" is not found.
echo Press any key to exit
pause>nul
exit 1
) else (
start powershell.exe -File .\Install.ps1 -ExecutionPolicy Bypass
exit
)
EOF
echo -e "Remove signature and add scripts done\n" echo -e "Remove signature and add scripts done\n"
echo "Generate info" echo "Generate info"

View File

@ -21,7 +21,6 @@
import sys import sys
import zipfile import zipfile
import os
from pathlib import Path from pathlib import Path
import platform import platform
@ -29,9 +28,9 @@ is_x86_64 = platform.machine() in ("AMD64", "x86_64")
host_abi = "x64" if is_x86_64 else "arm64" host_abi = "x64" if is_x86_64 else "arm64"
arch = sys.argv[1] arch = sys.argv[1]
magisk_zip = sys.argv[2] magisk_zip = sys.argv[2]
if not os.path.exists(Path.cwd().parent / sys.argv[3] / "magisk"): workdir = Path(sys.argv[3]) / "magisk"
os.makedirs(Path.cwd().parent / sys.argv[3] / "magisk") if not Path(workdir).is_dir():
workdir = Path.cwd().parent / sys.argv[3] / "magisk" workdir.mkdir()
abi_map = {"x64": ["x86_64", "x86"], "arm64": ["arm64-v8a", "armeabi-v7a"]} abi_map = {"x64": ["x86_64", "x86"], "arm64": ["arm64-v8a", "armeabi-v7a"]}

View File

@ -31,15 +31,15 @@ arch = sys.argv[1]
zip_name = "" zip_name = ""
wsa_zip_path= Path(sys.argv[2]).resolve() wsa_zip_path= Path(sys.argv[2]).resolve()
workdir = Path.cwd().parent / sys.argv[3] / "wsa" workdir = Path(sys.argv[3]) / "wsa"
if not os.path.exists(workdir): if not Path(workdir).is_dir():
os.makedirs(workdir) workdir.mkdir()
with zipfile.ZipFile(wsa_zip_path) as zip: with zipfile.ZipFile(wsa_zip_path) as zip:
for f in zip.filelist: for f in zip.filelist:
if arch in f.filename.lower(): if arch in f.filename.lower():
zip_name = f.filename zip_name = f.filename
output_name = zip_name[11:-5] output_name = zip_name[11:-5]
if not os.path.isfile(workdir / zip_name): if not Path(workdir / zip_name).is_file():
zip_path = workdir / zip_name zip_path = workdir / zip_name
print(f"unzipping to {workdir}", flush=True) print(f"unzipping to {workdir}", flush=True)
zip.extract(f, workdir) zip.extract(f, workdir)
@ -69,6 +69,6 @@ with zipfile.ZipFile(wsa_zip_path) as zip:
g.filename = f'{name}.xml' g.filename = f'{name}.xml'
l.extract(g, workdir / 'xml') l.extract(g, workdir / 'xml')
with zipfile.ZipFile(zip_path) as zip: with zipfile.ZipFile(zip_path) as zip:
if not os.path.isdir(workdir / arch): if not Path(workdir / arch).is_dir():
print(f"unzipping from {zip_path}", flush=True) print(f"unzipping from {zip_path}", flush=True)
zip.extractall(workdir / arch) zip.extractall(workdir / arch)

View File

@ -20,8 +20,8 @@
from __future__ import annotations from __future__ import annotations
from io import TextIOWrapper from io import TextIOWrapper
from os import system, path
from typing import OrderedDict from typing import OrderedDict
from pathlib import Path
import sys import sys
class Prop(OrderedDict): class Prop(OrderedDict):
def __init__(self, file: TextIOWrapper) -> None: def __init__(self, file: TextIOWrapper) -> None:
@ -61,7 +61,7 @@ def fingerprint(sec: str, p: Prop) -> str:
def fix_prop(sec, prop): def fix_prop(sec, prop):
if not path.exists(prop): if not Path(prop).is_file():
return return
print(f"fixing {prop}", flush=True) print(f"fixing {prop}", flush=True)

View File

@ -21,7 +21,6 @@
import sys import sys
import requests import requests
import os
import json import json
import re import re
from pathlib import Path from pathlib import Path

View File

@ -20,7 +20,6 @@
import sys import sys
import os
import json import json
import requests import requests
from pathlib import Path from pathlib import Path

View File

@ -25,7 +25,6 @@ from xml.dom import minidom
import html import html
import warnings import warnings
import re import re
import os
from pathlib import Path from pathlib import Path
warnings.filterwarnings("ignore") warnings.filterwarnings("ignore")
@ -81,8 +80,8 @@ for node in doc.getElementsByTagName('SecuredFragment'):
with open(Path.cwd().parent / "xml/FE3FileUrl.xml", "r") as f: with open(Path.cwd().parent / "xml/FE3FileUrl.xml", "r") as f:
file_content = f.read() file_content = f.read()
if not os.path.exists(download_dir): if not download_dir.is_dir():
os.makedirs(download_dir) download_dir.mkdir()
tmpdownlist = open(download_dir/tempScript, 'a') tmpdownlist = open(download_dir/tempScript, 'a')
for i, v, f in identities: for i, v, f in identities:
if re.match(f"Microsoft\.UI\.Xaml\..*_{arch}_.*\.appx", f): if re.match(f"Microsoft\.UI\.Xaml\..*_{arch}_.*\.appx", f):