Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions ports/sdformat6/CONTROL

This file was deleted.

12 changes: 12 additions & 0 deletions ports/sdformat6/disable-unneeded-include-findboost.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
diff --git a/cmake/SearchForStuff.cmake b/cmake/SearchForStuff.cmake
index c2a0ee4..2735a07 100644
--- a/cmake/SearchForStuff.cmake
+++ b/cmake/SearchForStuff.cmake
@@ -13,7 +13,6 @@ if (WIN32)
set(Boost_USE_STATIC_RUNTIME OFF)
endif()

-include(FindBoost)
find_package(Boost ${MIN_BOOST_VERSION})

if (NOT Boost_FOUND)
2 changes: 2 additions & 0 deletions ports/sdformat6/portfile.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ vcpkg_from_github(
REF sdformat6_6.2.0
SHA512 3d139ec4b4c9fbfd547ed8bfca0adb5cdca92c1b7cc4d4b554a7c51ccf755b9079c26a006ebfedc5bc5b1ba5e16ad950bb38c47ea97bf97e59a2fd7d12d60620
HEAD_REF sdf6
PATCHES
disable-unneeded-include-findboost.patch
)

# Ruby is required by the sdformat build process
Expand Down
15 changes: 15 additions & 0 deletions ports/sdformat6/vcpkg.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"name": "sdformat6",
"version": "6.2.0",
"port-version": 2,
"description": "Simulation Description Format (SDF) parser and description files.",
"homepage": "http://sdformat.org/",
"supports": "!(arm | uwp)",
"dependencies": [
"boost-any",
"boost-variant",
"ignition-math4",
"tinyxml",
"urdfdom"
]
}
2 changes: 1 addition & 1 deletion scripts/azure-pipelines/azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
variables:
windows-pool: 'PrWin-2021-04-23'
linux-pool: 'PrLin-2021-04-25'
osx-pool: 'PrOsx-2020-09-28'
osx-pool: 'PrOsx-2021-04-16'

stages:
- stage: FormatChecks
Expand Down
118 changes: 78 additions & 40 deletions scripts/azure-pipelines/osx/Install-Prerequisites.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,7 @@ Installs the set of prerequisites for the macOS CI hosts.
.DESCRIPTION
Install-Prerequisites.ps1 installs all of the necessary prerequisites
to run the vcpkg macOS CI in a vagrant virtual machine,
skipping all prerequisites that are already installed.

.PARAMETER Force
Don't skip the prerequisites that are already installed.
skipping all prerequisites that are already installed and of the right version.

.INPUTS
None
Expand All @@ -20,10 +17,7 @@ None
None
#>
[CmdletBinding()]
Param(
[Parameter()]
[Switch]$Force
)
Param()

Set-StrictMode -Version 2

Expand All @@ -37,21 +31,51 @@ Import-Module "$PSScriptRoot/Utilities.psm1"
$Installables = Get-Content "$PSScriptRoot/configuration/installables.json" | ConvertFrom-Json

$Installables.Applications | ForEach-Object {
if (-not (Get-CommandExists $_.TestCommand)) {
$VersionCommand = $_.VersionCommand
$InstalledVersion = (& $VersionCommand[0] $VersionCommand[1..$VersionCommand.Length])
if (-not $?) {
Write-Host "$($_.Name) not installed; installing now"
} elseif ($Force) {
Write-Host "$($_.Name) found; attempting to upgrade or re-install"
} else {
Write-Host "$($_.Name) already installed"
return
$InstalledVersion = $InstalledVersion -join "`n"
if ($InstalledVersion -match $_.VersionRegex) {
if ($Matches.Count -ne 2) {
Write-Error "$($_.Name) has a malformed version regex ($($_.VersionRegex)); it should have a single capture group
(it has $($Matches.Count - 1))"
throw
}
if ($Matches[1] -eq $_.Version) {
Write-Host "$($_.Name) already installed and at the correct version ($($Matches[1]))"
return
} else {
Write-Host "$($_.Name) already installed but with the incorrect version
installed version: '$($Matches[1])'
required version : '$($_.Version)'
upgrading now."
}
} else {
Write-Warning "$($_.Name)'s version command ($($VersionCommand -join ' ')) returned a value we did not expect:
$InstalledVersion
expected a version matching the regex: $($_.VersionRegex)
Installing anyways."
}
}

$pathToDmg = "~/Downloads/$($_.Name).dmg"
Get-RemoteFile -OutFile $pathToDmg -Uri $_.DmgUrl -Sha256 $_.Sha256
if ($null -ne (Get-Member -InputObject $_ -Name 'DmgUrl')) {
$pathToDmg = "~/Downloads/$($_.Name).dmg"
Get-RemoteFile -OutFile $pathToDmg -Uri $_.DmgUrl -Sha256 $_.Sha256

hdiutil attach $pathToDmg -mountpoint /Volumes/setup-installer
sudo installer -pkg "/Volumes/setup-installer/$($_.InstallerPath)" -target /
hdiutil detach /Volumes/setup-installer
} elseif ($null -ne (Get-Member -InputObject $_ -Name 'PkgUrl')) {
$pathToPkg = "~/Downloads/$($_.Name).pkg"
Get-RemoteFile -OutFile $pathToPkg -Uri $_.PkgUrl -Sha256 $_.Sha256

hdiutil attach $pathToDmg -mountpoint /Volumes/setup-installer
sudo installer -pkg "/Volumes/setup-installer/$($_.InstallerPath)" -target /
hdiutil detach /Volumes/setup-installer
sudo installer -pkg $pathToPkg -target /
} else {
Write-Error "$($_.Name) does not have an installer in the configuration file."
throw
}
}

$Installables.Brew | ForEach-Object {
Expand All @@ -64,31 +88,45 @@ $Installables.Brew | ForEach-Object {
default {
Write-Error "Invalid kind: $_. Expected either empty, or 'cask'."
}
}
}
}
}
}

