diff options
| author | Billy O'Neal <bion@microsoft.com> | 2020-05-19 13:43:30 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-05-19 13:43:30 -0700 |
| commit | 3b0080e3b0d395de7551cc2ce1ec89189e539eab (patch) | |
| tree | d0a6877c62dc90eab4a7ac1d7b9530985522cca9 /scripts | |
| parent | e806b2ed384fce2487562371fb32d9528d0c178a (diff) | |
| download | vcpkg-3b0080e3b0d395de7551cc2ce1ec89189e539eab.tar.gz vcpkg-3b0080e3b0d395de7551cc2ce1ec89189e539eab.zip | |
[vcpkg] Harden file removals and clean directory contents in "CI" inside vcpkg itself. (#11432)
`files.h/files.cpp`:
* Add end and else comments to all macros.
* Add "remove_all_inside" function which empties a directory without actually deleting the directory. This is necessary to handle the case where the directory is actually a directory symlink.
* Change remove_all to use std::remove when VCPKG_USE_STD_FILESYSTEM is set; this will engage POSIX delete support available on current Win10.
`commands.ci.cpp`: empty "installed".
`*/initialize_environment.*`: No longer clean the directories outside the tool.
`ci-step.ps1`: Remove unused console output tee-ing.
Diffstat (limited to 'scripts')
5 files changed, 17 insertions, 37 deletions
diff --git a/scripts/azure-pipelines/linux/initialize-environment.sh b/scripts/azure-pipelines/linux/initialize-environment.sh index 5346345a5..1cbdd3326 100755 --- a/scripts/azure-pipelines/linux/initialize-environment.sh +++ b/scripts/azure-pipelines/linux/initialize-environment.sh @@ -6,7 +6,3 @@ if [ ! -d "archives" ]; then ln -s /archives archives fi - -rm -rf installed -rm -rf buildtrees -rm -rf packages/* diff --git a/scripts/azure-pipelines/osx/initialize-environment.sh b/scripts/azure-pipelines/osx/initialize-environment.sh index 5eeba4255..6f42a809a 100755 --- a/scripts/azure-pipelines/osx/initialize-environment.sh +++ b/scripts/azure-pipelines/osx/initialize-environment.sh @@ -4,29 +4,20 @@ # Sets up the environment for MacOS runs of vcpkg CI -rm -rf installed || true mkdir -p ~/Data/installed || true ln -s ~/Data/installed -rm -rf ~/Data/installed/* || true -rm -rf buildtrees || true mkdir -p ~/Data/buildtrees || true ln -s ~/Data/buildtrees -rm -rf ~/Data/buildtrees/* || true -rm -rf packages || true mkdir -p ~/Data/packages || true ln -s ~/Data/packages -rm -rf ~/Data/packages/* || true rm archives || rm -rf archives || true ln -s ~/Data/archives -rm -rf downloads || true mkdir -p ~/Data/downloads || true ln -s ~/Data/downloads -if [ -d downloads/ ]; then #delete downloaded files that have not been used in 7 days find downloads/ -maxdepth 1 -type f ! -atime 7 -exec rm -f {} \; -fi diff --git a/scripts/azure-pipelines/windows/azure-pipelines.yml b/scripts/azure-pipelines/windows/azure-pipelines.yml index 71ffc7828..9d4de6794 100644 --- a/scripts/azure-pipelines/windows/azure-pipelines.yml +++ b/scripts/azure-pipelines/windows/azure-pipelines.yml @@ -41,12 +41,6 @@ jobs: cp $xmlPath $(Build.ArtifactStagingDirectory)
Move-Item $xmlPath -Destination $outputXmlPath
- # already in DevOps, no need for extra copies
- rm $(System.DefaultWorkingDirectory)\console-out.txt -ErrorAction Ignore
-
- Remove-Item "$(System.DefaultWorkingDirectory)\buildtrees\*" -Recurse -errorAction silentlycontinue
- Remove-Item "$(System.DefaultWorkingDirectory)\packages\*" -Recurse -errorAction silentlycontinue
- Remove-Item "$(System.DefaultWorkingDirectory)\installed\*" -Recurse -errorAction silentlycontinue
displayName: 'Collect logs and cleanup build'
- task: PowerShell@2
diff --git a/scripts/azure-pipelines/windows/ci-step.ps1 b/scripts/azure-pipelines/windows/ci-step.ps1 index 0e07895e0..f0aee4dfd 100644 --- a/scripts/azure-pipelines/windows/ci-step.ps1 +++ b/scripts/azure-pipelines/windows/ci-step.ps1 @@ -125,14 +125,13 @@ if (!$?) { throw "bootstrap failed" } Write-Host "Bootstrapping vcpkg ... done." $ciXmlPath = "$vcpkgRootDir\test-full-ci.xml" -$consoleOuputPath = "$vcpkgRootDir\console-out.txt" Remove-VcpkgItem $ciXmlPath $env:VCPKG_FEATURE_FLAGS = "binarycaching" if (![string]::IsNullOrEmpty($OnlyIncludePorts)) { ./vcpkg install --triplet $Triplet $OnlyIncludePorts $AdditionalVcpkgFlags ` - "--x-xunit=$ciXmlPath" | Tee-Object -FilePath "$consoleOuputPath" + "--x-xunit=$ciXmlPath" } else { $exclusions = "" @@ -155,9 +154,6 @@ else { | ForEach-Object { if ($_ -is [System.Management.Automation.ErrorRecord]) { $_.ToString() } else { $_ } } - - # Phasing out the console output (it is already saved in DevOps) Create a dummy file for now. - Set-Content -LiteralPath "$consoleOuputPath" -Value '' } Write-Host "CI test is complete" diff --git a/scripts/azure-pipelines/windows/initialize-environment.ps1 b/scripts/azure-pipelines/windows/initialize-environment.ps1 index 4bbc15665..8b1d8e8e4 100644 --- a/scripts/azure-pipelines/windows/initialize-environment.ps1 +++ b/scripts/azure-pipelines/windows/initialize-environment.ps1 @@ -68,21 +68,24 @@ else }
Write-Host "Linking archives => $archivesPath"
-Remove-DirectorySymlink archives
-cmd /c "mklink /D archives $archivesPath"
+if (-Not (Test-Path archives)) {
+ cmd /c "mklink /D archives $archivesPath"
+}
Write-Host 'Linking installed => E:\installed'
-Remove-DirectorySymlink installed
-Remove-Item E:\installed -Recurse -Force -ErrorAction SilentlyContinue
-mkdir E:\installed
-cmd /c "mklink /D installed E:\installed"
+if (-Not (Test-Path E:\installed)) {
+ mkdir E:\installed
+}
-Write-Host 'Linking downloads => D:\downloads'
-Remove-DirectorySymlink downloads
-cmd /c "mklink /D downloads D:\downloads"
+if (-Not (Test-Path installed)) {
+ cmd /c "mklink /D installed E:\installed"
+}
-Write-Host 'Cleaning buildtrees'
-Remove-Item buildtrees\* -Recurse -Force -errorAction silentlycontinue
+Write-Host 'Linking downloads => D:\downloads'
+if (-Not (Test-Path D:\downloads)) {
+ mkdir D:\downloads
+}
-Write-Host 'Cleaning packages'
-Remove-Item packages\* -Recurse -Force -errorAction silentlycontinue
+if (-Not (Test-Path downloads)) {
+ cmd /c "mklink /D downloads D:\downloads"
+}
|
