diff options
| author | Alexander Karatarakis <alkarata@microsoft.com> | 2018-04-03 21:05:31 -0700 |
|---|---|---|
| committer | Alexander Karatarakis <alkarata@microsoft.com> | 2018-04-06 17:24:45 -0700 |
| commit | 31377dee20dad9b95357934732996e2448f2eaf5 (patch) | |
| tree | 770015c4607ba633588ee3c1364544f2949026f9 /scripts | |
| parent | 997fddb3c1a3acb7579e1fe0ab82436b227a0dc4 (diff) | |
| download | vcpkg-31377dee20dad9b95357934732996e2448f2eaf5.tar.gz vcpkg-31377dee20dad9b95357934732996e2448f2eaf5.zip | |
Use 7z for extracting. Extract tools in downloads/tools
Diffstat (limited to 'scripts')
| -rw-r--r-- | scripts/VcpkgPowershellUtils.ps1 | 58 | ||||
| -rw-r--r-- | scripts/fetchTool.ps1 | 22 | ||||
| -rw-r--r-- | scripts/vcpkgTools.xml | 20 |
3 files changed, 41 insertions, 59 deletions
diff --git a/scripts/VcpkgPowershellUtils.ps1 b/scripts/VcpkgPowershellUtils.ps1 index 92e0f21d0..988c6dbf0 100644 --- a/scripts/VcpkgPowershellUtils.ps1 +++ b/scripts/VcpkgPowershellUtils.ps1 @@ -1,8 +1,3 @@ -function vcpkgHasModule([Parameter(Mandatory=$true)][string]$moduleName) -{ - return [bool](Get-Module -ListAvailable -Name $moduleName) -} - function vcpkgHasProperty([Parameter(Mandatory=$true)][AllowNull()]$object, [Parameter(Mandatory=$true)]$propertyName) { if ($object -eq $null) @@ -160,54 +155,21 @@ function vcpkgDownloadFile( [Parameter(Mandatory=$true)][string]$url, Move-Item -Path $downloadPartPath -Destination $downloadPath } -function vcpkgExtractFile( [Parameter(Mandatory=$true)][string]$archivePath, - [Parameter(Mandatory=$true)][string]$destinationDir, - [Parameter(Mandatory=$true)][string]$outFilename) +function vcpkgExtractFile( [Parameter(Mandatory=$true)][string]$sevenZipExe, + [Parameter(Mandatory=$true)][string]$archivePath, + [Parameter(Mandatory=$true)][string]$destinationDir) { - vcpkgCreateDirectoryIfNotExists $destinationDir - $output = "$destinationDir\$outFilename" - vcpkgRemoveItem $output - $destinationPartial = "$destinationDir\partially-extracted" - + vcpkgRemoveItem $destinationDir + $destinationPartial = "$destinationDir.partial" vcpkgRemoveItem $destinationPartial vcpkgCreateDirectoryIfNotExists $destinationPartial - - if (vcpkgHasCommand -commandName 'Microsoft.PowerShell.Archive\Expand-Archive') - { - Write-Verbose("Extracting with Microsoft.PowerShell.Archive\Expand-Archive") - Microsoft.PowerShell.Archive\Expand-Archive -path $archivePath -destinationpath $destinationPartial - } - elseif (vcpkgHasCommand -commandName 'Pscx\Expand-Archive') - { - Write-Verbose("Extracting with Pscx\Expand-Archive") - Pscx\Expand-Archive -path $archivePath -OutputPath $destinationPartial - } - else - { - Write-Verbose("Extracting via shell") - $shell = new-object -com shell.application - $zip = $shell.NameSpace($(Get-Item $archivePath).fullname) - foreach($item in $zip.items()) - { - # Piping to Out-Null is used to block until finished - $shell.Namespace($destinationPartial).copyhere($item) | Out-Null - } - } - - $items = @(Get-ChildItem "$destinationPartial") - $itemCount = $items.Count - - if ($itemCount -eq 1) - { - $item = $items | Select-Object -first 1 - Write-Host "$item" - Move-Item -Path "$destinationPartial\$item" -Destination $output - vcpkgRemoveItem $destinationPartial - } - else + $ec = vcpkgInvokeCommand "$sevenZipExe" "x `"$archivePath`" -o`"$destinationPartial`" -y" + if ($ec -ne 0) { - Move-Item -Path "$destinationPartial" -Destination $output + Write-Host "Could not extract $archivePath" + throw } + Rename-Item -Path "$destinationPartial" -NewName $destinationDir } function vcpkgInvokeCommand() diff --git a/scripts/fetchTool.ps1 b/scripts/fetchTool.ps1 index 26eedac3b..315983841 100644 --- a/scripts/fetchTool.ps1 +++ b/scripts/fetchTool.ps1 @@ -25,7 +25,8 @@ function fetchToolInternal([Parameter(Mandatory=$true)][string]$tool) throw "Unkown tool $tool" } - $exePath = "$downloadsDir\$($toolData.exeRelativePath)" + $toolPath="$downloadsDir\tools\$tool-$($toolData.requiredVersion)-windows" + $exePath = "$toolPath\$($toolData.exeRelativePath)" if (Test-Path $exePath) { @@ -39,7 +40,7 @@ function fetchToolInternal([Parameter(Mandatory=$true)][string]$tool) } else { - $downloadPath = "$downloadsDir\$($toolData.exeRelativePath)" + $downloadPath = "$toolPath\$($toolData.exeRelativePath)" } [String]$url = $toolData.url @@ -56,9 +57,22 @@ function fetchToolInternal([Parameter(Mandatory=$true)][string]$tool) if ($isArchive) { - $outFilename = (Get-ChildItem $downloadPath).BaseName Write-Host "Extracting $tool..." - vcpkgExtractFile -ArchivePath $downloadPath -DestinationDir $downloadsDir -outFilename $outFilename + if ($tool -eq "7zip") + { + $sevenZipR = fetchToolInternal "7zr" + $ec = vcpkgInvokeCommand "$sevenZipR" "x `"$downloadPath`" -o`"$toolPath`" -y" + if ($ec -ne 0) + { + Write-Host "Could not extract $downloadPath" + throw + } + } + else + { + $sevenZipExe = fetchToolInternal "7zip" + vcpkgExtractFile -sevenZipExe "$sevenZipExe" -ArchivePath $downloadPath -DestinationDir $toolPath + } Write-Host "Extracting $tool... done." } diff --git a/scripts/vcpkgTools.xml b/scripts/vcpkgTools.xml index 477584c5a..6ef1e4d35 100644 --- a/scripts/vcpkgTools.xml +++ b/scripts/vcpkgTools.xml @@ -23,20 +23,20 @@ </tool> <tool name="git"> <requiredVersion>2.16.2</requiredVersion> - <exeRelativePath>MinGit-2.16.2-32-bit\cmd\git.exe</exeRelativePath> + <exeRelativePath>cmd\git.exe</exeRelativePath> <url>https://github.com/git-for-windows/git/releases/download/v2.16.2.windows.1/MinGit-2.16.2-32-bit.zip</url> <sha256>322c727e482aa97522c64a5ac68bdda3780111e8670bcfb532beac8e11ece5da</sha256> <archiveRelativePath>MinGit-2.16.2-32-bit.zip</archiveRelativePath> </tool> <tool name="vswhere"> <requiredVersion>2.3.2</requiredVersion> - <exeRelativePath>vswhere-2.3.2\vswhere.exe</exeRelativePath> + <exeRelativePath>vswhere.exe</exeRelativePath> <url>https://github.com/Microsoft/vswhere/releases/download/2.3.2/vswhere.exe</url> <sha256>103f2784c4b2c8e70c7c1c03687abbf22bce052aae30639406e4e13ffa29ee04</sha256> </tool> <tool name="nuget"> <requiredVersion>4.4.0</requiredVersion> - <exeRelativePath>nuget-4.4.0\nuget.exe</exeRelativePath> + <exeRelativePath>nuget.exe</exeRelativePath> <url>https://dist.nuget.org/win-x86-commandline/v4.4.0/nuget.exe</url> <sha256>2cf9b118937eef825464e548f0c44f7f64090047746de295d75ac3dcffa3e1f6</sha256> </tool> @@ -49,10 +49,16 @@ </tool> <tool name="7zip"> <requiredVersion>18.01.0</requiredVersion> - <exeRelativePath>7za920\7za.exe</exeRelativePath> - <url>http://www.7-zip.org/a/7za920.zip</url> - <sha256>2a3afe19c180f8373fa02ff00254d5394fec0349f5804e0ad2f6067854ff28ac</sha256> - <archiveRelativePath>7za920.zip</archiveRelativePath> + <exeRelativePath>7za.exe</exeRelativePath> + <url>https://www.7-zip.org/a/7z1801-extra.7z</url> + <sha256>9371df22bcd0e1aff9eaa52aa3292350eecd011f11494e709314ae3f3eb279e2</sha256> + <archiveRelativePath>7z1801-extra.7z</archiveRelativePath> + </tool> + <tool name="7zr"> + <requiredVersion>18.01.0</requiredVersion> + <exeRelativePath>7zr.exe</exeRelativePath> + <url>https://www.7-zip.org/a/7zr.exe</url> + <sha256>2c7a8709260e0295a2a3cfd5a8ad0459f37490ed1794ea68bf85a6fab362553b</sha256> </tool> <tool name="ninja" os="linux"> <requiredVersion>1.8.2</requiredVersion> |
