Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(decompress): use innoextract if innounp fails #4192

Closed
wants to merge 10 commits into from
5 changes: 3 additions & 2 deletions lib/core.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ function Get-HelperPath {
[CmdletBinding()]
param(
[Parameter(Mandatory = $true, Position = 0, ValueFromPipeline = $true)]
[ValidateSet('7zip', 'Lessmsi', 'Innounp', 'Dark', 'Aria2')]
[ValidateSet('7zip', 'Lessmsi', 'Innounp', 'Dark', 'Aria2', 'Innoextract')]
[String]
$Helper
)
Expand All @@ -258,6 +258,7 @@ function Get-HelperPath {
}
'Lessmsi' { $HelperPath = Get-AppFilePath 'lessmsi' 'lessmsi.exe' }
'Innounp' { $HelperPath = Get-AppFilePath 'innounp' 'innounp.exe' }
'Innoextract' { $HelperPath = Get-AppFilePath 'innoextract' 'innoextract.exe' }
'Dark' {
$HelperPath = Get-AppFilePath 'dark' 'dark.exe'
if([String]::IsNullOrEmpty($HelperPath)) {
Expand All @@ -274,7 +275,7 @@ function Test-HelperInstalled {
[CmdletBinding()]
param(
[Parameter(Mandatory = $true, Position = 0, ValueFromPipeline = $true)]
[ValidateSet('7zip', 'Lessmsi', 'Innounp', 'Dark', 'Aria2')]
[ValidateSet('7zip', 'Lessmsi', 'Innounp', 'Dark', 'Aria2', 'Innoextract')]
[String]
$Helper
)
Expand Down
35 changes: 35 additions & 0 deletions lib/decompress.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,41 @@ function Expand-InnoArchive {
}
}

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')"
} else {
Get-ChildItem $DestinationPath\app\* | Move-Item -Destination $DestinationPath
Remove-Item $DestinationPath\app\
}
if (Test-Path $LogPath) {
Remove-Item $LogPath -Force
}
if ($Removal) {
# Remove original archive file
Remove-Item $Path -Force
}
}

function Expand-ZipArchive {
[CmdletBinding()]
param (
Expand Down
7 changes: 7 additions & 0 deletions lib/depends.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ function script_deps($script) {
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($script -like '*Expand-DarkArchive *') {
$deps += 'dark'
}
Expand All @@ -86,6 +89,10 @@ function install_deps($manifest, $arch) {
if (!(Test-HelperInstalled -Helper Innounp) -and $manifest.innosetup) {
$deps += 'innounp'
}
if (!(Test-HelperInstalled -Helper innoextract) -and $manifest.innosetup) {
$deps += 'innoextract'
}


$pre_install = arch_specific 'pre_install' $manifest $arch
$installer = arch_specific 'installer' $manifest $arch
Expand Down
2 changes: 2 additions & 0 deletions lib/install.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -582,6 +582,8 @@ 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)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You need to use something like this:

Best possible add simple switch parameter (-UseInnoExtract or just -InnoExtract) to expand-innoarchive function

Copy link
Contributor

@Ash258 Ash258 Dec 2, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I take it back. Sorry.

Only use this in depends:

if ($manifest.innosetup) { if (get_config 'INNOSETUP_USE_INNOEXTRACT' $false) { $depends += 'innoextract' } } else { $depends += 'innounp' }

And then inside decompress, inside function Expand-InnoArchive use same logic:

if get_config ''... {
 $Stratus = INvoke-external Innoextract
} else  {
$status = Invoke-External innounp }

Copy link
Author

@PorridgePi PorridgePi Dec 2, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You need to use something like this:

Thanks! I did not understand at first.

Best possible add simple switch parameter (-UseInnoExtract or just -InnoExtract) to expand-innoarchive function

Yea, that is indeed better. I shall try that out later in the day.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, to add the switch parameter/option, do I edit scoop-install.ps1 and scoop-update.ps1 in scoop\libexec?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Ash258 May I know how exactly do I add a switch parameter? Thanks.

Expand Down