Skip to content

Commit 93db5f4

Browse files
authored
chore(release): Bump to version 0.2.2
2 parents d63b7d6 + 5987e49 commit 93db5f4

File tree

13 files changed

+366
-131
lines changed

13 files changed

+366
-131
lines changed

CHANGELOG.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,16 @@
1+
## [v0.2.2](https://github.com/ScoopInstaller/Scoop/compare/v0.2.1...v0.2.2) - 2022-06-21
2+
3+
### Features
4+
5+
- **core:** Add `Get-Encoding` function to fix missing webclient encoding ([#4956](https://github.com/ScoopInstaller/Scoop/issues/4956))
6+
- **scoop-(un)hold:** Add `-g`/`--global` flag ([#4991](https://github.com/ScoopInstaller/Scoop/issues/4991))
7+
- **scoop-update:** Support `scoop update scoop` ([#4992](https://github.com/ScoopInstaller/Scoop/issues/4992))
8+
- **scoop-virustotal:** Migrate to VirusTotal API v3 ([#4983](https://github.com/ScoopInstaller/Scoop/issues/4983))
9+
10+
### Bug Fixes
11+
12+
- **manifest:** Fix bugs in 'Get-Manifest()' ([#4986](https://github.com/ScoopInstaller/Scoop/issues/4986))
13+
114
## [v0.2.1](https://github.com/ScoopInstaller/Scoop/compare/v0.2.0...v0.2.1) - 2022-06-10
215

316
### Features

bin/checkver.ps1

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ $Queue | ForEach-Object {
113113
} else {
114114
$wc.Headers.Add('User-Agent', (Get-UserAgent))
115115
}
116-
Register-ObjectEvent $wc downloadstringcompleted -ErrorAction Stop | Out-Null
116+
Register-ObjectEvent $wc downloadDataCompleted -ErrorAction Stop | Out-Null
117117

118118
$githubRegex = '\/releases\/tag\/(?:v|V)?([\d.]+)'
119119

@@ -190,7 +190,7 @@ $Queue | ForEach-Object {
190190
}
191191

192192
$wc.Headers.Add('Referer', (strip_filename $url))
193-
$wc.DownloadStringAsync($url, $state)
193+
$wc.DownloadDataAsync($url, $state)
194194
}
195195

196196
function next($er) {
@@ -218,7 +218,7 @@ while ($in_progress -gt 0) {
218218
$ver = $Version
219219

220220
if (!$ver) {
221-
$page = $ev.SourceEventArgs.Result
221+
$page = (Get-Encoding($wc)).GetString($ev.SourceEventArgs.Result)
222222
$err = $ev.SourceEventArgs.Error
223223
if ($json.checkver.script) {
224224
$page = Invoke-Command ([scriptblock]::Create($json.checkver.script -join "`r`n"))

bin/describe.ps1

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,8 @@ $Queue | ForEach-Object {
4444
try {
4545
$wc = New-Object Net.Webclient
4646
$wc.Headers.Add('User-Agent', (Get-UserAgent))
47-
$home_html = $wc.DownloadString($manifest.homepage)
47+
$homepage = $wc.DownloadData($manifest.homepage)
48+
$home_html = (Get-Encoding($wc)).GetString($homepage)
4849
} catch {
4950
Write-Host "`n$($_.Exception.Message)" -ForegroundColor Red
5051
return

lib/autoupdate.ps1

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,21 @@
11
# Must included with 'json.ps1'
22
function find_hash_in_rdf([String] $url, [String] $basename) {
3-
$data = $null
3+
$xml = $null
44
try {
55
# Download and parse RDF XML file
66
$wc = New-Object Net.Webclient
77
$wc.Headers.Add('Referer', (strip_filename $url))
88
$wc.Headers.Add('User-Agent', (Get-UserAgent))
9-
[xml]$data = $wc.downloadstring($url)
9+
$data = $wc.DownloadData($url)
10+
[xml]$xml = (Get-Encoding($wc)).GetString($data)
1011
} catch [system.net.webexception] {
1112
write-host -f darkred $_
1213
write-host -f darkred "URL $url is not valid"
1314
return $null
1415
}
1516

1617
# Find file content
17-
$digest = $data.RDF.Content | Where-Object { [String]$_.about -eq $basename }
18+
$digest = $xml.RDF.Content | Where-Object { [String]$_.about -eq $basename }
1819

1920
return format_hash $digest.sha256
2021
}
@@ -35,7 +36,8 @@ function find_hash_in_textfile([String] $url, [Hashtable] $substitutions, [Strin
3536
$wc = New-Object Net.Webclient
3637
$wc.Headers.Add('Referer', (strip_filename $url))
3738
$wc.Headers.Add('User-Agent', (Get-UserAgent))
38-
$hashfile = $wc.downloadstring($url)
39+
$data = $wc.DownloadData($url)
40+
$hashfile = (Get-Encoding($wc)).GetString($data)
3941
} catch [system.net.webexception] {
4042
write-host -f darkred $_
4143
write-host -f darkred "URL $url is not valid"
@@ -88,7 +90,8 @@ function find_hash_in_json([String] $url, [Hashtable] $substitutions, [String] $
8890
$wc = New-Object Net.Webclient
8991
$wc.Headers.Add('Referer', (strip_filename $url))
9092
$wc.Headers.Add('User-Agent', (Get-UserAgent))
91-
$json = $wc.downloadstring($url)
93+
$data = $wc.DownloadData($url)
94+
$json = (Get-Encoding($wc)).GetString($data)
9295
} catch [system.net.webexception] {
9396
write-host -f darkred $_
9497
write-host -f darkred "URL $url is not valid"
@@ -108,7 +111,8 @@ function find_hash_in_xml([String] $url, [Hashtable] $substitutions, [String] $x
108111
$wc = New-Object Net.Webclient
109112
$wc.Headers.Add('Referer', (strip_filename $url))
110113
$wc.Headers.Add('User-Agent', (Get-UserAgent))
111-
$xml = [xml]$wc.downloadstring($url)
114+
$data = $wc.DownloadData($url)
115+
$xml = [xml]((Get-Encoding($wc)).GetString($data))
112116
} catch [system.net.webexception] {
113117
write-host -f darkred $_
114118
write-host -f darkred "URL $url is not valid"

lib/core.ps1

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,14 @@ function Optimize-SecurityProtocol {
1515
}
1616
}
1717

18+
function Get-Encoding($wc) {
19+
if ($null -ne $wc.ResponseHeaders -and $wc.ResponseHeaders['Content-Type'] -match 'charset=([^;]*)') {
20+
return [System.Text.Encoding]::GetEncoding($Matches[1])
21+
} else {
22+
return [System.Text.Encoding]::GetEncoding('utf-8')
23+
}
24+
}
25+
1826
function Get-UserAgent() {
1927
return "Scoop/1.0 (+http://scoop.sh/) PowerShell/$($PSVersionTable.PSVersion.Major).$($PSVersionTable.PSVersion.Minor) (Windows NT $([System.Environment]::OSVersion.Version.Major).$([System.Environment]::OSVersion.Version.Minor); $(if($env:PROCESSOR_ARCHITECTURE -eq 'AMD64'){'Win64; x64; '})$(if($env:PROCESSOR_ARCHITEW6432 -eq 'AMD64'){'WOW64; '})$PSEdition)"
2028
}
@@ -847,7 +855,7 @@ function Confirm-InstallationStatus {
847855
$Global
848856
)
849857
$Installed = @()
850-
$Apps | Select-Object -Unique | Where-Object { $_.Name -ne 'scoop' } | ForEach-Object {
858+
$Apps | Select-Object -Unique | Where-Object { $_ -ne 'scoop' } | ForEach-Object {
851859
$App, $null, $null = parse_app $_
852860
if ($Global) {
853861
if (Test-Path (appdir $App $true)) {

lib/depends.ps1

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ function Get-Dependency {
3232
$Unresolved = @()
3333
)
3434
process {
35-
$AppName, $manifest, $bucket, $null = Get-Manifest $AppName
35+
$AppName, $manifest, $bucket, $url = Get-Manifest $AppName
3636
$Unresolved += $AppName
3737

3838
if (!$manifest) {
@@ -57,7 +57,11 @@ function Get-Dependency {
5757
if ($bucket) {
5858
$Resolved += "$bucket/$AppName"
5959
} else {
60-
$Resolved += $AppName
60+
if ($url) {
61+
$Resolved += $url
62+
} else {
63+
$Resolved += $AppName
64+
}
6165
}
6266
if ($Unresolved.Length -eq 0) {
6367
return $Resolved

lib/description.ps1

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ function find_description($url, $html, $redir = $false) {
1818
if($refresh -and !$redir) {
1919
$wc = New-Object Net.Webclient
2020
$wc.Headers.Add('User-Agent', (Get-UserAgent))
21-
$html = $wc.downloadstring($refresh)
21+
$data = $wc.DownloadData($refresh)
22+
$html = (Get-Encoding($wc)).GetString($data)
2223
return find_description $refresh $html $true
2324
}
2425

lib/manifest.ps1

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ function url_manifest($url) {
1212
try {
1313
$wc = New-Object Net.Webclient
1414
$wc.Headers.Add('User-Agent', (Get-UserAgent))
15-
$str = $wc.downloadstring($url)
15+
$data = $wc.DownloadData($url)
16+
$str = (Get-Encoding($wc)).GetString($data)
1617
} catch [system.management.automation.methodinvocationexception] {
1718
warn "error: $($_.exception.innerexception.message)"
1819
} catch {
@@ -24,6 +25,7 @@ function url_manifest($url) {
2425

2526
function Get-Manifest($app) {
2627
$bucket, $manifest, $url = $null
28+
$app = $app.TrimStart('/')
2729
# check if app is a URL or UNC path
2830
if ($app -match '^(ht|f)tps?://|\\\\') {
2931
$url = $app
@@ -44,6 +46,7 @@ function Get-Manifest($app) {
4446
if (!$manifest) {
4547
# couldn't find app in buckets: check if it's a local path
4648
$appPath = $app
49+
$bucket = $null
4750
if (!$appPath.EndsWith('.json')) {
4851
$appPath += '.json'
4952
}
@@ -66,7 +69,8 @@ function save_installed_manifest($app, $bucket, $dir, $url) {
6669
if ($url) {
6770
$wc = New-Object Net.Webclient
6871
$wc.Headers.Add('User-Agent', (Get-UserAgent))
69-
$wc.downloadstring($url) > "$dir\manifest.json"
72+
$data = $wc.DownloadData($url)
73+
(Get-Encoding($wc)).GetString($data) | Out-UTF8File "$dir\manifest.json"
7074
} else {
7175
Copy-Item (manifest_path $app $bucket) "$dir\manifest.json"
7276
}

libexec/scoop-download.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ foreach ($curr_app in $apps) {
5151
$bucket = $version = $app = $manifest = $url = $null
5252

5353
$app, $bucket, $version = parse_app $curr_app
54-
$app, $manifest, $bucket, $url = Get-Manifest $curr_app
54+
$app, $manifest, $bucket, $url = Get-Manifest "$bucket/$app"
5555

5656
info "Starting download for $app..."
5757

libexec/scoop-hold.ps1

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,43 @@
11
# Usage: scoop hold <apps>
22
# Summary: Hold an app to disable updates
3+
# Help: To hold a user-scoped app:
4+
# scoop hold <app>
5+
#
6+
# To hold a global app:
7+
# scoop hold -g <app>
8+
#
9+
# Options:
10+
# -g, --global Hold globally installed apps
311

12+
. "$PSScriptRoot\..\lib\getopt.ps1"
413
. "$PSScriptRoot\..\lib\json.ps1" # 'save_install_info' (indirectly)
514
. "$PSScriptRoot\..\lib\manifest.ps1" # 'install_info' 'Select-CurrentVersion' (indirectly)
615
. "$PSScriptRoot\..\lib\versions.ps1" # 'Select-CurrentVersion'
716

8-
$apps = $args
17+
$opt, $apps, $err = getopt $args 'g' 'global'
18+
if ($err) { "scoop hold: $err"; exit 1 }
919

10-
if(!$apps) {
20+
$global = $opt.g -or $opt.global
21+
22+
if (!$apps) {
1123
my_usage
1224
exit 1
1325
}
1426

27+
if ($global -and !(is_admin)) {
28+
error 'You need admin rights to hold a global app.'
29+
exit 1
30+
}
31+
1532
$apps | ForEach-Object {
1633
$app = $_
17-
$global = installed $app $true
1834

19-
if (!(installed $app)) {
20-
error "'$app' is not installed."
35+
if (!(installed $app $global)) {
36+
if ($global) {
37+
error "'$app' is not installed globally."
38+
} else {
39+
error "'$app' is not installed."
40+
}
2141
return
2242
}
2343

@@ -29,7 +49,7 @@ $apps | ForEach-Object {
2949
$dir = versiondir $app $version $global
3050
$json = install_info $app $version $global
3151
$install = @{}
32-
$json | Get-Member -MemberType Properties | ForEach-Object { $install.Add($_.Name, $json.($_.Name))}
52+
$json | Get-Member -MemberType Properties | ForEach-Object { $install.Add($_.Name, $json.($_.Name)) }
3353
$install.hold = $true
3454
save_install_info $install $dir
3555
success "$app is now held and can not be updated anymore."

0 commit comments

Comments
 (0)