Skip to content

Commit

Permalink
Optimize scripts & Fix arm64 MakePri
Browse files Browse the repository at this point in the history
  • Loading branch information
s1204IT authored Oct 10, 2023
1 parent 4c74f63 commit d0251c3
Show file tree
Hide file tree
Showing 10 changed files with 307 additions and 103 deletions.
19 changes: 10 additions & 9 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,10 @@ jobs:
./scripts/build.sh --arch ${{ inputs.arch }} --release-type $RELEASE_TYPE --magisk-ver stable --gapps-brand ${{ inputs.gapps }} --root-sol ${{ inputs.root }} --custom-model redfin --remove-amazon --compress-format zip
- name: Pass to Windows 💸
uses: actions/cache/save@v3
uses: actions/upload-artifact@v3
with:
name: ${{ steps.wsa.outputs.artifact }}
path: output
key: ${{ steps.wsa.outputs.artifact }}
enableCrossOsArchive: true

- name: Prepare release tag 🏷️
id: date
Expand All @@ -88,16 +87,18 @@ jobs:
uses: actions/checkout@v4

- name: Download built artifact ⌛
uses: actions/cache/restore@v3
uses: actions/download-artifact@v3
with:
path: output
key: ${{ needs.build.outputs.artifact }}
enableCrossOsArchive: true
fail-on-cache-miss: true
name: ${{ needs.build.outputs.zipname }}

- name: Merge language and density resources 🧙🏻‍♂️
run: (Start-Process pwsh.exe -NoNewWindow -PassThru -Args "-ExecutionPolicy Bypass -File MakePri.ps1" -WorkingDirectory "${{ github.workspace }}\output\${{ needs.build.outputs.zipname }}").WaitForExit()

