1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
|
#!pwsh
#Requires -Version 6.0
<#
.SYNOPSIS
Sets up the configuration for the vagrant virtual machines.
.DESCRIPTION
Setup-VagrantMachines.ps1 sets up the virtual machines for
vcpkg's macOS CI. It puts the VagrantFile and necessary
configuration JSON file into ~/vagrant/vcpkg-eg-mac.
.PARAMETER MachineId
The number to give the machine; should match [0-9]{2}.
.PARAMETER DevopsPat
The personal access token which has Read & Manage permissions on the ADO pool.
.PARAMETER Date
The date on which this pool is being created. Sets the default values for BoxVersion and AgentPool.
.PARAMETER BoxVersion
The version of the box to use. If -Date is passed, uses that as the version.
.PARAMETER AgentPool
The agent pool to add the machine to. If -Date is passed, uses "PrOsx-$Date" as the pool.
.PARAMETER DevopsUrl
The URL of the ADO instance; defaults to vcpkg's, which is https://dev.azure.com/vcpkg.
.PARAMETER ArchivesMachine
The machine where the archives are located; a URN.
.PARAMETER ArchivesPath
The path to where the archives are located on the machine. If -Date is passed,
uses "/Users/${ArchivesUsername}/share/archives/${Date}".
.PARAMETER ArchivesUsername
The user to log in to on the archives machine. Defaults to 'fileshare'.
.PARAMETER BaseName
The base name for the vagrant VM; the machine name is $BaseName-$MachineId.
Defaults to 'vcpkg-eg-mac'.
.PARAMETER BoxName
The name of the box to use. Defaults to 'vcpkg/macos-ci',
which is only available internally.
.PARAMETER Force
Delete any existing vagrant/vcpkg-eg-mac directory.
.PARAMETER DiskSize
The size to make the temporary disks in gigabytes. Defaults to 350.
.INPUTS
None
.OUTPUTS
None
#>
[CmdletBinding(PositionalBinding=$False, DefaultParameterSetName='DefineDate')]
Param(
[Parameter(Mandatory=$True)]
[String]$MachineId,
[Parameter(Mandatory=$True)]
[String]$DevopsPat,
[Parameter(Mandatory=$True, ParameterSetName='DefineDate')]
[String]$Date,
[Parameter(Mandatory=$True, ParameterSetName='DefineVersionAndAgentPool')]
[String]$BoxVersion,
[Parameter(Mandatory=$True, ParameterSetName='DefineVersionAndAgentPool')]
[String]$AgentPool,
[Parameter(Mandatory=$False)]
[String]$DevopsUrl = 'https://dev.azure.com/vcpkg',
[Parameter(Mandatory=$True)]
[String]$ArchivesMachine,
[Parameter(Mandatory=$True, ParameterSetName='DefineVersionAndAgentPool')]
[String]$ArchivesPath,
[Parameter(Mandatory=$False)]
[String]$ArchivesUsername = 'archivesshare',
[Parameter()]
[String]$BaseName = 'vcpkg-eg-mac',
[Parameter()]
[String]$BoxName = 'vcpkg/macos-ci',
[Parameter()]
[Int]$DiskSize = 350,
[Parameter()]
[Switch]$Force
)
Set-StrictMode -Version 2
if (-not $IsMacOS) {
throw 'This script should only be run on a macOS host'
}
if (-not [String]::IsNullOrEmpty($Date)) {
$BoxVersion = $Date
$AgentPool = "PrOsx-$Date"
$ArchivesPath = "/Users/${ArchivesUsername}/share/archives/${Date}"
}
if (Test-Path '~/vagrant/vcpkg-eg-mac') {
if ($Force) {
Write-Host 'Deleting existing directories'
Remove-Item -Recurse -Force -Path '~/vagrant/vcpkg-eg-mac' | Out-Null
} else {
throw '~/vagrant/vcpkg-eg-mac already exists; try re-running with -Force'
}
}
Write-Host 'Creating new directories'
if (-not (Test-Path -Path '~/vagrant')) {
New-Item -ItemType 'Directory' -Path '~/vagrant' | Out-Null
}
New-Item -ItemType 'Directory' -Path '~/vagrant/vcpkg-eg-mac' | Out-Null
Copy-Item `
-Path "$PSScriptRoot/configuration/Vagrantfile" `
-Destination '~/vagrant/vcpkg-eg-mac/Vagrantfile'
$configuration = @{
pat = $DevopsPat;
agent_pool = $AgentPool;
devops_url = $DevopsUrl;
machine_name = "${BaseName}-${MachineId}";
box_name = $BoxName;
box_version = $BoxVersion;
disk_size = $DiskSize;
archives = @{
username = $ArchivesUsername;
urn = $ArchivesMachine;
path = $ArchivesPath;
};
}
ConvertTo-Json -InputObject $configuration -Depth 5 `
| Set-Content -Path '~/vagrant/vcpkg-eg-mac/vagrant-configuration.json'
|