aboutsummaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorAlexander Karatarakis <alkarata@microsoft.com>2018-04-03 22:15:17 -0700
committerAlexander Karatarakis <alkarata@microsoft.com>2018-04-06 17:24:45 -0700
commit54c68da907e4881d29e8017e085e6786e1c34ace (patch)
treee45160ad783ed485e44ae61e33094e6b66e79b56 /scripts
parent31377dee20dad9b95357934732996e2448f2eaf5 (diff)
downloadvcpkg-54c68da907e4881d29e8017e085e6786e1c34ace.tar.gz
vcpkg-54c68da907e4881d29e8017e085e6786e1c34ace.zip
Use aria2 to do downloads (other than aria2 itself, 7za and 7zr)
Diffstat (limited to 'scripts')
-rw-r--r--scripts/VcpkgPowershellUtils.ps126
-rw-r--r--scripts/fetchTool.ps113
-rw-r--r--scripts/vcpkgTools.xml7
3 files changed, 45 insertions, 1 deletions
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 @@
<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>