run: |
if ("${{ inputs.arch }}" -eq "x64") {
(Start-Process pwsh.exe -NoNewWindow -PassThru -Args "-ExecutionPolicy Bypass -File MakePri.ps1" -WorkingDirectory "${{ github.workspace }}\output\${{ needs.build.outputs.zipname }}").WaitForExit()
} else {
Copy-Item -Force "C:\Program Files (x86)\Windows Kits\10\bin\10.0.22621.0\arm64\makepri.exe" "${{ github.workspace }}\output\${{ needs.build.outputs.zipname }}"
}
- name: Compact Images 💿
run: |
foreach ($Partition in 'system','product','system_ext','vendor') {
Expand Down
12 changes: 11 additions & 1 deletion .github/workflows/comment_on_issues.yml
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,7 @@ jobs:
./scripts/build.sh ${{ env.body }} --after-compress
- name: Pass to Windows
if: env.iscustom == 'true' && success() && env.released == 'false' && env.insider == 'false'
uses: actions/cache/save@v3
with:
path: output
Expand All @@ -238,9 +239,11 @@ jobs:
outputs:
artifact: ${{ steps.wsa.outputs.artifact }}
file_ext: ${{ steps.wsa.outputs.file_ext }}
arch: ${{ steps.wsa.outputs.arch }}
comment-id: ${{ steps.comment.outputs.comment-id }}

make-pri:
if: env.iscustom == 'true' && && env.released == 'false' && env.insider == 'false'
name: Merge PRI resources and Complete issue
runs-on: windows-latest
needs: build
Expand All @@ -257,9 +260,16 @@ jobs:
fail-on-cache-miss: true

- name: Merge language and density resources
run: (Start-Process pwsh.exe -NoNewWindow -PassThru -Args "-ExecutionPolicy Bypass -File MakePri.ps1" -WorkingDirectory "${{ github.workspace }}\output\${{ needs.build.outputs.artifact }}").WaitForExit()
if: success()
run: |
if ("${{ needs.build.outputs.arch }}" -eq "x64") {
(Start-Process pwsh.exe -NoNewWindow -PassThru -Args "-ExecutionPolicy Bypass -File MakePri.ps1" -WorkingDirectory "${{ github.workspace }}\output\${{ needs.build.outputs.artifact }}").WaitForExit()
} else {
Copy-Item -Force "C:\Program Files (x86)\Windows Kits\10\bin\10.0.22621.0\arm64\makepri.exe" "${{ github.workspace }}\output\${{ needs.build.outputs.artifact }}"
}
- name: Compact Images 💿
if: success()
run: |
foreach ($Partition in 'system','product','system_ext','vendor') {
Write-Output "Optimizing of $Partition..."
Expand Down
7 changes: 6 additions & 1 deletion .github/workflows/custom_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,12 @@ jobs:
fail-on-cache-miss: true

- name: Merge language and density resources 🧙🏻‍♂️
run: (Start-Process pwsh.exe -NoNewWindow -PassThru -Args "-ExecutionPolicy Bypass -File MakePri.ps1" -WorkingDirectory "${{ github.workspace }}\output\${{ needs.build.outputs.artifact }}").WaitForExit()
run: |
if ("${{ inputs.arch }}" -eq "x64") {
(Start-Process pwsh.exe -NoNewWindow -PassThru -Args "-ExecutionPolicy Bypass -File MakePri.ps1" -WorkingDirectory "${{ github.workspace }}\output\${{ needs.build.outputs.artifact }}").WaitForExit()
} else {
Copy-Item -Force "C:\Program Files (x86)\Windows Kits\10\bin\10.0.22621.0\arm64\makepri.exe" "${{ github.workspace }}\output\${{ needs.build.outputs.artifact }}"
}
- name: Compact Images 💿
run: |
Expand Down
8 changes: 4 additions & 4 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,14 +119,14 @@
<tr>
<td><a href=https://github.com/YT-Advanced/WSA-Script/releases/tag/WSA-Insider-Version><img src="https://img.shields.io/badge/Pre--Release%20Builds-orange?style=for-the-badge" height="28"></a></td>
<td>Follows the "WSA Preview Program Channel" </br> </br> Builds are generally newer than the "WSA Retail" and "Insider Fast Channel"</td>
<td>2309.40000.5.0<br></td>
<td>Builds Released: 05/10/2023</td>
<td>2309.40000.7.0<br></td>
<td>Builds Released: 10/10/2023</td>
</tr>
<tr>
<td><a href=https://github.com/YT-Advanced/releases/latest><img src="https://img.shields.io/badge/Stable%20Builds-blue?style=for-the-badge" alt="Image" height="28"></a></td>
<td>Follows the "WSA Retail Channel" <br><br> Builds are generally more stable than the builds in the "WSA Preview Program Channel" </td>
<td>2308.40000.3.0<br></td>
<td>Builds Released: 18/09/2023</td>
<td>2308.40000.4.0<br></td>
<td>Builds Released: 10/10/2023</td>
</tr>
<tr>
<td colspan="4"><h4>It is recommend to check this table regularly to see if there is a newer update avaliable for WSA for the Stable Builds and Pre-Release Builds<h4></td>
Expand Down
8 changes: 2 additions & 6 deletions installer/Run.bat
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
:: Automated Install batch script by Syuugo

@echo off
%~d0
cd "%~dp0"
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 -ExecutionPolicy Bypass -File .\Install.ps1
exit
)
start powershell.exe -ExecutionPolicy Bypass -File .\Install.ps1
exit
111 changes: 42 additions & 69 deletions installer/Install.ps1 → installer/arm64/Install.ps1
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#
# This file is part of MagiskOnWSALocal.
#
# MagiskOnWSALocal is free software: you can redistribute it and/or modify
Expand All @@ -16,103 +17,78 @@
# Copyright (C) 2023 LSPosed Contributors
#

$Host.UI.RawUI.WindowTitle = "Installing MagiskOnWSA...."
function Test-Administrator {
[OutputType([bool])]
param()
process {
[Security.Principal.WindowsPrincipal]$user = [Security.Principal.WindowsIdentity]::GetCurrent();
return $user.IsInRole([Security.Principal.WindowsBuiltinRole]::Administrator);
}
}

function Get-InstalledDependencyVersion {
param (
[string]$Name,
[string]$ProcessorArchitecture
)
PROCESS {
If ($null -Ne $ProcessorArchitecture) {
return Get-AppxPackage -Name $Name | ForEach-Object { if ($_.Architecture -Eq $ProcessorArchitecture) { $_ } } | Sort-Object -Property Version | Select-Object -ExpandProperty Version -Last 1;
}
}
}

Function Test-CommandExist {
Param ($Command)
$OldPreference = $ErrorActionPreference
$ErrorActionPreference = 'stop'
try { if (Get-Command $Command) { RETURN $true } }
Catch { RETURN $false }
Finally { $ErrorActionPreference = $OldPreference }
}
$Host.UI.RawUI.WindowTitle = "Installing MagiskOnWSA..."

function Finish {
Clear-Host
Start-Process "shell:AppsFolder\MicrosoftCorporationII.WindowsSubsystemForAndroid_8wekyb3d8bbwe!SettingsApp"
Start-Process "wsa://com.topjohnwu.magisk"
Start-Process "wsa://com.android.vending"
Start-Process "wsa://com.android.settings"
}

If (Test-CommandExist pwsh.exe) {
$pwsh = "pwsh.exe"
} Else {
$pwsh = "powershell.exe"
Write-Output "All Done!`r`nPress any key to exit"
$null = $Host.UI.RawUI.ReadKey('NoEcho,IncludeKeyDown')
exit 0
}

If (-Not (Test-Administrator)) {
$pwsh = "powershell.exe"

if ((New-Object Security.Principal.WindowsPrincipal([Security.Principal.WindowsIdentity]::GetCurrent())).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator) -ne $true) {
Set-ExecutionPolicy -Scope CurrentUser -ExecutionPolicy Bypass -Force
$Proc = Start-Process -PassThru -Verb RunAs $pwsh -Args "-ExecutionPolicy Bypass -Command Set-Location '$PSScriptRoot'; &'$PSCommandPath' EVAL"
If ($null -Ne $Proc) {
if ($null -ne $Proc) {
$Proc.WaitForExit()
}
If ($null -Eq $Proc -Or $Proc.ExitCode -Ne 0) {
if ($null -eq $Proc -or $Proc.ExitCode -ne 0) {
Write-Warning "`r`nFailed 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")) {
} elseif (($args.Count -eq 1) -and ($args[0] -eq "EVAL")) {
Start-Process $pwsh -NoNewWindow -Args "-ExecutionPolicy Bypass -Command Set-Location '$PSScriptRoot'; &'$PSCommandPath'"
exit
}

$FileList = Get-Content -Path .\filelist.txt
If (((Test-Path -Path $FileList) -Eq $false).Count) {
if (((Test-Path -Path $FileList) -eq $false).Count) {
Write-Error "`r`nSome files are missing in the folder.`r`nPlease try to build again.`r`n`r`nPress any key to exit"
$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"

# When using PowerShell which is installed with MSIX
# Get-WindowsOptionalFeature and Enable-WindowsOptionalFeature will fail
# See https://github.com/PowerShell/PowerShell/issues/13866
if ($PSHOME.contains("8wekyb3d8bbwe")) {
Import-Module DISM -UseWindowsPowerShell
}

If ($(Get-WindowsOptionalFeature -Online -FeatureName 'VirtualMachinePlatform').State -Ne "Enabled") {
if ($(Get-WindowsOptionalFeature -Online -FeatureName 'VirtualMachinePlatform').State -ne "Enabled") {
Enable-WindowsOptionalFeature -Online -NoRestart -FeatureName 'VirtualMachinePlatform'
Write-Warning "`r`nNeed 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) {
if ("y" -eq $Key.Character) {
Restart-Computer -Confirm
} Else {
} else {
exit 1
}
}

if (((Test-Path -Path "MakePri.ps1") -and (Test-Path -Path "makepri.exe")) -eq $true) {
$ProcMakePri = Start-Process $pwsh -PassThru -NoNewWindow -Args "-ExecutionPolicy Bypass -File MakePri.ps1" -WorkingDirectory $PSScriptRoot
$null = $ProcMakePri.Handle
$ProcMakePri.WaitForExit()
if ($ProcMakePri.ExitCode -ne 0) {
Write-Warning "`r`nFailed to merge resources, WSA Seetings will always be in English`r`nPress any key to continue"
$null = $Host.UI.RawUI.ReadKey('NoEcho,IncludeKeyDown')
}
$Host.UI.RawUI.WindowTitle = "Installing MagiskOnWSA...."
}

if ((Test-Path -Path 'uwp') -eq $true) {
[xml]$Xml = Get-Content ".\AppxManifest.xml";
$Name = $Xml.Package.Identity.Name;
Write-Output "Installing $Name version: $($Xml.Package.Identity.Version)"
$ProcessorArchitecture = $Xml.Package.Identity.ProcessorArchitecture;
$Dependencies = $Xml.Package.Dependencies.PackageDependency;
$Dependencies | ForEach-Object {
$InstalledVersion = Get-InstalledDependencyVersion -Name $_.Name -ProcessorArchitecture $ProcessorArchitecture;
if ( $InstalledVersion -Lt $_.MinVersion ) {
$InstalledVersion = Get-AppxPackage -Name $_.Name | ForEach-Object { if ($_.Architecture -eq $ProcessorArchitecture) { $_ } } | Sort-Object -Property Version | Select-Object -ExpandProperty Version -Last 1
if ( $InstalledVersion -lt $_.MinVersion ) {
if ($env:WT_SESSION) {
$env:WT_SESSION = $null
Write-Output "`r`nDependency should be installed but Windows Terminal is in use. Restarting to conhost.exe"
Expand All @@ -132,24 +108,24 @@ if ((Test-Path -Path 'uwp') -eq $true) {
$Installed = $null
$Installed = Get-AppxPackage -Name $Name

If (($null -Ne $Installed) -And (-Not ($Installed.IsDevelopmentMode))) {
if (($null -ne $Installed) -and (-not ($Installed.IsDevelopmentMode))) {
Write-Warning "`r`nThere is already one installed WSA.`r`nPlease uninstall it first.`r`n`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) {
if ("y" -eq $key.Character) {
Clear-Host
Remove-AppxPackage -Package $Installed.PackageFullName
}
Else {
} else {
exit 1
}
}

If (Test-CommandExist WsaClient) {
Write-Output "`r`nShutting down WSA...."
if ($Installed) {
Write-Output "`r`nShutting down WSA..."
Start-Process WsaClient -Wait -Args "/shutdown"
}
Stop-Process -Name "WsaClient" -ErrorAction SilentlyContinue
Write-Output "`r`nInstalling MagiskOnWSA...."

Write-Output "`r`nInstalling MagiskOnWSA..."

$winver = (Get-WmiObject -class Win32_OperatingSystem).Caption
if ($winver.Contains("10")) {
Expand All @@ -165,27 +141,24 @@ if ($winver.Contains("10")) {
$xml.Package.Extensions.RemoveChild($node) | Out-Null
$xml.Package.Dependencies.TargetDeviceFamily.MinVersion = "10.0.19041.264"
$xml.Save(".\AppxManifest.xml")

Clear-Host
Write-Output "`r`nDownloading modifided DLL file..."
Invoke-WebRequest -Uri https://github.com/cinit/WSAPatch/blob/main/original.dll.win11.22h2/x86_64/winhttp.dll?raw=true -OutFile .\WSAClient\winhttp.dll
Invoke-WebRequest -Uri https://github.com/YT-Advanced/WSA-Script/blob/main/DLL/WsaPatch.dll?raw=true -OutFile .\WSAClient\WsaPatch.dll
Invoke-WebRequest -Uri https://github.com/YT-Advanced/WSA-Script/blob/main/DLL/icu.dll?raw=true -OutFile .\WSAClient\icu.dll
$ProgressPreference = 'SilentlyContinue'
Invoke-WebRequest -Uri "https://github.com/cinit/WSAPatch/blob/main/original.dll.win11.22h2/x86_64/winhttp.dll?raw=true" -OutFile .\WSAClient\winhttp.dll
Invoke-WebRequest -Uri "https://github.com/YT-Advanced/WSA-Script/blob/main/DLL/WsaPatch.dll?raw=true" -OutFile .\WSAClient\WsaPatch.dll
Invoke-WebRequest -Uri "https://github.com/YT-Advanced/WSA-Script/blob/main/DLL/icu.dll?raw=true" -OutFile .\WSAClient\icu.dll
}

Add-AppxPackage -ForceApplicationShutdown -ForceUpdateFromAnyVersion -Register .\AppxManifest.xml
If ($?) {
if ($?) {
Finish
}
ElseIf ($null -Ne $Installed) {
} elseif ($null -ne $Installed) {
Write-Error "`r`nFailed to update.`r`nPress any key to uninstall existing installation while preserving user data.`r`nTake in mind that this will remove the Android apps' icon from the start menu.`r`nIf you want to cancel, close this window now."
$null = $Host.UI.RawUI.ReadKey('NoEcho,IncludeKeyDown')
Clear-Host
Remove-AppxPackage -PreserveApplicationData -Package $Installed.PackageFullName
Add-AppxPackage -ForceApplicationShutdown -ForceUpdateFromAnyVersion -Register .\AppxManifest.xml
If ($?) {
if ($?) {
Finish
}
}
Write-Output "All Done!`r`nPress any key to exit"
$null = $Host.UI.RawUI.ReadKey('NoEcho,IncludeKeyDown')
65 changes: 65 additions & 0 deletions installer/arm64/MakePri.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# 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) 2023 LSPosed Contributors
#

$Host.UI.RawUI.WindowTitle = "Merging resources...."
if (((Test-Path -Path $(Get-Content -Path .\filelist-pri.txt)) -eq $false).Count) {
Write-Error "Some files are missing in the folder. Please try to build again. Press any key to exit"
$null = $Host.UI.RawUI.ReadKey('NoEcho,IncludeKeyDown')
exit 1
} else {
New-Item -Path "." -Name "priinfo" -ItemType "directory" | Out-Null
Copy-Item .\resources.pri -Destination ".\pri\resources.pri" | Out-Null
Clear-Host
$AppxManifestFile = ".\AppxManifest.xml"
$PriItem = Get-Item ".\pri\*" -Include "*.pri"
Write-Output "Dumping resources...."
$i = 0
$Processes = foreach ($Item in $PriItem) {
Start-Process -PassThru -WindowStyle Hidden makepri.exe -Args "dump /if $($Item | Resolve-Path -Relative) /o /es .\pri\resources.pri /of .\priinfo\$($Item.Name).xml /dt detailed"
++$i
$Completed = ($i / $PriItem.count) * 100
Write-Progress -Activity "Dumping resources" -Status "Dumping $($Item.Name):" -PercentComplete $Completed
}
$Processes | Wait-Process
Write-Progress -Activity "Dumping resources" -Status "Ready" -Completed
Clear-Host
Write-Output "Creating pri from dumps...."
$ProcNewFromDump = Start-Process -PassThru -NoNewWindow makepri.exe -Args "new /pr .\priinfo /cf .\xml\priconfig.xml /of .\resources.pri /mn $AppxManifestFile /o"
$null = $ProcNewFromDump.Handle
$ProcNewFromDump.WaitForExit()
Remove-Item 'priinfo' -Recurse
if ($ProcNewFromDump.ExitCode -Ne 0) {
Write-Error "Failed to create resources from priinfos"
exit 1
}

$ProjectXml = [xml](Get-Content $AppxManifestFile)
$ProjectResources = $ProjectXml.Package.Resources;
$(Get-Item .\xml\* -Exclude "priconfig.xml" -Include "*.xml") | ForEach-Object {
$($([xml](Get-Content $_)).Package.Resources.Resource) | ForEach-Object {
$ProjectResources.AppendChild($($ProjectXml.ImportNode($_, $true)))
}
}
$ProjectXml.Save($AppxManifestFile)
Remove-Item 'pri' -Recurse -Force
Remove-Item 'xml' -Recurse -Force
Remove-Item 'makepri.exe' -Force
Remove-Item 'filelist-pri.txt' -Force
Remove-Item $PSCommandPath -Force
exit 0
}
Loading

0 comments on commit d0251c3

Please sign in to comment.