From 7ea2ab1f0abc4ff4fa0dfe2ebe4e9b2570c23df6 Mon Sep 17 00:00:00 2001 From: Hsiao-nan Cheung Date: Tue, 9 Apr 2024 01:39:28 +0800 Subject: [PATCH 1/2] Use `wix.exe` in WiX Toolset v4+ as primary extractor of `Expand-DarkArchive()` --- CHANGELOG.md | 1 + lib/core.ps1 | 4 ++-- lib/decompress.ps1 | 12 ++++++++++-- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7912cc5d07..212bf493b4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -48,6 +48,7 @@ - **core:** Fix arguments parsing method of `Invoke-ExternalCommand()` ([#5839](https://github.com/ScoopInstaller/Scoop/issues/5839)) - **scoop-alias:** Prevent overwrite existing file when adding alias ([#5577](https://github.com/ScoopInstaller/Scoop/issues/5577)) - **scoop-virustotal:** Fix the issue that escape character not available in PowerShell 5.1 ([#5870](https://github.com/ScoopInstaller/Scoop/issues/5870)) +- **decompress:** Use `wix.exe` in WiX Toolset v4+ as primary extractor of `Expand-DarkArchive()` ([#5871](https://github.com/ScoopInstaller/Scoop/issues/5871)) ### Performance Improvements diff --git a/lib/core.ps1 b/lib/core.ps1 index 5e60cb3c0f..c3148a7081 100644 --- a/lib/core.ps1 +++ b/lib/core.ps1 @@ -427,9 +427,9 @@ function Get-HelperPath { 'Lessmsi' { $HelperPath = Get-AppFilePath 'lessmsi' 'lessmsi.exe' } 'Innounp' { $HelperPath = Get-AppFilePath 'innounp' 'innounp.exe' } 'Dark' { - $HelperPath = Get-AppFilePath 'dark' 'dark.exe' + $HelperPath = Get-AppFilePath 'wixtoolset' 'wix.exe' if ([String]::IsNullOrEmpty($HelperPath)) { - $HelperPath = Get-AppFilePath 'wixtoolset' 'dark.exe' + $HelperPath = Get-AppFilePath 'dark' 'dark.exe' } } 'Aria2' { $HelperPath = Get-AppFilePath 'aria2' 'aria2c.exe' } diff --git a/lib/decompress.ps1 b/lib/decompress.ps1 index 4fade6dd0a..8a6b5cda0f 100644 --- a/lib/decompress.ps1 +++ b/lib/decompress.ps1 @@ -279,14 +279,22 @@ function Expand-DarkArchive { $Removal ) $LogPath = "$(Split-Path $Path)\dark.log" - $ArgList = @('-nologo', '-x', $DestinationPath, $Path) + $DarkPath = Get-HelperPath -Helper Dark + if ((Split-Path $DarkPath -Leaf) -eq 'wix.exe') { + $ArgList = @('burn', 'extract', $Path, '-out', $DestinationPath, '-outba', "$DestinationPath\UX") + } else { + $ArgList = @('-nologo', '-x', $DestinationPath, $Path) + } if ($Switches) { $ArgList += (-split $Switches) } - $Status = Invoke-ExternalCommand (Get-HelperPath -Helper Dark) $ArgList -LogPath $LogPath + $Status = Invoke-ExternalCommand $DarkPath $ArgList -LogPath $LogPath if (!$Status) { abort "Failed to extract files from $Path.`nLog file:`n $(friendly_path $LogPath)`n$(new_issue_msg $app $bucket 'decompress error')" } + if (Test-Path "$DestinationPath\WixAttachedContainer") { + Rename-Item "$DestinationPath\WixAttachedContainer" 'AttachedContainer' -ErrorAction Ignore + } if (Test-Path $LogPath) { Remove-Item $LogPath -Force } From febcb595e75aff13f2bcf2ca1402d484c47862b7 Mon Sep 17 00:00:00 2001 From: Hsiao-nan Cheung Date: Tue, 9 Apr 2024 15:05:00 +0800 Subject: [PATCH 2/2] Add fallback for`dark` --- lib/decompress.ps1 | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/lib/decompress.ps1 b/lib/decompress.ps1 index 8a6b5cda0f..d75f43fa7b 100644 --- a/lib/decompress.ps1 +++ b/lib/decompress.ps1 @@ -294,6 +294,16 @@ function Expand-DarkArchive { } if (Test-Path "$DestinationPath\WixAttachedContainer") { Rename-Item "$DestinationPath\WixAttachedContainer" 'AttachedContainer' -ErrorAction Ignore + } else { + if (Test-Path "$DestinationPath\AttachedContainer\a0") { + $Xml = [xml](Get-Content -Raw "$DestinationPath\UX\manifest.xml" -Encoding utf8) + $Xml.BurnManifest.UX.Payload | ForEach-Object { + Rename-Item "$DestinationPath\UX\$($_.SourcePath)" $_.FilePath -ErrorAction Ignore + } + $Xml.BurnManifest.Payload | ForEach-Object { + Rename-Item "$DestinationPath\AttachedContainer\$($_.SourcePath)" $_.FilePath -ErrorAction Ignore + } + } } if (Test-Path $LogPath) { Remove-Item $LogPath -Force