From 8f1b52935bb75883141b51bcfb0d6d164024810a Mon Sep 17 00:00:00 2001 From: PorridgePi Date: Thu, 3 Dec 2020 02:27:53 +0800 Subject: [PATCH] fix(compress): Switch to parameter --- lib/decompress.ps1 | 65 ++++++++++++++-------------------------------- lib/depends.ps1 | 25 +++++++++++------- lib/install.ps1 | 2 -- 3 files changed, 35 insertions(+), 57 deletions(-) diff --git a/lib/decompress.ps1 b/lib/decompress.ps1 index 92a193d189..2650ba5431 100644 --- a/lib/decompress.ps1 +++ b/lib/decompress.ps1 @@ -179,54 +179,29 @@ function Expand-InnoArchive { [Switch] $Removal ) - $LogPath = "$(Split-Path $Path)\innounp.log" - $ArgList = @('-x', "-d`"$DestinationPath`"", "`"$Path`"", '-y') - switch -Regex ($ExtractDir) { - "^[^{].*" { $ArgList += "-c{app}\$ExtractDir" } - "^{.*" { $ArgList += "-c$ExtractDir" } - Default { $ArgList += "-c{app}" } - } - if ($Switches) { - $ArgList += (-split $Switches) - } - $Status = Invoke-ExternalCommand (Get-HelperPath -Helper Innounp) $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 $LogPath) { - Remove-Item $LogPath -Force - } - if ($Removal) { - # Remove original archive file - Remove-Item $Path -Force - } -} - -function Expand-InnoExArchive { - [CmdletBinding()] - param ( - [Parameter(Mandatory = $true, Position = 0, ValueFromPipeline = $true)] - [String] - $Path, - [Parameter(Position = 1)] - [String] - $DestinationPath = (Split-Path $Path), - [String] - $ExtractDir, - [Parameter(ValueFromRemainingArguments = $true)] - [String] - $Switches, - [Switch] - $Removal - ) - $LogPath = "$(Split-Path $Path)\innoextract.log" - $ArgList = @($Path, "-d", $DestinationPath) - $Status = Invoke-ExternalCommand (Get-HelperPath -Helper Innoextract) $ArgList -LogPath $LogPath - if (!$Status) { - abort "Failed to extract files from $Path.`nLog file:`n $(friendly_path $LogPath)`n $(friendly_path $InnoextractLogPath)`n$(new_issue_msg $app $bucket 'decompress error')" + if (get_config 'INNOSETUP_USE_INNOEXTRACT' $false) { + $LogPath = "$(Split-Path $Path)\innounp.log" + $ArgList = @('-x', "-d`"$DestinationPath`"", "`"$Path`"", '-y') + switch -Regex ($ExtractDir) { + "^[^{].*" { $ArgList += "-c{app}\$ExtractDir" } + "^{.*" { $ArgList += "-c$ExtractDir" } + Default { $ArgList += "-c{app}" } + } + if ($Switches) { + $ArgList += (-split $Switches) + } + $Status = Invoke-ExternalCommand (Get-HelperPath -Helper Innounp) $ArgList -LogPath $LogPath } else { + $LogPath = "$(Split-Path $Path)\innoextract.log" + $ArgList = @($Path, "-d", $DestinationPath) + $Status = Invoke-ExternalCommand (Get-HelperPath -Helper Innoextract) $ArgList -LogPath $LogPath + if ($Status) { Get-ChildItem $DestinationPath\app\* | Move-Item -Destination $DestinationPath Remove-Item $DestinationPath\app\ + } + } + 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 $LogPath) { Remove-Item $LogPath -Force diff --git a/lib/depends.ps1 b/lib/depends.ps1 index ee39b7b7a3..6ce61f8053 100644 --- a/lib/depends.ps1 +++ b/lib/depends.ps1 @@ -65,10 +65,11 @@ function script_deps($script) { $deps += 'lessmsi' } if($script -like '*Expand-InnoArchive *' -or $script -like '*unpack_inno *') { - $deps += 'innounp' - } - if($script -like '*Expand-InnoExArchive *' -or $script -like '*unpack_innoex *') { - $deps += 'innoextract' + if (get_config 'INNOSETUP_USE_INNOEXTRACT' $false) { + $deps += 'innounp' + } else { + $deps += 'innoextract' + } } if($script -like '*Expand-DarkArchive *') { $deps += 'dark' @@ -86,14 +87,18 @@ function install_deps($manifest, $arch) { if (!(Test-HelperInstalled -Helper Lessmsi) -and (Test-LessmsiRequirement -URL (url $manifest $arch))) { $deps += 'lessmsi' } - if (!(Test-HelperInstalled -Helper Innounp) -and $manifest.innosetup) { - $deps += 'innounp' - } - if (!(Test-HelperInstalled -Helper innoextract) -and $manifest.innosetup) { - $deps += 'innoextract' + if ($manifest.innosetup) { + if (get_config 'INNOSETUP_USE_INNOEXTRACT' $false) { + if (!(Test-HelperInstalled -Helper Innounp)) { + $deps += 'innounp' + } + } else { + if (!(Test-HelperInstalled -Helper innoextract)) { + $deps += 'innoextract' + } + } } - $pre_install = arch_specific 'pre_install' $manifest $arch $installer = arch_specific 'installer' $manifest $arch $post_install = arch_specific 'post_install' $manifest $arch diff --git a/lib/install.ps1 b/lib/install.ps1 index add1263ee5..5c78268b31 100644 --- a/lib/install.ps1 +++ b/lib/install.ps1 @@ -582,8 +582,6 @@ function dl_urls($app, $version, $manifest, $bucket, $architecture, $dir, $use_c $extract_fn = $null if ($manifest.innosetup) { $extract_fn = 'Expand-InnoArchive' - } elseif($manifest.innoexsetup) { - $extract_fn = 'Expand-InnoExArchive' } elseif($fname -match '\.zip$') { # Use 7zip when available (more fast) if (((get_config 7ZIPEXTRACT_USE_EXTERNAL) -and (Test-CommandAvailable 7z)) -or (Test-HelperInstalled -Helper 7zip)) {