diff options
Diffstat (limited to 'scripts/fetchDependency.ps1')
| -rw-r--r-- | scripts/fetchDependency.ps1 | 57 |
1 files changed, 36 insertions, 21 deletions
diff --git a/scripts/fetchDependency.ps1 b/scripts/fetchDependency.ps1 index 8d31b0edb..6a40c9758 100644 --- a/scripts/fetchDependency.ps1 +++ b/scripts/fetchDependency.ps1 @@ -1,8 +1,14 @@ [CmdletBinding()] param( - [string]$Dependency + [string]$Dependency, + [ValidateNotNullOrEmpty()] + [string]$downloadPromptOverride = "0" ) +$downloadPromptOverride_NO_OVERRIDE= 0 +$downloadPromptOverride_DO_NOT_PROMPT = 1 +$downloadPromptOverride_ALWAYS_PROMPT = 2 + Import-Module BitsTransfer $scriptsDir = split-path -parent $MyInvocation.MyCommand.Definition @@ -12,9 +18,13 @@ $downloadsDir = "$vcpkgRootDir\downloads" function SelectProgram([Parameter(Mandatory=$true)][string]$Dependency) { - function promptForDownload([string]$title, [string]$message, [string]$yesDescription, [string]$noDescription) + function promptForDownload([string]$title, [string]$message, [string]$yesDescription, [string]$noDescription, [string]$downloadPromptOverride) { - if ((Test-Path "$downloadsDir\AlwaysAllowEverything") -Or (Test-Path "$downloadsDir\AlwaysAllowDownloads")) + $do_not_prompt = ($downloadPromptOverride -eq $downloadPromptOverride_DO_NOT_PROMPT) -Or + (Test-Path "$downloadsDir\AlwaysAllowEverything") -Or + (Test-Path "$downloadsDir\AlwaysAllowDownloads") + + if (($downloadPromptOverride -ne $downloadPromptOverride_ALWAYS_PROMPT) -And $do_not_prompt) { return $true } @@ -57,7 +67,7 @@ function SelectProgram([Parameter(Mandatory=$true)][string]$Dependency) $yesDescription = "Downloads " + $Dependency + " v" + $downloadVersion +" app-locally." $noDescription = "Does not download " + $Dependency + "." - $userAllowedDownload = promptForDownload $title $message $yesDescription $noDescription + $userAllowedDownload = promptForDownload $title $message $yesDescription $noDescription $downloadPromptOverride if (!$userAllowedDownload) { throw [System.IO.FileNotFoundException] ("Could not detect suitable version of " + $Dependency + " and download not allowed") @@ -113,8 +123,11 @@ function SelectProgram([Parameter(Mandatory=$true)][string]$Dependency) function Expand-ZIPFile($file, $destination) { - Write-Host($file) - Write-Host($destination) + if (!(Test-Path $destination)) + { + New-Item -ItemType Directory -Path $destination | Out-Null + } + $shell = new-object -com shell.application $zip = $shell.NameSpace($file) foreach($item in $zip.items()) @@ -126,13 +139,14 @@ function SelectProgram([Parameter(Mandatory=$true)][string]$Dependency) if($Dependency -eq "cmake") { - $requiredVersion = "3.7.2" - $downloadVersion = "3.7.2" - $url = "https://cmake.org/files/v3.7/cmake-3.7.2-win32-x86.zip" - $downloadPath = "$downloadsDir\cmake-3.7.2-win32-x86.zip" - $expectedDownloadedFileHash = "ec5e299d412e0272e01d4de5bf07718f42c96361f83d51cc39f91bf49cc3e5c3" - $executableFromDownload = "$downloadsDir\cmake-3.7.2-win32-x86\bin\cmake.exe" + $requiredVersion = "3.8.0" + $downloadVersion = "3.8.0" + $url = "https://cmake.org/files/v3.8/cmake-3.8.0-rc1-win32-x86.zip" + $downloadPath = "$downloadsDir\cmake-3.8.0-rc1-win32-x86.zip" + $expectedDownloadedFileHash = "ccdbd92fbfb548aa35a545e4e45ff19fd6d13c88c90370acdf940c3cf464e9c9" + $executableFromDownload = "$downloadsDir\cmake-3.8.0-rc1-win32-x86\bin\cmake.exe" $extractionType = $ExtractionType_ZIP + $extractionFolder = $downloadsDir } elseif($Dependency -eq "nuget") { @@ -147,14 +161,15 @@ function SelectProgram([Parameter(Mandatory=$true)][string]$Dependency) elseif($Dependency -eq "git") { $requiredVersion = "2.0.0" - $downloadVersion = "2.11.0" - $url = "https://github.com/git-for-windows/git/releases/download/v2.11.0.windows.3/PortableGit-2.11.0.3-32-bit.7z.exe" # We choose the 32-bit version - $downloadPath = "$downloadsDir\PortableGit-2.11.0.3-32-bit.7z.exe" - $expectedDownloadedFileHash = "8bf3769c37945e991903dd1b988c6b1d97bbf0f3afc9851508974f38bf94dc01" - # There is another copy of git.exe in PortableGit\bin. However, an installed version of git add the cmd dir to the PATH. + $downloadVersion = "2.11.1" + $url = "https://github.com/git-for-windows/git/releases/download/v2.11.1.windows.1/MinGit-2.11.1-32-bit.zip" # We choose the 32-bit version + $downloadPath = "$downloadsDir\MinGit-2.11.1-32-bit.zip" + $expectedDownloadedFileHash = "6ca79af09015625f350ef4ad74a75cfb001b340aec095b6963be9d45becb3bba" + # There is another copy of git.exe in MinGit\bin. However, an installed version of git add the cmd dir to the PATH. # Therefore, choosing the cmd dir here as well. - $executableFromDownload = "$downloadsDir\PortableGit\cmd\git.exe" - $extractionType = $ExtractionType_SELF_EXTRACTING_7Z + $executableFromDownload = "$downloadsDir\MinGit-2.11.1-32-bit\cmd\git.exe" + $extractionType = $ExtractionType_ZIP + $extractionFolder = "$downloadsDir\MinGit-2.11.1-32-bit" } else { @@ -188,8 +203,8 @@ function SelectProgram([Parameter(Mandatory=$true)][string]$Dependency) { if (-not (Test-Path $executableFromDownload)) # consider renaming the extraction folder to make sure the extraction finished { - # Expand-Archive $downloadPath -dest "$downloadsDir" -Force # Requires powershell 5+ - Expand-ZIPFile -File $downloadPath -Destination $downloadsDir + # Expand-Archive $downloadPath -dest "$extractionFolder" -Force # Requires powershell 5+ + Expand-ZIPFile -File $downloadPath -Destination $extractionFolder } } elseif($extractionType -eq $ExtractionType_SELF_EXTRACTING_7Z) |
