aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Karatarakis <alkarata@microsoft.com>2017-11-17 01:23:14 -0800
committerAlexander Karatarakis <alkarata@microsoft.com>2017-11-17 01:23:14 -0800
commit6290155eaaff1bd70ec9a893b090adea473effa8 (patch)
tree784ea908c7c13da2e76563bbea413d7049a98d21
parentc4ca996583c61d311bf15c40dbbb261ce5f59047 (diff)
downloadvcpkg-6290155eaaff1bd70ec9a893b090adea473effa8.tar.gz
vcpkg-6290155eaaff1bd70ec9a893b090adea473effa8.zip
[vcpkgExtractFile] Fix partial dir name. Special case 1-item zips
- If the zip contains a single item, pull that up a directory - If the zip contains multiple items, place that in a directory on of the same name as the zip
-rw-r--r--scripts/VcpkgPowershellUtils.ps123
-rw-r--r--scripts/fetchDependency.ps15
2 files changed, 18 insertions, 10 deletions
diff --git a/scripts/VcpkgPowershellUtils.ps1 b/scripts/VcpkgPowershellUtils.ps1
index 12eacec96..0b1a35262 100644
--- a/scripts/VcpkgPowershellUtils.ps1
+++ b/scripts/VcpkgPowershellUtils.ps1
@@ -141,11 +141,13 @@ function vcpkgDownloadFile( [Parameter(Mandatory=$true)][string]$url,
}
function vcpkgExtractFile( [Parameter(Mandatory=$true)][string]$file,
- [Parameter(Mandatory=$true)][string]$destination)
+ [Parameter(Mandatory=$true)][string]$destinationDir)
{
- vcpkgCreateDirectory $destination
- $baseName = (Get-ChildItem .\downloads\cmake-3.9.5-win32-x86.zip).BaseName
- $destinationPartial = "$destination\$baseName-partially_extracted"
+ $parentPath = split-path -parent $destinationDir
+ vcpkgCreateDirectory $parentPath
+ $baseName = (Get-ChildItem $file).BaseName
+ $destinationPartial = "$destinationDir\$baseName-partially_extracted"
+
vcpkgRemoveDirectory $destinationPartial
vcpkgCreateDirectory $destinationPartial
@@ -171,8 +173,17 @@ function vcpkgExtractFile( [Parameter(Mandatory=$true)][string]$file,
}
}
- Move-Item -Path "$destinationPartial\*" -Destination $destination
- vcpkgRemoveDirectory $destinationPartial
+ $hasASingleItem = (Get-ChildItem $destinationPartial | Measure-Object).Count -eq 1;
+
+ if ($hasASingleItem)
+ {
+ Move-Item -Path "$destinationPartial\*" -Destination $destinationDir
+ vcpkgRemoveDirectory $destinationPartial
+ }
+ else
+ {
+ Rename-Item -Path $destinationPartial -NewName $baseName
+ }
}
function vcpkgInvokeCommand()
diff --git a/scripts/fetchDependency.ps1 b/scripts/fetchDependency.ps1
index 2cc782feb..596845acb 100644
--- a/scripts/fetchDependency.ps1
+++ b/scripts/fetchDependency.ps1
@@ -27,7 +27,6 @@ function SelectProgram([Parameter(Mandatory=$true)][string]$Dependency)
$expectedDownloadedFileHash = "dd3e183254c12f7c338d3edfa642f1ac84a763b8b9a2feabb4ad5fccece5dff9"
$executableFromDownload = "$downloadsDir\cmake-3.9.5-win32-x86\bin\cmake.exe"
$extractionType = $ExtractionType_ZIP
- $extractionFolder = $downloadsDir
}
elseif($Dependency -eq "nuget")
{
@@ -60,7 +59,6 @@ function SelectProgram([Parameter(Mandatory=$true)][string]$Dependency)
# Therefore, choosing the cmd dir here as well.
$executableFromDownload = "$downloadsDir\MinGit-2.15.0-32-bit\cmd\git.exe"
$extractionType = $ExtractionType_ZIP
- $extractionFolder = "$downloadsDir\MinGit-2.15.0-32-bit"
}
elseif($Dependency -eq "installerbase")
{
@@ -71,7 +69,6 @@ function SelectProgram([Parameter(Mandatory=$true)][string]$Dependency)
$expectedDownloadedFileHash = "f2ce23cf5cf9fc7ce409bdca49328e09a070c0026d3c8a04e4dfde7b05b83fe8"
$executableFromDownload = "$downloadsDir\QtInstallerFramework-win-x86\bin\installerbase.exe"
$extractionType = $ExtractionType_ZIP
- $extractionFolder = $downloadsDir
}
else
{
@@ -91,7 +88,7 @@ function SelectProgram([Parameter(Mandatory=$true)][string]$Dependency)
{
if (-not (Test-Path $executableFromDownload))
{
- vcpkgExtractFile -File $downloadPath -Destination $extractionFolder
+ vcpkgExtractFile -File $downloadPath -DestinationDir $downloadsDir
}
}
elseif($extractionType -eq $ExtractionType_SELF_EXTRACTING_7Z)