From 54c68da907e4881d29e8017e085e6786e1c34ace Mon Sep 17 00:00:00 2001 From: Alexander Karatarakis Date: Tue, 3 Apr 2018 22:15:17 -0700 Subject: Use aria2 to do downloads (other than aria2 itself, 7za and 7zr) --- scripts/VcpkgPowershellUtils.ps1 | 26 ++++++++++++++++++++++++++ scripts/fetchTool.ps1 | 13 ++++++++++++- scripts/vcpkgTools.xml | 7 +++++++ 3 files changed, 45 insertions(+), 1 deletion(-) (limited to 'scripts') diff --git a/scripts/VcpkgPowershellUtils.ps1 b/scripts/VcpkgPowershellUtils.ps1 index 988c6dbf0..7082ca747 100644 --- a/scripts/VcpkgPowershellUtils.ps1 +++ b/scripts/VcpkgPowershellUtils.ps1 @@ -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) diff --git a/scripts/fetchTool.ps1 b/scripts/fetchTool.ps1 index 315983841..05335c724 100644 --- a/scripts/fetchTool.ps1 +++ b/scripts/fetchTool.ps1 @@ -47,7 +47,18 @@ function fetchToolInternal([Parameter(Mandatory=$true)][string]$tool) if (!(Test-Path $downloadPath)) { Write-Host "Downloading $tool..." - vcpkgDownloadFile $url $downloadPath + + # 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." } diff --git a/scripts/vcpkgTools.xml b/scripts/vcpkgTools.xml index 6ef1e4d35..fe1cc12a9 100644 --- a/scripts/vcpkgTools.xml +++ b/scripts/vcpkgTools.xml @@ -60,6 +60,13 @@ https://www.7-zip.org/a/7zr.exe 2c7a8709260e0295a2a3cfd5a8ad0459f37490ed1794ea68bf85a6fab362553b + + 18.01.0 + aria2-1.33.1-win-32bit-build1\aria2c.exe + https://github.com/aria2/aria2/releases/download/release-1.33.1/aria2-1.33.1-win-32bit-build1.zip + 04bf07c0449c703db17fbcd586365aebba00201ca513ca4808b543f1f9208f1f + aria2-1.33.1-win-32bit-build1.zip + 1.8.2 ninja -- cgit v1.2.3