diff --git a/CHANGELOG.md b/CHANGELOG.md index b571b365b1..81e6fb66e2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ ## [Unreleased](https://github.com/ScoopInstaller/Scoop/compare/master...develop) +### Features + +- **install:** Allow downloading from private repositories ([$4254](https://github.com/ScoopInstaller/Scoop/issues/4243)) + ### Bug Fixes - **shim:** Manipulating shims with UTF8 encoding ([#4791](https://github.com/ScoopInstaller/Scoop/issues/4791), [#4813](https://github.com/ScoopInstaller/Scoop/issues/4813)) @@ -14,10 +18,6 @@ - **relpath:** Use `$PSScriptRoot` instead of `relpath` ([#4793](https://github.com/ScoopInstaller/Scoop/issues/4793)) - **reset_aliases:** Move core function of `reset_aliases` to `scoop` ([#4794](https://github.com/ScoopInstaller/Scoop/issues/4794)) -### Features - -- **install:** Update to allow for dowloading from private repositories ([$4254](https://github.com/ScoopInstaller/Scoop/issues/4243)) - ## [v0.1.0](https://github.com/ScoopInstaller/Scoop/compare/2021-12-26...v0.1.0) - 2022-03-01 ### Features diff --git a/lib/install.ps1 b/lib/install.ps1 index ebe146e244..aad37b390d 100644 --- a/lib/install.ps1 +++ b/lib/install.ps1 @@ -387,26 +387,26 @@ function dl_with_cache_aria2($app, $version, $manifest, $architecture, $dir, $co # download with filesize and progress indicator function dl($url, $to, $cookies, $progress) { - $reqUrl = ($url -split "#")[0] - $wreq = [net.webrequest]::create($reqUrl) - if($wreq -is [net.httpwebrequest]) { - $wreq.useragent = Get-UserAgent - if (-not ($url -imatch "sourceforge\.net" -or $url -imatch "portableapps\.com")) { - $wreq.referer = strip_filename $url + $reqUrl = ($url -split '#')[0] + $wreq = [Net.WebRequest]::Create($reqUrl) + if ($wreq -is [Net.HttpWebRequest]) { + $wreq.UserAgent = Get-UserAgent + if (-not ($url -match 'sourceforge\.net' -or $url -match 'portableapps\.com')) { + $wreq.Referer = strip_filename $url } - if ($url -imatch "api\.github\.com/repos") { - $wreq.accept = "application/octet-stream" - $wreq.headers["Authorization"] = "token $(get_config 'checkver_token')" + if ($url -match 'api\.github\.com/repos') { + $wreq.Accept = 'application/octet-stream' + $wreq.Headers['Authorization'] = "token $(get_config 'checkver_token')" } - if($cookies) { - $wreq.headers.add('Cookie', (cookie_header $cookies)) + if ($cookies) { + $wreq.Headers.Add('Cookie', (cookie_header $cookies)) } - $hosts = get_config "hosts" - if ($hosts) { - $hosts | Where-Object { $url -match $_.match } | ForEach-Object { - (ConvertFrom-StringData -StringData $_.headers).GetEnumerator() | ForEach-Object { - $wreq.headers[$_.Key] = $_.Value + $privateHosts = get_config 'private_hosts' + if ($privateHosts) { + $privateHosts | Where-Object { $url -match $_.match } | ForEach-Object { + (ConvertFrom-StringData -StringData $_.Headers).GetEnumerator() | ForEach-Object { + $wreq.Headers[$_.Key] = $_.Value } } } diff --git a/libexec/scoop-config.ps1 b/libexec/scoop-config.ps1 index 32e4572dd0..47405e5da4 100644 --- a/libexec/scoop-config.ps1 +++ b/libexec/scoop-config.ps1 @@ -78,8 +78,8 @@ # # checkver_token: # GitHub API token used to make authenticated requests. -# This is essential for checkver and similar functions -# to run without incurring rate limits. +# This is essential for checkver and similar functions to run without +# incurring rate limits and download from private repositories. # # virustotal_api_key: # API key used for uploading/scanning files using virustotal. @@ -96,6 +96,11 @@ # any target app process is running. Procedure here refers to reset/uninstall/update. # When set to $true, Scoop only displays a warning message and continues procedure. # +# private_hosts: +# Array of private hosts that need additional authentication. +# For example, if you want to access a private GitHub repository, +# you need to add the host to this list with 'match' and 'headers' strings. +# # ARIA2 configuration # ------------------- #