From c5907c3e252982c2fd4f061e87e4b38d251b108c Mon Sep 17 00:00:00 2001 From: HUMORCE Date: Thu, 19 Sep 2024 07:41:28 +0000 Subject: [PATCH 01/20] first step --- lib/core.ps1 | 14 +++++++++++++- lib/manifest.ps1 | 10 ++++++++++ libexec/scoop-cat.ps1 | 1 + libexec/scoop-download.ps1 | 1 + libexec/scoop-home.ps1 | 1 + libexec/scoop-info.ps1 | 4 ++-- libexec/scoop-virustotal.ps1 | 1 + 7 files changed, 29 insertions(+), 3 deletions(-) diff --git a/lib/core.ps1 b/lib/core.ps1 index eeaa2c9ad4..76c7c2d91e 100644 --- a/lib/core.ps1 +++ b/lib/core.ps1 @@ -1140,7 +1140,19 @@ function applist($apps, $global) { function parse_app([string]$app) { if ($app -match '^(?:(?[a-zA-Z0-9-_.]+)/)?(?.*\.json|[a-zA-Z0-9-_.]+)(?:@(?.*))?$') { - return $Matches['app'], $Matches['bucket'], $Matches['version'] + $app = $Matches['app'] + $bucket = $Matches['bucket'] + $version = $Matches['version'] + if (installed $app) { + $global = installed $app $true + $ver = Select-CurrentVersion -AppName $app -Global:$global + $install_info_path = "$(versiondir $app $ver $global)\install.json" + if (Test-Path $install_info_path) { + $install_info = parse_json $install_info_path + $bucket = $install_info.bucket + } + } + return $app, $bucket, $version } else { return $app, $null, $null } diff --git a/lib/manifest.ps1 b/lib/manifest.ps1 index 9ca618158b..c5122681dc 100644 --- a/lib/manifest.ps1 +++ b/lib/manifest.ps1 @@ -53,6 +53,16 @@ function Get-Manifest($app) { } } if (!$manifest) { + if (installed $app) { + $global = installed $app $true + $ver = Select-CurrentVersion -AppName $app -Global:$global + $install_info_path = "$(versiondir $app $ver $global)\install.json" + if (Test-Path $install_info_path) { + $install_info = parse_json $install_info_path + $url = $install_info.url + } + $manifest = if (Test-Path $url) { parse_json $url } else { installed_manifest $app $ver $global } + } # couldn't find app in buckets: check if it's a local path if (Test-Path $app) { $url = Convert-Path $app diff --git a/libexec/scoop-cat.ps1 b/libexec/scoop-cat.ps1 index 5cf363162d..70863e2021 100644 --- a/libexec/scoop-cat.ps1 +++ b/libexec/scoop-cat.ps1 @@ -7,6 +7,7 @@ param($app) . "$PSScriptRoot\..\lib\json.ps1" # 'ConvertToPrettyJson' +. "$PSScriptRoot\..\lib\versions.ps1" # 'Select-CurrentVersion' . "$PSScriptRoot\..\lib\manifest.ps1" # 'Get-Manifest' if (!$app) { error ' missing'; my_usage; exit 1 } diff --git a/libexec/scoop-download.ps1 b/libexec/scoop-download.ps1 index f47a672e5a..996cb4e8e6 100644 --- a/libexec/scoop-download.ps1 +++ b/libexec/scoop-download.ps1 @@ -22,6 +22,7 @@ . "$PSScriptRoot\..\lib\getopt.ps1" . "$PSScriptRoot\..\lib\json.ps1" # 'autoupdate.ps1' (indirectly) . "$PSScriptRoot\..\lib\autoupdate.ps1" # 'generate_user_manifest' (indirectly) +. "$PSScriptRoot\..\lib\versions.ps1" # 'Select-CurrentVersion' . "$PSScriptRoot\..\lib\manifest.ps1" # 'generate_user_manifest' 'Get-Manifest' . "$PSScriptRoot\..\lib\download.ps1" if (get_config USE_SQLITE_CACHE) { diff --git a/libexec/scoop-home.ps1 b/libexec/scoop-home.ps1 index da495454ad..f76a5e06b0 100644 --- a/libexec/scoop-home.ps1 +++ b/libexec/scoop-home.ps1 @@ -2,6 +2,7 @@ # Summary: Opens the app homepage param($app) +. "$PSScriptRoot\..\lib\versions.ps1" # 'Select-CurrentVersion' . "$PSScriptRoot\..\lib\manifest.ps1" # 'Get-Manifest' if ($app) { diff --git a/libexec/scoop-info.ps1 b/libexec/scoop-info.ps1 index 7b23544551..45e782fb20 100644 --- a/libexec/scoop-info.ps1 +++ b/libexec/scoop-info.ps1 @@ -5,7 +5,7 @@ . "$PSScriptRoot\..\lib\getopt.ps1" . "$PSScriptRoot\..\lib\manifest.ps1" # 'Get-Manifest' -. "$PSScriptRoot\..\lib\versions.ps1" # 'Get-InstalledVersion' +. "$PSScriptRoot\..\lib\versions.ps1" # 'Get-InstalledVersion', 'Select-CurrentVersion' . "$PSScriptRoot\..\lib\download.ps1" # 'Get-RemoteFileSize' $opt, $app, $err = getopt $args 'v' 'verbose' @@ -23,7 +23,7 @@ if (!$manifest) { $global = installed $app $true $status = app_status $app $global $install = install_info $app $status.version $global -$status.installed = $bucket -and $install.bucket -eq $bucket +$status.installed = installed $app $version_output = $manifest.version $manifest_file = if ($bucket) { manifest_path $app $bucket diff --git a/libexec/scoop-virustotal.ps1 b/libexec/scoop-virustotal.ps1 index 72f1d2f14f..8fe63359cf 100644 --- a/libexec/scoop-virustotal.ps1 +++ b/libexec/scoop-virustotal.ps1 @@ -29,6 +29,7 @@ # -p, --passthru Return reports as objects . "$PSScriptRoot\..\lib\getopt.ps1" +. "$PSScriptRoot\..\lib\versions.ps1" # 'Select-CurrentVersion' . "$PSScriptRoot\..\lib\manifest.ps1" # 'Get-Manifest' . "$PSScriptRoot\..\lib\json.ps1" # 'json_path' . "$PSScriptRoot\..\lib\download.ps1" # 'hash_for_url' From fa6ef8a5feda486b70d9b5b67a444d235201460d Mon Sep 17 00:00:00 2001 From: HUMORCE Date: Fri, 20 Sep 2024 00:58:49 +0000 Subject: [PATCH 02/20] Revert "first step" This reverts commit c5907c3e252982c2fd4f061e87e4b38d251b108c. --- lib/core.ps1 | 14 +------------- lib/manifest.ps1 | 10 ---------- libexec/scoop-cat.ps1 | 1 - libexec/scoop-download.ps1 | 1 - libexec/scoop-home.ps1 | 1 - libexec/scoop-info.ps1 | 4 ++-- libexec/scoop-virustotal.ps1 | 1 - 7 files changed, 3 insertions(+), 29 deletions(-) diff --git a/lib/core.ps1 b/lib/core.ps1 index 76c7c2d91e..eeaa2c9ad4 100644 --- a/lib/core.ps1 +++ b/lib/core.ps1 @@ -1140,19 +1140,7 @@ function applist($apps, $global) { function parse_app([string]$app) { if ($app -match '^(?:(?[a-zA-Z0-9-_.]+)/)?(?.*\.json|[a-zA-Z0-9-_.]+)(?:@(?.*))?$') { - $app = $Matches['app'] - $bucket = $Matches['bucket'] - $version = $Matches['version'] - if (installed $app) { - $global = installed $app $true - $ver = Select-CurrentVersion -AppName $app -Global:$global - $install_info_path = "$(versiondir $app $ver $global)\install.json" - if (Test-Path $install_info_path) { - $install_info = parse_json $install_info_path - $bucket = $install_info.bucket - } - } - return $app, $bucket, $version + return $Matches['app'], $Matches['bucket'], $Matches['version'] } else { return $app, $null, $null } diff --git a/lib/manifest.ps1 b/lib/manifest.ps1 index c5122681dc..9ca618158b 100644 --- a/lib/manifest.ps1 +++ b/lib/manifest.ps1 @@ -53,16 +53,6 @@ function Get-Manifest($app) { } } if (!$manifest) { - if (installed $app) { - $global = installed $app $true - $ver = Select-CurrentVersion -AppName $app -Global:$global - $install_info_path = "$(versiondir $app $ver $global)\install.json" - if (Test-Path $install_info_path) { - $install_info = parse_json $install_info_path - $url = $install_info.url - } - $manifest = if (Test-Path $url) { parse_json $url } else { installed_manifest $app $ver $global } - } # couldn't find app in buckets: check if it's a local path if (Test-Path $app) { $url = Convert-Path $app diff --git a/libexec/scoop-cat.ps1 b/libexec/scoop-cat.ps1 index 70863e2021..5cf363162d 100644 --- a/libexec/scoop-cat.ps1 +++ b/libexec/scoop-cat.ps1 @@ -7,7 +7,6 @@ param($app) . "$PSScriptRoot\..\lib\json.ps1" # 'ConvertToPrettyJson' -. "$PSScriptRoot\..\lib\versions.ps1" # 'Select-CurrentVersion' . "$PSScriptRoot\..\lib\manifest.ps1" # 'Get-Manifest' if (!$app) { error ' missing'; my_usage; exit 1 } diff --git a/libexec/scoop-download.ps1 b/libexec/scoop-download.ps1 index 996cb4e8e6..f47a672e5a 100644 --- a/libexec/scoop-download.ps1 +++ b/libexec/scoop-download.ps1 @@ -22,7 +22,6 @@ . "$PSScriptRoot\..\lib\getopt.ps1" . "$PSScriptRoot\..\lib\json.ps1" # 'autoupdate.ps1' (indirectly) . "$PSScriptRoot\..\lib\autoupdate.ps1" # 'generate_user_manifest' (indirectly) -. "$PSScriptRoot\..\lib\versions.ps1" # 'Select-CurrentVersion' . "$PSScriptRoot\..\lib\manifest.ps1" # 'generate_user_manifest' 'Get-Manifest' . "$PSScriptRoot\..\lib\download.ps1" if (get_config USE_SQLITE_CACHE) { diff --git a/libexec/scoop-home.ps1 b/libexec/scoop-home.ps1 index f76a5e06b0..da495454ad 100644 --- a/libexec/scoop-home.ps1 +++ b/libexec/scoop-home.ps1 @@ -2,7 +2,6 @@ # Summary: Opens the app homepage param($app) -. "$PSScriptRoot\..\lib\versions.ps1" # 'Select-CurrentVersion' . "$PSScriptRoot\..\lib\manifest.ps1" # 'Get-Manifest' if ($app) { diff --git a/libexec/scoop-info.ps1 b/libexec/scoop-info.ps1 index 45e782fb20..7b23544551 100644 --- a/libexec/scoop-info.ps1 +++ b/libexec/scoop-info.ps1 @@ -5,7 +5,7 @@ . "$PSScriptRoot\..\lib\getopt.ps1" . "$PSScriptRoot\..\lib\manifest.ps1" # 'Get-Manifest' -. "$PSScriptRoot\..\lib\versions.ps1" # 'Get-InstalledVersion', 'Select-CurrentVersion' +. "$PSScriptRoot\..\lib\versions.ps1" # 'Get-InstalledVersion' . "$PSScriptRoot\..\lib\download.ps1" # 'Get-RemoteFileSize' $opt, $app, $err = getopt $args 'v' 'verbose' @@ -23,7 +23,7 @@ if (!$manifest) { $global = installed $app $true $status = app_status $app $global $install = install_info $app $status.version $global -$status.installed = installed $app +$status.installed = $bucket -and $install.bucket -eq $bucket $version_output = $manifest.version $manifest_file = if ($bucket) { manifest_path $app $bucket diff --git a/libexec/scoop-virustotal.ps1 b/libexec/scoop-virustotal.ps1 index 8fe63359cf..72f1d2f14f 100644 --- a/libexec/scoop-virustotal.ps1 +++ b/libexec/scoop-virustotal.ps1 @@ -29,7 +29,6 @@ # -p, --passthru Return reports as objects . "$PSScriptRoot\..\lib\getopt.ps1" -. "$PSScriptRoot\..\lib\versions.ps1" # 'Select-CurrentVersion' . "$PSScriptRoot\..\lib\manifest.ps1" # 'Get-Manifest' . "$PSScriptRoot\..\lib\json.ps1" # 'json_path' . "$PSScriptRoot\..\lib\download.ps1" # 'hash_for_url' From 03fd6bfa879c5d74c46c033ed972997359294dd4 Mon Sep 17 00:00:00 2001 From: HUMORCE Date: Fri, 20 Sep 2024 01:14:02 +0000 Subject: [PATCH 03/20] refactor(Get-Manifest): Select actual source for installed manifest --- lib/manifest.ps1 | 58 +++++++++++++++++++++++++++++++++--------------- 1 file changed, 40 insertions(+), 18 deletions(-) diff --git a/lib/manifest.ps1 b/lib/manifest.ps1 index 9ca618158b..7452f0a325 100644 --- a/lib/manifest.ps1 +++ b/lib/manifest.ps1 @@ -40,27 +40,49 @@ function Get-Manifest($app) { $app = appname_from_url $url $manifest = url_manifest $url } else { - $app, $bucket, $version = parse_app $app - if ($bucket) { - $manifest = manifest $app $bucket - } else { - foreach ($tekcub in Get-LocalBucket) { - $manifest = manifest $app $tekcub - if ($manifest) { - $bucket = $tekcub - break + # Check if the manifest is already installed + if (installed $app) { + $global = installed $app $true + $ver = Select-CurrentVersion -AppName $app -Global:$global + $install_info_path = "$(versiondir $app $ver $global)\install.json" + if (Test-Path $install_info_path) { + $install_info = parse_json $install_info_path + $bucket = $install_info.bucket + if (!$bucket) { + $url = $install_info.url + if ($url -and (Test-Path $url)) { + $manifest = parse_json $url + } else { + # Fallback to installed manifest + $manifest = installed_manifest $app $ver $global + } + } else { + $manifest = manifest $app $bucket } } - } - if (!$manifest) { - # couldn't find app in buckets: check if it's a local path - if (Test-Path $app) { - $url = Convert-Path $app - $app = appname_from_url $url - $manifest = url_manifest $url + } else { + $app, $bucket, $version = parse_app $app + if ($bucket) { + $manifest = manifest $app $bucket } else { - if (($app -match '\\/') -or $app.EndsWith('.json')) { $url = $app } - $app = appname_from_url $app + foreach ($tekcub in Get-LocalBucket) { + $manifest = manifest $app $tekcub + if ($manifest) { + $bucket = $tekcub + break + } + } + } + if (!$manifest) { + # couldn't find app in buckets: check if it's a local path + if (Test-Path $app) { + $url = Convert-Path $app + $app = appname_from_url $url + $manifest = url_manifest $url + } else { + if (($app -match '\\/') -or $app.EndsWith('.json')) { $url = $app } + $app = appname_from_url $app + } } } } From a03c882d4dd9b3a62c5ac17ff3f0170cbb278283 Mon Sep 17 00:00:00 2001 From: HUMORCE Date: Fri, 20 Sep 2024 01:18:15 +0000 Subject: [PATCH 04/20] rework sub-commands, `scoop-depends` is NOT working at this stage --- libexec/scoop-cat.ps1 | 1 + libexec/scoop-depends.ps1 | 1 + libexec/scoop-download.ps1 | 1 + libexec/scoop-home.ps1 | 1 + libexec/scoop-info.ps1 | 4 ++-- libexec/scoop-status.ps1 | 1 + libexec/scoop-virustotal.ps1 | 1 + 7 files changed, 8 insertions(+), 2 deletions(-) diff --git a/libexec/scoop-cat.ps1 b/libexec/scoop-cat.ps1 index 5cf363162d..70863e2021 100644 --- a/libexec/scoop-cat.ps1 +++ b/libexec/scoop-cat.ps1 @@ -7,6 +7,7 @@ param($app) . "$PSScriptRoot\..\lib\json.ps1" # 'ConvertToPrettyJson' +. "$PSScriptRoot\..\lib\versions.ps1" # 'Select-CurrentVersion' . "$PSScriptRoot\..\lib\manifest.ps1" # 'Get-Manifest' if (!$app) { error ' missing'; my_usage; exit 1 } diff --git a/libexec/scoop-depends.ps1 b/libexec/scoop-depends.ps1 index 414d1b7113..d67ff246dc 100644 --- a/libexec/scoop-depends.ps1 +++ b/libexec/scoop-depends.ps1 @@ -3,6 +3,7 @@ . "$PSScriptRoot\..\lib\getopt.ps1" . "$PSScriptRoot\..\lib\depends.ps1" # 'Get-Dependency' +. "$PSScriptRoot\..\lib\versions.ps1" # 'Select-CurrentVersion' . "$PSScriptRoot\..\lib\manifest.ps1" # 'Get-Manifest' (indirectly) $opt, $apps, $err = getopt $args 'a:' 'arch=' diff --git a/libexec/scoop-download.ps1 b/libexec/scoop-download.ps1 index f47a672e5a..996cb4e8e6 100644 --- a/libexec/scoop-download.ps1 +++ b/libexec/scoop-download.ps1 @@ -22,6 +22,7 @@ . "$PSScriptRoot\..\lib\getopt.ps1" . "$PSScriptRoot\..\lib\json.ps1" # 'autoupdate.ps1' (indirectly) . "$PSScriptRoot\..\lib\autoupdate.ps1" # 'generate_user_manifest' (indirectly) +. "$PSScriptRoot\..\lib\versions.ps1" # 'Select-CurrentVersion' . "$PSScriptRoot\..\lib\manifest.ps1" # 'generate_user_manifest' 'Get-Manifest' . "$PSScriptRoot\..\lib\download.ps1" if (get_config USE_SQLITE_CACHE) { diff --git a/libexec/scoop-home.ps1 b/libexec/scoop-home.ps1 index da495454ad..f76a5e06b0 100644 --- a/libexec/scoop-home.ps1 +++ b/libexec/scoop-home.ps1 @@ -2,6 +2,7 @@ # Summary: Opens the app homepage param($app) +. "$PSScriptRoot\..\lib\versions.ps1" # 'Select-CurrentVersion' . "$PSScriptRoot\..\lib\manifest.ps1" # 'Get-Manifest' if ($app) { diff --git a/libexec/scoop-info.ps1 b/libexec/scoop-info.ps1 index 7b23544551..181b8f9aa5 100644 --- a/libexec/scoop-info.ps1 +++ b/libexec/scoop-info.ps1 @@ -5,7 +5,7 @@ . "$PSScriptRoot\..\lib\getopt.ps1" . "$PSScriptRoot\..\lib\manifest.ps1" # 'Get-Manifest' -. "$PSScriptRoot\..\lib\versions.ps1" # 'Get-InstalledVersion' +. "$PSScriptRoot\..\lib\versions.ps1" # 'Get-InstalledVersion', 'Select-CurrentVersion' . "$PSScriptRoot\..\lib\download.ps1" # 'Get-RemoteFileSize' $opt, $app, $err = getopt $args 'v' 'verbose' @@ -23,7 +23,7 @@ if (!$manifest) { $global = installed $app $true $status = app_status $app $global $install = install_info $app $status.version $global -$status.installed = $bucket -and $install.bucket -eq $bucket +$status.installed = ($bucket -and $install.bucket -eq $bucket) -or (installed $app) $version_output = $manifest.version $manifest_file = if ($bucket) { manifest_path $app $bucket diff --git a/libexec/scoop-status.ps1 b/libexec/scoop-status.ps1 index a62cad2dd1..07b88a5e54 100644 --- a/libexec/scoop-status.ps1 +++ b/libexec/scoop-status.ps1 @@ -6,6 +6,7 @@ . "$PSScriptRoot\..\lib\manifest.ps1" # 'manifest' 'parse_json' "install_info" . "$PSScriptRoot\..\lib\versions.ps1" # 'Select-CurrentVersion' +. "$PSScriptRoot\..\lib\download.ps1" # 'Get-UserAgent' # check if scoop needs updating $currentdir = versiondir 'scoop' 'current' diff --git a/libexec/scoop-virustotal.ps1 b/libexec/scoop-virustotal.ps1 index 72f1d2f14f..8fe63359cf 100644 --- a/libexec/scoop-virustotal.ps1 +++ b/libexec/scoop-virustotal.ps1 @@ -29,6 +29,7 @@ # -p, --passthru Return reports as objects . "$PSScriptRoot\..\lib\getopt.ps1" +. "$PSScriptRoot\..\lib\versions.ps1" # 'Select-CurrentVersion' . "$PSScriptRoot\..\lib\manifest.ps1" # 'Get-Manifest' . "$PSScriptRoot\..\lib\json.ps1" # 'json_path' . "$PSScriptRoot\..\lib\download.ps1" # 'hash_for_url' From f6ce49640ef9654495886ed319a967f99b3ef526 Mon Sep 17 00:00:00 2001 From: HUMORCE Date: Fri, 20 Sep 2024 01:51:55 +0000 Subject: [PATCH 05/20] URI manifest --- lib/manifest.ps1 | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/lib/manifest.ps1 b/lib/manifest.ps1 index 7452f0a325..ba63ecc313 100644 --- a/lib/manifest.ps1 +++ b/lib/manifest.ps1 @@ -50,11 +50,18 @@ function Get-Manifest($app) { $bucket = $install_info.bucket if (!$bucket) { $url = $install_info.url - if ($url -and (Test-Path $url)) { - $manifest = parse_json $url - } else { - # Fallback to installed manifest - $manifest = installed_manifest $app $ver $global + if ($url) { + if ($url -match '^(ht|f)tps?://|\\\\') { + $manifest = url_manifest $url + } + } + if (!$manifest) { + if (Test-Path $url) { + $manifest = parse_json $url + } else { + # Fallback to installed manifest + $manifest = installed_manifest $app $ver $global + } } } else { $manifest = manifest $app $bucket From d50bb557f3961f8f1ad5261520b118c4102506f5 Mon Sep 17 00:00:00 2001 From: HUMORCE Date: Fri, 20 Sep 2024 02:35:18 +0000 Subject: [PATCH 06/20] opt --- lib/manifest.ps1 | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/lib/manifest.ps1 b/lib/manifest.ps1 index ba63ecc313..43cff18013 100644 --- a/lib/manifest.ps1 +++ b/lib/manifest.ps1 @@ -50,10 +50,8 @@ function Get-Manifest($app) { $bucket = $install_info.bucket if (!$bucket) { $url = $install_info.url - if ($url) { - if ($url -match '^(ht|f)tps?://|\\\\') { - $manifest = url_manifest $url - } + if ($url -match '^(ht|f)tps?://|\\\\') { + $manifest = url_manifest $url } if (!$manifest) { if (Test-Path $url) { From e7155eacc06584b428dd474dbf13edfe3e2f0e25 Mon Sep 17 00:00:00 2001 From: HUMORCE Date: Fri, 20 Sep 2024 05:19:51 +0000 Subject: [PATCH 07/20] deprecated manifest --- lib/core.ps1 | 4 +++- lib/manifest.ps1 | 6 +++++- libexec/scoop-info.ps1 | 20 +++++++++++++------- libexec/scoop-status.ps1 | 9 +++++---- 4 files changed, 26 insertions(+), 13 deletions(-) diff --git a/lib/core.ps1 b/lib/core.ps1 index eeaa2c9ad4..8789abbef6 100644 --- a/lib/core.ps1 +++ b/lib/core.ps1 @@ -554,6 +554,9 @@ function app_status($app, $global) { $status.failed = failed $app $global $status.hold = ($install_info.hold -eq $true) + $deprecated_dir = (Find-BucketDirectory -Name $install_info.bucket -Root) + "\deprecated" + $status.deprecated = (Get-ChildItem $deprecated_dir -Filter "$(sanitary_path $app).json" -Recurse).FullName + $manifest = manifest $app $install_info.bucket $install_info.url $status.removed = (!$manifest) if ($manifest.version) { @@ -581,7 +584,6 @@ function app_status($app, $global) { if ($deps) { $status.missing_deps += , $deps } - return $status } diff --git a/lib/manifest.ps1 b/lib/manifest.ps1 index 43cff18013..0993958027 100644 --- a/lib/manifest.ps1 +++ b/lib/manifest.ps1 @@ -32,7 +32,7 @@ function url_manifest($url) { } function Get-Manifest($app) { - $bucket, $manifest, $url = $null + $bucket, $manifest, $url, $deprecated = $null $app = $app.TrimStart('/') # check if app is a URL or UNC path if ($app -match '^(ht|f)tps?://|\\\\') { @@ -63,6 +63,10 @@ function Get-Manifest($app) { } } else { $manifest = manifest $app $bucket + if (!$manifest) { + $deprecated_dir = (Find-BucketDirectory -Name $bucket -Root) + "\deprecated" + $manifest = parse_json (Get-ChildItem $deprecated_dir -Filter "$(sanitary_path $app).json" -Recurse).FullName + } } } } else { diff --git a/libexec/scoop-info.ps1 b/libexec/scoop-info.ps1 index 181b8f9aa5..63f9c9a6ee 100644 --- a/libexec/scoop-info.ps1 +++ b/libexec/scoop-info.ps1 @@ -36,7 +36,7 @@ if ($verbose) { $original_dir = versiondir $app $manifest.version $global $persist_dir = persistdir $app $global } else { - $dir, $original_dir, $persist_dir = "", "", "" + $dir, $original_dir, $persist_dir = '', '', '' } if ($status.installed) { @@ -44,14 +44,20 @@ if ($status.installed) { if ($install.url) { $manifest_file = $install.url } - if ($status.version -eq $manifest.version) { + if ($status.deprecated) { + $manifest_file = $status.deprecated + } elseif ($status.version -eq $manifest.version) { $version_output = $status.version } else { $version_output = "$($status.version) (Update to $($manifest.version) available)" } + } $item = [ordered]@{ Name = $app } +if ($status.deprecated) { + $item.Name += ' (DEPRECATED)' +} if ($manifest.description) { $item.Description = $manifest.description } @@ -70,7 +76,7 @@ if ($manifest.license) { $manifest.license } elseif ($manifest.license -match '[|,]') { if ($verbose) { - "$($manifest.license) ($(($manifest.license -Split "\||," | ForEach-Object { "https://spdx.org/licenses/$_.html" }) -join ', '))" + "$($manifest.license) ($(($manifest.license -Split '\||,' | ForEach-Object { "https://spdx.org/licenses/$_.html" }) -join ', '))" } else { $manifest.license } @@ -103,7 +109,7 @@ if ($status.installed) { # Show installed versions $installed_output = @() Get-InstalledVersion -AppName $app -Global:$global | ForEach-Object { - $installed_output += if ($verbose) { versiondir $app $_ $global } else { "$_$(if ($global) { " *global*" })" } + $installed_output += if ($verbose) { versiondir $app $_ $global } else { "$_$(if ($global) { ' *global*' })" } } $item.Installed = $installed_output -join "`n" @@ -162,7 +168,7 @@ if ($status.installed) { foreach ($url in @(url $manifest (Get-DefaultArchitecture))) { try { if (Test-Path (cache_path $app $manifest.version $url)) { - $cached = " (latest version is cached)" + $cached = ' (latest version is cached)' } else { $cached = $null } @@ -197,7 +203,7 @@ if ($binaries) { $binary_output += $_ } } - $item.Binaries = $binary_output -join " | " + $item.Binaries = $binary_output -join ' | ' } $shortcuts = @(arch_specific 'shortcuts' $manifest $install.architecture) if ($shortcuts) { @@ -205,7 +211,7 @@ if ($shortcuts) { $shortcuts | ForEach-Object { $shortcut_output += $_[1] } - $item.Shortcuts = $shortcut_output -join " | " + $item.Shortcuts = $shortcut_output -join ' | ' } $env_set = arch_specific 'env_set' $manifest $install.architecture if ($env_set) { diff --git a/libexec/scoop-status.ps1 b/libexec/scoop-status.ps1 index 07b88a5e54..cc34ddac9f 100644 --- a/libexec/scoop-status.ps1 +++ b/libexec/scoop-status.ps1 @@ -59,7 +59,7 @@ $true, $false | ForEach-Object { # local and global apps Get-ChildItem $dir | Where-Object name -NE 'scoop' | ForEach-Object { $app = $_.name $status = app_status $app $global - if (!$status.outdated -and !$status.failed -and !$status.removed -and !$status.missing_deps) { return } + if (!$status.outdated -and !$status.failed -and !$status.deprecated -and !$status.removed -and !$status.missing_deps) { return } $item = [ordered]@{} $item.Name = $app @@ -67,9 +67,10 @@ $true, $false | ForEach-Object { # local and global apps $item.'Latest Version' = if ($status.outdated) { $status.latest_version } else { "" } $item.'Missing Dependencies' = $status.missing_deps -Split ' ' -Join ' | ' $info = @() - if ($status.failed) { $info += 'Install failed' } - if ($status.hold) { $info += 'Held package' } - if ($status.removed) { $info += 'Manifest removed' } + if ($status.failed) { $info += 'Install failed' } + if ($status.hold) { $info += 'Held package' } + if ($status.deprecated) { $info += 'Deprecated' } + if ($status.removed) { $info += 'Manifest removed' } $item.Info = $info -join ', ' $list += [PSCustomObject]$item } From 3ec539e62d1a806d77dab18bd87a033371ed4a44 Mon Sep 17 00:00:00 2001 From: HUMORCE Date: Fri, 20 Sep 2024 06:21:36 +0000 Subject: [PATCH 08/20] source of manifests --- libexec/scoop-info.ps1 | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libexec/scoop-info.ps1 b/libexec/scoop-info.ps1 index 63f9c9a6ee..af3678ec18 100644 --- a/libexec/scoop-info.ps1 +++ b/libexec/scoop-info.ps1 @@ -62,9 +62,9 @@ if ($manifest.description) { $item.Description = $manifest.description } $item.Version = $version_output -if ($bucket) { - $item.Bucket = $bucket -} + +$item.Source = if ($install.bucket) { $install.bucket } else { $install.url } + if ($manifest.homepage) { $item.Website = $manifest.homepage.TrimEnd('/') } From c5250058100538bba698b0af7c8906339b7f40a4 Mon Sep 17 00:00:00 2001 From: HUMORCE Date: Fri, 20 Sep 2024 08:15:31 +0000 Subject: [PATCH 09/20] source of manifest pt2 - Mark URI(path/URL/UNC/etc.) query as standalone manifest - Drop `installed` and `available update` items for [query] and [installed] are different sources. --- libexec/scoop-info.ps1 | 38 +++++++++++++++++++++++++++++++++----- 1 file changed, 33 insertions(+), 5 deletions(-) diff --git a/libexec/scoop-info.ps1 b/libexec/scoop-info.ps1 index af3678ec18..9a4d861f14 100644 --- a/libexec/scoop-info.ps1 +++ b/libexec/scoop-info.ps1 @@ -9,6 +9,7 @@ . "$PSScriptRoot\..\lib\download.ps1" # 'Get-RemoteFileSize' $opt, $app, $err = getopt $args 'v' 'verbose' +$original_app = $app if ($err) { error "scoop info: $err"; exit 1 } $verbose = $opt.v -or $opt.verbose @@ -31,6 +32,21 @@ $manifest_file = if ($bucket) { $url } +if ($install.url -and (Test-Path $original_app) -or ($original_app -match '^(ht|f)tps?://|\\\\')) { + $standalone = $true + if (Test-Path $original_app) { + $original_app = (Get-AbsolutePath "$original_app") + } + if (Test-Path $install.url) { + $install_url = (Get-AbsolutePath $install.url) + } else { + $install_url = $install.url + } +} +if ($original_app -eq $install_url) { + $same_source = $true +} + if ($verbose) { $dir = currentdir $app $global $original_dir = versiondir $app $manifest.version $global @@ -46,6 +62,8 @@ if ($status.installed) { } if ($status.deprecated) { $manifest_file = $status.deprecated + } elseif ($standalone -and !$same_source) { + $version_output = $manifest.version } elseif ($status.version -eq $manifest.version) { $version_output = $status.version } else { @@ -63,7 +81,15 @@ if ($manifest.description) { } $item.Version = $version_output -$item.Source = if ($install.bucket) { $install.bucket } else { $install.url } +$item.Source = if ($standalone) { + $original_app +} else { + if ($install.bucket) { + $install.bucket + } elseif ($install.url) { + $install.url + } +} if ($manifest.homepage) { $item.Website = $manifest.homepage.TrimEnd('/') @@ -107,11 +133,13 @@ if ($verbose) { $item.Manifest = $manifest_file } if ($status.installed) { # Show installed versions - $installed_output = @() - Get-InstalledVersion -AppName $app -Global:$global | ForEach-Object { - $installed_output += if ($verbose) { versiondir $app $_ $global } else { "$_$(if ($global) { ' *global*' })" } + if (!$standalone -or $same_source) { + $installed_output = @() + Get-InstalledVersion -AppName $app -Global:$global | ForEach-Object { + $installed_output += if ($verbose) { versiondir $app $_ $global } else { "$_$(if ($global) { ' *global*' })" } + } + $item.Installed = $installed_output -join "`n" } - $item.Installed = $installed_output -join "`n" if ($verbose) { # Show size of installation From 8d15b2fd36bcee7039dc3483d6be7dcf85d5c7c2 Mon Sep 17 00:00:00 2001 From: HUMORCE Date: Fri, 20 Sep 2024 08:38:12 +0000 Subject: [PATCH 10/20] remove variable preventing I forget it --- lib/manifest.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/manifest.ps1 b/lib/manifest.ps1 index 0993958027..5a3604c090 100644 --- a/lib/manifest.ps1 +++ b/lib/manifest.ps1 @@ -32,7 +32,7 @@ function url_manifest($url) { } function Get-Manifest($app) { - $bucket, $manifest, $url, $deprecated = $null + $bucket, $manifest, $url = $null $app = $app.TrimStart('/') # check if app is a URL or UNC path if ($app -match '^(ht|f)tps?://|\\\\') { From 366f651195332b9dc9f346ca739add764f0ec66e Mon Sep 17 00:00:00 2001 From: HUMORCE Date: Fri, 20 Sep 2024 09:47:08 +0000 Subject: [PATCH 11/20] scoop-info: fix source of manifest on bucket --- libexec/scoop-info.ps1 | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libexec/scoop-info.ps1 b/libexec/scoop-info.ps1 index 9a4d861f14..f4ba964e8e 100644 --- a/libexec/scoop-info.ps1 +++ b/libexec/scoop-info.ps1 @@ -88,6 +88,8 @@ $item.Source = if ($standalone) { $install.bucket } elseif ($install.url) { $install.url + } else { + $bucket } } From c38fc6303d3b33c52a5df00b33864539161fe875 Mon Sep 17 00:00:00 2001 From: HUMORCE Date: Fri, 20 Sep 2024 10:54:35 +0000 Subject: [PATCH 12/20] fix `scoop-depends` --- libexec/scoop-depends.ps1 | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/libexec/scoop-depends.ps1 b/libexec/scoop-depends.ps1 index d67ff246dc..25ed614ca3 100644 --- a/libexec/scoop-depends.ps1 +++ b/libexec/scoop-depends.ps1 @@ -5,6 +5,7 @@ . "$PSScriptRoot\..\lib\depends.ps1" # 'Get-Dependency' . "$PSScriptRoot\..\lib\versions.ps1" # 'Select-CurrentVersion' . "$PSScriptRoot\..\lib\manifest.ps1" # 'Get-Manifest' (indirectly) +. "$PSScriptRoot\..\lib\download.ps1" # 'Get-UserAgent' $opt, $apps, $err = getopt $args 'a:' 'arch=' $app = $apps[0] @@ -21,7 +22,14 @@ try { $deps = @() Get-Dependency $app $architecture | ForEach-Object { $dep = [ordered]@{} - $dep.Source, $dep.Name = $_ -split '/' + + $app, $null, $bucket, $url = Get-Manifest $_ + if (!$url) { + $bucket, $app = $_ -split '/' + } + $dep.Source = if ($url) { $url } else { $bucket } + $dep.Name = $app + $deps += [PSCustomObject]$dep } $deps From 58a5ead50b2a4e63ea597cd5fc127d94feab497b Mon Sep 17 00:00:00 2001 From: HUMORCE Date: Fri, 20 Sep 2024 11:18:12 +0000 Subject: [PATCH 13/20] Fix Standalone and Source detection --- lib/manifest.ps1 | 2 +- libexec/scoop-info.ps1 | 19 +++++++++++-------- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/lib/manifest.ps1 b/lib/manifest.ps1 index 5a3604c090..702ead4f35 100644 --- a/lib/manifest.ps1 +++ b/lib/manifest.ps1 @@ -87,7 +87,7 @@ function Get-Manifest($app) { if (Test-Path $app) { $url = Convert-Path $app $app = appname_from_url $url - $manifest = url_manifest $url + $manifest = parse_json $url } else { if (($app -match '\\/') -or $app.EndsWith('.json')) { $url = $app } $app = appname_from_url $app diff --git a/libexec/scoop-info.ps1 b/libexec/scoop-info.ps1 index f4ba964e8e..1322e33a63 100644 --- a/libexec/scoop-info.ps1 +++ b/libexec/scoop-info.ps1 @@ -32,19 +32,22 @@ $manifest_file = if ($bucket) { $url } -if ($install.url -and (Test-Path $original_app) -or ($original_app -match '^(ht|f)tps?://|\\\\')) { +# Standalone and Source detection +if ((Test-Path $original_app) -or ($original_app -match '^(ht|f)tps?://|\\\\')) { $standalone = $true if (Test-Path $original_app) { $original_app = (Get-AbsolutePath "$original_app") } - if (Test-Path $install.url) { - $install_url = (Get-AbsolutePath $install.url) - } else { - $install_url = $install.url + if ($install.url) { + if (Test-Path $install.url) { + $install_url = (Get-AbsolutePath $install.url) + } else { + $install_url = $install.url + } + } + if ($original_app -eq $install_url) { + $same_source = $true } -} -if ($original_app -eq $install_url) { - $same_source = $true } if ($verbose) { From 53603c665b277bcd509c85f5d9a9ca7fe8431341 Mon Sep 17 00:00:00 2001 From: HUMORCE Date: Fri, 20 Sep 2024 11:57:56 +0000 Subject: [PATCH 14/20] fix global install --- lib/manifest.ps1 | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/manifest.ps1 b/lib/manifest.ps1 index 702ead4f35..55dffbc2f6 100644 --- a/lib/manifest.ps1 +++ b/lib/manifest.ps1 @@ -44,6 +44,10 @@ function Get-Manifest($app) { if (installed $app) { $global = installed $app $true $ver = Select-CurrentVersion -AppName $app -Global:$global + if (!$ver) { + $app, $bucket, $ver = parse_app $app + $ver = Select-CurrentVersion -AppName $app -Global:$global + } $install_info_path = "$(versiondir $app $ver $global)\install.json" if (Test-Path $install_info_path) { $install_info = parse_json $install_info_path @@ -64,7 +68,7 @@ function Get-Manifest($app) { } else { $manifest = manifest $app $bucket if (!$manifest) { - $deprecated_dir = (Find-BucketDirectory -Name $bucket -Root) + "\deprecated" + $deprecated_dir = (Find-BucketDirectory -Name $bucket -Root) + '\deprecated' $manifest = parse_json (Get-ChildItem $deprecated_dir -Filter "$(sanitary_path $app).json" -Recurse).FullName } } From f14c57d04ccc06ba278d768431d88a835f9b33ea Mon Sep 17 00:00:00 2001 From: HUMORCE Date: Tue, 24 Sep 2024 07:39:11 +0000 Subject: [PATCH 15/20] Fix scoop-cat, scoop-home - Query for remote manifest --- libexec/scoop-cat.ps1 | 1 + libexec/scoop-home.ps1 | 1 + 2 files changed, 2 insertions(+) diff --git a/libexec/scoop-cat.ps1 b/libexec/scoop-cat.ps1 index 70863e2021..fc85fced92 100644 --- a/libexec/scoop-cat.ps1 +++ b/libexec/scoop-cat.ps1 @@ -9,6 +9,7 @@ param($app) . "$PSScriptRoot\..\lib\json.ps1" # 'ConvertToPrettyJson' . "$PSScriptRoot\..\lib\versions.ps1" # 'Select-CurrentVersion' . "$PSScriptRoot\..\lib\manifest.ps1" # 'Get-Manifest' +. "$PSScriptRoot\..\lib\download.ps1" # 'Get-UserAgent' if (!$app) { error ' missing'; my_usage; exit 1 } diff --git a/libexec/scoop-home.ps1 b/libexec/scoop-home.ps1 index f76a5e06b0..b1bd94e356 100644 --- a/libexec/scoop-home.ps1 +++ b/libexec/scoop-home.ps1 @@ -4,6 +4,7 @@ param($app) . "$PSScriptRoot\..\lib\versions.ps1" # 'Select-CurrentVersion' . "$PSScriptRoot\..\lib\manifest.ps1" # 'Get-Manifest' +. "$PSScriptRoot\..\lib\download.ps1" # 'Get-UserAgent' if ($app) { $null, $manifest, $bucket, $null = Get-Manifest $app From a65c84a82a18a8f920843c73c741cfc27f83b0bc Mon Sep 17 00:00:00 2001 From: HUMORCE Date: Tue, 24 Sep 2024 08:13:58 +0000 Subject: [PATCH 16/20] scoop-list: info +deprecated --- libexec/scoop-list.ps1 | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/libexec/scoop-list.ps1 b/libexec/scoop-list.ps1 index da44dd1410..f757146d47 100644 --- a/libexec/scoop-list.ps1 +++ b/libexec/scoop-list.ps1 @@ -5,8 +5,9 @@ param($query) . "$PSScriptRoot\..\lib\versions.ps1" # 'Select-CurrentVersion' . "$PSScriptRoot\..\lib\manifest.ps1" # 'parse_json' 'Select-CurrentVersion' (indirectly) +. "$PSScriptRoot\..\lib\download.ps1" # 'Get-UserAgent' -$def_arch = Get-DefaultArchitecture +$defaultArchitecture = Get-DefaultArchitecture if (-not (Get-FormatData ScoopApps)) { Update-FormatData "$PSScriptRoot\..\supporting\formats\ScoopTypes.Format.ps1xml" } @@ -47,10 +48,11 @@ $apps | Where-Object { !$query -or ($_.name -match $query) } | ForEach-Object { $item.Updated = $updated $info = @() + if ((app_status $app $global).deprecated) { $info += 'Deprecated package'} if ($global) { $info += 'Global install' } if (failed $app $global) { $info += 'Install failed' } if ($install_info.hold) { $info += 'Held package' } - if ($install_info.architecture -and $def_arch -ne $install_info.architecture) { + if ($install_info.architecture -and $defaultArchitecture -ne $install_info.architecture) { $info += $install_info.architecture } $item.Info = $info -join ', ' From 61b325986ec6f806e8accdbd357a4dfe820155d5 Mon Sep 17 00:00:00 2001 From: HUMORCE Date: Tue, 24 Sep 2024 10:42:31 +0000 Subject: [PATCH 17/20] manifest: Fix first selected manifest --- lib/manifest.ps1 | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/lib/manifest.ps1 b/lib/manifest.ps1 index 55dffbc2f6..f0156f9824 100644 --- a/lib/manifest.ps1 +++ b/lib/manifest.ps1 @@ -78,11 +78,16 @@ function Get-Manifest($app) { if ($bucket) { $manifest = manifest $app $bucket } else { + $count = 0 foreach ($tekcub in Get-LocalBucket) { - $manifest = manifest $app $tekcub + if (!$manifest) { + $manifest = manifest $app $tekcub + } if ($manifest) { - $bucket = $tekcub - break + if (!$bucket) { + $bucket = $tekcub + } + $count++ } } } @@ -99,6 +104,13 @@ function Get-Manifest($app) { } } } + + if ($count) { + if ($count -gt 1) { + warn "Multiple buckets contain '$app', selected manifest are '$bucket/$app'." + } + } + return $app, $manifest, $bucket, $url } From 8f1840638aa3b519c3c78ac29a71efe5b3b2e858 Mon Sep 17 00:00:00 2001 From: HUMORCE Date: Tue, 24 Sep 2024 10:46:25 +0000 Subject: [PATCH 18/20] gramma.. --- lib/manifest.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/manifest.ps1 b/lib/manifest.ps1 index f0156f9824..95615711fc 100644 --- a/lib/manifest.ps1 +++ b/lib/manifest.ps1 @@ -107,7 +107,7 @@ function Get-Manifest($app) { if ($count) { if ($count -gt 1) { - warn "Multiple buckets contain '$app', selected manifest are '$bucket/$app'." + warn "Multiple buckets contain manifest '$app', the current selection is '$bucket/$app'." } } From c5c82cdf6a50ca7b6e79e92ade16c217f0e5d828 Mon Sep 17 00:00:00 2001 From: HUMORCE Date: Thu, 26 Sep 2024 12:14:38 +0000 Subject: [PATCH 19/20] Fix 61b3259 --- lib/manifest.ps1 | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/lib/manifest.ps1 b/lib/manifest.ps1 index 95615711fc..826679b2e9 100644 --- a/lib/manifest.ps1 +++ b/lib/manifest.ps1 @@ -78,16 +78,15 @@ function Get-Manifest($app) { if ($bucket) { $manifest = manifest $app $bucket } else { - $count = 0 + $matched_buckets = @() foreach ($tekcub in Get-LocalBucket) { - if (!$manifest) { - $manifest = manifest $app $tekcub + $current_manifest = manifest $app $tekcub + if (!$manifest -and $current_manifest) { + $manifest = $current_manifest + $bucket = $tekcub } - if ($manifest) { - if (!$bucket) { - $bucket = $tekcub - } - $count++ + if ($current_manifest) { + $matched_buckets += $tekcub } } } @@ -105,10 +104,8 @@ function Get-Manifest($app) { } } - if ($count) { - if ($count -gt 1) { - warn "Multiple buckets contain manifest '$app', the current selection is '$bucket/$app'." - } + if ($matched_buckets -gt 1) { + warn "Multiple buckets contain manifest '$app', the current selection is '$bucket/$app'." } return $app, $manifest, $bucket, $url From 984c662b3783aaf41e6cc3c2fb0e72c88d1ea1c2 Mon Sep 17 00:00:00 2001 From: HUMORCE Date: Fri, 27 Sep 2024 18:36:50 +0000 Subject: [PATCH 20/20] length --- lib/manifest.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/manifest.ps1 b/lib/manifest.ps1 index 826679b2e9..29c898b6a7 100644 --- a/lib/manifest.ps1 +++ b/lib/manifest.ps1 @@ -104,7 +104,7 @@ function Get-Manifest($app) { } } - if ($matched_buckets -gt 1) { + if ($matched_buckets.Length -gt 1) { warn "Multiple buckets contain manifest '$app', the current selection is '$bucket/$app'." }