diff options
| author | yurybura <yurybura@gmail.com> | 2018-05-11 13:33:49 +0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2018-05-11 13:33:49 +0300 |
| commit | 9535a5631ac212b1c657a02be3ed9398df30c96c (patch) | |
| tree | a1124b7b5d81606c6d7413bb7075e8bdbc6afad3 /scripts/fetchTool.ps1 | |
| parent | 92eb878b3efdb780097178125066a6070869c954 (diff) | |
| parent | 9a19dae13a0fa594245db2df45ec54a504bc82f3 (diff) | |
| download | vcpkg-9535a5631ac212b1c657a02be3ed9398df30c96c.tar.gz vcpkg-9535a5631ac212b1c657a02be3ed9398df30c96c.zip | |
Merge pull request #1 from Microsoft/master
update
Diffstat (limited to 'scripts/fetchTool.ps1')
| -rw-r--r-- | scripts/fetchTool.ps1 | 66 |
1 files changed, 50 insertions, 16 deletions
diff --git a/scripts/fetchTool.ps1 b/scripts/fetchTool.ps1 index 2c2f599ef..eca405b62 100644 --- a/scripts/fetchTool.ps1 +++ b/scripts/fetchTool.ps1 @@ -4,6 +4,7 @@ param( ) Set-StrictMode -Version Latest + $scriptsDir = split-path -parent $script:MyInvocation.MyCommand.Definition . "$scriptsDir\VcpkgPowershellUtils.ps1" @@ -12,6 +13,7 @@ $vcpkgRootDir = vcpkgFindFileRecursivelyUp $scriptsDir .vcpkg-root $downloadsDir = "$vcpkgRootDir\downloads" vcpkgCreateDirectoryIfNotExists $downloadsDir +$downloadsDir = Resolve-Path $downloadsDir function fetchToolInternal([Parameter(Mandatory=$true)][string]$tool) { @@ -22,49 +24,81 @@ function fetchToolInternal([Parameter(Mandatory=$true)][string]$tool) if ($toolData -eq $null) { - throw "Unkown tool $tool" + throw "Unknown tool $tool" } - $exePath = "$downloadsDir\$($toolData.exeRelativePath)" + $toolPath="$downloadsDir\tools\$tool-$($toolData.version)-windows" + $exePath = "$toolPath\$($toolData.exeRelativePath)" if (Test-Path $exePath) { return $exePath } - $isArchive = vcpkgHasProperty -object $toolData -propertyName "archiveRelativePath" + $isArchive = vcpkgHasProperty -object $toolData -propertyName "archiveName" if ($isArchive) { - $downloadPath = "$downloadsDir\$($toolData.archiveRelativePath)" + $downloadPath = "$downloadsDir\$($toolData.archiveName)" } else { - $downloadPath = "$downloadsDir\$($toolData.exeRelativePath)" + $downloadPath = "$toolPath\$($toolData.exeRelativePath)" } - $url = $toolData.url + [String]$url = $toolData.url if (!(Test-Path $downloadPath)) { Write-Host "Downloading $tool..." - vcpkgDownloadFile $url $downloadPath - Write-Host "Downloading $tool has completed successfully." - } - $expectedDownloadedFileHash = $toolData.sha256 - $downloadedFileHash = vcpkgGetSHA256 $downloadPath - vcpkgCheckEqualFileHash -filePath $downloadPath -expectedHash $expectedDownloadedFileHash -actualHash $downloadedFileHash + # Download aria2 with .NET. aria2 will be used to download everything else. + if ($tool -eq "aria2") + { + vcpkgDownloadFile $url $downloadPath $toolData.sha512 + } + else + { + $aria2exe = fetchToolInternal "aria2" + vcpkgDownloadFileWithAria2 $aria2exe $url $downloadPath $toolData.sha512 + } + + Write-Host "Downloading $tool... done." + } + else + { + vcpkgCheckEqualFileHash -url $url -filePath $downloadPath -expectedHash $toolData.sha512 + } if ($isArchive) { - $outFilename = (Get-ChildItem $downloadPath).BaseName Write-Host "Extracting $tool..." - vcpkgExtractFile -File $downloadPath -DestinationDir $downloadsDir -outFilename $outFilename - Write-Host "Extracting $tool has completed successfully." + # Extract 7zip920 with shell because we need it to extract 7zip + # Extract aria2 with shell because we need it to download 7zip + if ($tool -eq "7zip920" -or $tool -eq "aria2") + { + vcpkgExtractZipFile -ArchivePath $downloadPath -DestinationDir $toolPath + } + elseif ($tool -eq "7zip") + { + $sevenZip920 = fetchToolInternal "7zip920" + $ec = vcpkgInvokeCommand "$sevenZip920" "x `"$downloadPath`" -o`"$toolPath`" -y" + if ($ec -ne 0) + { + Write-Host "Could not extract $downloadPath" + throw + } + } + else + { + $sevenZipExe = fetchToolInternal "7zip" + vcpkgExtractFileWith7z -sevenZipExe "$sevenZipExe" -ArchivePath $downloadPath -DestinationDir $toolPath + } + Write-Host "Extracting $tool... done." } if (-not (Test-Path $exePath)) { - throw ("Could not detect or download " + $tool) + Write-Error "Could not detect or download $tool" + throw } return $exePath |
