-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
feat(scoop-install|update): Update extraction tools ahead of installs/updates #6572
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
Open
z-Fng
wants to merge
7
commits into
ScoopInstaller:develop
Choose a base branch
from
z-Fng:update-helper-before-install
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+259
−135
Open
Changes from 6 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
fa74f78
feat(scoop-install|update): Update extraction tools ahead of installs…
z-Fng 4ffe9e6
Fix typos and add missing $force parameter
z-Fng d5f1219
Merge branch 'develop' into update-helper-before-install
z-Fng 597ca42
Fix incorrect parameter handling in Get-OutdatedHelper function
z-Fng bad8870
Fix typos, simplify Parameter attributes
z-Fng 932fba6
Properly handle 'Get-Manifest' return value
z-Fng b3a5da3
Merge branch 'develop' into update-helper-before-install
z-Fng File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,126 @@ | ||
| function update($app, $global, $force, $quiet = $false, $independent, $suggested, $use_cache = $true, $check_hash = $true) { | ||
| $old_version = Select-CurrentVersion -AppName $app -Global:$global | ||
| $old_manifest = installed_manifest $app $old_version $global | ||
| $install = install_info $app $old_version $global | ||
|
|
||
| # re-use architecture, bucket and url from first install | ||
| $architecture = Format-ArchitectureString $install.architecture | ||
| $bucket = $install.bucket | ||
| if ($null -eq $bucket) { | ||
| $bucket = 'main' | ||
| } | ||
| $url = $install.url | ||
|
|
||
| $manifest = manifest $app $bucket $url | ||
| $version = $manifest.version | ||
| $is_nightly = $version -eq 'nightly' | ||
| if ($is_nightly) { | ||
| $version = nightly_version $quiet | ||
| $check_hash = $false | ||
| } | ||
|
|
||
| if (!$force -and ($old_version -eq $version)) { | ||
| if (!$quiet) { | ||
| warn "The latest version of '$app' ($version) is already installed." | ||
| } | ||
| return | ||
| } | ||
| if (!$version) { | ||
| # installed from a custom bucket/no longer supported | ||
| error "No manifest available for '$app'." | ||
| return | ||
| } | ||
|
|
||
| Write-Host "Updating '$app' ($old_version -> $version)" | ||
|
|
||
| #region Workaround for #2952 | ||
| if (test_running_process $app $global) { | ||
| Write-Host 'Running process detected, skip updating.' | ||
| return | ||
| } | ||
| #endregion Workaround for #2952 | ||
|
|
||
| # region Workaround | ||
| # Workaround for https://github.com/ScoopInstaller/Scoop/issues/2220 until install is refactored | ||
| # Remove and replace whole region after proper fix | ||
| Write-Host 'Downloading new version' | ||
| if (Test-Aria2Enabled) { | ||
| Invoke-CachedAria2Download $app $version $manifest $architecture $cachedir $manifest.cookie $true $check_hash | ||
| } else { | ||
| $urls = script:url $manifest $architecture | ||
|
|
||
| foreach ($url in $urls) { | ||
| Invoke-CachedDownload $app $version $url $null $manifest.cookie $true | ||
|
|
||
| if ($check_hash) { | ||
| $manifest_hash = hash_for_url $manifest $url $architecture | ||
| $source = cache_path $app $version $url | ||
| $ok, $err = check_hash $source $manifest_hash $(show_app $app $bucket) | ||
|
|
||
| if (!$ok) { | ||
| error $err | ||
| if (Test-Path $source) { | ||
| # rm cached file | ||
| Remove-Item -Force $source | ||
| } | ||
| if ($url.Contains('sourceforge.net')) { | ||
| Write-Host -f yellow 'SourceForge.net is known for causing hash validation fails. Please try again before opening a ticket.' | ||
| } | ||
| abort $(new_issue_msg $app $bucket 'hash check failed') | ||
| } | ||
| } | ||
| } | ||
| } | ||
| # There is no need to check hash again while installing | ||
| $check_hash = $false | ||
| # endregion Workaround | ||
|
|
||
| $dir = versiondir $app $old_version $global | ||
| $persist_dir = persistdir $app $global | ||
|
|
||
| Invoke-HookScript -HookType 'pre_uninstall' -Manifest $old_manifest -Arch $architecture | ||
|
|
||
| Write-Host "Uninstalling '$app' ($old_version)" | ||
| Invoke-Installer -Path $dir -Manifest $old_manifest -ProcessorArchitecture $architecture -Global:$global -Uninstall | ||
| rm_shims $app $old_manifest $global $architecture | ||
|
|
||
| # If a junction was used during install, that will have been used | ||
| # as the reference directory. Otherwise it will just be the version | ||
| # directory. | ||
| $refdir = unlink_current $dir | ||
| uninstall_psmodule $old_manifest $refdir $global | ||
| env_rm_path $old_manifest $refdir $global $architecture | ||
| env_rm $old_manifest $global $architecture | ||
|
|
||
| if ($force -and ($old_version -eq $version)) { | ||
| if (!(Test-Path "$dir/../_$version.old")) { | ||
| Move-Item "$dir" "$dir/../_$version.old" | ||
| } else { | ||
| $i = 1 | ||
| while (Test-Path "$dir/../_$version.old($i)") { | ||
| $i++ | ||
| } | ||
| Move-Item "$dir" "$dir/../_$version.old($i)" | ||
| } | ||
| } | ||
|
|
||
| Invoke-HookScript -HookType 'post_uninstall' -Manifest $old_manifest -Arch $architecture | ||
|
|
||
| if ($bucket) { | ||
| # add bucket name it was installed from | ||
| $app = "$bucket/$app" | ||
| } | ||
| if ($install.url) { | ||
| # use the url of the install json if the application was installed through url | ||
| $app = $install.url | ||
| } | ||
|
|
||
| if ($independent) { | ||
| install_app $app $architecture $global $suggested $use_cache $check_hash | ||
| } else { | ||
| # Also add missing dependencies | ||
| $apps = @(Get-Dependency $app $architecture) -ne $app | ||
| ensure_none_failed $apps | ||
| $apps.Where({ !(installed $_) }) + $app | ForEach-Object { install_app $_ $architecture $global $suggested $use_cache $check_hash } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.