mirror of
https://github.com/microsoft/vcpkg.git
synced 2024-11-28 16:35:05 +08:00
Use aria2 to do downloads (other than aria2 itself, 7za and 7zr)
This commit is contained in:
parent
31377dee20
commit
54c68da907
@ -155,6 +155,32 @@ function vcpkgDownloadFile( [Parameter(Mandatory=$true)][string]$url,
|
||||
Move-Item -Path $downloadPartPath -Destination $downloadPath
|
||||
}
|
||||
|
||||
function vcpkgDownloadFileWithAria2( [Parameter(Mandatory=$true)][string]$aria2exe,
|
||||
[Parameter(Mandatory=$true)][string]$url,
|
||||
[Parameter(Mandatory=$true)][string]$downloadPath)
|
||||
{
|
||||
if (Test-Path $downloadPath)
|
||||
{
|
||||
return
|
||||
}
|
||||
|
||||
vcpkgCreateParentDirectoryIfNotExists $downloadPath
|
||||
$downloadPartPath = "$downloadPath.part"
|
||||
vcpkgRemoveItem $downloadPartPath
|
||||
|
||||
$parentDir = split-path -parent $downloadPath
|
||||
$filename = split-path -leaf $downloadPath
|
||||
|
||||
$ec = vcpkgInvokeCommand "$aria2exe" "--dir `"$parentDir`" --out `"$filename.part`" $url"
|
||||
if ($ec -ne 0)
|
||||
{
|
||||
Write-Host "Could not download $url"
|
||||
throw
|
||||
}
|
||||
|
||||
Move-Item -Path $downloadPartPath -Destination $downloadPath
|
||||
}
|
||||
|
||||
function vcpkgExtractFile( [Parameter(Mandatory=$true)][string]$sevenZipExe,
|
||||
[Parameter(Mandatory=$true)][string]$archivePath,
|
||||
[Parameter(Mandatory=$true)][string]$destinationDir)
|
||||
|
@ -47,7 +47,18 @@ function fetchToolInternal([Parameter(Mandatory=$true)][string]$tool)
|
||||
if (!(Test-Path $downloadPath))
|
||||
{
|
||||
Write-Host "Downloading $tool..."
|
||||
|
||||
# aria2 needs 7zip & 7zr to extract. So, we need to download those trough powershell
|
||||
if ($tool -eq "aria2" -or $tool -eq "7zip" -or $tool -eq "7zr")
|
||||
{
|
||||
vcpkgDownloadFile $url $downloadPath
|
||||
}
|
||||
else
|
||||
{
|
||||
$aria2exe = fetchToolInternal "aria2"
|
||||
vcpkgDownloadFileWithAria2 $aria2exe $url $downloadPath
|
||||
}
|
||||
|
||||
Write-Host "Downloading $tool... done."
|
||||
}
|
||||
|
||||
|
@ -60,6 +60,13 @@
|
||||
<url>https://www.7-zip.org/a/7zr.exe</url>
|
||||
<sha256>2c7a8709260e0295a2a3cfd5a8ad0459f37490ed1794ea68bf85a6fab362553b</sha256>
|
||||
</tool>
|
||||
<tool name="aria2">
|
||||
<requiredVersion>18.01.0</requiredVersion>
|
||||
<exeRelativePath>aria2-1.33.1-win-32bit-build1\aria2c.exe</exeRelativePath>
|
||||
<url>https://github.com/aria2/aria2/releases/download/release-1.33.1/aria2-1.33.1-win-32bit-build1.zip</url>
|
||||
<sha256>04bf07c0449c703db17fbcd586365aebba00201ca513ca4808b543f1f9208f1f</sha256>
|
||||
<archiveRelativePath>aria2-1.33.1-win-32bit-build1.zip</archiveRelativePath>
|
||||
</tool>
|
||||
<tool name="ninja" os="linux">
|
||||
<requiredVersion>1.8.2</requiredVersion>
|
||||
<exeRelativePath>ninja</exeRelativePath>
|
||||
|
Loading…
Reference in New Issue
Block a user