Skip to content

Commit

Permalink
fix(compress): Re-done config option
Browse files Browse the repository at this point in the history
  • Loading branch information
PorridgePi committed Dec 2, 2020
1 parent 8e03fb9 commit 532b53c
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 57 deletions.
65 changes: 20 additions & 45 deletions lib/decompress.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
25 changes: 15 additions & 10 deletions lib/depends.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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
Expand Down
2 changes: 0 additions & 2 deletions lib/install.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down

0 comments on commit 532b53c

Please sign in to comment.