-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInstall-Scoop.ps1
More file actions
86 lines (74 loc) · 2.74 KB
/
Install-Scoop.ps1
File metadata and controls
86 lines (74 loc) · 2.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
$buckets = @{
"developing-today" = "https://github.com/developing-today/scoop-developing-today"
"charmbracelet" = "https://github.com/developing-today-forks/scoop-charmbracelet"
"charm" = "https://github.com/charmbracelet/scoop-bucket"
"extras" = ""
"versions" = ""
}
Set-StrictMode -Version Latest
$PSNativeCommandUseErrorActionPreference = $true
if ($PSNativeCommandUseErrorActionPreference) {
# always true, this is a linter workaround
$ErrorActionPreference = "Stop"
$PSDefaultParameterValues['*:ErrorAction'] = 'Stop'
}
function CheckLastExitCode {
param ([int[]]$SuccessCodes = @(0))
if (!$?) {
if (-not (Test-Path variable://LastExitCode)) {
$LastExitCode = 1
Write-Verbose -Verbose "No LastExitCode found, setting to 1"
}
Write-Verbose -Verbose "Last CMD failed $LastExitCode"
exit
}
if (-not (Test-Path variable://LastExitCode)) {
Write-Verbose -Verbose "No LastExitCode found, setting to 0"
$LastExitCode = 0
}
if ($SuccessCodes -notcontains $LastExitCode) {
Write-Verbose -Verbose "EXE RETURNED EXIT CODE $LastExitCode"
exit
}
}
if (-not (Get-Command 'scoop' -ErrorAction SilentlyContinue)) {
$scoop = Invoke-RestMethod get.scoop.sh
CheckLastExitCode
Invoke-Expression $scoop
CheckLastExitCode
} else {
Write-Verbose -Verbose "Scoop already installed."
}
# causes ffpmeg errors # occurred 2023-11 try again after 2024-03
# scoop install aria2
# scoop config aria2-enabled true
scoop install git
scoop update git
powershell.exe -Command "scoop install pwsh" # https://github.com/ScoopInstaller/Main/issues/3572#issuecomment-1292873053
powershell.exe -Command "scoop update pwsh" # https://github.com/ScoopInstaller/Main/issues/3572#issuecomment-1292873053
reg import (Join-Path (Get-Item (scoop which pwsh)).Directory.FullName install-explorer-context.reg)
reg import (Join-Path (Get-Item (scoop which pwsh)).Directory.FullName install-file-context.reg)
Write-Verbose -Verbose "Getting current scoop bucket list. If you see errors here, try removing the given bucket and running this script again. `scoop bucket rm <bucket>``"
$bucketList = scoop bucket list
CheckLastExitCode
$currentBuckets = $bucketList | ForEach-Object { $_.Name }
CheckLastExitCode
foreach ($bucket in $buckets.GetEnumerator()) {
$name = $bucket.Key
$url = $bucket.Value
if ($currentBuckets -contains $name) {
Write-Verbose -Verbose "Bucket $name already added. Removing..."
scoop bucket rm $name
CheckLastExitCode
}
Invoke-Expression "scoop bucket add $name $url"
CheckLastExitCode
}
scoop update
CheckLastExitCode
scoop update *
CheckLastExitCode
scoop --version
CheckLastExitCode
scoop status
CheckLastExitCode