Skip to content

Commit

Permalink
Fix resources merge for 2302 (#430)
Browse files Browse the repository at this point in the history
Fix #424
  • Loading branch information
Howard20181 committed Mar 19, 2023
1 parent ec58edf commit 87ec298
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 29 deletions.
10 changes: 7 additions & 3 deletions installer/Install.ps1
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Automated Install script by Midonei
$Host.UI.RawUI.WindowTitle = "Installing MagiskOnWSA..."
$Host.UI.RawUI.WindowTitle = "Installing MagiskOnWSA...."
function Test-Administrator {
[OutputType([bool])]
param()
Expand Down Expand Up @@ -49,7 +49,11 @@ If (((Test-Path -Path $FileList) -Eq $false).Count) {
}

If ((Test-Path -Path "MakePri.ps1") -Eq $true) {
Start-Process powershell.exe -Wait -Args "-ExecutionPolicy Bypass -File MakePri.ps1" -WorkingDirectory $PSScriptRoot
$ProcMakePri = Start-Process powershell.exe -PassThru -Args "-ExecutionPolicy Bypass -File MakePri.ps1" -WorkingDirectory $PSScriptRoot
$ProcMakePri.WaitForExit()
If ($ProcMakePri.ExitCode -Ne 0) {
Write-Warning "Failed to merge resources, WSA Seetings will always be in English`r`n"
}
}

reg add "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\AppModelUnlock" /t REG_DWORD /f /v "AllowDevelopmentWithoutDevLicense" /d "1"
Expand Down Expand Up @@ -101,7 +105,7 @@ If (($null -Ne $Installed) -And (-Not ($Installed.IsDevelopmentMode))) {
}
}
Clear-Host
Write-Host "Installing MagiskOnWSA..."
Write-Host "Installing MagiskOnWSA...."
Stop-Process -Name "WsaClient" -ErrorAction SilentlyContinue
Add-AppxPackage -ForceApplicationShutdown -ForceUpdateFromAnyVersion -Register .\AppxManifest.xml
If ($?) {
Expand Down
65 changes: 40 additions & 25 deletions installer/MakePri.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -16,34 +16,49 @@
# Copyright (C) 2023 LSPosed Contributors
#

$Host.UI.RawUI.WindowTitle = "Merging resources...."
If ((Test-Path -Path "pri") -Eq $true -And (Test-Path -Path "xml") -Eq $true) {
$AppxManifestFile = ".\AppxManifest.xml"
Copy-Item .\resources.pri -Destination ".\pri\resources.pri"
$proc = Start-Process -PassThru makepri.exe -Args "new /pr .\pri /cf .\xml\priconfig.xml /of .\resources.pri /mn $AppxManifestFile /o"
$proc.WaitForExit()
If ($proc.ExitCode -Ne 0) {
Write-Warning "Failed to merge resources`r`n"
exit 1
}
else {
$ProjectXml = [xml](Get-Content $AppxManifestFile)
$ProjectResources = $ProjectXml.Package.Resources;
$Item = Get-Item .\xml\* -Exclude "priconfig.xml" -Include "*.xml"
$Item | ForEach-Object {
$Xml = [xml](Get-Content $_)
$Resource = $Xml.Package.Resources.Resource
$newNode = $ProjectXml.ImportNode($Resource, $true)
$ProjectResources.AppendChild($newNode)
$ProcNew = Start-Process -PassThru makepri.exe -WindowStyle Hidden -Args "new /pr .\pri /cf .\xml\priconfig.xml /of .\resources.pri /mn $AppxManifestFile /o"
$ProcNew.WaitForExit()
If ($ProcNew.ExitCode -Ne 0) {
Write-Warning "Failed to merge resources from pri`r`nTrying to dump...."
New-Item -Path "." -Name "priinfo" -ItemType "directory"
$Processes = ForEach ($Item in Get-Item ".\pri\*" -Include "*.pri") {
$Name = $Item.Name
Write-Host "Dumping $Name....`r`n"
Start-Process -PassThru -WindowStyle Hidden makepri.exe -Args "dump /if $Item /o /es .\resources.pri /of .\priinfo\$Name.xml /dt detailed"
}
Write-Host "Dumping resources....`r`n"
$Processes | Wait-Process
Write-Host "Creating pri from dumps....`r`n"
$ProcNewFromDump = Start-Process -PassThru -WindowStyle Hidden makepri.exe -Args "new /pr .\priinfo /cf .\xml\priconfig.xml /of .\resources.pri /mn $AppxManifestFile /o"
$ProcNewFromDump.WaitForExit()
Remove-Item 'priinfo' -Recurse
If ($ProcNewFromDump.ExitCode -Ne 0) {
Write-Warning "Failed to merge resources from dump`r`n"
exit 1
}
$ProjectXml.Save($AppxManifestFile)
Remove-Item 'pri' -Recurse
Set-Content -Path "filelist.txt" -Value (Get-Content -Path "filelist.txt" | Select-String -Pattern '^pri$' -NotMatch)
Remove-Item 'xml' -Recurse
Set-Content -Path "filelist.txt" -Value (Get-Content -Path "filelist.txt" | Select-String -Pattern '^xml$' -NotMatch)
Remove-Item 'makepri.exe'
Set-Content -Path "filelist.txt" -Value (Get-Content -Path "filelist.txt" | Select-String -Pattern 'makepri.exe' -NotMatch)
Remove-Item $PSCommandPath -Force
Set-Content -Path "filelist.txt" -Value (Get-Content -Path "filelist.txt" | Select-String -Pattern 'MakePri.ps1' -NotMatch)
exit 0
}

$ProjectXml = [xml](Get-Content $AppxManifestFile)
$ProjectResources = $ProjectXml.Package.Resources;
$Item = Get-Item .\xml\* -Exclude "priconfig.xml" -Include "*.xml"
$Item | ForEach-Object {
$Xml = [xml](Get-Content $_)
$Resource = $Xml.Package.Resources.Resource
$newNode = $ProjectXml.ImportNode($Resource, $true)
$ProjectResources.AppendChild($newNode)
}
$ProjectXml.Save($AppxManifestFile)
Remove-Item 'pri' -Recurse
Set-Content -Path "filelist.txt" -Value (Get-Content -Path "filelist.txt" | Select-String -Pattern '^pri$' -NotMatch)
Remove-Item 'xml' -Recurse
Set-Content -Path "filelist.txt" -Value (Get-Content -Path "filelist.txt" | Select-String -Pattern '^xml$' -NotMatch)
Remove-Item 'makepri.exe'
Set-Content -Path "filelist.txt" -Value (Get-Content -Path "filelist.txt" | Select-String -Pattern 'makepri.exe' -NotMatch)
Remove-Item $PSCommandPath -Force
Set-Content -Path "filelist.txt" -Value (Get-Content -Path "filelist.txt" | Select-String -Pattern 'MakePri.ps1' -NotMatch)
exit 0
}
2 changes: 1 addition & 1 deletion scripts/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -898,7 +898,7 @@ if [ "$COMPRESS_OUTPUT" ] || [ -n "$COMPRESS_FORMAT" ]; then
elif [ "$COMPRESS_FORMAT" = "xz" ]; then
echo "Compressing with tar xz"
if ! (tar -cP -I 'xz -9 -T0' -f "$OUTPUT_PATH" "$WORK_DIR/wsa/$artifact_name"); then
echo "Out of memory? Trying again with single threads..."
echo "Out of memory? Trying again with single threads...."
tar -cPJvf "$OUTPUT_PATH" "$WORK_DIR/wsa/$artifact_name" || abort
fi
elif [ "$COMPRESS_FORMAT" = "zip" ]; then
Expand Down
1 change: 1 addition & 0 deletions xml/priconfig.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@
<indexer-config type="folder" foldernameAsQualifier="true" filenameAsQualifier="true"
qualifierDelimiter="." />
<indexer-config type="PRI" />
<indexer-config type="priinfo" />
</index>
</resources>

0 comments on commit 87ec298

Please sign in to comment.