Skip to content
This repository was archived by the owner on Oct 11, 2025. It is now read-only.
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@

## [0.6.5](https://github.com/Ash258/Scoop-Core/milestone/5)

- **core**:
- Prevent leaking of exceptions stack traces to user
- Use `[System.IO.Path]::Combine` for path joining
- **Schema**:
- Better properties descriptions
- More strict object validation
- Better ergonomics for editing of the schema
- **core**: Use `[System.IO.Path]::Combine` for path joining
- **Download**: Do not show progress in CI by default
- **Uninstall**: Run `post_uninstall` after current unlinking
- **Tests**: Fix detection of 1 new line at the end and allow CRLF/LF for powershell executables
Expand Down
28 changes: 13 additions & 15 deletions bin/scoop.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ Upgrade PowerShell: 'https://docs.microsoft.com/en-us/powershell/scripting/insta
}

# This simple import is fine as for the command this is entry. It is also desired to refresh all the variables/functions
'core', 'buckets', 'Helpers', 'commands', 'Git' | ForEach-Object {
'core', 'Helpers', 'buckets', 'commands' | ForEach-Object {
. (Join-Path $PSScriptRoot "..\lib\$_.ps1")
}

$ExitCode = 0

# Powershell automatically bind bash like short parameters as $args, and does not put it in $Command parameter
# Powershell automatically bind bash-like short parameters as $args, and does not put it in $Command parameter
# ONLY if:
# - No command passed
# - -v or --version passed
Expand All @@ -42,33 +42,31 @@ $validCommand = $Command -and ($Command -in (commands))
$commandHelp = !$scoopHelp -and $validCommand -and (($args.Contains('--help')) -or ($args.Contains('-h')))

if ($version) {
# TODO: Printout architecture Architecture: detected (configured default)
Write-UserMessage -Output -Message @(
"PowerShell version: $($PSVersionTable.PSVersion)"
"Useragent: $SHOVEL_USERAGENT"
"Administrator: $SHOVEL_IS_ADMIN"
"Architecture: $SHOVEL_ARCHITECTURE"
"System architecture: $SHOVEL_SYSTEM_ARCHITECTURE"
'Current Scoop (Shovel) version:'
)
Invoke-GitCmd -Command 'VersionLog' -Repository (versiondir 'scoop' 'current')

# TODO: Export to lib/buckets
Get-LocalBucket | ForEach-Object {
$b = Find-BucketDirectory $_ -Root

if (Join-Path $b '.git' | Test-Path -PathType 'Container') {
Write-UserMessage -Message "`r`n'$_' bucket:" -Output
Invoke-GitCmd -Command 'VersionLog' -Repository $b
}
}
Show-BucketVersion
} elseif ($scoopHelp) {
Invoke-ScoopCommand 'help'
$ExitCode = $LASTEXITCODE
} elseif ($commandHelp) {
Invoke-ScoopCommand 'help' @($Command)
$ExitCode = $LASTEXITCODE
} elseif ($validCommand) {
Invoke-ScoopCommand $Command $args
$ExitCode = $LASTEXITCODE
# Capture top level exceptions for more user friendliness. Let's see what impact it will have
try {
Invoke-ScoopCommand $Command $args
$ExitCode = $LASTEXITCODE
} catch {
Write-UserMessage -Message "scoop: $($_.Exception.Message)" -Err
$ExitCode = 3
}
} else {
Write-UserMessage -Message "scoop: '$Command' isn't a scoop command. See 'scoop help'." -Output
$ExitCode = 2
Expand Down
2 changes: 1 addition & 1 deletion bin/update-supporting.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ $ErrorActionPreference = 'Stop'
$checkver = Join-Path $PSScriptRoot 'checkver.ps1'
$Sups = Join-Path $PSScriptRoot '..\supporting\*' | Get-ChildItem -Include "$Supporting.*" -File

'decompress', 'Helpers', 'manifest', 'install' | ForEach-Object {
'core', 'decompress', 'Helpers', 'manifest', 'install' | ForEach-Object {
. (Join-Path $PSScriptRoot "..\lib\$_.ps1")
}

Expand Down
2 changes: 1 addition & 1 deletion lib/Update.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ function Update-Scoop {
return
}

if (!(Test-CommandAvailable -Command 'git')) { Stop-ScoopExecution -Message 'Scoop uses Git to update itself. Run ''scoop install git'' and try again.' }
if (!$SHOVEL_IS_GIT_AVAILABLE) { Stop-ScoopExecution -Message 'Scoop uses Git to update itself. Run ''scoop install git'' and try again.' }

Write-UserMessage -Message 'Updating Scoop...' -Output

Expand Down
20 changes: 20 additions & 0 deletions lib/buckets.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,26 @@ function Remove-Bucket {
}
}

function Show-BucketVersion {
param([Switch] $IncludeShovel)

if (!$SHOVEL_IS_GIT_AVAILABLE) {
Write-UserMessage -Message 'Install git to see version information about Shovel and buckets' -Warn
return
}

if ($IncludeShovel) { Invoke-GitCmd -Command 'VersionLog' -Repository (versiondir 'scoop' 'current') }

foreach ($_bucket in Get-LocalBucket) {
$b = Find-BucketDirectory $_bucket -Root

if (Join-Path $b '.git' | Test-Path -PathType 'Container') {
Write-UserMessage -Message "`r`n'$_bucket' bucket:" -Output
Invoke-GitCmd -Command 'VersionLog' -Repository $b
}
}
}

#region Deprecated
function bucketdir($name) {
Show-DeprecatedWarning $MyInvocation 'Find-BucketDirectory'
Expand Down
45 changes: 44 additions & 1 deletion lib/core.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,21 @@ function Optimize-SecurityProtocol {
}
}

function Get-SystemArchitecture {
$arch = ''

switch ($env:PROCESSOR_ARCHITECTURE) {
'AMD64' { $arch = '64bit' }
'ARM64' { $arch = 'arm64' }
}

if ($SHOVEL_IS_UNIX) {
$arch = Invoke-SystemComSpecCommand -Unix 'uname -m'
}

return ensure_architecture $arch
}

# Shovel/1.0 (+https://shovel.ash258.com) PowerShell/7.2 (Windows NT 10.0; Win64; x64; Core)
# Shovel/1.0 (+https://shovel.ash258.com) PowerShell/7.2 (Linux; Linux 5.8.0-1032-raspi #35-Ubuntu SMP PREEMPT Wed Jul 14 10:51:21 UTC 2021;)
function Get-UserAgent {
Expand Down Expand Up @@ -407,7 +422,11 @@ function basedir($global) { if ($global) { return $SCOOP_GLOBAL_ROOT_DIRECTORY }
function appsdir($global) { return basedir $global | Join-Path -ChildPath 'apps' }
function shimdir($global) { return basedir $global | Join-Path -ChildPath 'shims' }
function appdir($app, $global) { return appsdir $global | Join-Path -ChildPath $app }
function versiondir($app, $version, $global) { return appdir $app $global | Join-Path -ChildPath $version }
function versiondir($app, $version, $global) {
if ($app -eq 'shovel') { $app = 'scoop' }

return appdir $app $global | Join-Path -ChildPath $version
}
function persistdir($app, $global) { return basedir $global | Join-Path -ChildPath "persist\$app" }
function usermanifestsdir { return Join-Path (basedir) 'workspace' }
function usermanifest($app) { return Join-Path (usermanifestsdir) "$app.json" }
Expand Down Expand Up @@ -772,6 +791,27 @@ function ensure_in_path($dir, $global) {
}
}


function default_architecture {
$arch = get_config 'default-architecture'
$system = if ([System.IntPtr]::Size -eq 8) { '64bit' } else { '32bit' }

if ($SHOVEL_IS_ARM_ARCH) { $arch = 'arm' + ($system -replace 'bit') }

if ($null -eq $arch) {
$arch = $system
} else {
try {
$arch = ensure_architecture $arch
} catch {
Write-UserMessage -Message 'Invalid default architecture configured. Determining default system architecture' -Warning
$arch = $system
}
}

return $arch
}

function ensure_architecture($architecture_opt) {
if (!$architecture_opt) { return default_architecture }

Expand Down Expand Up @@ -1068,7 +1108,10 @@ $SHOVEL_DEBUG_ENABLED = Test-ScoopDebugEnabled
$SHOVEL_IS_UNIX = Test-IsUnix
$SHOVEL_IS_ADMIN = is_admin
$SHOVEL_IS_ARM_ARCH = Test-IsArmArchitecture
$SHOVEL_IS_GIT_AVAILABLE = Test-CommandAvailable -Command 'git'
$SHOVEL_USERAGENT = Get-UserAgent
$SHOVEL_ARCHITECTURE = default_architecture
$SHOVEL_SYSTEM_ARCHITECTURE = Get-SystemArchitecture

# All supported architectures
$SHOVEL_SUPPORTED_ARCHITECTURES = @('64bit', '32bit', 'arm64')
Expand Down
20 changes: 0 additions & 20 deletions lib/manifest.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -616,26 +616,6 @@ function install_info($app, $version, $global) {
return parse_json $path
}

function default_architecture {
$arch = get_config 'default-architecture'
$system = if ([System.IntPtr]::Size -eq 8) { '64bit' } else { '32bit' }

if ($SHOVEL_IS_ARM_ARCH) { $arch = 'arm' + ($system -replace 'bit') }

if ($null -eq $arch) {
$arch = $system
} else {
try {
$arch = ensure_architecture $arch
} catch {
Write-UserMessage -Message 'Invalid default architecture configured. Determining default system architecture' -Warning
$arch = $system
}
}

return $arch
}

function arch_specific($prop, $manifest, $architecture) {
if ($manifest.architecture) {
$val = $manifest.architecture.$architecture.$prop
Expand Down