-
Notifications
You must be signed in to change notification settings - Fork 1
/
local-download.ps1
96 lines (76 loc) · 2.67 KB
/
local-download.ps1
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
87
88
89
90
91
92
93
94
95
96
#!/usr/bin/env pwsh
# TLS enable tls12/tls13
[enum]::GetValues('Net.SecurityProtocolType') | Where-Object { $_ -ge 'Tls12' } | ForEach-Object {
[Net.ServicePointManager]::SecurityProtocol = [Net.ServicePointManager]::SecurityProtocol -bor $_
}
Import-Module -Name "$PSScriptRoot/script/Utility"
Function DecompressTar {
param(
[String]$URL,
[String]$File,
[String]$Hash
)
if (!(Test-Path $File)) {
if (!(WinGet -URL $URL -O $File)) {
return $false
}
}
Write-Host "Get-FileHash $File"
$xhash = Get-FileHash -Algorithm SHA256 $File
if ($xhash.Hash -ne $Hash) {
Write-Host "download $File checksum mismatch expected $Hash actual $($xhash.Hash)"
Remove-Item -Force $File
if (!(WinGet -URL $URL -O $File)) {
return $false
}
}
$xhash = Get-FileHash -Algorithm SHA256 $File
if ($xhash.Hash -ne $Hash) {
Write-Host "download $File checksum mismatch expected $Hash actual $($xhash.Hash)"
return $false
}
return $true
}
Write-Host "build wincurl $RefName <$PSScriptRoot>"
$WD = "build"
if (![String]::IsNullOrEmpty($env:BUILD_DIR)) {
$WD = $env:BUILD_DIR
}
$WD = Join-Path $PSScriptRoot $WD
if (!(MakeDirs -Dir $WD)) {
exit 1
}
Set-Location $WD
Write-Host "download root in $WD"
. "$PSScriptRoot/version.ps1"
Write-Host -ForegroundColor Yellow "Build zstd $ZSTD_VERSION"
if (!(DecompressTar -URL "https://mirror.ghproxy.com/$ZSTD_URL" -File "$ZSTD_FILE.tar.gz" -Hash $ZSTD_HASH)) {
exit 1
}
if (!(DecompressTar -URL "https://mirror.ghproxy.com/$BROTLI_URL" -File "$BROTLI_FILE.tar.gz" -Hash $BROTLI_HASH)) {
exit 1
}
if (!(DecompressTar -URL $ZLIB_URL -File "$ZLIB_FILENAME.tar.xz" -Hash $ZLIB_HASH)) {
exit 1
}
if (!(DecompressTar -URL $OPENSSL_URL -File "$OPENSSL_FILE.tar.gz" -Hash $OPENSSL_HASH)) {
exit 1
}
if (!(DecompressTar -URL "https://mirror.ghproxy.com/$NGHTTP3_URL" -File "$NGHTTP3_FILE.tar.xz" -Hash $NGHTTP3_HASH)) {
exit 1
}
if (!(DecompressTar -URL "https://mirror.ghproxy.com/$NGTCP2_URL" -File "$NGTCP2_FILE.tar.xz" -Hash $NGTCP2_HASH)) {
exit 1
}
if (!(DecompressTar -URL "https://mirror.ghproxy.com/$NGHTTP2_URL" -File "$NGHTTP2_FILE.tar.xz" -Hash $NGHTTP2_HASH)) {
exit 1
}
if (!(DecompressTar -URL $LIBSSH2_URL -File "$LIBSSH2_FILE.tar.gz" -Hash $LIBSSH2_HASH)) {
exit 1
}
if (!(DecompressTar -URL $CURL_URL -File "$CURL_FILE.tar.xz" -Hash $CURL_HASH)) {
exit 1
}
if (!(DecompressTar -URL "https://mirror.ghproxy.com/$QUICTLS_URL" -File "$QUICTLS_FILE.tar.gz" -Hash $QUICTLS_HASH)) {
exit 1
}