mirror of
https://github.com/ScoopInstaller/Scoop.git
synced 2025-10-29 21:57:26 +00:00
refactor(Get-Manifest): Select actual source for manifest (#6142)
* first step * Revert "first step" This reverts commitc5907c3e25. * refactor(Get-Manifest): Select actual source for installed manifest * rework sub-commands, `scoop-depends` is NOT working at this stage * URI manifest * opt * deprecated manifest * source of manifests * 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. * remove variable preventing I forget it * scoop-info: fix source of manifest on bucket * fix `scoop-depends` * Fix Standalone and Source detection * fix global install * Fix scoop-cat, scoop-home - Query for remote manifest * scoop-list: info +deprecated * manifest: Fix first selected manifest * gramma.. * Fix61b3259* length
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
|
||||
@@ -40,30 +40,74 @@ 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
|
||||
# Check if the manifest is already installed
|
||||
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
|
||||
$bucket = $install_info.bucket
|
||||
if (!$bucket) {
|
||||
$url = $install_info.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
|
||||
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 {
|
||||
foreach ($tekcub in Get-LocalBucket) {
|
||||
$manifest = manifest $app $tekcub
|
||||
if ($manifest) {
|
||||
$bucket = $tekcub
|
||||
break
|
||||
$app, $bucket, $version = parse_app $app
|
||||
if ($bucket) {
|
||||
$manifest = manifest $app $bucket
|
||||
} else {
|
||||
$matched_buckets = @()
|
||||
foreach ($tekcub in Get-LocalBucket) {
|
||||
$current_manifest = manifest $app $tekcub
|
||||
if (!$manifest -and $current_manifest) {
|
||||
$manifest = $current_manifest
|
||||
$bucket = $tekcub
|
||||
}
|
||||
if ($current_manifest) {
|
||||
$matched_buckets += $tekcub
|
||||
}
|
||||
}
|
||||
}
|
||||
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 = parse_json $url
|
||||
} else {
|
||||
if (($app -match '\\/') -or $app.EndsWith('.json')) { $url = $app }
|
||||
$app = appname_from_url $app
|
||||
}
|
||||
}
|
||||
}
|
||||
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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($matched_buckets.Length -gt 1) {
|
||||
warn "Multiple buckets contain manifest '$app', the current selection is '$bucket/$app'."
|
||||
}
|
||||
|
||||
return $app, $manifest, $bucket, $url
|
||||
}
|
||||
|
||||
|
||||
@@ -7,7 +7,9 @@
|
||||
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 '<app> missing'; my_usage; exit 1 }
|
||||
|
||||
|
||||
@@ -3,7 +3,9 @@
|
||||
|
||||
. "$PSScriptRoot\..\lib\getopt.ps1"
|
||||
. "$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]
|
||||
@@ -20,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
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -2,7 +2,9 @@
|
||||
# Summary: Opens the app homepage
|
||||
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
|
||||
|
||||
@@ -5,10 +5,11 @@
|
||||
|
||||
. "$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'
|
||||
$original_app = $app
|
||||
if ($err) { error "scoop info: $err"; exit 1 }
|
||||
$verbose = $opt.v -or $opt.verbose
|
||||
|
||||
@@ -23,7 +24,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
|
||||
@@ -31,12 +32,30 @@ $manifest_file = if ($bucket) {
|
||||
$url
|
||||
}
|
||||
|
||||
# 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 ($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 ($verbose) {
|
||||
$dir = currentdir $app $global
|
||||
$original_dir = versiondir $app $manifest.version $global
|
||||
$persist_dir = persistdir $app $global
|
||||
} else {
|
||||
$dir, $original_dir, $persist_dir = "<root>", "<root>", "<root>"
|
||||
$dir, $original_dir, $persist_dir = '<root>', '<root>', '<root>'
|
||||
}
|
||||
|
||||
if ($status.installed) {
|
||||
@@ -44,21 +63,39 @@ if ($status.installed) {
|
||||
if ($install.url) {
|
||||
$manifest_file = $install.url
|
||||
}
|
||||
if ($status.version -eq $manifest.version) {
|
||||
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 {
|
||||
$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
|
||||
}
|
||||
$item.Version = $version_output
|
||||
if ($bucket) {
|
||||
$item.Bucket = $bucket
|
||||
|
||||
$item.Source = if ($standalone) {
|
||||
$original_app
|
||||
} else {
|
||||
if ($install.bucket) {
|
||||
$install.bucket
|
||||
} elseif ($install.url) {
|
||||
$install.url
|
||||
} else {
|
||||
$bucket
|
||||
}
|
||||
}
|
||||
|
||||
if ($manifest.homepage) {
|
||||
$item.Website = $manifest.homepage.TrimEnd('/')
|
||||
}
|
||||
@@ -70,7 +107,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
|
||||
}
|
||||
@@ -101,11 +138,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
|
||||
@@ -162,7 +201,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 +236,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 +244,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) {
|
||||
|
||||
@@ -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 ', '
|
||||
|
||||
@@ -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'
|
||||
@@ -58,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
|
||||
@@ -66,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
|
||||
}
|
||||
|
||||
@@ -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'
|
||||
|
||||
Reference in New Issue
Block a user