-
Notifications
You must be signed in to change notification settings - Fork 7.7k
[vcpkg ci] add macos scripts to vcpkg repo #12172
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 2 commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -334,3 +334,4 @@ __pycache__/ | |
| archives | ||
| .DS_Store | ||
| prefab/ | ||
| *.swp | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,63 @@ | ||
| #!pwsh | ||
| #Requires -Version 6.0 | ||
|
|
||
| <##> | ||
| [CmdletBinding()] | ||
| Param( | ||
| [Parameter()] | ||
| [Switch]$Force | ||
| ) | ||
|
|
||
| Set-StrictMode -Version 2 | ||
|
|
||
| if (-not $IsMacOS) { | ||
| Write-Error 'This script should only be run on a macOS host' | ||
| throw | ||
|
strega-nil marked this conversation as resolved.
|
||
| } | ||
|
|
||
| Import-Module "$PSScriptRoot/Utilities.psm1" | ||
|
|
||
| $Installables = Get-Content "$PSScriptRoot/configuration/installables.json" | ConvertFrom-Json | ||
|
|
||
| $Installables.Applications | ForEach-Object { | ||
| if (-not (Get-CommandExists $_.TestCommand)) { | ||
| 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 | ||
| } | ||
|
|
||
| $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 | ||
| } | ||
|
|
||
| # Install plugins | ||
| $installedExtensionPacks = VBoxManage list extpacks | ConvertFrom-VirtualBoxExtensionPacks | ||
|
|
||
| $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" | ||
| } else { | ||
| Write-Host "VBox extension: $($extension.Name) already installed" | ||
| 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 | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,69 @@ | ||
| # `vcpkg-eg-mac` VMs | ||
|
|
||
| ## Table of Contents | ||
|
|
||
| - [`vcpkg-eg-mac` VMs](#vcpkg-eg-mac-vms) | ||
| - [Table of Contents](#table-of-contents) | ||
| - [Basic Usage](#basic-usage) | ||
| - [Setting up a new macOS machine](#setting-up-a-new-macos-machine) | ||
|
|
||
| ## Basic Usage | ||
|
|
||
| The simplest usage, and one which should be used for when spinning up | ||
| new VMs, and when restarting old ones, is a simple: | ||
|
|
||
| ``` | ||
| $ cd ~/vagrant/vcpkg-eg-mac | ||
| $ vagrant up | ||
| ``` | ||
|
|
||
| Any modifications to the machines should be made in `configuration/VagrantFile` | ||
| and `Setup-VagrantMachines.ps1`, and make sure to push any changes! | ||
|
|
||
| ## Setting up a new macOS machine | ||
|
|
||
| Before anything else, one must download `brew` and `powershell`. | ||
|
|
||
| ```sh | ||
| $ /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" | ||
| $ brew cask install powershell | ||
| ``` | ||
|
|
||
| Then, we need to download the `vcpkg` repository: | ||
|
|
||
| ```sh | ||
| $ git clone https://github.com/microsoft/vcpkg | ||
| ``` | ||
|
|
||
| And now all we need to do is set it up! Replace `XX` with the number of | ||
| the virtual machine. Generally, that should be the same as the number | ||
| for the physical machine; i.e., vcpkgmm-04 will have vcpkg-eg-mac-04. | ||
|
|
||
| ```sh | ||
| $ cd vcpkg/scripts/azure-pipelines/osx | ||
| $ ./Install-Prerequisites.ps1 -Force | ||
| # NOTE: you may get an error about CoreCLR; see the following paragraph if you do | ||
| $ ./Setup-VagrantMachines.ps1 XX \ | ||
| -Pat '<get this from azure>' \ | ||
| -ArchivesUsername '<get this from the archives share>' \ | ||
| -ArchivesAccessKey '<get this from the archives share>' \ | ||
| -ArchivesUri '<something>.file.core.windows.net' \ | ||
| -ArchivesShare 'archives' | ||
| $ cd ~/vagrant/vcpkg-eg-mac | ||
| $ vagrant up | ||
| ``` | ||
|
|
||
| If you see the following error: | ||
|
|
||
| ``` | ||
| Failed to initialize CoreCLR, HRESULT: 0x8007001F | ||
| ``` | ||
|
|
||
| You have to reboot the machine; run | ||
|
|
||
| ```sh | ||
| $ sudo shutdown -r now | ||
| ``` | ||
|
|
||
| and wait for the machine to start back up. Then, start again from | ||
| `Install-Prerequisites.ps1`. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,71 @@ | ||
| #!pwsh | ||
| #Requires -Version 6.0 | ||
|
|
||
| <##> | ||
| [CmdletBinding(PositionalBinding=$False)] | ||
| Param( | ||
| [Parameter(Mandatory=$True)] | ||
| [String]$Pat, | ||
|
|
||
| [Parameter(Mandatory=$True)] | ||
| [String]$ArchivesUsername, | ||
|
|
||
| [Parameter(Mandatory=$True)] | ||
| [String]$ArchivesAccessKey, | ||
|
|
||
| [Parameter(Mandatory=$True)] | ||
| [String]$ArchivesUri, | ||
|
|
||
| [Parameter(Mandatory=$True)] | ||
| [String]$ArchivesShare, | ||
|
strega-nil marked this conversation as resolved.
|
||
|
|
||
| [Parameter()] | ||
| [String]$BaseName = 'vcpkg-eg-mac', | ||
|
strega-nil marked this conversation as resolved.
|
||
|
|
||
| [Parameter()] | ||
| [Switch]$Force, | ||
|
|
||
| [Parameter()] | ||
| [Int]$DiskSize = 425, | ||
|
|
||
| [Parameter(Mandatory=$True, ValueFromRemainingArguments)] | ||
| [String[]]$MachineIdentifiers | ||
| ) | ||
|
|
||
| Set-StrictMode -Version 2 | ||
|
|
||
| if (-not $IsMacOS) { | ||
| throw 'This script should only be run on a macOS host' | ||
| } | ||
|
|
||
| if (Test-Path '~/vagrant') { | ||
| if ($Force) { | ||
| Write-Host 'Deleting existing directories' | ||
| Remove-Item -Recurse -Force -Path '~/vagrant' | Out-Null | ||
| } else { | ||
| throw '~/vagrant already exists; try re-running with -Force' | ||
| } | ||
| } | ||
|
|
||
| Write-Host 'Creating new directories' | ||
| 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 = $Pat; | ||
| base_name = $BaseName; | ||
| machine_identifiers = $MachineIdentifiers; | ||
| disk_size = $DiskSize; | ||
| archives = @{ | ||
| username = $ArchivesUsername; | ||
| access_key = $ArchivesAccessKey; | ||
| url = $ArchivesUri; | ||
| share = $ArchivesShare; | ||
| }; | ||
| } | ||
| ConvertTo-Json -InputObject $configuration -Depth 5 ` | ||
| | Set-Content -Path '~/vagrant/vcpkg-eg-mac/vagrant-configuration.json' | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,108 @@ | ||
| #Requires -Version 6.0 | ||
| Set-StrictMode -Version 2 | ||
|
|
||
| <# | ||
| .SYNOPSIS | ||
| Returns whether the specified command exists in the current environment. | ||
|
|
||
| .DESCRIPTION | ||
| Get-CommandExists takes a string as a parameter, | ||
| and returns whether it exists in the current environment; | ||
| either a function, alias, or an executable in the path. | ||
| It's somewhat equivalent to `which`. | ||
|
|
||
| .PARAMETER Name | ||
| Specifies the name of the command which may or may not exist. | ||
|
|
||
| .INPUTS | ||
| System.String | ||
| The name of the command. | ||
|
|
||
| .OUTPUTS | ||
| System.Boolean | ||
| Whether the command exists. | ||
| #> | ||
| function Get-CommandExists | ||
| { | ||
| [CmdletBinding()] | ||
| [OutputType([Boolean])] | ||
| Param( | ||
| [Parameter(ValueFromPipeline)] | ||
| [String]$Name | ||
| ) | ||
|
|
||
| $null -ne (Get-Command -Name $Command -ErrorAction SilentlyContinue) | ||
| } | ||
|
|
||
| <##> | ||
| function Get-RemoteFile | ||
|
BillyONeal marked this conversation as resolved.
|
||
| { | ||
| [CmdletBinding(PositionalBinding=$False)] | ||
| [OutputType([System.IO.FileInfo])] | ||
| Param( | ||
| [Parameter(Mandatory=$True)] | ||
| [String]$OutFile, | ||
| [Parameter(Mandatory=$True)] | ||
| [String]$Uri, | ||
| [Parameter(Mandatory=$True)] | ||
| [String]$Sha256 | ||
| ) | ||
|
|
||
| Invoke-WebRequest -OutFile $OutFile -Uri $Uri | ||
| $actualHash = Get-FileHash -Algorithm SHA256 -Path $OutFile | ||
|
|
||
| if ($actualHash.Hash -ne $Sha256) { | ||
| throw @" | ||
| Invalid hash for file $OutFile; | ||
| expected: $Hash | ||
| found: $($actualHash.Hash) | ||
| Please make sure that the hash in the powershell file is correct. | ||
| "@ | ||
| } | ||
|
|
||
| Get-Item $OutFile | ||
| } | ||
|
|
||
| <##> | ||
| function ConvertFrom-VirtualBoxExtensionPacks | ||
| { | ||
| [CmdletBinding()] | ||
| [OutputType([PSCustomObject])] | ||
| Param( | ||
| [Parameter(ValueFromPipeline)] | ||
| [String]$Line | ||
| ) | ||
|
|
||
| Begin { | ||
| $currentObject = $null | ||
| $currentKey = "" | ||
| $currentString = "" | ||
| } | ||
|
|
||
| Process { | ||
| if ($Line[0] -eq ' ') { | ||
| $currentString += "`n$($Line.Trim())" | ||
| } else { | ||
| if ($null -ne $currentObject) { | ||
| $currentObject.$currentKey = $currentString | ||
| } | ||
| $currentKey, $currentString = $Line -Split ':' | ||
| $currentString = $currentString.Trim() | ||
|
|
||
| if ($currentKey.StartsWith('Pack no')) { | ||
| $currentKey = 'Pack' | ||
| if ($null -ne $currentObject) { | ||
| $PSCmdlet.WriteObject([PSCustomObject]$currentObject) | ||
| } | ||
| $currentObject = @{} | ||
| } | ||
| } | ||
| } | ||
|
|
||
| End { | ||
| if ($null -ne $currentObject) { | ||
| $currentObject.$currentKey = $currentString | ||
| $PSCmdlet.WriteObject([PSCustomObject]$currentObject) | ||
| } | ||
| } | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.