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
10 changes: 6 additions & 4 deletions lib/decompress.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -177,9 +177,11 @@ function Expand-InnoArchive {
[String]
$Switches,
[Switch]
$Removal
$Removal,
[Switch]
$UseInnoextract
)
if (get_config 'INNOSETUP_USE_INNOEXTRACT') {
if ((get_config 'INNOSETUP_USE_INNOEXTRACT') -or ($UseInnoextract)) {
$LogPath = "$(Split-Path $Path)\innoextract.log"
$ArgList = @($Path, "-d", $DestinationPath)
$Status = Invoke-ExternalCommand (Get-HelperPath -Helper Innoextract) $ArgList -LogPath $LogPath
Expand Down Expand Up @@ -311,9 +313,9 @@ function extract_msi($path, $to, $removal) {
Expand-MsiArchive -Path $path -DestinationPath $to -Removal:$removal
}

function unpack_inno($path, $to, $removal) {
function unpack_inno($path, $to, $removal, $useinnoextract) {
Show-DeprecatedWarning $MyInvocation 'Expand-InnoArchive'
Expand-InnoArchive -Path $path -DestinationPath $to -Removal:$removal @args
Expand-InnoArchive -Path $path -DestinationPath $to -Removal:$removal -UseInnoextract:$useinnoextract @args
PorridgePi marked this conversation as resolved.
Show resolved Hide resolved
}

function extract_zip($path, $to, $removal) {
Expand Down
10 changes: 5 additions & 5 deletions lib/install.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ function nightly_version($date, $quiet = $false) {
"nightly-$date_str"
}

function install_app($app, $architecture, $global, $suggested, $use_cache = $true, $check_hash = $true) {
function install_app($app, $architecture, $global, $suggested, $use_cache = $true, $check_hash = $true, $useinnoextract) {
Copy link
Contributor

@Ash258 Ash258 Dec 12, 2020

Choose a reason for hiding this comment

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

It will be patched in manifests itself. with Expand-InnoArchive -UseInnoextract

It is nonsense to have additional switch, and 20 checks for this.

Remove

Copy link
Author

Choose a reason for hiding this comment

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

Sorry, I did not understand the part about the patch being in the manifest instead. Really sorry for the hassle caused.

Copy link
Author

Choose a reason for hiding this comment

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

The patches in the manifest should be something similar to the instaler script in this manifest, right?

$app, $bucket, $null = parse_app $app
$app, $manifest, $bucket, $url = Find-Manifest $app $bucket

Expand Down Expand Up @@ -40,7 +40,7 @@ function install_app($app, $architecture, $global, $suggested, $use_cache = $tru
$original_dir = $dir # keep reference to real (not linked) directory
$persist_dir = persistdir $app $global

$fname = dl_urls $app $version $manifest $bucket $architecture $dir $use_cache $check_hash
$fname = dl_urls $app $version $manifest $bucket $architecture $dir $use_cache $check_hash $useinnoextract
PorridgePi marked this conversation as resolved.
Show resolved Hide resolved
pre_install $manifest $architecture
run_installer $fname $manifest $architecture $dir $global
ensure_install_dir_not_in_path $dir $global
Expand Down Expand Up @@ -520,10 +520,10 @@ function dl_progress($read, $total, $url) {
[console]::SetCursorPosition($left, $top)
}

function dl_urls($app, $version, $manifest, $bucket, $architecture, $dir, $use_cache = $true, $check_hash = $true) {
function dl_urls($app, $version, $manifest, $bucket, $architecture, $dir, $use_cache = $true, $check_hash = $true, $useinnoextract) {
PorridgePi marked this conversation as resolved.
Show resolved Hide resolved
# we only want to show this warning once
if(!$use_cache) { warn "Cache is being ignored." }

if($useinnoextract) { warn "Use of innoextract is experimental as it may not work in all scenarios" }
PorridgePi marked this conversation as resolved.
Show resolved Hide resolved
# can be multiple urls: if there are, then msi or installer should go last,
# so that $fname is set properly
$urls = @(url $manifest $architecture)
Expand Down Expand Up @@ -604,7 +604,7 @@ function dl_urls($app, $version, $manifest, $bucket, $architecture, $dir, $use_c
Write-Host "Extracting " -NoNewline
Write-Host $fname -f Cyan -NoNewline
Write-Host " ... " -NoNewline
& $extract_fn -Path "$dir\$fname" -DestinationPath "$dir\$extract_to" -ExtractDir $extract_dir -Removal
& $extract_fn -Path "$dir\$fname" -DestinationPath "$dir\$extract_to" -ExtractDir $extract_dir -Removal -UseInnoextract:$useinnoextract
PorridgePi marked this conversation as resolved.
Show resolved Hide resolved
Write-Host "done." -f Green
$extracted++
}
Expand Down
5 changes: 3 additions & 2 deletions libexec/scoop-install.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,15 @@ function is_installed($app, $global) {
return $false
}

$opt, $apps, $err = getopt $args 'gfiksa:' 'global', 'force', 'independent', 'no-cache', 'skip', 'arch='
$opt, $apps, $err = getopt $args 'gfiksa:' 'global', 'force', 'independent', 'no-cache', 'skip', 'arch=', 'useinnoextract'
PorridgePi marked this conversation as resolved.
Show resolved Hide resolved
if ($err) { "scoop install: $err"; exit 1 }

$global = $opt.g -or $opt.global
$check_hash = !($opt.s -or $opt.skip)
$independent = $opt.i -or $opt.independent
$use_cache = !($opt.k -or $opt.'no-cache')
$architecture = default_architecture
$useinnoextract = $opt.useinnoextract
PorridgePi marked this conversation as resolved.
Show resolved Hide resolved
try {
$architecture = ensure_architecture ($opt.a + $opt.arch)
} catch {
Expand Down Expand Up @@ -123,7 +124,7 @@ if (Test-Aria2Enabled) {
warn "Scoop uses 'aria2c' for multi-connection downloads."
warn "Should it cause issues, run 'scoop config aria2-enabled false' to disable it."
}
$apps | ForEach-Object { install_app $_ $architecture $global $suggested $use_cache $check_hash }
$apps | ForEach-Object { install_app $_ $architecture $global $suggested $use_cache $check_hash $useinnoextract }
PorridgePi marked this conversation as resolved.
Show resolved Hide resolved

show_suggestions $suggested

Expand Down
12 changes: 6 additions & 6 deletions libexec/scoop-update.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,15 @@

reset_aliases

$opt, $apps, $err = getopt $args 'gfiksq:' 'global', 'force', 'independent', 'no-cache', 'skip', 'quiet'
$opt, $apps, $err = getopt $args 'gfiksq:' 'global', 'force', 'independent', 'no-cache', 'skip', 'quiet', 'useinnoextract'
PorridgePi marked this conversation as resolved.
Show resolved Hide resolved
if ($err) { "scoop update: $err"; exit 1 }
$global = $opt.g -or $opt.global
$force = $opt.f -or $opt.force
$check_hash = !($opt.s -or $opt.skip)
$use_cache = !($opt.k -or $opt.'no-cache')
$quiet = $opt.q -or $opt.quiet
$independent = $opt.i -or $opt.independent
$useinnoextract = $opt.useinnoextract
PorridgePi marked this conversation as resolved.
Show resolved Hide resolved

# load config
$configRepo = get_config SCOOP_REPO
Expand Down Expand Up @@ -153,11 +154,10 @@ function update_scoop() {
success 'Scoop was updated successfully!'
}

function update($app, $global, $quiet = $false, $independent, $suggested, $use_cache = $true, $check_hash = $true) {
function update($app, $global, $quiet = $false, $independent, $suggested, $use_cache = $true, $check_hash = $true, $useinnoextract) {
PorridgePi marked this conversation as resolved.
Show resolved Hide resolved
$old_version = current_version $app $global
$old_manifest = installed_manifest $app $old_version $global
$install = install_info $app $old_version $global

PorridgePi marked this conversation as resolved.
Show resolved Hide resolved
# re-use architecture, bucket and url from first install
$architecture = ensure_architecture $install.architecture
$bucket = $install.bucket
Expand All @@ -170,7 +170,7 @@ function update($app, $global, $quiet = $false, $independent, $suggested, $use_c
# check dependencies
$man = if ($url) { $url } else { $app }
$deps = @(deps $man $architecture) | Where-Object { !(installed $_) }
$deps | ForEach-Object { install_app $_ $architecture $global $suggested $use_cache $check_hash }
$deps | ForEach-Object { install_app $_ $architecture $global $suggested $use_cache $check_hash $useinnoextract }
PorridgePi marked this conversation as resolved.
Show resolved Hide resolved
}

$version = latest_version $app $bucket $url
Expand Down Expand Up @@ -273,7 +273,7 @@ function update($app, $global, $quiet = $false, $independent, $suggested, $use_c
# use the url of the install json if the application was installed through url
$app = $install.url
}
install_app $app $architecture $global $suggested $use_cache $check_hash
install_app $app $architecture $global $suggested $use_cache $check_hash $useinnoextract
PorridgePi marked this conversation as resolved.
Show resolved Hide resolved
}

if (!$apps) {
Expand Down Expand Up @@ -334,7 +334,7 @@ if (!$apps) {

$suggested = @{};
# $outdated is a list of ($app, $global) tuples
$outdated | ForEach-Object { update @_ $quiet $independent $suggested $use_cache $check_hash }
$outdated | ForEach-Object { update @_ $quiet $independent $suggested $use_cache $check_hash $useinnoextract }
PorridgePi marked this conversation as resolved.
Show resolved Hide resolved
}

exit 0