# Install plugins
$installedExtensionPacks = Get-InstalledVirtualBoxExtensionPacks

$Installables.VBoxExtensions | ForEach-Object {
$extension = $_
$installedExts = $installedExtensionPacks | Where-Object { $_.Pack -eq $extension.FullName -and $_.Usable -eq 'true' }

if ($null -eq $installedExts) {
Write-Host "VBox extension: $($extension.Name) not installed; installing now"
} elseif ($Force) {
Write-Host "VBox extension: $($extension.Name) found; attempting to upgrade or re-install"
brew upgrade

$installedVagrantPlugins = @{}
vagrant plugin list --machine-readable | ForEach-Object {
$timestamp, $target, $type, $data = $_ -split ','
switch ($type) {
# these are not important
'ui' { }
'plugin-version-constraint' { }
'plugin-name' {
$installedVagrantPlugins[$data] = $Null
}
'plugin-version' {
$version = $data -replace '%!\(VAGRANT_COMMA\)',','
if ($version -notmatch '^(.*), global') {
Write-Error "Invalid version string for plugin ${target}: $version"
throw
}
$installedVagrantPlugins[$target] = $Matches[1]
}
default {
Write-Warning "Unknown plugin list member type $type for plugin $target"
}
}
}
$Installables.VagrantPlugins | ForEach-Object {
if (-not $installedVagrantPlugins.Contains($_.Name)) {
Write-Host "$($_.Name) not installed; installing now"
} elseif ($installedVagrantPlugins[$_.Name] -ne $_.Version) {
Write-Host "$($_.Name) already installed but with the incorrect version
installed version: '$($installedVagrantPlugins[$_.Name])'
required version: '$($_.Version)'"
} else {
Write-Host "VBox extension: $($extension.Name) already installed"
Write-Host "$($_.Name) already installed and at the correct version ($($_.Version))"
return
}

$pathToExt = "~/Downloads/$($extension.FullName -replace ' ','_').vbox-extpack"

Get-RemoteFile -OutFile $pathToExt -Uri $extension.Url -Sha256 $extension.Sha256 | Out-Null

Write-Host 'Attempting to install extension with sudo; you may need to enter your password'
sudo VBoxManage extpack install --replace $pathToExt
sudo VBoxManage extpack cleanup
vagrant plugin install $_.Name --plugin-version $_.Version
}
110 changes: 73 additions & 37 deletions scripts/azure-pipelines/osx/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
- [Table of Contents](#table-of-contents)
- [Basic Usage](#basic-usage)
- [Setting up a new macOS machine](#setting-up-a-new-macos-machine)
- [Troubleshooting](#troubleshooting)
- [Creating a new Vagrant box](#creating-a-new-vagrant-box)
- [VM Software Versions](#vm-software-versions)
- [(Internal) Accessing the macOS fileshare](#internal-accessing-the-macos-fileshare)

## Basic Usage

Expand Down Expand Up @@ -70,7 +74,7 @@ for the physical machine; i.e., vcpkgmm-04 would use 04.
$ ./Setup-VagrantMachines.ps1 \
-MachineId XX \
-DevopsPat '<get this from azure devops; it needs agent pool read and manage access>' \
-Date <this is the date of the pool; 2020-09-28 at time of writing>
-Date <this is the date of the pool; 2021-04-16 at time of writing>
$ cd ~/vagrant/vcpkg-eg-mac
$ vagrant up
```
Expand All @@ -89,6 +93,13 @@ $ sudo shutdown -r now

and wait for the machine to start back up. Then, start again from where the error was emitted.

### Troubleshooting

The following are issues that we've run into:

- (with a Parallels box) `vagrant up` doesn't work, and vagrant gives the error that the VM is `'stopped'`.
- Try logging into the GUI with the KVM, and retrying `vagrant up`.

## Creating a new Vagrant box

Whenever we want to install updated versions of the command line tools,
Expand All @@ -100,74 +111,99 @@ you can set up your own vagrant boxes that are the same as ours by doing the fol

You'll need some prerequisites:

- macinbox - installable via `sudo gem install macinbox`
- vagrant - found at <https://www.vagrantup.com/>
- VirtualBox - found at <https://www.virtualbox.org/>
- A macOS installer application - you can get this from the App Store (although I believe only the latest is available)
- An Xcode Command Line Tools installer - you can get this from Apple's developer website,
- The vagrant-parallels plugin - `vagrant plugin install vagrant-parallels`
- Parallels - found at <https://parallels.com>
- An Xcode installer - you can get this from Apple's developer website,
although you'll need to sign in first: <https://developer.apple.com/downloads>

First, you'll need to create a base box;
First, you'll need to create a base VM;
this is where you determine what version of macOS is installed.
Just follow the Parallels process for creating a macOS VM.

Once you've done this, you can run through the installation of macOS onto a new VM.
You should set the username to `vagrant`.

Once it's finished installing, make sure to turn on the SSH server.
Open System Preferences, then go to Sharing > Remote Login,
and turn it on.
You'll then want to add the vagrant SSH keys to the VM's vagrant user.
Open the terminal application and run the following:

```sh
$ # basic stuff
$ date | sudo tee '/etc/vagrant_box_build_time'
$ printf 'vagrant\tALL=(ALL)\tNOPASSWD:\tALL\n' | sudo tee -a '/etc/sudoers.d/vagrant'
$ sudo chmod 0440 '/etc/sudoers.d/vagrant'
$ # then install vagrant keys
$ mkdir -p ~/.ssh
$ curl -fsSL 'https://raw.github.com/mitchellh/vagrant/master/keys/vagrant.pub' >~/.ssh/authorized_keys
$ chmod 0600 ~/.ssh/authorized_keys
```
> sudo macinbox \
--box-format virtualbox \
--name macos-ci-base \
--installer <path to macOS installer> \
--no-gui
```

Once you've done that, create a Vagrantfile that looks like the following:
Finally, you'll need to install the Parallel Tools.
From your host, in the top bar,
go to Actions > Install Parallels Tools...,
and then follow the instructions.

Now, let's package the VM into a base box.
(The following instructions are adapted from
[these official instructions][base-box-instructions]).

```rb
Vagrant.configure('2') do |config|
config.vm.box = 'macos-ci-base'
config.vm.boot_timeout = 600
config.vm.synced_folder ".", "/vagrant", disabled: true
end
Run the following commands:

```sh
$ cd ~/Parallels
$ echo '{ "provider": "parallels" }' >metadata.json
$ tar zgvf <current date>.box ./metadata.json ./<name of VM>.pvm
```

then, run the following in that vagrant directory:
This will create a box file which contains all the necessary data.
You can delete the `metadata.json` file after.

Once you've done that, you can upload it to the fileshare,
under `share/boxes/vcpkg-ci-base`, add it to `share/boxes/vcpkg-ci-base.json`,
and finally add it to vagrant:

```sh
$ vagrant up
$ vagrant scp <path to Command Line Tools for Xcode installer> :clt.dmg
$ vagrant ssh -c 'hdiutil attach clt.dmg -mountpoint /Volumes/setup-installer'
$ vagrant ssh -c 'sudo installer -pkg "/Volumes/setup-installer/Command Line Tools.pkg" -target /'
$ vagrant ssh -c 'hdiutil detach /Volumes/setup-installer'
$ vagrant ssh -c 'rm clt.dmg'
$ vagrant ssh -c '/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"'
$ vagrant reload
$ vagrant box add ~/vagrant/share/boxes/vcpkg-ci-base.json
```

if that works, you can now package the box:
Then, we'll create the final box,
which contains all the necessary programs for doing CI work.
Copy `configuration/Vagrantfile-box.rb` as `Vagrantfile`, and
`configuration/vagrant-box-configuration.json`
into a new directory; into that same directory,
download the Xcode command line tools dmg, and name it `clt.dmg`.
Then, run the following in that directory:

```sh
$ vagrant ssh -c 'umount testmnt && rmdir testmnt'
$ vagrant up
$ vagrant package
```

This will create a `package.box`, which is the box file for the base VM.
Then, you can `vagrant box add <package.box> --name <name for the box>`,
and you'll have the base vcpkg box added for purposes of `Setup-VagrantMachines.ps1`!

Once you've created the base box, if you're making it the new base box for the CI,
upload it to the fileshare, under `share/vcpkg-boxes`.
Then, add the metadata about the box (the name and version) to the JSON file there.
Once you've created this box, if you're making it the new box for the CI,
upload it to the fileshare, under `share/boxes/vcpkg-ci`.
Then, add the metadata about the box (the name and version) to
`share/boxes/vcpkg-ci.json`.
Once you've done that, add the software versions under [VM Software Versions](#vm-software-versions).

[base-box-instructions]: https://parallels.github.io/vagrant-parallels/docs/boxes/base.html

### VM Software Versions

* 2020-09-28:
* macOS: 10.15.6
* Xcode CLTs: 12
* 2021-04-16:
* macOS: 11.2.3
* Xcode CLTs: 12.4

### (Internal) Accessing the macOS fileshare

The fileshare is located on `vcpkgmm-01`, under the `fileshare` user, in the `share` directory.
In order to get `sshfs` working on the physical machine,
you'll need to do the same thing one needs to do for building the base box.
You can run `Install-Prerequisites.ps1` to grab the right software, then either:

```sh
Expand Down
Loading