mirror of
https://github.com/ScoopInstaller/Scoop.git
synced 2025-12-10 18:15:37 +00:00
Compare commits
87 Commits
2019-05-15
...
2020-10-22
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
643cfb0da8 | ||
|
|
9b29bbb711 | ||
|
|
22a59866c7 | ||
|
|
6df80c1aee | ||
|
|
22fd6986bf | ||
|
|
078b29bc80 | ||
|
|
33a357241d | ||
|
|
573e0933cf | ||
|
|
96de9c14bb | ||
|
|
7995f99dc1 | ||
|
|
f91968cb16 | ||
|
|
48f121e466 | ||
|
|
eada459be9 | ||
|
|
398ccea2ae | ||
|
|
50df0c52c4 | ||
|
|
e6b355eae0 | ||
|
|
4eba120897 | ||
|
|
fe01ed52d5 | ||
|
|
ad9f7c6ff1 | ||
|
|
062e6d7973 | ||
|
|
48bb96a3d8 | ||
|
|
e0c5ac2396 | ||
|
|
7e32139322 | ||
|
|
a9fa775d59 | ||
|
|
5afad4e3d1 | ||
|
|
8ac23f8fbc | ||
|
|
6eb90c9c11 | ||
|
|
eb3d42de8f | ||
|
|
e997017f1a | ||
|
|
8ee45a57dc | ||
|
|
ce3464f2f4 | ||
|
|
08af9ff6e7 | ||
|
|
e44b848f24 | ||
|
|
d948720961 | ||
|
|
11c42d782f | ||
|
|
5643818e1b | ||
|
|
19ed5e42a8 | ||
|
|
9a3579c523 | ||
|
|
15e11e62ae | ||
|
|
9c04608c48 | ||
|
|
9f693cbb7d | ||
|
|
6fc708cb25 | ||
|
|
a09926f5b9 | ||
|
|
8165b1d468 | ||
|
|
3e55a70971 | ||
|
|
e37e4ca666 | ||
|
|
0d251bafd1 | ||
|
|
c7d72d21b9 | ||
|
|
f555968c39 | ||
|
|
f52b339523 | ||
|
|
96fef5827d | ||
|
|
7879d272b2 | ||
|
|
79f8538b57 | ||
|
|
073d10dbc9 | ||
|
|
7decfd4c10 | ||
|
|
3ca08a5ae8 | ||
|
|
9ad783d3a5 | ||
|
|
1508d2ab00 | ||
|
|
544e6094cc | ||
|
|
78d2ff75f4 | ||
|
|
f33799dee8 | ||
|
|
0550605de1 | ||
|
|
b71b5074b2 | ||
|
|
b9b48182b4 | ||
|
|
1caaed8f3d | ||
|
|
e12a7da593 | ||
|
|
c8047bd5ed | ||
|
|
a882c4f1eb | ||
|
|
2fafcb880a | ||
|
|
61d1c1c41a | ||
|
|
2d22ac8233 | ||
|
|
1836edba88 | ||
|
|
e8d0be663b | ||
|
|
03bb07c823 | ||
|
|
2849e0f960 | ||
|
|
69a0843e9a | ||
|
|
81e3cf61b6 | ||
|
|
51f40e11c9 | ||
|
|
1ac8ac0c65 | ||
|
|
5d0d39abae | ||
|
|
1b84fe04fc | ||
|
|
a775d452ff | ||
|
|
f5fdc275ca | ||
|
|
e6b2e3d31e | ||
|
|
6141e46d6a | ||
|
|
b9deb57d03 | ||
|
|
ad6198eeb4 |
@@ -12,7 +12,7 @@ indent_style = space
|
||||
insert_final_newline = true
|
||||
trim_trailing_whitespace = true
|
||||
|
||||
[*.{bat,cmd,[Bb][Aa][Tt],[Cc][Mm][Dd]]
|
||||
[*.{[Bb][Aa][Tt],[Cc][Mm][Dd]}]
|
||||
# DOS/Win *requires* BAT/CMD files to have CRLF newlines
|
||||
end_of_line = crlf
|
||||
|
||||
|
||||
45
README.md
45
README.md
@@ -64,10 +64,13 @@ If you've built software that you'd like others to use, Scoop is an alternative
|
||||
|
||||
## Installation
|
||||
|
||||
Run this command from your PowerShell to install scoop to its default location (`C:\Users\<user>\scoop`)
|
||||
Run the following command from your PowerShell to install scoop to its default location (`C:\Users\<user>\scoop`)
|
||||
|
||||
```powershell
|
||||
iex (new-object net.webclient).downloadstring('https://get.scoop.sh')
|
||||
Invoke-Expression (New-Object System.Net.WebClient).DownloadString('https://get.scoop.sh')
|
||||
|
||||
# or shorter
|
||||
iwr -useb get.scoop.sh | iex
|
||||
```
|
||||
|
||||
Once installed, run `scoop help` for instructions.
|
||||
@@ -76,19 +79,20 @@ The default setup is configured so all user installed programs and Scoop itself
|
||||
Globally installed programs (`--global`) live in `C:\ProgramData\scoop`.
|
||||
These settings can be changed through environment variables.
|
||||
|
||||
### Install Scoop to a Custom Directory
|
||||
### Install Scoop to a Custom Directory by changing `SCOOP`
|
||||
|
||||
```powershell
|
||||
$env:SCOOP='D:\Applications\Scoop'
|
||||
[Environment]::SetEnvironmentVariable('SCOOP', $env:SCOOP, 'User')
|
||||
iex (new-object net.webclient).downloadstring('https://get.scoop.sh')
|
||||
# run the installer
|
||||
```
|
||||
|
||||
### Configure Scoop to install global programs to a Custom Directory
|
||||
### Configure Scoop to install global programs to a Custom Directory by changing `SCOOP_GLOBAL`
|
||||
|
||||
```powershell
|
||||
$env:SCOOP_GLOBAL='F:\GlobalScoopApps'
|
||||
[Environment]::SetEnvironmentVariable('SCOOP_GLOBAL', $env:SCOOP_GLOBAL, 'Machine')
|
||||
# run the installer
|
||||
```
|
||||
|
||||
## [Documentation](https://github.com/lukesampson/scoop/wiki)
|
||||
@@ -120,10 +124,39 @@ The apps that install best with Scoop are commonly called "portable" apps: i.e.
|
||||
|
||||
Since installers are common, Scoop supports them too (and their uninstallers).
|
||||
|
||||
Scoop is also great at handling single-file programs and Powershell scripts. These don't even need to be compressed. See the [runat](https://github.com/lukesampson/scoop/blob/master/bucket/runat.json) package for an example: it's really just a GitHub gist.
|
||||
Scoop is also great at handling single-file programs and Powershell scripts. These don't even need to be compressed. See the [runat](https://github.com/ScoopInstaller/Main/blob/master/bucket/runat.json) package for an example: it's really just a GitHub gist.
|
||||
|
||||
### Support this project
|
||||
|
||||
If you find Scoop useful and would like to support ongoing development and maintenance, here's how:
|
||||
|
||||
- [PayPal](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=DM2SUH9EUXSKJ) (one-time donation)
|
||||
|
||||
## Known application buckets
|
||||
|
||||
The following buckets are known to scoop:
|
||||
|
||||
- [main](https://github.com/ScoopInstaller/Main) - Default bucket for the most common (mostly CLI) apps
|
||||
- [extras](https://github.com/lukesampson/scoop-extras) - Apps that don't fit the main bucket's [criteria](https://github.com/lukesampson/scoop/wiki/Criteria-for-including-apps-in-the-main-bucket)
|
||||
- [games](https://github.com/Calinou/scoop-games) - Open source/freeware games and game-related tools
|
||||
- [nerd-fonts](https://github.com/matthewjberger/scoop-nerd-fonts) - Nerd Fonts
|
||||
- [nirsoft](https://github.com/kodybrown/scoop-nirsoft) - A subset of the [250](https://github.com/rasa/scoop-directory/blob/master/by-score.md#MCOfficer_scoop-nirsoft) [Nirsoft](https://nirsoft.net) apps
|
||||
- [java](https://github.com/ScoopInstaller/Java) - Installers for Oracle Java, OpenJDK, Zulu, ojdkbuild, AdoptOpenJDK, Amazon Corretto, BellSoft Liberica & SapMachine
|
||||
- [jetbrains](https://github.com/Ash258/Scoop-JetBrains) - Installers for all JetBrains utilities and IDEs
|
||||
<!-- * [nightlies](https://github.com/ScoopInstaller/Nightlies) - No longer used -->
|
||||
- [nonportable](https://github.com/TheRandomLabs/scoop-nonportable) - Non-portable apps (may require UAC)
|
||||
- [php](https://github.com/ScoopInstaller/PHP) - Installers for most versions of PHP
|
||||
- [versions](https://github.com/ScoopInstaller/Versions) - Alternative versions of apps found in other buckets
|
||||
|
||||
The main bucket is installed by default. To add any of the other buckets, type:
|
||||
```
|
||||
scoop bucket add bucketname
|
||||
```
|
||||
For example, to add the extras bucket, type:
|
||||
```
|
||||
scoop bucket add extras
|
||||
```
|
||||
|
||||
## Other application buckets
|
||||
|
||||
Many other application buckets hosted on Github can be found in the [Scoop Directory](https://github.com/rasa/scoop-directory).
|
||||
|
||||
@@ -5,8 +5,7 @@ branches:
|
||||
build: off
|
||||
deploy: off
|
||||
clone_depth: 49
|
||||
image:
|
||||
- Visual Studio 2017
|
||||
image: Visual Studio 2019
|
||||
environment:
|
||||
scoop: C:\projects\scoop
|
||||
scoop_home: C:\projects\scoop
|
||||
|
||||
@@ -185,8 +185,8 @@ hub diff --name-only | ForEach-Object {
|
||||
|
||||
# detect if file was staged, because it's not when only LF or CRLF have changed
|
||||
$status = execute 'hub status --porcelain -uno'
|
||||
$status = $status | Select-Object -First 1
|
||||
if ($status -and $status -match "^\x20*M\x20+.*$app.json") {
|
||||
$status = $status | Where-Object { $_ -match "M\s{2}.*$app.json" }
|
||||
if ($status -and $status.StartsWith('M ') -and $status.EndsWith("$app.json")) {
|
||||
execute "hub commit -m '${app}: Update to version $version'"
|
||||
} else {
|
||||
Write-Host "Skipping $app because only LF/CRLF changes were detected ..." -ForegroundColor Yellow
|
||||
@@ -204,4 +204,4 @@ if ($Push) {
|
||||
execute 'hub checkout -f master'
|
||||
}
|
||||
|
||||
execute 'hub reset'
|
||||
execute 'hub reset --hard'
|
||||
|
||||
@@ -52,7 +52,7 @@ param(
|
||||
$Dir = Resolve-Path $Dir
|
||||
if ($ForceUpdate) { $Update = $true }
|
||||
# Cleanup
|
||||
if (!$UseCache) { scoop cache rm '*HASH_CHECK*' }
|
||||
if (!$UseCache) { Remove-Item "$cachedir\*HASH_CHECK*" -Force }
|
||||
|
||||
function err ([String] $name, [String[]] $message) {
|
||||
Write-Host "$name`: " -ForegroundColor Red -NoNewline
|
||||
@@ -70,15 +70,15 @@ foreach ($single in Get-ChildItem $Dir "$App.json") {
|
||||
$urls = @()
|
||||
$hashes = @()
|
||||
|
||||
if ($manifest.architecture) {
|
||||
if ($manifest.url) {
|
||||
$manifest.url | ForEach-Object { $urls += $_ }
|
||||
$manifest.hash | ForEach-Object { $hashes += $_ }
|
||||
} elseif ($manifest.architecture) {
|
||||
# First handle 64bit
|
||||
url $manifest '64bit' | ForEach-Object { $urls += $_ }
|
||||
hash $manifest '64bit' | ForEach-Object { $hashes += $_ }
|
||||
url $manifest '32bit' | ForEach-Object { $urls += $_ }
|
||||
hash $manifest '32bit' | ForEach-Object { $hashes += $_ }
|
||||
} elseif ($manifest.url) {
|
||||
$manifest.url | ForEach-Object { $urls += $_ }
|
||||
$manifest.hash | ForEach-Object { $hashes += $_ }
|
||||
} else {
|
||||
err $name 'Manifest does not contain URL property.'
|
||||
continue
|
||||
|
||||
@@ -50,6 +50,9 @@ Write-Host ']ailed'
|
||||
Write-Host ' | | |'
|
||||
|
||||
function test_dl([String] $url, $cookies) {
|
||||
# Trim renaming suffix, prevent getting 40x response
|
||||
$url = ($url -split '#/')[0]
|
||||
|
||||
$wreq = [Net.WebRequest]::Create($url)
|
||||
$wreq.Timeout = $Timeout * 1000
|
||||
if ($wreq -is [Net.HttpWebRequest]) {
|
||||
|
||||
@@ -196,8 +196,11 @@ while ($in_progress -gt 0) {
|
||||
$expected_ver = $json.version
|
||||
$ver = ''
|
||||
|
||||
$err = $ev.SourceEventArgs.Error
|
||||
$page = $ev.SourceEventArgs.Result
|
||||
$err = $ev.SourceEventArgs.Error
|
||||
if ($json.checkver.script) {
|
||||
$page = $json.checkver.script -join "`r`n" | Invoke-Expression
|
||||
}
|
||||
|
||||
if ($err) {
|
||||
next "$($err.message)`r`nURL $url is not valid"
|
||||
|
||||
@@ -1,25 +1,26 @@
|
||||
#Requires -Version 5
|
||||
|
||||
# remote install:
|
||||
# iex (new-object net.webclient).downloadstring('https://get.scoop.sh')
|
||||
# Invoke-Expression (New-Object System.Net.WebClient).DownloadString('https://get.scoop.sh')
|
||||
$old_erroractionpreference = $erroractionpreference
|
||||
$erroractionpreference = 'stop' # quit if anything goes wrong
|
||||
|
||||
if(($PSVersionTable.PSVersion.Major) -lt 5) {
|
||||
if (($PSVersionTable.PSVersion.Major) -lt 5) {
|
||||
Write-Output "PowerShell 5 or later is required to run Scoop."
|
||||
Write-Output "Upgrade PowerShell: https://docs.microsoft.com/en-us/powershell/scripting/setup/installing-windows-powershell"
|
||||
break
|
||||
}
|
||||
|
||||
# show notification to change execution policy:
|
||||
if((Get-ExecutionPolicy) -gt 'RemoteSigned' -or (Get-ExecutionPolicy) -eq 'ByPass') {
|
||||
Write-Output "PowerShell requires an execution policy of 'RemoteSigned' to run Scoop."
|
||||
Write-Output "To make this change please run:"
|
||||
$allowedExecutionPolicy = @('Unrestricted', 'RemoteSigned', 'ByPass')
|
||||
if ((Get-ExecutionPolicy).ToString() -notin $allowedExecutionPolicy) {
|
||||
Write-Output "PowerShell requires an execution policy in [$($allowedExecutionPolicy -join ", ")] to run Scoop."
|
||||
Write-Output "For example, to set the execution policy to 'RemoteSigned' please run :"
|
||||
Write-Output "'Set-ExecutionPolicy RemoteSigned -scope CurrentUser'"
|
||||
break
|
||||
}
|
||||
|
||||
if([System.Enum]::GetNames([System.Net.SecurityProtocolType]) -notcontains 'Tls12') {
|
||||
if ([System.Enum]::GetNames([System.Net.SecurityProtocolType]) -notcontains 'Tls12') {
|
||||
Write-Output "Scoop requires at least .NET Framework 4.5"
|
||||
Write-Output "Please download and install it first:"
|
||||
Write-Output "https://www.microsoft.com/net/download"
|
||||
@@ -32,10 +33,10 @@ Write-Output 'Initializing...'
|
||||
Invoke-Expression (new-object net.webclient).downloadstring($core_url)
|
||||
|
||||
# prep
|
||||
if(installed 'scoop') {
|
||||
if (installed 'scoop') {
|
||||
write-host "Scoop is already installed. Run 'scoop update' to get the latest version." -f red
|
||||
# don't abort if invoked with iex that would close the PS session
|
||||
if($myinvocation.mycommand.commandtype -eq 'Script') { return } else { exit 1 }
|
||||
if ($myinvocation.mycommand.commandtype -eq 'Script') { return } else { exit 1 }
|
||||
}
|
||||
$dir = ensure (versiondir 'scoop' 'current')
|
||||
|
||||
@@ -47,7 +48,7 @@ dl $zipurl $zipfile
|
||||
|
||||
Write-Output 'Extracting...'
|
||||
Add-Type -Assembly "System.IO.Compression.FileSystem"
|
||||
[IO.Compression.ZipFile]::ExtractToDirectory($zipfile,"$dir\_tmp")
|
||||
[IO.Compression.ZipFile]::ExtractToDirectory($zipfile, "$dir\_tmp")
|
||||
Copy-Item "$dir\_tmp\*master\*" $dir -Recurse -Force
|
||||
Remove-Item "$dir\_tmp", $zipfile -Recurse -Force
|
||||
|
||||
|
||||
@@ -10,19 +10,11 @@ set-strictmode -off
|
||||
|
||||
reset_aliases
|
||||
|
||||
# TODO: remove this in a few weeks
|
||||
if ((Get-LocalBucket) -notcontains 'main') {
|
||||
warn "The main bucket of Scoop has been separated to 'https://github.com/ScoopInstaller/Main'"
|
||||
warn "You don't have the main bucket added, adding main bucket for you..."
|
||||
add_bucket 'main'
|
||||
exit
|
||||
}
|
||||
|
||||
$commands = commands
|
||||
if ('--version' -contains $cmd -or (!$cmd -and '-v' -contains $args)) {
|
||||
Push-Location $(versiondir 'scoop' 'current')
|
||||
write-host "Current Scoop version:"
|
||||
git_log --oneline HEAD -n 1
|
||||
Invoke-Expression "git --no-pager log --oneline HEAD -n 1"
|
||||
write-host ""
|
||||
Pop-Location
|
||||
|
||||
@@ -30,7 +22,7 @@ if ('--version' -contains $cmd -or (!$cmd -and '-v' -contains $args)) {
|
||||
Push-Location (Find-BucketDirectory $_ -Root)
|
||||
if(test-path '.git') {
|
||||
write-host "'$_' bucket:"
|
||||
git_log --oneline HEAD -n 1
|
||||
Invoke-Expression "git --no-pager log --oneline HEAD -n 1"
|
||||
write-host ""
|
||||
}
|
||||
Pop-Location
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
"nirsoft": "https://github.com/kodybrown/scoop-nirsoft",
|
||||
"php": "https://github.com/ScoopInstaller/PHP",
|
||||
"nerd-fonts": "https://github.com/matthewjberger/scoop-nerd-fonts",
|
||||
"nonportable": "https://github.com/oltolm/scoop-nonportable",
|
||||
"nonportable": "https://github.com/TheRandomLabs/scoop-nonportable",
|
||||
"java": "https://github.com/ScoopInstaller/Java",
|
||||
"games": "https://github.com/Calinou/scoop-games",
|
||||
"jetbrains": "https://github.com/Ash258/Scoop-JetBrains"
|
||||
|
||||
@@ -58,7 +58,7 @@ function find_hash_in_textfile([String] $url, [Hashtable] $substitutions, [Strin
|
||||
$regex = substitute $regex $substitutions $true
|
||||
debug $regex
|
||||
if ($hashfile -match $regex) {
|
||||
$hash = $matches[1] -replace ' ',''
|
||||
$hash = $matches[1] -replace '\s',''
|
||||
}
|
||||
|
||||
# convert base64 encoded hash values
|
||||
@@ -172,12 +172,15 @@ function get_hash_for_app([String] $app, $config, [String] $version, [String] $u
|
||||
$hash = $null
|
||||
|
||||
$hashmode = $config.mode
|
||||
$basename = url_remote_filename($url)
|
||||
$basename = [System.Web.HttpUtility]::UrlDecode((url_remote_filename($url)))
|
||||
|
||||
$substitutions = $substitutions.Clone()
|
||||
$substitutions.Add('$url', (strip_fragment $url))
|
||||
$substitutions.Add('$baseurl', (strip_filename (strip_fragment $url)).TrimEnd('/'))
|
||||
$substitutions.Add('$basename', $basename)
|
||||
$substitutions.Add('$urlNoExt', (strip_ext (strip_fragment $url)))
|
||||
$substitutions.Add('$basenameNoExt', (strip_ext $basename))
|
||||
|
||||
debug $substitutions
|
||||
|
||||
$hashfile_url = substitute $config.url $substitutions
|
||||
|
||||
@@ -59,7 +59,7 @@ function Get-LocalBucket {
|
||||
List all local buckets.
|
||||
#>
|
||||
|
||||
return (Get-ChildItem $bucketsdir).Name
|
||||
return (Get-ChildItem -Directory $bucketsdir).Name
|
||||
}
|
||||
|
||||
function buckets {
|
||||
@@ -128,7 +128,7 @@ function new_issue_msg($app, $bucket, $title, $body) {
|
||||
|
||||
if (Test-path $bucket_path) {
|
||||
Push-Location $bucket_path
|
||||
$remote = git_config --get remote.origin.url
|
||||
$remote = Invoke-Expression "git config --get remote.origin.url"
|
||||
# Support ssh and http syntax
|
||||
# git@PROVIDER:USER/REPO.git
|
||||
# https://PROVIDER/USER/REPO.git
|
||||
|
||||
108
lib/core.ps1
108
lib/core.ps1
@@ -100,7 +100,7 @@ function setup_proxy() {
|
||||
[net.webrequest]::defaultwebproxy.credentials = [net.credentialcache]::defaultcredentials
|
||||
} elseif($credentials) {
|
||||
$username, $password = $credentials -split '(?<!\\):' | ForEach-Object { $_ -replace '\\([@:])','$1' }
|
||||
[net.webrequest]::defaultwebproxy.credentials = new-object net.networkcredential($user, $pass)
|
||||
[net.webrequest]::defaultwebproxy.credentials = new-object net.networkcredential($username, $password)
|
||||
}
|
||||
} catch {
|
||||
warn "Failed to use proxy '$proxy': $($_.exception.message)"
|
||||
@@ -233,7 +233,7 @@ function Get-AppFilePath {
|
||||
}
|
||||
|
||||
Function Test-CommandAvailable {
|
||||
Param (
|
||||
param (
|
||||
[String]$Name
|
||||
)
|
||||
Return [Boolean](Get-Command $Name -ErrorAction Ignore)
|
||||
@@ -366,6 +366,93 @@ function is_local($path) {
|
||||
}
|
||||
|
||||
# operations
|
||||
|
||||
function run($exe, $arg, $msg, $continue_exit_codes) {
|
||||
Show-DeprecatedWarning $MyInvocation 'Invoke-ExternalCommand'
|
||||
Invoke-ExternalCommand -FilePath $exe -ArgumentList $arg -Activity $msg -ContinueExitCodes $continue_exit_codes
|
||||
}
|
||||
|
||||
function Invoke-ExternalCommand {
|
||||
[CmdletBinding(DefaultParameterSetName = "Default")]
|
||||
[OutputType([Boolean])]
|
||||
param (
|
||||
[Parameter(Mandatory = $true,
|
||||
Position = 0)]
|
||||
[Alias("Path")]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[String]
|
||||
$FilePath,
|
||||
[Parameter(Position = 1)]
|
||||
[Alias("Args")]
|
||||
[String[]]
|
||||
$ArgumentList,
|
||||
[Parameter(ParameterSetName = "UseShellExecute")]
|
||||
[Switch]
|
||||
$RunAs,
|
||||
[Alias("Msg")]
|
||||
[String]
|
||||
$Activity,
|
||||
[Alias("cec")]
|
||||
[Hashtable]
|
||||
$ContinueExitCodes,
|
||||
[Parameter(ParameterSetName = "Default")]
|
||||
[Alias("Log")]
|
||||
[String]
|
||||
$LogPath
|
||||
)
|
||||
if ($Activity) {
|
||||
Write-Host "$Activity " -NoNewline
|
||||
}
|
||||
$Process = New-Object System.Diagnostics.Process
|
||||
$Process.StartInfo.FileName = $FilePath
|
||||
$Process.StartInfo.Arguments = ($ArgumentList | Select-Object -Unique) -join ' '
|
||||
$Process.StartInfo.UseShellExecute = $false
|
||||
if ($LogPath) {
|
||||
if ($FilePath -match '(^|\W)msiexec($|\W)') {
|
||||
$Process.StartInfo.Arguments += " /lwe `"$LogPath`""
|
||||
} else {
|
||||
$Process.StartInfo.RedirectStandardOutput = $true
|
||||
$Process.StartInfo.RedirectStandardError = $true
|
||||
}
|
||||
}
|
||||
if ($RunAs) {
|
||||
$Process.StartInfo.UseShellExecute = $true
|
||||
$Process.StartInfo.Verb = 'RunAs'
|
||||
}
|
||||
try {
|
||||
$Process.Start() | Out-Null
|
||||
} catch {
|
||||
if ($Activity) {
|
||||
Write-Host "error." -ForegroundColor DarkRed
|
||||
}
|
||||
error $_.Exception.Message
|
||||
return $false
|
||||
}
|
||||
if ($LogPath -and ($FilePath -notmatch '(^|\W)msiexec($|\W)')) {
|
||||
Out-File -FilePath $LogPath -Encoding ASCII -Append -InputObject $Process.StandardOutput.ReadToEnd()
|
||||
}
|
||||
$Process.WaitForExit()
|
||||
if ($Process.ExitCode -ne 0) {
|
||||
if ($ContinueExitCodes -and ($ContinueExitCodes.ContainsKey($Process.ExitCode))) {
|
||||
if ($Activity) {
|
||||
Write-Host "done." -ForegroundColor DarkYellow
|
||||
}
|
||||
warn $ContinueExitCodes[$Process.ExitCode]
|
||||
return $true
|
||||
} else {
|
||||
if ($Activity) {
|
||||
Write-Host "error." -ForegroundColor DarkRed
|
||||
}
|
||||
error "Exit code was $($Process.ExitCode)!"
|
||||
return $false
|
||||
}
|
||||
}
|
||||
if ($Activity) {
|
||||
Write-Host "done." -ForegroundColor Green
|
||||
}
|
||||
return $true
|
||||
}
|
||||
|
||||
function dl($url,$to) {
|
||||
$wc = New-Object Net.Webclient
|
||||
$wc.headers.add('Referer', (strip_filename $url))
|
||||
@@ -594,13 +681,25 @@ function strip_path($orig_path, $dir) {
|
||||
return ($stripped -ne $orig_path), $stripped
|
||||
}
|
||||
|
||||
function remove_from_path($dir,$global) {
|
||||
function add_first_in_path($dir, $global) {
|
||||
$dir = fullpath $dir
|
||||
|
||||
# future sessions
|
||||
$null, $currpath = strip_path (env 'path' $global) $dir
|
||||
env 'path' $global "$dir;$currpath"
|
||||
|
||||
# this session
|
||||
$null, $env:PATH = strip_path $env:PATH $dir
|
||||
$env:PATH = "$dir;$env:PATH"
|
||||
}
|
||||
|
||||
function remove_from_path($dir, $global) {
|
||||
$dir = fullpath $dir
|
||||
|
||||
# future sessions
|
||||
$was_in_path, $newpath = strip_path (env 'path' $global) $dir
|
||||
if($was_in_path) {
|
||||
write-output "Removing $(friendly_path $dir) from your path."
|
||||
Write-Output "Removing $(friendly_path $dir) from your path."
|
||||
env 'path' $global $newpath
|
||||
}
|
||||
|
||||
@@ -801,6 +900,7 @@ function handle_special_urls($url)
|
||||
$Body = @{
|
||||
projectUri = $Matches.name;
|
||||
fileName = $Matches.filename;
|
||||
source = 'CF';
|
||||
isLatestVersion = $true
|
||||
}
|
||||
if ((Invoke-RestMethod -Uri $url) -match '"p":"(?<pid>[a-f0-9]{24}).*?"r":"(?<rid>[a-f0-9]{24})') {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
function Test-7zipRequirement {
|
||||
[CmdletBinding(DefaultParameterSetName = "URL")]
|
||||
[OutputType([Boolean])]
|
||||
param(
|
||||
param (
|
||||
[Parameter(Mandatory = $true, ParameterSetName = "URL")]
|
||||
[String[]]
|
||||
$URL,
|
||||
@@ -23,7 +23,7 @@ function Test-7zipRequirement {
|
||||
function Test-LessmsiRequirement {
|
||||
[CmdletBinding()]
|
||||
[OutputType([Boolean])]
|
||||
param(
|
||||
param (
|
||||
[Parameter(Mandatory = $true)]
|
||||
[String[]]
|
||||
$URL
|
||||
@@ -37,49 +37,63 @@ function Test-LessmsiRequirement {
|
||||
|
||||
function Expand-7zipArchive {
|
||||
[CmdletBinding()]
|
||||
param(
|
||||
param (
|
||||
[Parameter(Mandatory = $true, Position = 0, ValueFromPipeline = $true)]
|
||||
[String]
|
||||
$Path,
|
||||
[Parameter(Position = 1)]
|
||||
[String]
|
||||
$DestinationPath = (Split-Path $Path),
|
||||
[ValidateSet("All", "Skip", "Rename")]
|
||||
[String]
|
||||
$Overwrite,
|
||||
$ExtractDir,
|
||||
[Parameter(ValueFromRemainingArguments = $true)]
|
||||
[String]
|
||||
$Switches,
|
||||
[ValidateSet("All", "Skip", "Rename")]
|
||||
[String]
|
||||
$Overwrite,
|
||||
[Switch]
|
||||
$Removal
|
||||
)
|
||||
$LogLocation = "$(Split-Path $Path)\7zip.log"
|
||||
switch ($Overwrite) {
|
||||
"All" { $Switches += " -aoa" }
|
||||
"Skip" { $Switches += " -aos" }
|
||||
"Rename" { $Switches += " -aou" }
|
||||
}
|
||||
if ((get_config 7ZIPEXTRACT_USE_EXTERNAL)) {
|
||||
try {
|
||||
7z x "$Path" -o"$DestinationPath" (-split $Switches) -y | Out-File $LogLocation
|
||||
$7zPath = (Get-Command '7z' -CommandType Application | Select-Object -First 1).Source
|
||||
} catch [System.Management.Automation.CommandNotFoundException] {
|
||||
abort "Cannot find external 7-Zip (7z.exe) while '7ZIPEXTRACT_USE_EXTERNAL' is 'true'!`nRun 'scoop config 7ZIPEXTRACT_USE_EXTERNAL false' or install 7-Zip manually and try again."
|
||||
}
|
||||
} else {
|
||||
& (Get-HelperPath -Helper 7zip) x "$Path" -o"$DestinationPath" (-split $Switches) -y | Out-File $LogLocation
|
||||
$7zPath = Get-HelperPath -Helper 7zip
|
||||
}
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
abort "Failed to extract files from $Path.`nLog file:`n $(friendly_path $LogLocation)"
|
||||
$LogPath = "$(Split-Path $Path)\7zip.log"
|
||||
$ArgList = @('x', "`"$Path`"", "-o`"$DestinationPath`"", '-y')
|
||||
$IsTar = ((strip_ext $Path) -match '\.tar$') -or ($Path -match '\.t[abgpx]z2?$')
|
||||
if (!$IsTar -and $ExtractDir) {
|
||||
$ArgList += "-ir!`"$ExtractDir\*`""
|
||||
}
|
||||
if (Test-Path $LogLocation) {
|
||||
Remove-Item $LogLocation -Force
|
||||
if ($Switches) {
|
||||
$ArgList += (-split $Switches)
|
||||
}
|
||||
if ((strip_ext $Path) -match '\.tar$' -or $Path -match '\.tgz$') {
|
||||
switch ($Overwrite) {
|
||||
"All" { $ArgList += "-aoa" }
|
||||
"Skip" { $ArgList += "-aos" }
|
||||
"Rename" { $ArgList += "-aou" }
|
||||
}
|
||||
$Status = Invoke-ExternalCommand $7zPath $ArgList -LogPath $LogPath
|
||||
if (!$Status) {
|
||||
abort "Failed to extract files from $Path.`nLog file:`n $(friendly_path $LogPath)`n$(new_issue_msg $app $bucket 'decompress error')"
|
||||
}
|
||||
if (!$IsTar -and $ExtractDir) {
|
||||
movedir "$DestinationPath\$ExtractDir" $DestinationPath | Out-Null
|
||||
}
|
||||
if (Test-Path $LogPath) {
|
||||
Remove-Item $LogPath -Force
|
||||
}
|
||||
if ($IsTar) {
|
||||
# Check for tar
|
||||
$ArchivedFile = & (Get-HelperPath -Helper 7zip) l "$Path"
|
||||
if ($LASTEXITCODE -eq 0) {
|
||||
$TarFile = $ArchivedFile[-3] -replace '.{53}(.*)', '$1' # get inner tar file name
|
||||
Expand-7zipArchive "$DestinationPath\$TarFile" $DestinationPath -Removal
|
||||
$Status = Invoke-ExternalCommand $7zPath @('l', "`"$Path`"") -LogPath $LogPath
|
||||
if ($Status) {
|
||||
$TarFile = (Get-Content -Path $LogPath)[-4] -replace '.{53}(.*)', '$1' # get inner tar file name
|
||||
Expand-7zipArchive -Path "$DestinationPath\$TarFile" -DestinationPath $DestinationPath -ExtractDir $ExtractDir -Removal
|
||||
} else {
|
||||
abort "Failed to list files in $Path.`nNot a 7-Zip supported archive file."
|
||||
}
|
||||
@@ -92,34 +106,55 @@ function Expand-7zipArchive {
|
||||
|
||||
function Expand-MsiArchive {
|
||||
[CmdletBinding()]
|
||||
param(
|
||||
param (
|
||||
[Parameter(Mandatory = $true, Position = 0, ValueFromPipeline = $true)]
|
||||
[String]
|
||||
$Path,
|
||||
[Parameter(Position = 1)]
|
||||
[String]
|
||||
$DestinationPath = (Split-Path $Path),
|
||||
[String]
|
||||
$ExtractDir,
|
||||
[Parameter(ValueFromRemainingArguments = $true)]
|
||||
[String]
|
||||
$Switches,
|
||||
[Switch]
|
||||
$Removal
|
||||
)
|
||||
$LogLocation = "$(Split-Path $Path)\msi.log"
|
||||
$DestinationPath = $DestinationPath.TrimEnd("\")
|
||||
if ($ExtractDir) {
|
||||
$OriDestinationPath = $DestinationPath
|
||||
$DestinationPath = "$DestinationPath\_tmp"
|
||||
}
|
||||
if ((get_config MSIEXTRACT_USE_LESSMSI)) {
|
||||
& (Get-HelperPath -Helper Lessmsi) x "$Path" "$DestinationPath\" | Out-File $LogLocation
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
abort "Failed to extract files from $Path.`nLog file:`n $(friendly_path $LogLocation)"
|
||||
}
|
||||
if (Test-Path "$DestinationPath\SourceDir") {
|
||||
movedir "$DestinationPath\SourceDir" "$DestinationPath" | Out-Null
|
||||
}
|
||||
$MsiPath = Get-HelperPath -Helper Lessmsi
|
||||
$ArgList = @('x', "`"$Path`"", "`"$DestinationPath\\`"")
|
||||
} else {
|
||||
$ok = run 'msiexec' @('/a', "`"$Path`"", '/qn', "TARGETDIR=`"$DestinationPath`"", "/lwe `"$LogLocation`"")
|
||||
if (!$ok) {
|
||||
abort "Failed to extract files from $Path.`nLog file:`n $(friendly_path $LogLocation)"
|
||||
}
|
||||
$MsiPath = 'msiexec.exe'
|
||||
$ArgList = @('/a', "`"$Path`"", '/qn', "TARGETDIR=`"$DestinationPath\\SourceDir`"")
|
||||
}
|
||||
$LogPath = "$(Split-Path $Path)\msi.log"
|
||||
if ($Switches) {
|
||||
$ArgList += (-split $Switches)
|
||||
}
|
||||
$Status = Invoke-ExternalCommand $MsiPath $ArgList -LogPath $LogPath
|
||||
if (!$Status) {
|
||||
abort "Failed to extract files from $Path.`nLog file:`n $(friendly_path $LogPath)`n$(new_issue_msg $app $bucket 'decompress error')"
|
||||
}
|
||||
if ($ExtractDir -and (Test-Path "$DestinationPath\SourceDir")) {
|
||||
movedir "$DestinationPath\SourceDir\$ExtractDir" $OriDestinationPath | Out-Null
|
||||
Remove-Item $DestinationPath -Recurse -Force
|
||||
} elseif ($ExtractDir) {
|
||||
movedir "$DestinationPath\$ExtractDir" $OriDestinationPath | Out-Null
|
||||
Remove-Item $DestinationPath -Recurse -Force
|
||||
} elseif (Test-Path "$DestinationPath\SourceDir") {
|
||||
movedir "$DestinationPath\SourceDir" $DestinationPath | Out-Null
|
||||
}
|
||||
if (($DestinationPath -ne (Split-Path $Path)) -and (Test-Path "$DestinationPath\$(fname $Path)")) {
|
||||
Remove-Item "$DestinationPath\$(fname $Path)" -Force
|
||||
}
|
||||
if (Test-Path $LogLocation) {
|
||||
Remove-Item $LogLocation -Force
|
||||
if (Test-Path $LogPath) {
|
||||
Remove-Item $LogPath -Force
|
||||
}
|
||||
if ($Removal) {
|
||||
# Remove original archive file
|
||||
@@ -129,26 +164,37 @@ function Expand-MsiArchive {
|
||||
|
||||
function Expand-InnoArchive {
|
||||
[CmdletBinding()]
|
||||
param(
|
||||
param (
|
||||
[Parameter(Mandatory = $true, Position = 0, ValueFromPipeline = $true)]
|
||||
[String]
|
||||
$Path,
|
||||
[Parameter(Position = 1)]
|
||||
[String]
|
||||
$DestinationPath = (Split-Path $Path),
|
||||
[String]
|
||||
$ExtractDir,
|
||||
[Parameter(ValueFromRemainingArguments = $true)]
|
||||
[String]
|
||||
$Switches,
|
||||
[Switch]
|
||||
$Removal
|
||||
)
|
||||
$LogLocation = "$(Split-Path $Path)\innounp.log"
|
||||
& (Get-HelperPath -Helper Innounp) -x -d"$DestinationPath" -c'{app}' "$Path" (-split $Switches) -y | Out-File $LogLocation
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
abort "Failed to extract files from $Path.`nLog file:`n $(friendly_path $LogLocation)"
|
||||
$LogPath = "$(Split-Path $Path)\innounp.log"
|
||||
$ArgList = @('-x', "-d`"$DestinationPath`"", "`"$Path`"", '-y')
|
||||
switch -Regex ($ExtractDir) {
|
||||
"^[^{].*" { $ArgList += "-c{app}\$ExtractDir" }
|
||||
"^{.*" { $ArgList += "-c$ExtractDir" }
|
||||
Default { $ArgList += "-c{app}" }
|
||||
}
|
||||
if (Test-Path $LogLocation) {
|
||||
Remove-Item $LogLocation -Force
|
||||
if ($Switches) {
|
||||
$ArgList += (-split $Switches)
|
||||
}
|
||||
$Status = Invoke-ExternalCommand (Get-HelperPath -Helper Innounp) $ArgList -LogPath $LogPath
|
||||
if (!$Status) {
|
||||
abort "Failed to extract files from $Path.`nLog file:`n $(friendly_path $LogPath)`n$(new_issue_msg $app $bucket 'decompress error')"
|
||||
}
|
||||
if (Test-Path $LogPath) {
|
||||
Remove-Item $LogPath -Force
|
||||
}
|
||||
if ($Removal) {
|
||||
# Remove original archive file
|
||||
@@ -158,16 +204,22 @@ function Expand-InnoArchive {
|
||||
|
||||
function Expand-ZipArchive {
|
||||
[CmdletBinding()]
|
||||
param(
|
||||
param (
|
||||
[Parameter(Mandatory = $true, Position = 0, ValueFromPipeline = $true)]
|
||||
[String]
|
||||
$Path,
|
||||
[Parameter(Position = 1)]
|
||||
[String]
|
||||
$DestinationPath = (Split-Path $Path),
|
||||
[String]
|
||||
$ExtractDir,
|
||||
[Switch]
|
||||
$Removal
|
||||
)
|
||||
if ($ExtractDir) {
|
||||
$OriDestinationPath = $DestinationPath
|
||||
$DestinationPath = "$DestinationPath\_tmp"
|
||||
}
|
||||
# All methods to unzip the file require .NET4.5+
|
||||
if ($PSVersionTable.PSVersion.Major -lt 5) {
|
||||
Add-Type -AssemblyName System.IO.Compression.FileSystem
|
||||
@@ -196,6 +248,10 @@ function Expand-ZipArchive {
|
||||
# Compatible with Pscx (https://github.com/Pscx/Pscx)
|
||||
Microsoft.PowerShell.Archive\Expand-Archive -Path $Path -DestinationPath $DestinationPath -Force
|
||||
}
|
||||
if ($ExtractDir) {
|
||||
movedir "$DestinationPath\$ExtractDir" $OriDestinationPath | Out-Null
|
||||
Remove-Item $DestinationPath -Recurse -Force
|
||||
}
|
||||
if ($Removal) {
|
||||
# Remove original archive file
|
||||
Remove-Item $Path -Force
|
||||
@@ -204,23 +260,30 @@ function Expand-ZipArchive {
|
||||
|
||||
function Expand-DarkArchive {
|
||||
[CmdletBinding()]
|
||||
param(
|
||||
param (
|
||||
[Parameter(Mandatory = $true, Position = 0, ValueFromPipeline = $true)]
|
||||
[String]
|
||||
$Path,
|
||||
[Parameter(Position = 1)]
|
||||
[String]
|
||||
$DestinationPath = (Split-Path $Path),
|
||||
[Parameter(ValueFromRemainingArguments = $true)]
|
||||
[String]
|
||||
$Switches,
|
||||
[Switch]
|
||||
$Removal
|
||||
)
|
||||
$LogLocation = "$(Split-Path $Path)\dark.log"
|
||||
& (Get-HelperPath -Helper Dark) -nologo -x "$Path" "$DestinationPath" | Out-File $LogLocation
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
abort "Failed to extract files from $Path.`nLog file:`n $(friendly_path $LogLocation)"
|
||||
$LogPath = "$(Split-Path $Path)\dark.log"
|
||||
$ArgList = @('-nologo', "-x `"$DestinationPath`"", "`"$Path`"")
|
||||
if ($Switches) {
|
||||
$ArgList += (-split $Switches)
|
||||
}
|
||||
if (Test-Path $LogLocation) {
|
||||
Remove-Item $LogLocation -Force
|
||||
$Status = Invoke-ExternalCommand (Get-HelperPath -Helper Dark) $ArgList -LogPath $LogPath
|
||||
if (!$Status) {
|
||||
abort "Failed to extract files from $Path.`nLog file:`n $(friendly_path $LogPath)`n$(new_issue_msg $app $bucket 'decompress error')"
|
||||
}
|
||||
if (Test-Path $LogPath) {
|
||||
Remove-Item $LogPath -Force
|
||||
}
|
||||
if ($Removal) {
|
||||
# Remove original archive file
|
||||
|
||||
@@ -50,3 +50,14 @@ function check_long_paths {
|
||||
|
||||
return $true
|
||||
}
|
||||
|
||||
function check_envs_requirements {
|
||||
if ($null -eq $env:COMSPEC) {
|
||||
warn '$env:COMSPEC environment variable is missing.'
|
||||
Write-Host " By default the variable should points to the cmd.exe in Windows: '%SystemRoot%\system32\cmd.exe'."
|
||||
|
||||
return $false
|
||||
}
|
||||
|
||||
return $true
|
||||
}
|
||||
|
||||
24
lib/git.ps1
24
lib/git.ps1
@@ -4,7 +4,7 @@ function git_proxy_cmd {
|
||||
if($proxy -and $proxy -ne 'none') {
|
||||
$cmd = "SET HTTPS_PROXY=$proxy&&SET HTTP_PROXY=$proxy&&$cmd"
|
||||
}
|
||||
& "$env:COMSPEC" /c $cmd
|
||||
& "$env:COMSPEC" /d /c $cmd
|
||||
}
|
||||
|
||||
function git_clone {
|
||||
@@ -19,34 +19,14 @@ function git_checkout {
|
||||
git_proxy_cmd checkout $args
|
||||
}
|
||||
|
||||
function git_branch {
|
||||
git_proxy_cmd branch $args
|
||||
}
|
||||
|
||||
function git_pull {
|
||||
git_proxy_cmd pull $args
|
||||
git_proxy_cmd pull --rebase=false $args
|
||||
}
|
||||
|
||||
function git_fetch {
|
||||
git_proxy_cmd fetch $args
|
||||
}
|
||||
|
||||
function git_log {
|
||||
git_proxy_cmd --no-pager log $args
|
||||
}
|
||||
|
||||
function git_checkout {
|
||||
git_proxy_cmd checkout $args
|
||||
}
|
||||
|
||||
function git_branch {
|
||||
git_proxy_cmd branch $args
|
||||
}
|
||||
|
||||
function git_config {
|
||||
git_proxy_cmd config $args
|
||||
}
|
||||
|
||||
function git_reset {
|
||||
git_proxy_cmd reset $args
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ function summary($text) {
|
||||
$text | Select-String '(?m)^# Summary: ([^\n]*)$' | ForEach-Object { $_.matches[0].groups[1].value }
|
||||
}
|
||||
|
||||
function help($text) {
|
||||
function scoop_help($text) {
|
||||
$help_lines = $text | Select-String '(?ms)^# Help:(.(?!^[^#]))*' | ForEach-Object { $_.matches[0].value; }
|
||||
$help_lines -replace '(?ms)^#\s?(Help: )?', ''
|
||||
}
|
||||
|
||||
221
lib/install.ps1
221
lib/install.ps1
@@ -49,8 +49,8 @@ function install_app($app, $architecture, $global, $suggested, $use_cache = $tru
|
||||
create_startmenu_shortcuts $manifest $dir $global $architecture
|
||||
install_psmodule $manifest $dir $global
|
||||
if($global) { ensure_scoop_in_path $global } # can assume local scoop is in path
|
||||
env_add_path $manifest $dir $global
|
||||
env_set $manifest $dir $global
|
||||
env_add_path $manifest $dir $global $architecture
|
||||
env_set $manifest $dir $global $architecture
|
||||
|
||||
# persist data
|
||||
persist_data $manifest $original_dir $persist_dir
|
||||
@@ -203,7 +203,7 @@ function dl_with_cache_aria2($app, $version, $manifest, $architecture, $dir, $co
|
||||
$urls = @(url $manifest $architecture)
|
||||
|
||||
# aria2 input file
|
||||
$urlstxt = "$cachedir\$app.txt"
|
||||
$urlstxt = Join-Path $cachedir "$app.txt"
|
||||
$urlstxt_content = ''
|
||||
$has_downloads = $false
|
||||
|
||||
@@ -225,6 +225,7 @@ function dl_with_cache_aria2($app, $version, $manifest, $architecture, $dir, $co
|
||||
"--min-tls-version=TLSv1.2"
|
||||
"--stop-with-process=$PID"
|
||||
"--continue"
|
||||
"--summary-interval 0"
|
||||
)
|
||||
|
||||
if($cookies) {
|
||||
@@ -282,21 +283,29 @@ function dl_with_cache_aria2($app, $version, $manifest, $architecture, $dir, $co
|
||||
|
||||
# handle aria2 console output
|
||||
Write-Host "Starting download with aria2 ..."
|
||||
$prefix = "Download: "
|
||||
|
||||
Invoke-Expression $aria2 | ForEach-Object {
|
||||
if([String]::IsNullOrWhiteSpace($_)) {
|
||||
# skip blank lines
|
||||
return
|
||||
}
|
||||
Write-Host $prefix -NoNewline
|
||||
if($_.StartsWith('(OK):')) {
|
||||
Write-Host $_ -f Green
|
||||
} elseif($_.StartsWith('[') -and $_.EndsWith(']')) {
|
||||
Write-Host $_ -f Cyan
|
||||
} else {
|
||||
Write-Host $_ -f Gray
|
||||
# Skip blank lines
|
||||
if ([String]::IsNullOrWhiteSpace($_)) { return }
|
||||
|
||||
# Prevent potential overlaping of text when one line is shorter
|
||||
$len = $Host.UI.RawUI.WindowSize.Width - $_.Length - 20
|
||||
$blank = if ($len -gt 0) { ' ' * $len } else { '' }
|
||||
$color = 'Gray'
|
||||
|
||||
if ($_.StartsWith('(OK):')) {
|
||||
$noNewLine = $true
|
||||
$color = 'Green'
|
||||
} elseif ($_.StartsWith('[') -and $_.EndsWith(']')) {
|
||||
$noNewLine = $true
|
||||
$color = 'Cyan'
|
||||
} elseif ($_.StartsWith('Download Results:')) {
|
||||
$noNewLine = $false
|
||||
}
|
||||
|
||||
Write-Host "`rDownload: $_$blank" -ForegroundColor $color -NoNewline:$noNewLine
|
||||
}
|
||||
Write-Host ''
|
||||
|
||||
if($lastexitcode -gt 0) {
|
||||
error "Download failed! (Error $lastexitcode) $(aria_exit_code $lastexitcode)"
|
||||
@@ -357,7 +366,7 @@ function dl($url, $to, $cookies, $progress) {
|
||||
$wreq = [net.webrequest]::create($reqUrl)
|
||||
if($wreq -is [net.httpwebrequest]) {
|
||||
$wreq.useragent = Get-UserAgent
|
||||
if (-not ($url -imatch "sourceforge\.net")) {
|
||||
if (-not ($url -imatch "sourceforge\.net" -or $url -imatch "portableapps\.com")) {
|
||||
$wreq.referer = strip_filename $url
|
||||
}
|
||||
if($cookies) {
|
||||
@@ -365,7 +374,41 @@ function dl($url, $to, $cookies, $progress) {
|
||||
}
|
||||
}
|
||||
|
||||
$wres = $wreq.getresponse()
|
||||
try {
|
||||
$wres = $wreq.GetResponse()
|
||||
} catch [System.Net.WebException] {
|
||||
$exc = $_.Exception
|
||||
$handledCodes = @(
|
||||
[System.Net.HttpStatusCode]::MovedPermanently, # HTTP 301
|
||||
[System.Net.HttpStatusCode]::Found, # HTTP 302
|
||||
[System.Net.HttpStatusCode]::SeeOther, # HTTP 303
|
||||
[System.Net.HttpStatusCode]::TemporaryRedirect # HTTP 307
|
||||
)
|
||||
|
||||
# Only handle redirection codes
|
||||
$redirectRes = $exc.Response
|
||||
if ($handledCodes -notcontains $redirectRes.StatusCode) {
|
||||
throw $exc
|
||||
}
|
||||
|
||||
# Get the new location of the file
|
||||
if ((-not $redirectRes.Headers) -or ($redirectRes.Headers -notcontains 'Location')) {
|
||||
throw $exc
|
||||
}
|
||||
|
||||
$newUrl = $redirectRes.Headers['Location']
|
||||
info "Following redirect to $newUrl..."
|
||||
|
||||
# Handle manual file rename
|
||||
if ($url -like '*#/*') {
|
||||
$null, $postfix = $url -split '#/'
|
||||
$newUrl = "$newUrl#/$postfix"
|
||||
}
|
||||
|
||||
dl $newUrl $to $cookies $progress
|
||||
return
|
||||
}
|
||||
|
||||
$total = $wres.ContentLength
|
||||
if($total -eq -1 -and $wreq -is [net.ftpwebrequest]) {
|
||||
$total = ftp_file_size($url)
|
||||
@@ -469,6 +512,7 @@ function dl_progress($read, $total, $url) {
|
||||
write-host
|
||||
$left = 0
|
||||
$top = $top + 1
|
||||
if($top -gt $console.CursorPosition.Y) { $top = $console.CursorPosition.Y }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -539,7 +583,12 @@ function dl_urls($app, $version, $manifest, $bucket, $architecture, $dir, $use_c
|
||||
if ($manifest.innosetup) {
|
||||
$extract_fn = 'Expand-InnoArchive'
|
||||
} elseif($fname -match '\.zip$') {
|
||||
$extract_fn = 'Expand-ZipArchive'
|
||||
# Use 7zip when available (more fast)
|
||||
if (((get_config 7ZIPEXTRACT_USE_EXTERNAL) -and (Test-CommandAvailable 7z)) -or (Test-HelperInstalled -Helper 7zip)) {
|
||||
$extract_fn = 'Expand-7zipArchive'
|
||||
} else {
|
||||
$extract_fn = 'Expand-ZipArchive'
|
||||
}
|
||||
} elseif($fname -match '\.msi$') {
|
||||
# check manifest doesn't use deprecated install method
|
||||
if(msi $manifest $architecture) {
|
||||
@@ -555,33 +604,8 @@ function dl_urls($app, $version, $manifest, $bucket, $architecture, $dir, $use_c
|
||||
Write-Host "Extracting " -NoNewline
|
||||
Write-Host $fname -f Cyan -NoNewline
|
||||
Write-Host " ... " -NoNewline
|
||||
ensure "$dir\_tmp" | Out-Null
|
||||
& $extract_fn "$dir\$fname" "$dir\_tmp" -Removal
|
||||
if ($extract_to) {
|
||||
ensure "$dir\$extract_to" | Out-Null
|
||||
}
|
||||
# fails if zip contains long paths (e.g. atom.json)
|
||||
#cp "$dir\_tmp\$extract_dir\*" "$dir\$extract_to" -r -force -ea stop
|
||||
try {
|
||||
movedir "$dir\_tmp\$extract_dir" "$dir\$extract_to"
|
||||
}
|
||||
catch {
|
||||
error $_
|
||||
abort $(new_issue_msg $app $bucket "extract_dir error")
|
||||
}
|
||||
|
||||
if(Test-Path "$dir\_tmp") { # might have been moved by movedir
|
||||
try {
|
||||
Remove-Item -r -force "$dir\_tmp" -ea stop
|
||||
} catch [system.io.pathtoolongexception] {
|
||||
& "$env:COMSPEC" /c "rmdir /s /q $dir\_tmp"
|
||||
} catch [system.unauthorizedaccessexception] {
|
||||
warn "Couldn't remove $dir\_tmp: unauthorized access."
|
||||
}
|
||||
}
|
||||
|
||||
& $extract_fn -Path "$dir\$fname" -DestinationPath "$dir\$extract_to" -ExtractDir $extract_dir -Removal
|
||||
Write-Host "done." -f Green
|
||||
|
||||
$extracted++
|
||||
}
|
||||
}
|
||||
@@ -686,37 +710,6 @@ function args($config, $dir, $global) {
|
||||
@()
|
||||
}
|
||||
|
||||
function run($exe, $arg, $msg, $continue_exit_codes) {
|
||||
if($msg) { write-host "$msg " -nonewline }
|
||||
try {
|
||||
#Allow null/no arguments to be passed
|
||||
$parameters = @{ }
|
||||
if ($arg)
|
||||
{
|
||||
$parameters.arg = $arg;
|
||||
}
|
||||
|
||||
# Don't use Start-Process -Wait
|
||||
# https://github.com/PowerShell/PowerShell/issues/6561
|
||||
$proc = start-process $exe -ea stop -passthru @parameters
|
||||
$proc | Wait-Process
|
||||
|
||||
|
||||
if($proc.exitcode -ne 0) {
|
||||
if($continue_exit_codes -and ($continue_exit_codes.containskey($proc.exitcode))) {
|
||||
warn $continue_exit_codes[$proc.exitcode]
|
||||
return $true
|
||||
}
|
||||
write-host "Exit code was $($proc.exitcode)."; return $false
|
||||
}
|
||||
} catch {
|
||||
write-host -f darkred $_.exception.tostring()
|
||||
return $false
|
||||
}
|
||||
if($msg) { Write-Host "done." -f Green }
|
||||
return $true
|
||||
}
|
||||
|
||||
function run_installer($fname, $manifest, $architecture, $dir, $global) {
|
||||
# MSI or other installer
|
||||
$msi = msi $manifest $architecture
|
||||
@@ -753,7 +746,7 @@ function install_msi($fname, $dir, $msi) {
|
||||
|
||||
$continue_exit_codes = @{ 3010 = "a restart is required to complete installation" }
|
||||
|
||||
$installed = run 'msiexec' $arg "Running installer..." $continue_exit_codes
|
||||
$installed = Invoke-ExternalCommand 'msiexec' $arg -Activity "Running installer..." -ContinueExitCodes $continue_exit_codes
|
||||
if(!$installed) {
|
||||
abort "Installation aborted. You might need to run 'scoop uninstall $app' before trying again."
|
||||
}
|
||||
@@ -785,7 +778,7 @@ function install_prog($fname, $dir, $installer, $global) {
|
||||
if($prog.endswith('.ps1')) {
|
||||
& $prog @arg
|
||||
} else {
|
||||
$installed = run $prog $arg "Running installer..."
|
||||
$installed = Invoke-ExternalCommand $prog $arg -Activity "Running installer..."
|
||||
if(!$installed) {
|
||||
abort "Installation aborted. You might need to run 'scoop uninstall $app' before trying again."
|
||||
}
|
||||
@@ -800,6 +793,7 @@ function install_prog($fname, $dir, $installer, $global) {
|
||||
function run_uninstaller($manifest, $architecture, $dir) {
|
||||
$msi = msi $manifest $architecture
|
||||
$uninstaller = uninstaller $manifest $architecture
|
||||
$version = $manifest.version
|
||||
if($uninstaller.script) {
|
||||
write-output "Running uninstaller script..."
|
||||
Invoke-Expression (@($uninstaller.script) -join "`r`n")
|
||||
@@ -837,7 +831,7 @@ function run_uninstaller($manifest, $architecture, $dir) {
|
||||
if($exe.endswith('.ps1')) {
|
||||
& $exe @arg
|
||||
} else {
|
||||
$uninstalled = run $exe $arg "Running uninstaller..." $continue_exit_codes
|
||||
$uninstalled = Invoke-ExternalCommand $exe $arg -Activity "Running uninstaller..." -ContinueExitCodes $continue_exit_codes
|
||||
if(!$uninstalled) { abort "Uninstallation aborted." }
|
||||
}
|
||||
}
|
||||
@@ -949,7 +943,7 @@ function unlink_current($versiondir) {
|
||||
attrib $currentdir -R /L
|
||||
|
||||
# remove the junction
|
||||
& "$env:COMSPEC" /c "rmdir $currentdir"
|
||||
& "$env:COMSPEC" /c "rmdir `"$currentdir`""
|
||||
return $currentdir
|
||||
}
|
||||
return $versiondir
|
||||
@@ -986,54 +980,49 @@ function find_dir_or_subdir($path, $dir) {
|
||||
return [string]::join(';', $fixed), $removed
|
||||
}
|
||||
|
||||
function env_add_path($manifest, $dir, $global) {
|
||||
$manifest.env_add_path | Where-Object { $_ } | ForEach-Object {
|
||||
$path_dir = join-path $dir $_
|
||||
function env_add_path($manifest, $dir, $global, $arch) {
|
||||
$env_add_path = arch_specific 'env_add_path' $manifest $arch
|
||||
if ($env_add_path) {
|
||||
# GH-3785: Add path in ascending order.
|
||||
[Array]::Reverse($env_add_path)
|
||||
$env_add_path | Where-Object { $_ } | ForEach-Object {
|
||||
$path_dir = Join-Path $dir $_
|
||||
|
||||
if(!(is_in_dir $dir $path_dir)) {
|
||||
abort "Error in manifest: env_add_path '$_' is outside the app directory."
|
||||
if (!(is_in_dir $dir $path_dir)) {
|
||||
abort "Error in manifest: env_add_path '$_' is outside the app directory."
|
||||
}
|
||||
add_first_in_path $path_dir $global
|
||||
}
|
||||
add_first_in_path $path_dir $global
|
||||
}
|
||||
}
|
||||
|
||||
function add_first_in_path($dir, $global) {
|
||||
$dir = fullpath $dir
|
||||
|
||||
# future sessions
|
||||
$null, $currpath = strip_path (env 'path' $global) $dir
|
||||
env 'path' $global "$dir;$currpath"
|
||||
|
||||
# this session
|
||||
$null, $env:PATH = strip_path $env:PATH $dir
|
||||
$env:PATH = "$dir;$env:PATH"
|
||||
}
|
||||
|
||||
function env_rm_path($manifest, $dir, $global) {
|
||||
# remove from path
|
||||
$manifest.env_add_path | Where-Object { $_ } | ForEach-Object {
|
||||
$path_dir = join-path $dir $_
|
||||
function env_rm_path($manifest, $dir, $global, $arch) {
|
||||
$env_add_path = arch_specific 'env_add_path' $manifest $arch
|
||||
$env_add_path | Where-Object { $_ } | ForEach-Object {
|
||||
$path_dir = Join-Path $dir $_
|
||||
|
||||
remove_from_path $path_dir $global
|
||||
}
|
||||
}
|
||||
|
||||
function env_set($manifest, $dir, $global) {
|
||||
if($manifest.env_set) {
|
||||
$manifest.env_set | Get-Member -member noteproperty | ForEach-Object {
|
||||
function env_set($manifest, $dir, $global, $arch) {
|
||||
$env_set = arch_specific 'env_set' $manifest $arch
|
||||
if ($env_set) {
|
||||
$env_set | Get-Member -Member NoteProperty | ForEach-Object {
|
||||
$name = $_.name;
|
||||
$val = format $manifest.env_set.$($_.name) @{ "dir" = $dir }
|
||||
$val = format $env_set.$($_.name) @{ "dir" = $dir }
|
||||
env $name $global $val
|
||||
Set-Content env:\$name $val
|
||||
}
|
||||
}
|
||||
}
|
||||
function env_rm($manifest, $global) {
|
||||
if($manifest.env_set) {
|
||||
$manifest.env_set | Get-Member -member noteproperty | ForEach-Object {
|
||||
function env_rm($manifest, $global, $arch) {
|
||||
$env_set = arch_specific 'env_set' $manifest $arch
|
||||
if ($env_set) {
|
||||
$env_set | Get-Member -Member NoteProperty | ForEach-Object {
|
||||
$name = $_.name
|
||||
env $name $global $null
|
||||
if(test-path env:\$name) { Remove-Item env:\$name }
|
||||
if (Test-Path env:\$name) { Remove-Item env:\$name }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1080,11 +1069,11 @@ function prune_installed($apps, $global) {
|
||||
|
||||
# check whether the app failed to install
|
||||
function failed($app, $global) {
|
||||
$ver = current_version $app $global
|
||||
if(!$ver) { return $false }
|
||||
$info = install_info $app $ver $global
|
||||
if(!$info) { return $true }
|
||||
return $false
|
||||
if (is_directory (appdir $app $global)) {
|
||||
return !(install_info $app (current_version $app $global) $global)
|
||||
} else {
|
||||
return $false
|
||||
}
|
||||
}
|
||||
|
||||
function ensure_none_failed($apps, $global) {
|
||||
@@ -1200,10 +1189,10 @@ function unlink_persist_data($dir) {
|
||||
# remove read-only attribute on the link
|
||||
attrib -R /L $filepath
|
||||
# remove the junction
|
||||
& "$env:COMSPEC" /c "rmdir /s /q $filepath"
|
||||
& "$env:COMSPEC" /c "rmdir /s /q `"$filepath`""
|
||||
} else {
|
||||
# remove the hard link
|
||||
& "$env:COMSPEC" /c "del $filepath"
|
||||
& "$env:COMSPEC" /c "del `"$filepath`""
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -59,8 +59,20 @@ function install_info($app, $version, $global) {
|
||||
}
|
||||
|
||||
function default_architecture {
|
||||
if([intptr]::size -eq 8) { return "64bit" }
|
||||
"32bit"
|
||||
$arch = get_config 'default-architecture'
|
||||
$system = if ([Environment]::Is64BitOperatingSystem) { '64bit' } else { '32bit' }
|
||||
if ($null -eq $arch) {
|
||||
$arch = $system
|
||||
} else {
|
||||
try {
|
||||
$arch = ensure_architecture $arch
|
||||
} catch {
|
||||
warn 'Invalid default architecture configured. Determining default system architecture'
|
||||
$arch = $system
|
||||
}
|
||||
}
|
||||
|
||||
return $arch
|
||||
}
|
||||
|
||||
function arch_specific($prop, $manifest, $architecture) {
|
||||
|
||||
@@ -23,10 +23,10 @@ function install_psmodule($manifest, $dir, $global) {
|
||||
|
||||
if(test-path $linkfrom) {
|
||||
warn "$(friendly_path $linkfrom) already exists. It will be replaced."
|
||||
& "$env:COMSPEC" /c "rmdir $linkfrom"
|
||||
& "$env:COMSPEC" /c "rmdir `"$linkfrom`""
|
||||
}
|
||||
|
||||
& "$env:COMSPEC" /c "mklink /j $linkfrom $dir" | out-null
|
||||
& "$env:COMSPEC" /c "mklink /j `"$linkfrom`" `"$dir`"" | out-null
|
||||
}
|
||||
|
||||
function uninstall_psmodule($manifest, $dir, $global) {
|
||||
@@ -40,7 +40,7 @@ function uninstall_psmodule($manifest, $dir, $global) {
|
||||
if(test-path $linkfrom) {
|
||||
write-host "Removing $(friendly_path $linkfrom)"
|
||||
$linkfrom = resolve-path $linkfrom
|
||||
& "$env:COMSPEC" /c "rmdir $linkfrom"
|
||||
& "$env:COMSPEC" /c "rmdir `"$linkfrom`""
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@ $issues += !(check_windows_defender $false)
|
||||
$issues += !(check_windows_defender $true)
|
||||
$issues += !(check_main_bucket)
|
||||
$issues += !(check_long_paths)
|
||||
$issues += !(check_envs_requirements)
|
||||
|
||||
if (!(Test-HelperInstalled -Helper 7zip)) {
|
||||
error "'7-Zip' is not installed! It's required for unpacking most programs. Please Run 'scoop install 7zip' or 'scoop install 7zip-zstd'."
|
||||
@@ -24,7 +25,7 @@ if (!(Test-HelperInstalled -Helper Innounp)) {
|
||||
}
|
||||
|
||||
if (!(Test-HelperInstalled -Helper Dark)) {
|
||||
error "'dark' is not installed! It's require for unpacking installers created with the WiX Toolset. Please run 'scoop install dark' or 'scoop install wixtoolset'."
|
||||
error "'dark' is not installed! It's required for unpacking installers created with the WiX Toolset. Please run 'scoop install dark' or 'scoop install wixtoolset'."
|
||||
$issues++
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# Usage: scoop config [rm] name [value]
|
||||
# Summary: Get or set configuration values
|
||||
# Help: The scoop configuration file is saved at ~/.scoop.
|
||||
# Help: The scoop configuration file is saved at ~/.config/scoop/config.json.
|
||||
#
|
||||
# To get a configuration setting:
|
||||
#
|
||||
@@ -37,7 +37,7 @@ if(!$name) { my_usage; exit 1 }
|
||||
|
||||
if($name -like 'rm') {
|
||||
set_config $value $null | Out-Null
|
||||
Write-Output "'$name' has been removed"
|
||||
Write-Output "'$value' has been removed"
|
||||
} elseif($null -ne $value) {
|
||||
set_config $name $value | Out-Null
|
||||
Write-Output "'$name' has been set to '$value'"
|
||||
|
||||
@@ -13,7 +13,7 @@ function print_help($cmd) {
|
||||
|
||||
$usage = usage $file
|
||||
$summary = summary $file
|
||||
$help = help $file
|
||||
$help = scoop_help $file
|
||||
|
||||
if($usage) { "$usage`n" }
|
||||
if($help) { $help }
|
||||
|
||||
@@ -27,7 +27,7 @@ $apps | ForEach-Object {
|
||||
$json | Get-Member -MemberType Properties | ForEach-Object { $install.Add($_.Name, $json.($_.Name))}
|
||||
$install.hold = $true
|
||||
save_install_info $install $dir
|
||||
success "$app is now locked and can not be updated anymore."
|
||||
success "$app is now held and can not be updated anymore."
|
||||
}
|
||||
|
||||
exit $exitcode
|
||||
|
||||
@@ -35,6 +35,7 @@ if (!$manifest) {
|
||||
}
|
||||
|
||||
$install = install_info $app $status.version $global
|
||||
$status.installed = $install.bucket -eq $bucket
|
||||
$version_output = $manifest.version
|
||||
if (!$manifest_file) {
|
||||
$manifest_file = manifest_path $app $bucket
|
||||
@@ -94,9 +95,9 @@ if($status.installed) {
|
||||
Write-Output "Installed: No"
|
||||
}
|
||||
|
||||
$binaries = arch_specific 'bin' $manifest $install.architecture
|
||||
$binaries = @(arch_specific 'bin' $manifest $install.architecture)
|
||||
if($binaries) {
|
||||
$binary_output = "Binaries:`n "
|
||||
$binary_output = "Binaries:`n "
|
||||
$binaries | ForEach-Object {
|
||||
if($_ -is [System.Array]) {
|
||||
$binary_output += " $($_[1]).exe"
|
||||
|
||||
@@ -72,8 +72,8 @@ if (is_scoop_outdated) {
|
||||
}
|
||||
|
||||
if ($apps.length -eq 1) {
|
||||
$app, $null, $null = parse_app $apps
|
||||
if (is_installed $app $global) {
|
||||
$app, $null, $version = parse_app $apps
|
||||
if ($null -eq $version -and (is_installed $app $global)) {
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ if($apps) {
|
||||
if (!$install_info) { Write-Host ' *failed*' -ForegroundColor DarkRed -NoNewline }
|
||||
if ($install_info.hold) { Write-Host ' *hold*' -ForegroundColor DarkMagenta -NoNewline }
|
||||
|
||||
if ($install_info.bucket -and ($install_info.bucket -ne 'main')) {
|
||||
if ($install_info.bucket) {
|
||||
write-host -f Yellow " [$($install_info.bucket)]" -NoNewline
|
||||
} elseif ($install_info.url) {
|
||||
write-host -f Yellow " [$($install_info.url)]" -NoNewline
|
||||
|
||||
@@ -27,7 +27,7 @@ $apps | ForEach-Object {
|
||||
$json | Get-Member -MemberType Properties | ForEach-Object { $install.Add($_.Name, $json.($_.Name))}
|
||||
$install.hold = $null
|
||||
save_install_info $install $dir
|
||||
success "$app is now unlocked and can be updated again."
|
||||
success "$app is no longer held and can be updated again."
|
||||
}
|
||||
|
||||
exit $exitcode
|
||||
|
||||
@@ -56,6 +56,14 @@ if (!$apps) { exit 0 }
|
||||
$dir = versiondir $app $version $global
|
||||
$persist_dir = persistdir $app $global
|
||||
|
||||
#region Workaround for #2952
|
||||
$processdir = appdir $app $global | Resolve-Path | Select-Object -ExpandProperty Path
|
||||
if (Get-Process | Where-Object { $_.Path -like "$processdir\*" }) {
|
||||
error "Application is still running. Close all instances and try again."
|
||||
continue
|
||||
}
|
||||
#endregion Workaround for #2952
|
||||
|
||||
try {
|
||||
Test-Path $dir -ErrorAction Stop | Out-Null
|
||||
} catch [UnauthorizedAccessException] {
|
||||
|
||||
@@ -52,16 +52,9 @@ if (!$configBranch) {
|
||||
|
||||
if(($PSVersionTable.PSVersion.Major) -lt 5) {
|
||||
# check powershell version
|
||||
# should be deleted after Oct 1, 2019
|
||||
If ((Get-Date).ToUniversalTime() -ge "2019-10-01") {
|
||||
Write-Output "PowerShell 5 or later is required to run Scoop."
|
||||
Write-Output "Upgrade PowerShell: https://docs.microsoft.com/en-us/powershell/scripting/setup/installing-windows-powershell"
|
||||
break
|
||||
} else {
|
||||
Write-Output "Scoop is going to stop supporting old version of PowerShell."
|
||||
Write-Output "Please upgrade to PowerShell 5 or later version before Oct 1, 2019 UTC."
|
||||
Write-Output "Guideline: https://docs.microsoft.com/en-us/powershell/scripting/setup/installing-windows-powershell"
|
||||
}
|
||||
Write-Output "PowerShell 5 or later is required to run Scoop."
|
||||
Write-Output "Upgrade PowerShell: https://docs.microsoft.com/en-us/powershell/scripting/install/installing-powershell-core-on-windows"
|
||||
break
|
||||
}
|
||||
|
||||
function update_scoop() {
|
||||
@@ -91,34 +84,35 @@ function update_scoop() {
|
||||
} else {
|
||||
Push-Location $currentdir
|
||||
|
||||
$currentRepo = git_config remote.origin.url
|
||||
$currentBranch = git_branch
|
||||
$previousCommit = Invoke-Expression 'git rev-parse HEAD'
|
||||
$currentRepo = Invoke-Expression "git config remote.origin.url"
|
||||
$currentBranch = Invoke-Expression "git branch"
|
||||
|
||||
$isRepoChanged = !($currentRepo -match $configRepo)
|
||||
$isBranchChanged = !($currentBranch -match "\*\s+$configBranch")
|
||||
|
||||
# Change remote url if the repo is changed
|
||||
if ($isRepoChanged) {
|
||||
git_config remote.origin.url "$configRepo"
|
||||
Invoke-Expression "git config remote.origin.url '$configRepo'"
|
||||
}
|
||||
|
||||
# Fetch and reset local repo if the repo or the branch is changed
|
||||
if ($isRepoChanged -or $isBranchChanged) {
|
||||
# Reset git fetch refs, so that it can fetch all branches (GH-3368)
|
||||
git_config remote.origin.fetch "+refs/heads/*:refs/remotes/origin/*"
|
||||
Invoke-Expression "git config remote.origin.fetch '+refs/heads/*:refs/remotes/origin/*'"
|
||||
# fetch remote branch
|
||||
git_fetch --force origin "refs/heads/`"$configBranch`":refs/remotes/origin/$configBranch" -q
|
||||
# checkout and track the branch
|
||||
git_checkout -B $configBranch -t origin/$configBranch -q
|
||||
# reset branch HEAD
|
||||
git_reset --hard origin/$configBranch -q
|
||||
Invoke-Expression "git reset --hard origin/$configBranch -q"
|
||||
} else {
|
||||
git_pull -q
|
||||
}
|
||||
|
||||
$res = $lastexitcode
|
||||
if ($show_update_log) {
|
||||
git_log --no-decorate --date=local --since="`"$last_update`"" --format="`"tformat: * %C(yellow)%h%Creset %<|(72,trunc)%s %C(cyan)%cr%Creset`"" HEAD
|
||||
Invoke-Expression "git --no-pager log --no-decorate --format='tformat: * %C(yellow)%h%Creset %<|(72,trunc)%s %C(cyan)%cr%Creset' '$previousCommit..HEAD'"
|
||||
}
|
||||
|
||||
Pop-Location
|
||||
@@ -147,9 +141,10 @@ function update_scoop() {
|
||||
}
|
||||
|
||||
Push-Location $loc
|
||||
$previousCommit = (Invoke-Expression 'git rev-parse HEAD')
|
||||
git_pull -q
|
||||
if ($show_update_log) {
|
||||
git_log --no-decorate --date=local --since="`"$last_update`"" --format="`"tformat: * %C(yellow)%h%Creset %<|(72,trunc)%s %C(cyan)%cr%Creset`"" HEAD
|
||||
Invoke-Expression "git --no-pager log --no-decorate --format='tformat: * %C(yellow)%h%Creset %<|(72,trunc)%s %C(cyan)%cr%Creset' '$previousCommit..HEAD'"
|
||||
}
|
||||
Pop-Location
|
||||
}
|
||||
@@ -173,7 +168,8 @@ function update($app, $global, $quiet = $false, $independent, $suggested, $use_c
|
||||
|
||||
if (!$independent) {
|
||||
# check dependencies
|
||||
$deps = @(deps $app $architecture) | Where-Object { !(installed $_) }
|
||||
$man = if ($url) { $url } else { $app }
|
||||
$deps = @(deps $man $architecture) | Where-Object { !(installed $_) }
|
||||
$deps | ForEach-Object { install_app $_ $architecture $global $suggested $use_cache $check_hash }
|
||||
}
|
||||
|
||||
@@ -236,6 +232,15 @@ function update($app, $global, $quiet = $false, $independent, $suggested, $use_c
|
||||
# endregion Workaround
|
||||
|
||||
$dir = versiondir $app $old_version $global
|
||||
$persist_dir = persistdir $app $global
|
||||
|
||||
#region Workaround for #2952
|
||||
$processdir = appdir $app $global | Resolve-Path | Select-Object -ExpandProperty Path
|
||||
if (Get-Process | Where-Object { $_.Path -like "$processdir\*" }) {
|
||||
error "Application is still running. Close all instances and try again."
|
||||
return
|
||||
}
|
||||
#endregion Workaround for #2952
|
||||
|
||||
write-host "Uninstalling '$app' ($old_version)"
|
||||
run_uninstaller $old_manifest $architecture $dir
|
||||
@@ -264,6 +269,10 @@ function update($app, $global, $quiet = $false, $independent, $suggested, $use_c
|
||||
# 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
|
||||
}
|
||||
install_app $app $architecture $global $suggested $use_cache $check_hash
|
||||
}
|
||||
|
||||
@@ -303,7 +312,7 @@ if (!$apps) {
|
||||
$outdated += applist $app $global
|
||||
write-host -f yellow ("$app`: $($status.version) -> $($status.latest_version){0}" -f ('',' (global)')[$global])
|
||||
} else {
|
||||
warn "'$app' is locked to version $($status.version)"
|
||||
warn "'$app' is held to version $($status.version)"
|
||||
}
|
||||
} elseif ($apps_param -ne '*') {
|
||||
write-host -f green "$app`: $($status.version) (latest version)"
|
||||
|
||||
10
schema.json
10
schema.json
@@ -95,6 +95,12 @@
|
||||
"checkver": {
|
||||
"$ref": "#/definitions/checkver"
|
||||
},
|
||||
"env_add_path": {
|
||||
"$ref": "#/definitions/stringOrArrayOfStrings"
|
||||
},
|
||||
"env_set": {
|
||||
"type": "object"
|
||||
},
|
||||
"extract_dir": {
|
||||
"$ref": "#/definitions/stringOrArrayOfStrings"
|
||||
},
|
||||
@@ -254,6 +260,10 @@
|
||||
},
|
||||
"useragent": {
|
||||
"type": "string"
|
||||
},
|
||||
"script": {
|
||||
"$ref": "#/definitions/stringOrArrayOfStrings",
|
||||
"description": "Custom PowerShell script to retrieve application version using more complex approach."
|
||||
}
|
||||
},
|
||||
"type": "object"
|
||||
|
||||
@@ -1,10 +1,16 @@
|
||||
Write-Host "PowerShell: $($PSVersionTable.PSVersion)"
|
||||
(7z.exe | Select-String -Pattern '7-Zip').ToString()
|
||||
Write-Host "Install dependencies ..."
|
||||
Install-Module -Repository PSGallery -Scope CurrentUser -Force -Name Pester -SkipPublisherCheck
|
||||
Install-Module -Repository PSGallery -Scope CurrentUser -Force -Name Pester -RequiredVersion 4.10.1 -SkipPublisherCheck
|
||||
Install-Module -Repository PSGallery -Scope CurrentUser -Force -Name PSScriptAnalyzer,BuildHelpers
|
||||
|
||||
if ($env:CI_WINDOWS -eq $true) {
|
||||
# Do not force maintainers to have this inside environment appveyor config
|
||||
if (-not $env:SCOOP_HELPERS) {
|
||||
$env:SCOOP_HELPERS = 'C:\projects\helpers'
|
||||
[System.Environment]::SetEnvironmentVariable('SCOOP_HELPERS', $env:SCOOP_HELPERS, 'Machine')
|
||||
}
|
||||
|
||||
if(!(Test-Path $env:SCOOP_HELPERS)) {
|
||||
New-Item -ItemType Directory -Path $env:SCOOP_HELPERS
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user