mirror of
https://github.com/ScoopInstaller/Scoop.git
synced 2026-09-05 21:15:39 +00:00
Merge remote-tracking branch 'upstream/master'
This commit is contained in:
+2
-1
@@ -106,7 +106,8 @@ while($in_progress -gt 0) {
|
||||
write-host "$app`: " -nonewline
|
||||
|
||||
if($err) {
|
||||
write-host "ERROR: $err" -f darkyellow
|
||||
write-host -f darkred $err.message
|
||||
write-host -f darkred "URL $url is not valid"
|
||||
} else {
|
||||
if($page -match $regexp) {
|
||||
$ver = $matches[1]
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
"homepage": "https://slproweb.com/products/Win32OpenSSL.html",
|
||||
"version": "1.1.0e",
|
||||
"license": "https://www.openssl.org/source/license.html",
|
||||
"_comment": "Hashes at https://slproweb.com/download/win32_openssl_hashes.json",
|
||||
"architecture": {
|
||||
"64bit": {
|
||||
"url": "https://slproweb.com/download/Win64OpenSSL-1_1_0e.exe",
|
||||
|
||||
+47
-25
@@ -23,9 +23,12 @@ function check_url([String] $url) {
|
||||
return $true
|
||||
}
|
||||
|
||||
$response = Invoke-WebRequest -Uri $url -Method HEAD
|
||||
if ($response.StatusCode.Equals(200)) { # redirects might be ok
|
||||
return $true
|
||||
try {
|
||||
$response = Invoke-WebRequest -Uri $url -Method HEAD
|
||||
return ($response -and $response.StatusCode.Equals(200)) # redirects might be ok
|
||||
} catch [system.net.webexception] {
|
||||
write-host -f darkred $_
|
||||
write-host -f darkred "URL $url is not valid"
|
||||
}
|
||||
|
||||
return $false
|
||||
@@ -36,8 +39,15 @@ function find_hash_in_rdf([String] $url, [String] $filename)
|
||||
Write-Host -f DarkYellow "RDF URL: $url"
|
||||
Write-Host -f DarkYellow "File: $filename"
|
||||
|
||||
# Download and parse RDF XML file
|
||||
[xml]$data = (new-object net.webclient).downloadstring($url)
|
||||
$data = ""
|
||||
try {
|
||||
# Download and parse RDF XML file
|
||||
[xml]$data = (new-object net.webclient).downloadstring($url)
|
||||
} catch [system.net.webexception] {
|
||||
write-host -f darkred $_
|
||||
write-host -f darkred "URL $url is not valid"
|
||||
return $null
|
||||
}
|
||||
|
||||
# Find file content
|
||||
$digest = $data.RDF.Content | ? { [String]$_.about -eq $filename }
|
||||
@@ -60,7 +70,15 @@ function get_hash_for_app([String] $app, $config, [String] $version, [String] $u
|
||||
if ($hashmode -eq "extract") {
|
||||
$hashfile_url = substitute $config.url @{'$url' = $url}
|
||||
$hashfile_url = substitute $hashfile_url $substitutions
|
||||
$hashfile = (new-object net.webclient).downloadstring($hashfile_url)
|
||||
$hashfile = $null
|
||||
|
||||
try {
|
||||
$hashfile = (new-object net.webclient).downloadstring($hashfile_url)
|
||||
} catch [system.net.webexception] {
|
||||
write-host -f darkred $_
|
||||
write-host -f darkred "URL $hashfile_url is not valid"
|
||||
return $null
|
||||
}
|
||||
|
||||
$regex = $config.find
|
||||
if ($regex -eq $null) {
|
||||
@@ -81,7 +99,13 @@ function get_hash_for_app([String] $app, $config, [String] $version, [String] $u
|
||||
return find_hash_in_rdf $config.url $basename
|
||||
} else {
|
||||
Write-Host "Download files to compute hashes!" -f DarkYellow
|
||||
dl_with_cache $app $version $url $null $null $true
|
||||
try {
|
||||
dl_with_cache $app $version $url $null $null $true
|
||||
} catch [system.net.webexception] {
|
||||
write-host -f darkred $_
|
||||
write-host -f darkred "URL $url is not valid"
|
||||
return $null
|
||||
}
|
||||
$file = fullpath (cache_path $app $version $url)
|
||||
return compute_hash $file "sha256"
|
||||
}
|
||||
@@ -164,16 +188,15 @@ function autoupdate([String] $app, $dir, $json, [String] $version, [Hashtable] $
|
||||
$url = substitute $json.autoupdate.url $substitutions
|
||||
|
||||
# check url
|
||||
if (!(check_url $url)) {
|
||||
$valid = $false
|
||||
Write-Host -f DarkRed "URL $url is not valid"
|
||||
}
|
||||
$valid = check_url $url
|
||||
|
||||
# create hash
|
||||
$hash = get_hash_for_app $app $json.autoupdate.hash $version $url $substitutions
|
||||
if ($hash -eq $null) {
|
||||
$valid = $false
|
||||
Write-Host -f DarkRed "Could not find hash!"
|
||||
if($valid) {
|
||||
# create hash
|
||||
$hash = get_hash_for_app $app $json.autoupdate.hash $version $url $substitutions
|
||||
if ($hash -eq $null) {
|
||||
$valid = $false
|
||||
Write-Host -f DarkRed "Could not find hash!"
|
||||
}
|
||||
}
|
||||
|
||||
# write changes to the json object
|
||||
@@ -193,16 +216,15 @@ function autoupdate([String] $app, $dir, $json, [String] $version, [Hashtable] $
|
||||
$url = substitute (arch_specific "url" $json.autoupdate $architecture) $substitutions
|
||||
|
||||
# check url
|
||||
if (!(check_url $url)) {
|
||||
$valid = $false
|
||||
Write-Host -f DarkRed "URL $url is not valid"
|
||||
}
|
||||
$valid = check_url $url
|
||||
|
||||
# create hash
|
||||
$hash = get_hash_for_app $app (arch_specific "hash" $json.autoupdate $architecture) $version $url $substitutions
|
||||
if ($hash -eq $null) {
|
||||
$valid = $false
|
||||
Write-Host -f DarkRed "Could not find hash!"
|
||||
if($valid) {
|
||||
# create hash
|
||||
$hash = get_hash_for_app $app (arch_specific "hash" $json.autoupdate $architecture) $version $url $substitutions
|
||||
if ($hash -eq $null) {
|
||||
$valid = $false
|
||||
Write-Host -f DarkRed "Could not find hash!"
|
||||
}
|
||||
}
|
||||
|
||||
# write changes to the json object
|
||||
|
||||
+7
-2
@@ -142,7 +142,7 @@ function do_dl($url, $to, $cookies) {
|
||||
} catch {
|
||||
$e = $_.exception
|
||||
if($e.innerexception) { $e = $e.innerexception }
|
||||
abort $e.message
|
||||
throw $e
|
||||
} finally {
|
||||
set_https_protocols $original_protocols
|
||||
}
|
||||
@@ -300,7 +300,12 @@ function dl_urls($app, $version, $manifest, $architecture, $dir, $use_cache = $t
|
||||
}
|
||||
$fname = $data.$url.fname
|
||||
|
||||
dl_with_cache $app $version $url "$dir\$fname" $cookies $use_cache
|
||||
try {
|
||||
dl_with_cache $app $version $url "$dir\$fname" $cookies $use_cache
|
||||
} catch {
|
||||
write-host -f darkred $_
|
||||
abort "URL $url is not valid"
|
||||
}
|
||||
}
|
||||
|
||||
foreach($url in $urls) {
|
||||
|
||||
Reference in New Issue
Block a user