[macos] Add path variables to packer templates (#9155)

* Update macos-12.pkr.hcl template

* Update remaining macos templates

* Update Get-ToolsetContent and get_toolset_value functions

* Fix ~ symbol expansion issues

* Fix bad path in macOS-14.arm64.anka.pkr.hcl
This commit is contained in:
Shamil Mubarakshin
2024-01-15 12:21:24 +01:00
committed by GitHub
parent 2a7ca2e6a2
commit ba2e955e0b
9 changed files with 904 additions and 855 deletions

View File

@@ -40,9 +40,17 @@ function Get-OSVersion {
} }
} }
# Get the value of the toolset
function Get-ToolsetContent { function Get-ToolsetContent {
$toolsetPath = Join-Path $env:HOME "image-generation" "toolset.json" <#
.SYNOPSIS
Retrieves the content of the toolset.json file.
.DESCRIPTION
This function reads the toolset.json in path provided by IMAGE_FOLDER
environment variable and returns the content as a PowerShell object.
#>
$toolsetPath = Join-Path $env:IMAGE_FOLDER "toolset.json"
$toolsetJson = Get-Content -Path $toolsetPath -Raw $toolsetJson = Get-Content -Path $toolsetPath -Raw
ConvertFrom-Json -InputObject $toolsetJson ConvertFrom-Json -InputObject $toolsetJson
} }

View File

@@ -82,7 +82,7 @@ is_Veertu() {
} }
get_toolset_value() { get_toolset_value() {
local toolset_path=$(echo "$HOME/image-generation/toolset.json") local toolset_path=$(echo "$IMAGE_FOLDER/toolset.json")
local query=$1 local query=$1
echo "$(jq -r "$query" $toolset_path)" echo "$(jq -r "$query" $toolset_path)"
} }

View File

@@ -7,6 +7,10 @@ packer {
} }
} }
locals {
image_folder = "/Users/${var.vm_username}/image-generation"
}
variable "baseimage_name" { variable "baseimage_name" {
type = string type = string
} }
@@ -100,37 +104,37 @@ build {
sources = ["source.vsphere-clone.template"] sources = ["source.vsphere-clone.template"]
provisioner "shell" { provisioner "shell" {
inline = ["mkdir ~/image-generation"] inline = ["mkdir ${local.image_folder}"]
} }
provisioner "file" { provisioner "file" {
destination = "~/image-generation/" destination = "${local.image_folder}/"
sources = [ sources = [
"./assets/xamarin-selector", "${path.root}/../assets/xamarin-selector",
"./scripts/tests", "${path.root}/../scripts/tests",
"./scripts/docs-gen", "${path.root}/../scripts/docs-gen",
"./scripts/helpers" "${path.root}/../scripts/helpers"
] ]
} }
provisioner "file" { provisioner "file" {
destination = "~/image-generation/docs-gen/" destination = "${local.image_folder}/docs-gen/"
source = "../../helpers/software-report-base" source = "${path.root}/../../../helpers/software-report-base"
} }
provisioner "file" { provisioner "file" {
destination = "~/image-generation/add-certificate.swift" destination = "${local.image_folder}/add-certificate.swift"
source = "./assets/add-certificate.swift" source = "${path.root}/../assets/add-certificate.swift"
} }
provisioner "file" { provisioner "file" {
destination = "~/.bashrc" destination = "~/.bashrc"
source = "./assets/bashrc" source = "${path.root}/../assets/bashrc"
} }
provisioner "file" { provisioner "file" {
destination = "~/.bash_profile" destination = "~/.bash_profile"
source = "./assets/bashprofile" source = "${path.root}/../assets/bashprofile"
} }
provisioner "shell" { provisioner "shell" {
@@ -139,32 +143,32 @@ build {
provisioner "file" { provisioner "file" {
destination = "~/bootstrap" destination = "~/bootstrap"
source = "./assets/bootstrap-provisioner/" source = "${path.root}/../assets/bootstrap-provisioner/"
} }
provisioner "file" { provisioner "file" {
destination = "~/image-generation/toolset.json" destination = "${local.image_folder}/toolset.json"
source = "./toolsets/toolset-11.json" source = "${path.root}/../toolsets/toolset-11.json"
} }
provisioner "shell" { provisioner "shell" {
execute_command = "sudo sh -c '{{ .Vars }} {{ .Path }}'" execute_command = "sudo sh -c '{{ .Vars }} {{ .Path }}'"
inline = [ inline = [
"mv ~/image-generation/docs-gen ~/image-generation/software-report", "mv ${local.image_folder}/docs-gen ${local.image_folder}/software-report",
"mv ~/image-generation/xamarin-selector ~/image-generation/assets", "mv ${local.image_folder}/xamarin-selector ${local.image_folder}/assets",
"mkdir ~/utils", "mkdir ~/utils",
"mv ~/image-generation/helpers/confirm-identified-developers.scpt ~/utils", "mv ${local.image_folder}/helpers/confirm-identified-developers.scpt ~/utils",
"mv ~/image-generation/helpers/invoke-tests.sh ~/utils", "mv ${local.image_folder}/helpers/invoke-tests.sh ~/utils",
"mv ~/image-generation/helpers/utils.sh ~/utils", "mv ${local.image_folder}/helpers/utils.sh ~/utils",
"mv ~/image-generation/helpers/xamarin-utils.sh ~/utils" "mv ${local.image_folder}/helpers/xamarin-utils.sh ~/utils"
] ]
} }
provisioner "shell" { provisioner "shell" {
execute_command = "chmod +x {{ .Path }}; {{ .Vars }} {{ .Path }}" execute_command = "chmod +x {{ .Path }}; {{ .Vars }} {{ .Path }}"
scripts = [ scripts = [
"./scripts/build/install-xcode-clt.sh", "${path.root}/../scripts/build/install-xcode-clt.sh",
"./scripts/build/install-homebrew.sh" "${path.root}/../scripts/build/install-homebrew.sh"
] ]
} }
@@ -172,14 +176,14 @@ build {
environment_vars = ["PASSWORD=${var.vm_password}", "USERNAME=${var.vm_username}"] environment_vars = ["PASSWORD=${var.vm_password}", "USERNAME=${var.vm_username}"]
execute_command = "chmod +x {{ .Path }}; sudo {{ .Vars }} {{ .Path }}" execute_command = "chmod +x {{ .Path }}; sudo {{ .Vars }} {{ .Path }}"
scripts = [ scripts = [
"./scripts/build/install-xcode-clt.sh", "${path.root}/../scripts/build/install-xcode-clt.sh",
"./scripts/build/configure-network-interface-detection.sh", "${path.root}/../scripts/build/configure-network-interface-detection.sh",
"./scripts/build/configure-autologin.sh", "${path.root}/../scripts/build/configure-autologin.sh",
"./scripts/build/configure-auto-updates.sh", "${path.root}/../scripts/build/configure-auto-updates.sh",
"./scripts/build/configure-screensaver.sh", "${path.root}/../scripts/build/configure-screensaver.sh",
"./scripts/build/configure-ntpconf.sh", "${path.root}/../scripts/build/configure-ntpconf.sh",
"./scripts/build/configure-max-files-limitation.sh", "${path.root}/../scripts/build/configure-max-files-limitation.sh",
"./scripts/build/configure-shell.sh" "${path.root}/../scripts/build/configure-shell.sh"
] ]
} }
@@ -187,9 +191,9 @@ build {
environment_vars = ["IMAGE_VERSION=${var.build_id}", "IMAGE_OS=${var.image_os}"] environment_vars = ["IMAGE_VERSION=${var.build_id}", "IMAGE_OS=${var.image_os}"]
execute_command = "chmod +x {{ .Path }}; {{ .Vars }} {{ .Path }}" execute_command = "chmod +x {{ .Path }}; {{ .Vars }} {{ .Path }}"
scripts = [ scripts = [
"./scripts/build/configure-preimagedata.sh", "${path.root}/../scripts/build/configure-preimagedata.sh",
"./scripts/build/configure-ssh.sh", "${path.root}/../scripts/build/configure-ssh.sh",
"./scripts/build/configure-machine.sh" "${path.root}/../scripts/build/configure-machine.sh"
] ]
} }
@@ -200,28 +204,28 @@ build {
} }
provisioner "shell" { provisioner "shell" {
environment_vars = ["API_PAT=${var.github_api_pat}"] environment_vars = ["API_PAT=${var.github_api_pat}", "IMAGE_FOLDER=${local.image_folder}"]
execute_command = "chmod +x {{ .Path }}; {{ .Vars }} {{ .Path }}" execute_command = "chmod +x {{ .Path }}; {{ .Vars }} {{ .Path }}"
pause_before = "30s" pause_before = "30s"
scripts = [ scripts = [
"./scripts/build/configure-windows.sh", "${path.root}/../scripts/build/configure-windows.sh",
"./scripts/build/install-powershell.sh", "${path.root}/../scripts/build/install-powershell.sh",
"./scripts/build/install-dotnet.sh", "${path.root}/../scripts/build/install-dotnet.sh",
"./scripts/build/install-python.sh", "${path.root}/../scripts/build/install-python.sh",
"./scripts/build/install-azcopy.sh", "${path.root}/../scripts/build/install-azcopy.sh",
"./scripts/build/install-openssl.sh", "${path.root}/../scripts/build/install-openssl.sh",
"./scripts/build/install-ruby.sh", "${path.root}/../scripts/build/install-ruby.sh",
"./scripts/build/install-rubygems.sh", "${path.root}/../scripts/build/install-rubygems.sh",
"./scripts/build/install-git.sh", "${path.root}/../scripts/build/install-git.sh",
"./scripts/build/install-mongodb.sh", "${path.root}/../scripts/build/install-mongodb.sh",
"./scripts/build/install-node.sh" "${path.root}/../scripts/build/install-node.sh"
] ]
} }
provisioner "shell" { provisioner "shell" {
environment_vars = ["XCODE_INSTALL_STORAGE_URL=${var.xcode_install_storage_url}", "XCODE_INSTALL_SAS=${var.xcode_install_sas}"] environment_vars = ["XCODE_INSTALL_STORAGE_URL=${var.xcode_install_storage_url}", "XCODE_INSTALL_SAS=${var.xcode_install_sas}", "IMAGE_FOLDER=${local.image_folder}"]
execute_command = "chmod +x {{ .Path }}; {{ .Vars }} pwsh -f {{ .Path }}" execute_command = "chmod +x {{ .Path }}; {{ .Vars }} pwsh -f {{ .Path }}"
script = "./scripts/build/Install-Xcode.ps1" script = "${path.root}/../scripts/build/Install-Xcode.ps1"
} }
provisioner "shell" { provisioner "shell" {
@@ -231,73 +235,75 @@ build {
} }
provisioner "shell" { provisioner "shell" {
environment_vars = ["API_PAT=${var.github_api_pat}"] environment_vars = ["API_PAT=${var.github_api_pat}", "IMAGE_FOLDER=${local.image_folder}"]
execute_command = "chmod +x {{ .Path }}; {{ .Vars }} {{ .Path }}" execute_command = "chmod +x {{ .Path }}; {{ .Vars }} {{ .Path }}"
scripts = [ scripts = [
"./scripts/build/install-actions-cache.sh", "${path.root}/../scripts/build/install-actions-cache.sh",
"./scripts/build/install-common-utils.sh", "${path.root}/../scripts/build/install-common-utils.sh",
"./scripts/build/install-llvm.sh", "${path.root}/../scripts/build/install-llvm.sh",
"./scripts/build/install-golang.sh", "${path.root}/../scripts/build/install-golang.sh",
"./scripts/build/install-swiftlint.sh", "${path.root}/../scripts/build/install-swiftlint.sh",
"./scripts/build/install-openjdk.sh", "${path.root}/../scripts/build/install-openjdk.sh",
"./scripts/build/install-php.sh", "${path.root}/../scripts/build/install-php.sh",
"./scripts/build/install-aws-tools.sh", "${path.root}/../scripts/build/install-aws-tools.sh",
"./scripts/build/install-rust.sh", "${path.root}/../scripts/build/install-rust.sh",
"./scripts/build/install-gcc.sh", "${path.root}/../scripts/build/install-gcc.sh",
"./scripts/build/install-haskell.sh", "${path.root}/../scripts/build/install-haskell.sh",
"./scripts/build/install-cocoapods.sh", "${path.root}/../scripts/build/install-cocoapods.sh",
"./scripts/build/install-android-sdk.sh", "${path.root}/../scripts/build/install-android-sdk.sh",
"./scripts/build/install-xamarin.sh", "${path.root}/../scripts/build/install-xamarin.sh",
"./scripts/build/install-visualstudio.sh", "${path.root}/../scripts/build/install-visualstudio.sh",
"./scripts/build/install-nvm.sh", "${path.root}/../scripts/build/install-nvm.sh",
"./scripts/build/install-apache.sh", "${path.root}/../scripts/build/install-apache.sh",
"./scripts/build/install-nginx.sh", "${path.root}/../scripts/build/install-nginx.sh",
"./scripts/build/install-postgresql.sh", "${path.root}/../scripts/build/install-postgresql.sh",
"./scripts/build/install-audiodevice.sh", "${path.root}/../scripts/build/install-audiodevice.sh",
"./scripts/build/install-vcpkg.sh", "${path.root}/../scripts/build/install-vcpkg.sh",
"./scripts/build/install-miniconda.sh", "${path.root}/../scripts/build/install-miniconda.sh",
"./scripts/build/install-safari.sh", "${path.root}/../scripts/build/install-safari.sh",
"./scripts/build/install-chrome.sh", "${path.root}/../scripts/build/install-chrome.sh",
"./scripts/build/install-edge.sh", "${path.root}/../scripts/build/install-edge.sh",
"./scripts/build/install-firefox.sh", "${path.root}/../scripts/build/install-firefox.sh",
"./scripts/build/install-pypy.sh", "${path.root}/../scripts/build/install-pypy.sh",
"./scripts/build/install-pipx-packages.sh", "${path.root}/../scripts/build/install-pipx-packages.sh",
"./scripts/build/install-bicep.sh", "${path.root}/../scripts/build/install-bicep.sh",
"./scripts/build/install-codeql-bundle.sh" "${path.root}/../scripts/build/install-codeql-bundle.sh"
] ]
} }
provisioner "shell" { provisioner "shell" {
environment_vars = ["IMAGE_FOLDER=${local.image_folder}"]
execute_command = "chmod +x {{ .Path }}; {{ .Vars }} pwsh -f {{ .Path }}" execute_command = "chmod +x {{ .Path }}; {{ .Vars }} pwsh -f {{ .Path }}"
scripts = [ scripts = [
"./scripts/build/Install-Toolset.ps1", "${path.root}/../scripts/build/Install-Toolset.ps1",
"./scripts/build/Configure-Toolset.ps1" "${path.root}/../scripts/build/Configure-Toolset.ps1"
] ]
} }
provisioner "shell" { provisioner "shell" {
execute_command = "ruby {{ .Path }}" execute_command = "ruby {{ .Path }}"
script = "./scripts/build/configure-xcode-simulators.rb" script = "${path.root}/../scripts/build/configure-xcode-simulators.rb"
} }
provisioner "shell" { provisioner "shell" {
environment_vars = ["IMAGE_FOLDER=${local.image_folder}"]
inline = [ inline = [
"pwsh -File \"$HOME/image-generation/software-report/Generate-SoftwareReport.ps1\" -OutputDirectory \"$HOME/image-generation/output/software-report\" -ImageName ${var.build_id}", "pwsh -File \"${local.image_folder}/software-report/Generate-SoftwareReport.ps1\" -OutputDirectory \"${local.image_folder}/output/software-report\" -ImageName ${var.build_id}",
"pwsh -File \"$HOME/image-generation/tests/RunAll-Tests.ps1\"" "pwsh -File \"${local.image_folder}/tests/RunAll-Tests.ps1\""
] ]
} }
provisioner "file" { provisioner "file" {
destination = "../image-output/" destination = "${path.root}/../../image-output/"
direction = "download" direction = "download"
source = "~/image-generation/output/*" source = "${local.image_folder}/output/*"
} }
provisioner "shell" { provisioner "shell" {
execute_command = "chmod +x {{ .Path }}; {{ .Vars }} {{ .Path }}" execute_command = "chmod +x {{ .Path }}; {{ .Vars }} {{ .Path }}"
scripts = [ scripts = [
"./scripts/build/configure-hostname.sh", "${path.root}/../scripts/build/configure-hostname.sh",
"./scripts/build/configure-system.sh" "${path.root}/../scripts/build/configure-system.sh"
] ]
} }
} }

View File

@@ -7,6 +7,10 @@ packer {
} }
} }
locals {
image_folder = "/Users/${var.vm_username}/image-generation"
}
variable "source_vm_name" { variable "source_vm_name" {
type = string type = string
} }
@@ -69,210 +73,213 @@ source "veertu-anka-vm-clone" "template" {
} }
build { build {
sources = [ sources = ["source.veertu-anka-vm-clone.template"]
"source.veertu-anka-vm-clone.template"
]
provisioner "shell" { provisioner "shell" {
inline = [ inline = ["mkdir ${local.image_folder}"]
"mkdir ~/image-generation"
]
} }
provisioner "file" { provisioner "file" {
destination = "image-generation/" destination = "${local.image_folder}/"
sources = [ sources = [
"./assets/xamarin-selector", "${path.root}/../assets/xamarin-selector",
"./scripts/tests", "${path.root}/../scripts/tests",
"./scripts/docs-gen", "${path.root}/../scripts/docs-gen",
"./scripts/helpers" "${path.root}/../scripts/helpers"
] ]
} }
provisioner "file" { provisioner "file" {
destination = "image-generation/docs-gen/" destination = "${local.image_folder}/docs-gen/"
source = "../../helpers/software-report-base" source = "${path.root}/../../../helpers/software-report-base"
} }
provisioner "file" { provisioner "file" {
destination = "image-generation/add-certificate.swift" destination = "${local.image_folder}/add-certificate.swift"
source = "./assets/add-certificate.swift" source = "${path.root}/../assets/add-certificate.swift"
} }
provisioner "file" { provisioner "file" {
destination = ".bashrc" destination = ".bashrc"
source = "./assets/bashrc" source = "${path.root}/../assets/bashrc"
} }
provisioner "file" { provisioner "file" {
destination = ".bash_profile" destination = ".bash_profile"
source = "./assets/bashprofile" source = "${path.root}/../assets/bashprofile"
} }
provisioner "shell" { provisioner "shell" {
inline = [ inline = [ "mkdir ~/bootstrap" ]
"mkdir ~/bootstrap"
]
} }
provisioner "file" { provisioner "file" {
destination = "bootstrap" destination = "bootstrap"
source = "./assets/bootstrap-provisioner/" source = "${path.root}/../assets/bootstrap-provisioner/"
} }
provisioner "file" { provisioner "file" {
destination = "image-generation/toolset.json" destination = "${local.image_folder}/toolset.json"
source = "./toolsets/toolset-12.json" source = "${path.root}/../toolsets/toolset-12.json"
} }
provisioner "shell" { provisioner "shell" {
execute_command = "sudo sh -c '{{ .Vars }} {{ .Path }}'" execute_command = "sudo sh -c '{{ .Vars }} {{ .Path }}'"
inline = [ inline = [
"mv ~/image-generation/docs-gen ~/image-generation/software-report", "mv ${local.image_folder}/docs-gen ${local.image_folder}/software-report",
"mv ~/image-generation/xamarin-selector ~/image-generation/assets", "mv ${local.image_folder}/xamarin-selector ${local.image_folder}/assets",
"mkdir ~/utils", "mkdir ~/utils",
"mv ~/image-generation/helpers/confirm-identified-developers.scpt ~/utils", "mv ${local.image_folder}/helpers/confirm-identified-developers.scpt ~/utils",
"mv ~/image-generation/helpers/invoke-tests.sh ~/utils", "mv ${local.image_folder}/helpers/invoke-tests.sh ~/utils",
"mv ~/image-generation/helpers/utils.sh ~/utils", "mv ${local.image_folder}/helpers/utils.sh ~/utils",
"mv ~/image-generation/helpers/xamarin-utils.sh ~/utils" "mv ${local.image_folder}/helpers/xamarin-utils.sh ~/utils"
] ]
} }
provisioner "shell" { provisioner "shell" {
scripts = [
"./scripts/build/install-xcode-clt.sh",
"./scripts/build/install-homebrew.sh"
]
execute_command = "chmod +x {{ .Path }}; source $HOME/.bash_profile; {{ .Vars }} {{ .Path }}" execute_command = "chmod +x {{ .Path }}; source $HOME/.bash_profile; {{ .Vars }} {{ .Path }}"
}
provisioner "shell" {
scripts = [ scripts = [
"./scripts/build/configure-tccdb-macos.sh", "${path.root}/../scripts/build/install-xcode-clt.sh",
"./scripts/build/configure-network-interface-detection.sh", "${path.root}/../scripts/build/install-homebrew.sh"
"./scripts/build/configure-autologin.sh",
"./scripts/build/configure-auto-updates.sh",
"./scripts/build/configure-screensaver.sh",
"./scripts/build/configure-ntpconf.sh",
"./scripts/build/configure-max-files-limitation.sh",
"./scripts/build/configure-shell.sh"
]
environment_vars = [
"PASSWORD=${var.vm_password}",
"USERNAME=${var.vm_username}"
] ]
}
provisioner "shell" {
environment_vars = ["PASSWORD=${var.vm_password}", "USERNAME=${var.vm_username}"]
execute_command = "chmod +x {{ .Path }}; source $HOME/.bash_profile; sudo {{ .Vars }} {{ .Path }}" execute_command = "chmod +x {{ .Path }}; source $HOME/.bash_profile; sudo {{ .Vars }} {{ .Path }}"
}
provisioner "shell" {
scripts = [ scripts = [
"./scripts/build/configure-preimagedata.sh", "${path.root}/../scripts/build/configure-tccdb-macos.sh",
"./scripts/build/configure-ssh.sh", "${path.root}/../scripts/build/configure-network-interface-detection.sh",
"./scripts/build/configure-machine.sh" "${path.root}/../scripts/build/configure-autologin.sh",
"${path.root}/../scripts/build/configure-auto-updates.sh",
"${path.root}/../scripts/build/configure-screensaver.sh",
"${path.root}/../scripts/build/configure-ntpconf.sh",
"${path.root}/../scripts/build/configure-max-files-limitation.sh",
"${path.root}/../scripts/build/configure-shell.sh"
] ]
environment_vars = [
"IMAGE_VERSION=${var.build_id}",
"IMAGE_OS=${var.image_os}",
"PASSWORD=${var.vm_password}"
]
execute_command = "chmod +x {{ .Path }}; source $HOME/.bash_profile; {{ .Vars }} {{ .Path }}"
} }
provisioner "shell" {
environment_vars = ["IMAGE_VERSION=${var.build_id}", "IMAGE_OS=${var.image_os}", "PASSWORD=${var.vm_password}"]
execute_command = "chmod +x {{ .Path }}; source $HOME/.bash_profile; {{ .Vars }} {{ .Path }}"
scripts = [
"${path.root}/../scripts/build/configure-preimagedata.sh",
"${path.root}/../scripts/build/configure-ssh.sh",
"${path.root}/../scripts/build/configure-machine.sh"
]
}
provisioner "shell" { provisioner "shell" {
execute_command = "source $HOME/.bash_profile; sudo {{ .Vars }} {{ .Path }}" execute_command = "source $HOME/.bash_profile; sudo {{ .Vars }} {{ .Path }}"
expect_disconnect = true expect_disconnect = true
inline = ["echo 'Reboot VM'", "shutdown -r now"] inline = ["echo 'Reboot VM'", "shutdown -r now"]
} }
provisioner "shell" { provisioner "shell" {
environment_vars = ["API_PAT=${var.github_api_pat}", "USER_PASSWORD=${var.vm_password}", "IMAGE_FOLDER=${local.image_folder}"]
execute_command = "chmod +x {{ .Path }}; source $HOME/.bash_profile; {{ .Vars }} {{ .Path }}"
pause_before = "30s" pause_before = "30s"
scripts = [ scripts = [
"./scripts/build/configure-windows.sh", "${path.root}/../scripts/build/configure-windows.sh",
"./scripts/build/install-powershell.sh", "${path.root}/../scripts/build/install-powershell.sh",
"./scripts/build/install-dotnet.sh", "${path.root}/../scripts/build/install-dotnet.sh",
"./scripts/build/install-python.sh", "${path.root}/../scripts/build/install-python.sh",
"./scripts/build/install-azcopy.sh", "${path.root}/../scripts/build/install-azcopy.sh",
"./scripts/build/install-openssl.sh", "${path.root}/../scripts/build/install-openssl.sh",
"./scripts/build/install-ruby.sh", "${path.root}/../scripts/build/install-ruby.sh",
"./scripts/build/install-rubygems.sh", "${path.root}/../scripts/build/install-rubygems.sh",
"./scripts/build/install-git.sh", "${path.root}/../scripts/build/install-git.sh",
"./scripts/build/install-mongodb.sh", "${path.root}/../scripts/build/install-mongodb.sh",
"./scripts/build/install-node.sh", "${path.root}/../scripts/build/install-node.sh",
"./scripts/build/install-common-utils.sh" "${path.root}/../scripts/build/install-common-utils.sh"
] ]
environment_vars = [
"API_PAT=${var.github_api_pat}",
"USER_PASSWORD=${var.vm_password}"
]
execute_command = "chmod +x {{ .Path }}; source $HOME/.bash_profile; {{ .Vars }} {{ .Path }}"
} }
provisioner "shell" { provisioner "shell" {
script = "./scripts/build/Install-Xcode.ps1" environment_vars = ["XCODE_INSTALL_STORAGE_URL=${var.xcode_install_storage_url}", "XCODE_INSTALL_SAS=${var.xcode_install_sas}", "IMAGE_FOLDER=${local.image_folder}"]
environment_vars = [
"XCODE_INSTALL_STORAGE_URL=${var.xcode_install_storage_url}",
"XCODE_INSTALL_SAS=${var.xcode_install_sas}"
]
execute_command = "chmod +x {{ .Path }}; source $HOME/.bash_profile; {{ .Vars }} pwsh -f {{ .Path }}" execute_command = "chmod +x {{ .Path }}; source $HOME/.bash_profile; {{ .Vars }} pwsh -f {{ .Path }}"
script = "${path.root}/../scripts/build/Install-Xcode.ps1"
} }
provisioner "shell" { provisioner "shell" {
execute_command = "source $HOME/.bash_profile; sudo {{ .Vars }} {{ .Path }}" execute_command = "source $HOME/.bash_profile; sudo {{ .Vars }} {{ .Path }}"
expect_disconnect = true expect_disconnect = true
inline = ["echo 'Reboot VM'", "shutdown -r now"] inline = ["echo 'Reboot VM'", "shutdown -r now"]
} }
provisioner "shell" { provisioner "shell" {
scripts = [ environment_vars = ["API_PAT=${var.github_api_pat}", "IMAGE_FOLDER=${local.image_folder}"]
"./scripts/build/install-actions-cache.sh",
"./scripts/build/install-llvm.sh",
"./scripts/build/install-golang.sh",
"./scripts/build/install-swiftlint.sh",
"./scripts/build/install-openjdk.sh",
"./scripts/build/install-php.sh",
"./scripts/build/install-aws-tools.sh",
"./scripts/build/install-rust.sh",
"./scripts/build/install-gcc.sh",
"./scripts/build/install-haskell.sh",
"./scripts/build/install-cocoapods.sh",
"./scripts/build/install-android-sdk.sh",
"./scripts/build/install-xamarin.sh",
"./scripts/build/install-visualstudio.sh",
"./scripts/build/install-nvm.sh",
"./scripts/build/install-apache.sh",
"./scripts/build/install-nginx.sh",
"./scripts/build/install-postgresql.sh",
"./scripts/build/install-audiodevice.sh",
"./scripts/build/install-vcpkg.sh",
"./scripts/build/install-miniconda.sh",
"./scripts/build/install-safari.sh",
"./scripts/build/install-chrome.sh",
"./scripts/build/install-edge.sh",
"./scripts/build/install-firefox.sh",
"./scripts/build/install-pypy.sh",
"./scripts/build/install-pipx-packages.sh",
"./scripts/build/install-bicep.sh",
"./scripts/build/install-codeql-bundle.sh"
]
environment_vars = [
"API_PAT=${var.github_api_pat}"
]
execute_command = "chmod +x {{ .Path }}; source $HOME/.bash_profile; {{ .Vars }} {{ .Path }}" execute_command = "chmod +x {{ .Path }}; source $HOME/.bash_profile; {{ .Vars }} {{ .Path }}"
}
provisioner "shell" {
scripts = [ scripts = [
"./scripts/build/Install-Toolset.ps1", "${path.root}/../scripts/build/install-actions-cache.sh",
"./scripts/build/Configure-Toolset.ps1" "${path.root}/../scripts/build/install-llvm.sh",
"${path.root}/../scripts/build/install-golang.sh",
"${path.root}/../scripts/build/install-swiftlint.sh",
"${path.root}/../scripts/build/install-openjdk.sh",
"${path.root}/../scripts/build/install-php.sh",
"${path.root}/../scripts/build/install-aws-tools.sh",
"${path.root}/../scripts/build/install-rust.sh",
"${path.root}/../scripts/build/install-gcc.sh",
"${path.root}/../scripts/build/install-haskell.sh",
"${path.root}/../scripts/build/install-cocoapods.sh",
"${path.root}/../scripts/build/install-android-sdk.sh",
"${path.root}/../scripts/build/install-xamarin.sh",
"${path.root}/../scripts/build/install-visualstudio.sh",
"${path.root}/../scripts/build/install-nvm.sh",
"${path.root}/../scripts/build/install-apache.sh",
"${path.root}/../scripts/build/install-nginx.sh",
"${path.root}/../scripts/build/install-postgresql.sh",
"${path.root}/../scripts/build/install-audiodevice.sh",
"${path.root}/../scripts/build/install-vcpkg.sh",
"${path.root}/../scripts/build/install-miniconda.sh",
"${path.root}/../scripts/build/install-safari.sh",
"${path.root}/../scripts/build/install-chrome.sh",
"${path.root}/../scripts/build/install-edge.sh",
"${path.root}/../scripts/build/install-firefox.sh",
"${path.root}/../scripts/build/install-pypy.sh",
"${path.root}/../scripts/build/install-pipx-packages.sh",
"${path.root}/../scripts/build/install-bicep.sh",
"${path.root}/../scripts/build/install-codeql-bundle.sh"
] ]
}
provisioner "shell" {
environment_vars = ["IMAGE_FOLDER=${local.image_folder}"]
execute_command = "chmod +x {{ .Path }}; source $HOME/.bash_profile; {{ .Vars }} pwsh -f {{ .Path }}" execute_command = "chmod +x {{ .Path }}; source $HOME/.bash_profile; {{ .Vars }} pwsh -f {{ .Path }}"
}
provisioner "shell" {
script = "./scripts/build/configure-xcode-simulators.rb"
execute_command = "source $HOME/.bash_profile; ruby {{ .Path }}"
}
provisioner "shell" {
script = "./scripts/build/Update-XcodeSimulators.ps1"
execute_command = "chmod +x {{ .Path }}; {{ .Vars }} pwsh -f {{ .Path }}"
}
provisioner "shell" {
inline = [
"pwsh -File \"$HOME/image-generation/software-report/Generate-SoftwareReport.ps1\" -OutputDirectory \"$HOME/image-generation/output/software-report\" -ImageName ${var.build_id}",
"pwsh -File \"$HOME/image-generation/tests/RunAll-Tests.ps1\""
]
execute_command = "source $HOME/.bash_profile; {{ .Vars }} {{ .Path }}"
}
provisioner "file" {
destination = "../image-output/"
direction = "download"
source = "./image-generation/output/"
}
provisioner "shell" {
scripts = [ scripts = [
"./scripts/build/configure-hostname.sh", "${path.root}/../scripts/build/Install-Toolset.ps1",
"./scripts/build/configure-system.sh" "${path.root}/../scripts/build/Configure-Toolset.ps1"
] ]
}
provisioner "shell" {
execute_command = "source $HOME/.bash_profile; ruby {{ .Path }}"
script = "${path.root}/../scripts/build/configure-xcode-simulators.rb"
}
provisioner "shell" {
execute_command = "chmod +x {{ .Path }}; {{ .Vars }} pwsh -f {{ .Path }}"
script = "${path.root}/../scripts/build/Update-XcodeSimulators.ps1"
}
provisioner "shell" {
environment_vars = ["IMAGE_FOLDER=${local.image_folder}"]
execute_command = "source $HOME/.bash_profile; {{ .Vars }} {{ .Path }}"
inline = [
"pwsh -File \"${local.image_folder}/software-report/Generate-SoftwareReport.ps1\" -OutputDirectory \"${local.image_folder}/output/software-report\" -ImageName ${var.build_id}",
"pwsh -File \"${local.image_folder}/tests/RunAll-Tests.ps1\""
]
}
provisioner "file" {
destination = "${path.root}/../../image-output/"
direction = "download"
source = "${local.image_folder}/output/"
}
provisioner "shell" {
execute_command = "chmod +x {{ .Path }}; source $HOME/.bash_profile; {{ .Vars }} {{ .Path }}" execute_command = "chmod +x {{ .Path }}; source $HOME/.bash_profile; {{ .Vars }} {{ .Path }}"
scripts = [
"${path.root}/../scripts/build/configure-hostname.sh",
"${path.root}/../scripts/build/configure-system.sh"
]
} }
} }

View File

@@ -7,6 +7,10 @@ packer {
} }
} }
locals {
image_folder = "/Users/${var.vm_username}/image-generation"
}
variable "baseimage_name" { variable "baseimage_name" {
type = string type = string
} }
@@ -100,37 +104,37 @@ build {
sources = ["source.vsphere-clone.template"] sources = ["source.vsphere-clone.template"]
provisioner "shell" { provisioner "shell" {
inline = ["mkdir ~/image-generation"] inline = ["mkdir ${local.image_folder}"]
} }
provisioner "file" { provisioner "file" {
destination = "~/image-generation/" destination = "${local.image_folder}/"
sources = [ sources = [
"./assets/xamarin-selector", "${path.root}/../assets/xamarin-selector",
"./scripts/tests", "${path.root}/../scripts/tests",
"./scripts/docs-gen", "${path.root}/../scripts/docs-gen",
"./scripts/helpers" "${path.root}/../scripts/helpers"
] ]
} }
provisioner "file" { provisioner "file" {
destination = "~/image-generation/docs-gen/" destination = "${local.image_folder}/docs-gen/"
source = "../../helpers/software-report-base" source = "${path.root}/../../../helpers/software-report-base"
} }
provisioner "file" { provisioner "file" {
destination = "~/image-generation/add-certificate.swift" destination = "${local.image_folder}/add-certificate.swift"
source = "./assets/add-certificate.swift" source = "${path.root}/../assets/add-certificate.swift"
} }
provisioner "file" { provisioner "file" {
destination = "~/.bashrc" destination = "~/.bashrc"
source = "./assets/bashrc" source = "${path.root}/../assets/bashrc"
} }
provisioner "file" { provisioner "file" {
destination = "~/.bash_profile" destination = "~/.bash_profile"
source = "./assets/bashprofile" source = "${path.root}/../assets/bashprofile"
} }
provisioner "shell" { provisioner "shell" {
@@ -139,32 +143,32 @@ build {
provisioner "file" { provisioner "file" {
destination = "~/bootstrap" destination = "~/bootstrap"
source = "./assets/bootstrap-provisioner/" source = "${path.root}/../assets/bootstrap-provisioner/"
} }
provisioner "file" { provisioner "file" {
destination = "~/image-generation/toolset.json" destination = "${local.image_folder}/toolset.json"
source = "./toolsets/toolset-12.json" source = "${path.root}/../toolsets/toolset-12.json"
} }
provisioner "shell" { provisioner "shell" {
execute_command = "sudo sh -c '{{ .Vars }} {{ .Path }}'" execute_command = "sudo sh -c '{{ .Vars }} {{ .Path }}'"
inline = [ inline = [
"mv ~/image-generation/docs-gen ~/image-generation/software-report", "mv ${local.image_folder}/docs-gen ${local.image_folder}/software-report",
"mv ~/image-generation/xamarin-selector ~/image-generation/assets", "mv ${local.image_folder}/xamarin-selector ${local.image_folder}/assets",
"mkdir ~/utils", "mkdir ~/utils",
"mv ~/image-generation/helpers/confirm-identified-developers.scpt ~/utils", "mv ${local.image_folder}/helpers/confirm-identified-developers.scpt ~/utils",
"mv ~/image-generation/helpers/invoke-tests.sh ~/utils", "mv ${local.image_folder}/helpers/invoke-tests.sh ~/utils",
"mv ~/image-generation/helpers/utils.sh ~/utils", "mv ${local.image_folder}/helpers/utils.sh ~/utils",
"mv ~/image-generation/helpers/xamarin-utils.sh ~/utils" "mv ${local.image_folder}/helpers/xamarin-utils.sh ~/utils"
] ]
} }
provisioner "shell" { provisioner "shell" {
execute_command = "chmod +x {{ .Path }}; {{ .Vars }} {{ .Path }}" execute_command = "chmod +x {{ .Path }}; {{ .Vars }} {{ .Path }}"
scripts = [ scripts = [
"./scripts/build/install-xcode-clt.sh", "${path.root}/../scripts/build/install-xcode-clt.sh",
"./scripts/build/install-homebrew.sh" "${path.root}/../scripts/build/install-homebrew.sh"
] ]
} }
@@ -172,13 +176,13 @@ build {
environment_vars = ["PASSWORD=${var.vm_password}", "USERNAME=${var.vm_username}"] environment_vars = ["PASSWORD=${var.vm_password}", "USERNAME=${var.vm_username}"]
execute_command = "chmod +x {{ .Path }}; sudo {{ .Vars }} {{ .Path }}" execute_command = "chmod +x {{ .Path }}; sudo {{ .Vars }} {{ .Path }}"
scripts = [ scripts = [
"./scripts/build/configure-network-interface-detection.sh", "${path.root}/../scripts/build/configure-network-interface-detection.sh",
"./scripts/build/configure-autologin.sh", "${path.root}/../scripts/build/configure-autologin.sh",
"./scripts/build/configure-auto-updates.sh", "${path.root}/../scripts/build/configure-auto-updates.sh",
"./scripts/build/configure-screensaver.sh", "${path.root}/../scripts/build/configure-screensaver.sh",
"./scripts/build/configure-ntpconf.sh", "${path.root}/../scripts/build/configure-ntpconf.sh",
"./scripts/build/configure-max-files-limitation.sh", "${path.root}/../scripts/build/configure-max-files-limitation.sh",
"./scripts/build/configure-shell.sh" "${path.root}/../scripts/build/configure-shell.sh"
] ]
} }
@@ -186,9 +190,9 @@ build {
environment_vars = ["IMAGE_VERSION=${var.build_id}", "IMAGE_OS=${var.image_os}", "PASSWORD=${var.vm_password}"] environment_vars = ["IMAGE_VERSION=${var.build_id}", "IMAGE_OS=${var.image_os}", "PASSWORD=${var.vm_password}"]
execute_command = "chmod +x {{ .Path }}; {{ .Vars }} {{ .Path }}" execute_command = "chmod +x {{ .Path }}; {{ .Vars }} {{ .Path }}"
scripts = [ scripts = [
"./scripts/build/configure-preimagedata.sh", "${path.root}/../scripts/build/configure-preimagedata.sh",
"./scripts/build/configure-ssh.sh", "${path.root}/../scripts/build/configure-ssh.sh",
"./scripts/build/configure-machine.sh" "${path.root}/../scripts/build/configure-machine.sh"
] ]
} }
@@ -199,29 +203,29 @@ build {
} }
provisioner "shell" { provisioner "shell" {
environment_vars = ["API_PAT=${var.github_api_pat}", "USER_PASSWORD=${var.vm_password}"] environment_vars = ["API_PAT=${var.github_api_pat}", "USER_PASSWORD=${var.vm_password}", "IMAGE_FOLDER=${local.image_folder}"]
execute_command = "chmod +x {{ .Path }}; {{ .Vars }} {{ .Path }}" execute_command = "chmod +x {{ .Path }}; {{ .Vars }} {{ .Path }}"
pause_before = "30s" pause_before = "30s"
scripts = [ scripts = [
"./scripts/build/configure-windows.sh", "${path.root}/../scripts/build/configure-windows.sh",
"./scripts/build/install-powershell.sh", "${path.root}/../scripts/build/install-powershell.sh",
"./scripts/build/install-dotnet.sh", "${path.root}/../scripts/build/install-dotnet.sh",
"./scripts/build/install-python.sh", "${path.root}/../scripts/build/install-python.sh",
"./scripts/build/install-azcopy.sh", "${path.root}/../scripts/build/install-azcopy.sh",
"./scripts/build/install-openssl.sh", "${path.root}/../scripts/build/install-openssl.sh",
"./scripts/build/install-ruby.sh", "${path.root}/../scripts/build/install-ruby.sh",
"./scripts/build/install-rubygems.sh", "${path.root}/../scripts/build/install-rubygems.sh",
"./scripts/build/install-git.sh", "${path.root}/../scripts/build/install-git.sh",
"./scripts/build/install-mongodb.sh", "${path.root}/../scripts/build/install-mongodb.sh",
"./scripts/build/install-node.sh", "${path.root}/../scripts/build/install-node.sh",
"./scripts/build/install-common-utils.sh" "${path.root}/../scripts/build/install-common-utils.sh"
] ]
} }
provisioner "shell" { provisioner "shell" {
environment_vars = ["XCODE_INSTALL_STORAGE_URL=${var.xcode_install_storage_url}", "XCODE_INSTALL_SAS=${var.xcode_install_sas}"] environment_vars = ["XCODE_INSTALL_STORAGE_URL=${var.xcode_install_storage_url}", "XCODE_INSTALL_SAS=${var.xcode_install_sas}", "IMAGE_FOLDER=${local.image_folder}"]
execute_command = "chmod +x {{ .Path }}; {{ .Vars }} pwsh -f {{ .Path }}" execute_command = "chmod +x {{ .Path }}; {{ .Vars }} pwsh -f {{ .Path }}"
script = "./scripts/build/Install-Xcode.ps1" script = "${path.root}/../scripts/build/Install-Xcode.ps1"
} }
provisioner "shell" { provisioner "shell" {
@@ -231,77 +235,79 @@ build {
} }
provisioner "shell" { provisioner "shell" {
environment_vars = ["API_PAT=${var.github_api_pat}"] environment_vars = ["API_PAT=${var.github_api_pat}", "IMAGE_FOLDER=${local.image_folder}"]
execute_command = "chmod +x {{ .Path }}; {{ .Vars }} {{ .Path }}" execute_command = "chmod +x {{ .Path }}; {{ .Vars }} {{ .Path }}"
scripts = [ scripts = [
"./scripts/build/install-actions-cache.sh", "${path.root}/../scripts/build/install-actions-cache.sh",
"./scripts/build/install-llvm.sh", "${path.root}/../scripts/build/install-llvm.sh",
"./scripts/build/install-golang.sh", "${path.root}/../scripts/build/install-golang.sh",
"./scripts/build/install-swiftlint.sh", "${path.root}/../scripts/build/install-swiftlint.sh",
"./scripts/build/install-openjdk.sh", "${path.root}/../scripts/build/install-openjdk.sh",
"./scripts/build/install-php.sh", "${path.root}/../scripts/build/install-php.sh",
"./scripts/build/install-aws-tools.sh", "${path.root}/../scripts/build/install-aws-tools.sh",
"./scripts/build/install-rust.sh", "${path.root}/../scripts/build/install-rust.sh",
"./scripts/build/install-gcc.sh", "${path.root}/../scripts/build/install-gcc.sh",
"./scripts/build/install-haskell.sh", "${path.root}/../scripts/build/install-haskell.sh",
"./scripts/build/install-cocoapods.sh", "${path.root}/../scripts/build/install-cocoapods.sh",
"./scripts/build/install-android-sdk.sh", "${path.root}/../scripts/build/install-android-sdk.sh",
"./scripts/build/install-xamarin.sh", "${path.root}/../scripts/build/install-xamarin.sh",
"./scripts/build/install-visualstudio.sh", "${path.root}/../scripts/build/install-visualstudio.sh",
"./scripts/build/install-nvm.sh", "${path.root}/../scripts/build/install-nvm.sh",
"./scripts/build/install-apache.sh", "${path.root}/../scripts/build/install-apache.sh",
"./scripts/build/install-nginx.sh", "${path.root}/../scripts/build/install-nginx.sh",
"./scripts/build/install-postgresql.sh", "${path.root}/../scripts/build/install-postgresql.sh",
"./scripts/build/install-audiodevice.sh", "${path.root}/../scripts/build/install-audiodevice.sh",
"./scripts/build/install-vcpkg.sh", "${path.root}/../scripts/build/install-vcpkg.sh",
"./scripts/build/install-miniconda.sh", "${path.root}/../scripts/build/install-miniconda.sh",
"./scripts/build/install-safari.sh", "${path.root}/../scripts/build/install-safari.sh",
"./scripts/build/install-chrome.sh", "${path.root}/../scripts/build/install-chrome.sh",
"./scripts/build/install-edge.sh", "${path.root}/../scripts/build/install-edge.sh",
"./scripts/build/install-firefox.sh", "${path.root}/../scripts/build/install-firefox.sh",
"./scripts/build/install-pypy.sh", "${path.root}/../scripts/build/install-pypy.sh",
"./scripts/build/install-pipx-packages.sh", "${path.root}/../scripts/build/install-pipx-packages.sh",
"./scripts/build/install-bicep.sh", "${path.root}/../scripts/build/install-bicep.sh",
"./scripts/build/install-codeql-bundle.sh" "${path.root}/../scripts/build/install-codeql-bundle.sh"
] ]
} }
provisioner "shell" { provisioner "shell" {
environment_vars = ["IMAGE_FOLDER=${local.image_folder}"]
execute_command = "chmod +x {{ .Path }}; {{ .Vars }} pwsh -f {{ .Path }}" execute_command = "chmod +x {{ .Path }}; {{ .Vars }} pwsh -f {{ .Path }}"
scripts = [ scripts = [
"./scripts/build/Install-Toolset.ps1", "${path.root}/../scripts/build/Install-Toolset.ps1",
"./scripts/build/Configure-Toolset.ps1" "${path.root}/../scripts/build/Configure-Toolset.ps1"
] ]
} }
provisioner "shell" { provisioner "shell" {
execute_command = "ruby {{ .Path }}" execute_command = "ruby {{ .Path }}"
script = "./scripts/build/configure-xcode-simulators.rb" script = "${path.root}/../scripts/build/configure-xcode-simulators.rb"
} }
provisioner "shell" { provisioner "shell" {
execute_command = "chmod +x {{ .Path }}; {{ .Vars }} pwsh -f {{ .Path }}" execute_command = "chmod +x {{ .Path }}; {{ .Vars }} pwsh -f {{ .Path }}"
script = "./scripts/build/Update-XcodeSimulators.ps1" script = "${path.root}/../scripts/build/Update-XcodeSimulators.ps1"
} }
provisioner "shell" { provisioner "shell" {
environment_vars = ["IMAGE_FOLDER=${local.image_folder}"]
inline = [ inline = [
"pwsh -File \"$HOME/image-generation/software-report/Generate-SoftwareReport.ps1\" -OutputDirectory \"$HOME/image-generation/output/software-report\" -ImageName ${var.build_id}", "pwsh -File \"${local.image_folder}/software-report/Generate-SoftwareReport.ps1\" -OutputDirectory \"${local.image_folder}/output/software-report\" -ImageName ${var.build_id}",
"pwsh -File \"$HOME/image-generation/tests/RunAll-Tests.ps1\"" "pwsh -File \"${local.image_folder}/tests/RunAll-Tests.ps1\""
] ]
} }
provisioner "file" { provisioner "file" {
destination = "../image-output/" destination = "${path.root}/../../image-output/"
direction = "download" direction = "download"
source = "~/image-generation/output/*" source = "${local.image_folder}/output/*"
} }
provisioner "shell" { provisioner "shell" {
execute_command = "chmod +x {{ .Path }}; {{ .Vars }} {{ .Path }}" execute_command = "chmod +x {{ .Path }}; {{ .Vars }} {{ .Path }}"
scripts = [ scripts = [
"./scripts/build/configure-hostname.sh", "${path.root}/../scripts/build/configure-hostname.sh",
"./scripts/build/configure-system.sh" "${path.root}/../scripts/build/configure-system.sh"
] ]
} }
} }

View File

@@ -7,6 +7,10 @@ packer {
} }
} }
locals {
image_folder = "/Users/${var.vm_username}/image-generation"
}
variable "source_vm_name" { variable "source_vm_name" {
type = string type = string
} }
@@ -69,197 +73,200 @@ source "veertu-anka-vm-clone" "template" {
} }
build { build {
sources = [ sources = ["source.veertu-anka-vm-clone.template"]
"source.veertu-anka-vm-clone.template"
]
provisioner "shell" { provisioner "shell" {
inline = [ inline = ["mkdir ${local.image_folder}"]
"mkdir ~/image-generation"
]
} }
provisioner "file" { provisioner "file" {
destination = "image-generation/" destination = "${local.image_folder}/"
sources = [ sources = [
"./assets/xamarin-selector", "${path.root}/../assets/xamarin-selector",
"./scripts/tests", "${path.root}/../scripts/tests",
"./scripts/docs-gen", "${path.root}/../scripts/docs-gen",
"./scripts/helpers" "${path.root}/../scripts/helpers"
] ]
} }
provisioner "file" { provisioner "file" {
destination = "image-generation/docs-gen/" destination = "${local.image_folder}/docs-gen/"
source = "../../helpers/software-report-base" source = "${path.root}/../../../helpers/software-report-base"
} }
provisioner "file" { provisioner "file" {
destination = "image-generation/add-certificate.swift" destination = "${local.image_folder}/add-certificate.swift"
source = "./assets/add-certificate.swift" source = "${path.root}/../assets/add-certificate.swift"
} }
provisioner "file" { provisioner "file" {
destination = ".bashrc" destination = ".bashrc"
source = "./assets/bashrc" source = "${path.root}/../assets/bashrc"
} }
provisioner "file" { provisioner "file" {
destination = ".bash_profile" destination = ".bash_profile"
source = "./assets/bashprofile" source = "${path.root}/../assets/bashprofile"
} }
provisioner "shell" { provisioner "shell" {
inline = [ inline = ["mkdir ~/bootstrap"]
"mkdir ~/bootstrap"
]
} }
provisioner "file" { provisioner "file" {
destination = "bootstrap" destination = "bootstrap"
source = "./assets/bootstrap-provisioner/" source = "${path.root}/../assets/bootstrap-provisioner/"
} }
provisioner "file" { provisioner "file" {
destination = "image-generation/toolset.json" destination = "${local.image_folder}/toolset.json"
source = "./toolsets/toolset-13.json" source = "${path.root}/../toolsets/toolset-13.json"
} }
provisioner "shell" { provisioner "shell" {
execute_command = "sudo sh -c '{{ .Vars }} {{ .Path }}'" execute_command = "sudo sh -c '{{ .Vars }} {{ .Path }}'"
inline = [ inline = [
"mv ~/image-generation/docs-gen ~/image-generation/software-report", "mv ${local.image_folder}/docs-gen ${local.image_folder}/software-report",
"mv ~/image-generation/xamarin-selector ~/image-generation/assets", "mv ${local.image_folder}/xamarin-selector ${local.image_folder}/assets",
"mkdir ~/utils", "mkdir ~/utils",
"mv ~/image-generation/helpers/confirm-identified-developers.scpt ~/utils", "mv ${local.image_folder}/helpers/confirm-identified-developers.scpt ~/utils",
"mv ~/image-generation/helpers/invoke-tests.sh ~/utils", "mv ${local.image_folder}/helpers/invoke-tests.sh ~/utils",
"mv ~/image-generation/helpers/utils.sh ~/utils", "mv ${local.image_folder}/helpers/utils.sh ~/utils",
"mv ~/image-generation/helpers/xamarin-utils.sh ~/utils" "mv ${local.image_folder}/helpers/xamarin-utils.sh ~/utils"
] ]
} }
provisioner "shell" { provisioner "shell" {
scripts = [
"./scripts/build/install-xcode-clt.sh",
"./scripts/build/install-homebrew.sh"
]
execute_command = "chmod +x {{ .Path }}; source $HOME/.bash_profile; {{ .Vars }} {{ .Path }}" execute_command = "chmod +x {{ .Path }}; source $HOME/.bash_profile; {{ .Vars }} {{ .Path }}"
}
provisioner "shell" {
scripts = [ scripts = [
"./scripts/build/configure-tccdb-macos.sh", "${path.root}/../scripts/build/install-xcode-clt.sh",
"./scripts/build/configure-auto-updates.sh", "${path.root}/../scripts/build/install-homebrew.sh"
"./scripts/build/configure-ntpconf.sh",
"./scripts/build/configure-shell.sh"
]
environment_vars = [
"PASSWORD=${var.vm_password}",
"USERNAME=${var.vm_username}"
] ]
}
provisioner "shell" {
environment_vars = ["PASSWORD=${var.vm_password}", "USERNAME=${var.vm_username}"]
execute_command = "chmod +x {{ .Path }}; source $HOME/.bash_profile; sudo {{ .Vars }} {{ .Path }}" execute_command = "chmod +x {{ .Path }}; source $HOME/.bash_profile; sudo {{ .Vars }} {{ .Path }}"
}
provisioner "shell" {
scripts = [ scripts = [
"./scripts/build/configure-preimagedata.sh", "${path.root}/../scripts/build/configure-tccdb-macos.sh",
"./scripts/build/configure-ssh.sh", "${path.root}/../scripts/build/configure-auto-updates.sh",
"./scripts/build/configure-machine.sh" "${path.root}/../scripts/build/configure-ntpconf.sh",
"${path.root}/../scripts/build/configure-shell.sh"
] ]
environment_vars = [
"IMAGE_VERSION=${var.build_id}",
"IMAGE_OS=${var.image_os}",
"PASSWORD=${var.vm_password}"
]
execute_command = "chmod +x {{ .Path }}; source $HOME/.bash_profile; {{ .Vars }} {{ .Path }}"
} }
provisioner "shell" {
environment_vars = ["IMAGE_VERSION=${var.build_id}", "IMAGE_OS=${var.image_os}", "PASSWORD=${var.vm_password}"]
execute_command = "chmod +x {{ .Path }}; source $HOME/.bash_profile; {{ .Vars }} {{ .Path }}"
scripts = [
"${path.root}/../scripts/build/configure-preimagedata.sh",
"${path.root}/../scripts/build/configure-ssh.sh",
"${path.root}/../scripts/build/configure-machine.sh"
]
}
provisioner "shell" { provisioner "shell" {
execute_command = "source $HOME/.bash_profile; sudo {{ .Vars }} {{ .Path }}" execute_command = "source $HOME/.bash_profile; sudo {{ .Vars }} {{ .Path }}"
expect_disconnect = true expect_disconnect = true
inline = ["echo 'Reboot VM'", "shutdown -r now"] inline = ["echo 'Reboot VM'", "shutdown -r now"]
} }
provisioner "shell" { provisioner "shell" {
environment_vars = ["API_PAT=${var.github_api_pat}", "USER_PASSWORD=${var.vm_password}", "IMAGE_FOLDER=${local.image_folder}"]
execute_command = "chmod +x {{ .Path }}; source $HOME/.bash_profile; {{ .Vars }} {{ .Path }}"
pause_before = "30s" pause_before = "30s"
scripts = [ scripts = [
"./scripts/build/configure-windows.sh", "${path.root}/../scripts/build/configure-windows.sh",
"./scripts/build/install-powershell.sh", "${path.root}/../scripts/build/install-powershell.sh",
"./scripts/build/install-mono.sh", "${path.root}/../scripts/build/install-mono.sh",
"./scripts/build/install-dotnet.sh", "${path.root}/../scripts/build/install-dotnet.sh",
"./scripts/build/install-python.sh", "${path.root}/../scripts/build/install-python.sh",
"./scripts/build/install-azcopy.sh", "${path.root}/../scripts/build/install-azcopy.sh",
"./scripts/build/install-openssl.sh", "${path.root}/../scripts/build/install-openssl.sh",
"./scripts/build/install-ruby.sh", "${path.root}/../scripts/build/install-ruby.sh",
"./scripts/build/install-rubygems.sh", "${path.root}/../scripts/build/install-rubygems.sh",
"./scripts/build/install-git.sh", "${path.root}/../scripts/build/install-git.sh",
"./scripts/build/install-node.sh", "${path.root}/../scripts/build/install-node.sh",
"./scripts/build/install-common-utils.sh" "${path.root}/../scripts/build/install-common-utils.sh"
] ]
environment_vars = [
"API_PAT=${var.github_api_pat}",
"USER_PASSWORD=${var.vm_password}"
]
execute_command = "chmod +x {{ .Path }}; source $HOME/.bash_profile; {{ .Vars }} {{ .Path }}"
} }
provisioner "shell" { provisioner "shell" {
script = "./scripts/build/Install-Xcode.ps1" environment_vars = ["XCODE_INSTALL_STORAGE_URL=${var.xcode_install_storage_url}", "XCODE_INSTALL_SAS=${var.xcode_install_sas}", "IMAGE_FOLDER=${local.image_folder}"]
environment_vars = [
"XCODE_INSTALL_STORAGE_URL=${var.xcode_install_storage_url}",
"XCODE_INSTALL_SAS=${var.xcode_install_sas}"
]
execute_command = "chmod +x {{ .Path }}; source $HOME/.bash_profile; {{ .Vars }} pwsh -f {{ .Path }}" execute_command = "chmod +x {{ .Path }}; source $HOME/.bash_profile; {{ .Vars }} pwsh -f {{ .Path }}"
script = "${path.root}/../scripts/build/Install-Xcode.ps1"
} }
provisioner "shell" { provisioner "shell" {
execute_command = "source $HOME/.bash_profile; sudo {{ .Vars }} {{ .Path }}" execute_command = "source $HOME/.bash_profile; sudo {{ .Vars }} {{ .Path }}"
expect_disconnect = true expect_disconnect = true
inline = ["echo 'Reboot VM'", "shutdown -r now"] inline = ["echo 'Reboot VM'", "shutdown -r now"]
} }
provisioner "shell" { provisioner "shell" {
scripts = [ environment_vars = ["API_PAT=${var.github_api_pat}", "IMAGE_FOLDER=${local.image_folder}"]
"./scripts/build/install-actions-cache.sh",
"./scripts/build/install-llvm.sh",
"./scripts/build/install-swiftlint.sh",
"./scripts/build/install-openjdk.sh",
"./scripts/build/install-php.sh",
"./scripts/build/install-aws-tools.sh",
"./scripts/build/install-rust.sh",
"./scripts/build/install-gcc.sh",
"./scripts/build/install-cocoapods.sh",
"./scripts/build/install-android-sdk.sh",
"./scripts/build/install-apache.sh",
"./scripts/build/install-vcpkg.sh",
"./scripts/build/install-safari.sh",
"./scripts/build/install-chrome.sh",
"./scripts/build/install-edge.sh",
"./scripts/build/install-firefox.sh",
"./scripts/build/install-pypy.sh",
"./scripts/build/install-bicep.sh",
"./scripts/build/install-codeql-bundle.sh"
]
environment_vars = [
"API_PAT=${var.github_api_pat}"
]
execute_command = "chmod +x {{ .Path }}; source $HOME/.bash_profile; {{ .Vars }} {{ .Path }}" execute_command = "chmod +x {{ .Path }}; source $HOME/.bash_profile; {{ .Vars }} {{ .Path }}"
}
provisioner "shell" {
scripts = [ scripts = [
"./scripts/build/Install-Toolset.ps1", "${path.root}/../scripts/build/install-actions-cache.sh",
"./scripts/build/Configure-Toolset.ps1" "${path.root}/../scripts/build/install-llvm.sh",
"${path.root}/../scripts/build/install-swiftlint.sh",
"${path.root}/../scripts/build/install-openjdk.sh",
"${path.root}/../scripts/build/install-php.sh",
"${path.root}/../scripts/build/install-aws-tools.sh",
"${path.root}/../scripts/build/install-rust.sh",
"${path.root}/../scripts/build/install-gcc.sh",
"${path.root}/../scripts/build/install-cocoapods.sh",
"${path.root}/../scripts/build/install-android-sdk.sh",
"${path.root}/../scripts/build/install-apache.sh",
"${path.root}/../scripts/build/install-vcpkg.sh",
"${path.root}/../scripts/build/install-safari.sh",
"${path.root}/../scripts/build/install-chrome.sh",
"${path.root}/../scripts/build/install-edge.sh",
"${path.root}/../scripts/build/install-firefox.sh",
"${path.root}/../scripts/build/install-pypy.sh",
"${path.root}/../scripts/build/install-bicep.sh",
"${path.root}/../scripts/build/install-codeql-bundle.sh"
] ]
}
provisioner "shell" {
environment_vars = ["IMAGE_FOLDER=${local.image_folder}"]
execute_command = "chmod +x {{ .Path }}; source $HOME/.bash_profile; {{ .Vars }} pwsh -f {{ .Path }}" execute_command = "chmod +x {{ .Path }}; source $HOME/.bash_profile; {{ .Vars }} pwsh -f {{ .Path }}"
}
provisioner "shell" {
script = "./scripts/build/configure-xcode-simulators.rb"
execute_command = "source $HOME/.bash_profile; ruby {{ .Path }}"
}
provisioner "shell" {
inline = [
"pwsh -File \"$HOME/image-generation/software-report/Generate-SoftwareReport.ps1\" -OutputDirectory \"$HOME/image-generation/output/software-report\" -ImageName ${var.build_id}",
"pwsh -File \"$HOME/image-generation/tests/RunAll-Tests.ps1\""
]
execute_command = "source $HOME/.bash_profile; {{ .Vars }} {{ .Path }}"
}
provisioner "file" {
destination = "../image-output/"
direction = "download"
source = "./image-generation/output/"
}
provisioner "shell" {
inline = [
"rm -rf \"$(brew --cache)\""
]
}
provisioner "shell" {
scripts = [ scripts = [
"./scripts/build/configure-hostname.sh", "${path.root}/../scripts/build/Install-Toolset.ps1",
"./scripts/build/configure-system.sh" "${path.root}/../scripts/build/Configure-Toolset.ps1"
] ]
}
provisioner "shell" {
execute_command = "source $HOME/.bash_profile; ruby {{ .Path }}"
script = "${path.root}/../scripts/build/configure-xcode-simulators.rb"
}
provisioner "shell" {
environment_vars = ["IMAGE_FOLDER=${local.image_folder}"]
execute_command = "source $HOME/.bash_profile; {{ .Vars }} {{ .Path }}"
inline = [
"pwsh -File \"${local.image_folder}/software-report/Generate-SoftwareReport.ps1\" -OutputDirectory \"${local.image_folder}/output/software-report\" -ImageName ${var.build_id}",
"pwsh -File \"${local.image_folder}/tests/RunAll-Tests.ps1\""
]
}
provisioner "file" {
destination = "${path.root}/../../image-output/"
direction = "download"
source = "${local.image_folder}/output/"
}
provisioner "shell" {
inline = ["rm -rf \"$(brew --cache)\""]
}
provisioner "shell" {
execute_command = "chmod +x {{ .Path }}; source $HOME/.bash_profile; {{ .Vars }} {{ .Path }}" execute_command = "chmod +x {{ .Path }}; source $HOME/.bash_profile; {{ .Vars }} {{ .Path }}"
scripts = [
"${path.root}/../scripts/build/configure-hostname.sh",
"${path.root}/../scripts/build/configure-system.sh"
]
} }
} }

View File

@@ -7,6 +7,10 @@ packer {
} }
} }
locals {
image_folder = "/Users/${var.vm_username}/image-generation"
}
variable "source_vm_name" { variable "source_vm_name" {
type = string type = string
} }
@@ -70,184 +74,186 @@ source "veertu-anka-vm-clone" "template" {
} }
build { build {
sources = [ sources = ["source.veertu-anka-vm-clone.template"]
"source.veertu-anka-vm-clone.template"
]
provisioner "shell" { provisioner "shell" {
inline = [ inline = ["mkdir ${local.image_folder}"]
"mkdir ~/image-generation"
]
} }
provisioner "file" { provisioner "file" {
destination = "image-generation/" destination = "${local.image_folder}/"
sources = [ sources = [
"./assets/xamarin-selector", "${path.root}/../assets/xamarin-selector",
"./scripts/tests", "${path.root}/../scripts/tests",
"./scripts/docs-gen", "${path.root}/../scripts/docs-gen",
"./scripts/helpers" "${path.root}/../scripts/helpers"
] ]
} }
provisioner "file" { provisioner "file" {
destination = "image-generation/docs-gen/" destination = "${local.image_folder}/docs-gen/"
source = "../../helpers/software-report-base" source = "${path.root}/../../../helpers/software-report-base"
} }
provisioner "file" { provisioner "file" {
destination = "image-generation/add-certificate.swift" destination = "${local.image_folder}/add-certificate.swift"
source = "./assets/add-certificate.swift" source = "${path.root}/../assets/add-certificate.swift"
} }
provisioner "file" { provisioner "file" {
destination = ".bashrc" destination = ".bashrc"
source = "./assets/bashrc" source = "${path.root}/../assets/bashrc"
} }
provisioner "file" { provisioner "file" {
destination = ".bash_profile" destination = ".bash_profile"
source = "./assets/bashprofile" source = "${path.root}/../assets/bashprofile"
} }
provisioner "shell" { provisioner "shell" {
inline = [ inline = ["mkdir ~/bootstrap"]
"mkdir ~/bootstrap"
]
} }
provisioner "file" { provisioner "file" {
destination = "bootstrap" destination = "bootstrap"
source = "./assets/bootstrap-provisioner/" source = "${path.root}/../assets/bootstrap-provisioner/"
} }
provisioner "file" { provisioner "file" {
destination = "image-generation/toolset.json" destination = "${local.image_folder}/toolset.json"
source = "./toolsets/toolset-13.json" source = "${path.root}/../toolsets/toolset-13.json"
} }
provisioner "shell" { provisioner "shell" {
execute_command = "sudo sh -c '{{ .Vars }} {{ .Path }}'" execute_command = "sudo sh -c '{{ .Vars }} {{ .Path }}'"
inline = [ inline = [
"mv ~/image-generation/docs-gen ~/image-generation/software-report", "mv ${local.image_folder}/docs-gen ${local.image_folder}/software-report",
"mv ~/image-generation/xamarin-selector ~/image-generation/assets", "mv ${local.image_folder}/xamarin-selector ${local.image_folder}/assets",
"mkdir ~/utils", "mkdir ~/utils",
"mv ~/image-generation/helpers/confirm-identified-developers.scpt ~/utils", "mv ${local.image_folder}/helpers/confirm-identified-developers.scpt ~/utils",
"mv ~/image-generation/helpers/invoke-tests.sh ~/utils", "mv ${local.image_folder}/helpers/invoke-tests.sh ~/utils",
"mv ~/image-generation/helpers/utils.sh ~/utils", "mv ${local.image_folder}/helpers/utils.sh ~/utils",
"mv ~/image-generation/helpers/xamarin-utils.sh ~/utils" "mv ${local.image_folder}/helpers/xamarin-utils.sh ~/utils"
] ]
} }
provisioner "shell" { provisioner "shell" {
scripts = [
"./scripts/build/install-xcode-clt.sh",
"./scripts/build/install-homebrew.sh"
]
execute_command = "chmod +x {{ .Path }}; source $HOME/.bash_profile; {{ .Vars }} {{ .Path }}" execute_command = "chmod +x {{ .Path }}; source $HOME/.bash_profile; {{ .Vars }} {{ .Path }}"
}
provisioner "shell" {
scripts = [ scripts = [
"./scripts/build/configure-tccdb-macos.sh", "${path.root}/../scripts/build/install-xcode-clt.sh",
"./scripts/build/configure-auto-updates.sh", "${path.root}/../scripts/build/install-homebrew.sh"
"./scripts/build/configure-ntpconf.sh",
"./scripts/build/configure-shell.sh"
]
environment_vars = [
"PASSWORD=${var.vm_password}",
"USERNAME=${var.vm_username}"
] ]
}
provisioner "shell" {
environment_vars = ["PASSWORD=${var.vm_password}", "USERNAME=${var.vm_username}"]
execute_command = "chmod +x {{ .Path }}; source $HOME/.bash_profile; sudo {{ .Vars }} {{ .Path }}" execute_command = "chmod +x {{ .Path }}; source $HOME/.bash_profile; sudo {{ .Vars }} {{ .Path }}"
}
provisioner "shell" {
scripts = [ scripts = [
"./scripts/build/configure-preimagedata.sh", "${path.root}/../scripts/build/configure-tccdb-macos.sh",
"./scripts/build/configure-ssh.sh", "${path.root}/../scripts/build/configure-auto-updates.sh",
"./scripts/build/configure-machine.sh" "${path.root}/../scripts/build/configure-ntpconf.sh",
"${path.root}/../scripts/build/configure-shell.sh"
] ]
environment_vars = [
"IMAGE_VERSION=${var.build_id}",
"IMAGE_OS=${var.image_os}",
"PASSWORD=${var.vm_password}"
]
execute_command = "chmod +x {{ .Path }}; source $HOME/.bash_profile; {{ .Vars }} {{ .Path }}"
} }
provisioner "shell" {
environment_vars = ["IMAGE_VERSION=${var.build_id}", "IMAGE_OS=${var.image_os}", "PASSWORD=${var.vm_password}"]
execute_command = "chmod +x {{ .Path }}; source $HOME/.bash_profile; {{ .Vars }} {{ .Path }}"
scripts = [
"${path.root}/../scripts/build/configure-preimagedata.sh",
"${path.root}/../scripts/build/configure-ssh.sh",
"${path.root}/../scripts/build/configure-machine.sh"
]
}
provisioner "shell" { provisioner "shell" {
execute_command = "source $HOME/.bash_profile; sudo {{ .Vars }} {{ .Path }}" execute_command = "source $HOME/.bash_profile; sudo {{ .Vars }} {{ .Path }}"
expect_disconnect = true expect_disconnect = true
inline = ["echo 'Reboot VM'", "shutdown -r now"] inline = ["echo 'Reboot VM'", "shutdown -r now"]
} }
provisioner "shell" { provisioner "shell" {
environment_vars = ["API_PAT=${var.github_api_pat}", "USER_PASSWORD=${var.vm_password}", "IMAGE_FOLDER=${local.image_folder}"]
execute_command = "chmod +x {{ .Path }}; source $HOME/.bash_profile; {{ .Vars }} {{ .Path }}"
pause_before = "30s" pause_before = "30s"
scripts = [ scripts = [
"./scripts/build/install-rosetta.sh", "${path.root}/../scripts/build/install-rosetta.sh",
"./scripts/build/configure-windows.sh", "${path.root}/../scripts/build/configure-windows.sh",
"./scripts/build/install-powershell.sh", "${path.root}/../scripts/build/install-powershell.sh",
"./scripts/build/install-mono.sh", "${path.root}/../scripts/build/install-mono.sh",
"./scripts/build/install-dotnet.sh", "${path.root}/../scripts/build/install-dotnet.sh",
"./scripts/build/install-azcopy.sh", "${path.root}/../scripts/build/install-azcopy.sh",
"./scripts/build/install-openssl.sh", "${path.root}/../scripts/build/install-openssl.sh",
"./scripts/build/install-ruby.sh", "${path.root}/../scripts/build/install-ruby.sh",
"./scripts/build/install-rubygems.sh", "${path.root}/../scripts/build/install-rubygems.sh",
"./scripts/build/install-git.sh", "${path.root}/../scripts/build/install-git.sh",
"./scripts/build/install-node.sh", "${path.root}/../scripts/build/install-node.sh",
"./scripts/build/install-common-utils.sh" "${path.root}/../scripts/build/install-common-utils.sh"
] ]
environment_vars = [
"API_PAT=${var.github_api_pat}",
"USER_PASSWORD=${var.vm_password}"
]
execute_command = "chmod +x {{ .Path }}; source $HOME/.bash_profile; {{ .Vars }} {{ .Path }}"
} }
provisioner "shell" { provisioner "shell" {
script = "./scripts/build/Install-Xcode.ps1" environment_vars = ["XCODE_INSTALL_STORAGE_URL=${var.xcode_install_storage_url}", "XCODE_INSTALL_SAS=${var.xcode_install_sas}", "IMAGE_FOLDER=${local.image_folder}"]
environment_vars = [
"XCODE_INSTALL_STORAGE_URL=${var.xcode_install_storage_url}",
"XCODE_INSTALL_SAS=${var.xcode_install_sas}"
]
execute_command = "chmod +x {{ .Path }}; source $HOME/.bash_profile; {{ .Vars }} pwsh -f {{ .Path }}" execute_command = "chmod +x {{ .Path }}; source $HOME/.bash_profile; {{ .Vars }} pwsh -f {{ .Path }}"
script = "${path.root}/../scripts/build/Install-Xcode.ps1"
} }
provisioner "shell" { provisioner "shell" {
execute_command = "source $HOME/.bash_profile; sudo {{ .Vars }} {{ .Path }}" execute_command = "source $HOME/.bash_profile; sudo {{ .Vars }} {{ .Path }}"
expect_disconnect = true expect_disconnect = true
inline = ["echo 'Reboot VM'", "shutdown -r now"] inline = ["echo 'Reboot VM'", "shutdown -r now"]
} }
provisioner "shell" { provisioner "shell" {
scripts = [ environment_vars = ["API_PAT=${var.github_api_pat}", "IMAGE_FOLDER=${local.image_folder}"]
"./scripts/build/install-actions-cache.sh",
"./scripts/build/install-llvm.sh",
"./scripts/build/install-openjdk.sh",
"./scripts/build/install-aws-tools.sh",
"./scripts/build/install-rust.sh",
"./scripts/build/install-gcc.sh",
"./scripts/build/install-cocoapods.sh",
"./scripts/build/install-android-sdk.sh",
"./scripts/build/install-safari.sh",
"./scripts/build/install-chrome.sh",
"./scripts/build/install-bicep.sh",
"./scripts/build/install-codeql-bundle.sh"
]
environment_vars = [
"API_PAT=${var.github_api_pat}"
]
execute_command = "chmod +x {{ .Path }}; source $HOME/.bash_profile; {{ .Vars }} {{ .Path }}" execute_command = "chmod +x {{ .Path }}; source $HOME/.bash_profile; {{ .Vars }} {{ .Path }}"
}
provisioner "shell" {
scripts = [ scripts = [
"./scripts/build/Install-Toolset.ps1", "${path.root}/../scripts/build/install-actions-cache.sh",
"./scripts/build/Configure-Toolset.ps1" "${path.root}/../scripts/build/install-llvm.sh",
"${path.root}/../scripts/build/install-openjdk.sh",
"${path.root}/../scripts/build/install-aws-tools.sh",
"${path.root}/../scripts/build/install-rust.sh",
"${path.root}/../scripts/build/install-gcc.sh",
"${path.root}/../scripts/build/install-cocoapods.sh",
"${path.root}/../scripts/build/install-android-sdk.sh",
"${path.root}/../scripts/build/install-safari.sh",
"${path.root}/../scripts/build/install-chrome.sh",
"${path.root}/../scripts/build/install-bicep.sh",
"${path.root}/../scripts/build/install-codeql-bundle.sh"
] ]
}
provisioner "shell" {
environment_vars = ["IMAGE_FOLDER=${local.image_folder}"]
execute_command = "chmod +x {{ .Path }}; source $HOME/.bash_profile; {{ .Vars }} pwsh -f {{ .Path }}" execute_command = "chmod +x {{ .Path }}; source $HOME/.bash_profile; {{ .Vars }} pwsh -f {{ .Path }}"
}
provisioner "shell" {
script = "./scripts/build/configure-xcode-simulators.rb"
execute_command = "source $HOME/.bash_profile; ruby {{ .Path }}"
}
provisioner "shell" {
inline = [
"pwsh -File \"$HOME/image-generation/software-report/Generate-SoftwareReport.ps1\" -OutputDirectory \"$HOME/image-generation/output/software-report\" -ImageName ${var.build_id}",
"pwsh -File \"$HOME/image-generation/tests/RunAll-Tests.ps1\""
]
execute_command = "source $HOME/.bash_profile; {{ .Vars }} {{ .Path }}"
}
provisioner "file" {
destination = "../image-output/"
direction = "download"
source = "./image-generation/output/"
}
provisioner "shell" {
scripts = [ scripts = [
"./scripts/build/configure-hostname.sh" "${path.root}/../scripts/build/Install-Toolset.ps1",
"${path.root}/../scripts/build/Configure-Toolset.ps1"
] ]
}
provisioner "shell" {
execute_command = "source $HOME/.bash_profile; ruby {{ .Path }}"
script = "${path.root}/../scripts/build/configure-xcode-simulators.rb"
}
provisioner "shell" {
environment_vars = ["IMAGE_FOLDER=${local.image_folder}"]
execute_command = "source $HOME/.bash_profile; {{ .Vars }} {{ .Path }}"
inline = [
"pwsh -File \"${local.image_folder}/software-report/Generate-SoftwareReport.ps1\" -OutputDirectory \"${local.image_folder}/output/software-report\" -ImageName ${var.build_id}",
"pwsh -File \"${local.image_folder}/tests/RunAll-Tests.ps1\""
]
}
provisioner "file" {
destination = "${path.root}/../../image-output/"
direction = "download"
source = "${local.image_folder}/output/"
}
provisioner "shell" {
execute_command = "chmod +x {{ .Path }}; source $HOME/.bash_profile; {{ .Vars }} {{ .Path }}" execute_command = "chmod +x {{ .Path }}; source $HOME/.bash_profile; {{ .Vars }} {{ .Path }}"
scripts = ["${path.root}/../scripts/build/configure-hostname.sh"]
} }
} }

View File

@@ -7,6 +7,10 @@ packer {
} }
} }
locals {
image_folder = "/Users/${var.vm_username}/image-generation"
}
variable "source_vm_name" { variable "source_vm_name" {
type = string type = string
} }
@@ -69,189 +73,190 @@ source "veertu-anka-vm-clone" "template" {
} }
build { build {
sources = [ sources = ["source.veertu-anka-vm-clone.template"]
"source.veertu-anka-vm-clone.template"
]
provisioner "shell" { provisioner "shell" {
inline = [ inline = ["mkdir ${local.image_folder}"]
"mkdir ~/image-generation"
]
} }
provisioner "file" { provisioner "file" {
destination = "image-generation/" destination = "${local.image_folder}/"
sources = [ sources = [
"./assets/xamarin-selector", "${path.root}/../assets/xamarin-selector",
"./scripts/tests", "${path.root}/../scripts/tests",
"./scripts/docs-gen", "${path.root}/../scripts/docs-gen",
"./scripts/helpers" "${path.root}/../scripts/helpers"
] ]
} }
provisioner "file" { provisioner "file" {
destination = "image-generation/docs-gen/" destination = "${local.image_folder}/docs-gen/"
source = "../../helpers/software-report-base" source = "${path.root}/../../../helpers/software-report-base"
} }
provisioner "file" { provisioner "file" {
destination = "image-generation/add-certificate.swift" destination = "${local.image_folder}/add-certificate.swift"
source = "./assets/add-certificate.swift" source = "${path.root}/../assets/add-certificate.swift"
} }
provisioner "file" { provisioner "file" {
destination = ".bashrc" destination = ".bashrc"
source = "./assets/bashrc" source = "${path.root}/../assets/bashrc"
} }
provisioner "file" { provisioner "file" {
destination = ".bash_profile" destination = ".bash_profile"
source = "./assets/bashprofile" source = "${path.root}/../assets/bashprofile"
} }
provisioner "shell" { provisioner "shell" {
inline = [ inline = ["mkdir ~/bootstrap"]
"mkdir ~/bootstrap"
]
} }
provisioner "file" { provisioner "file" {
destination = "bootstrap" destination = "bootstrap"
source = "./assets/bootstrap-provisioner/" source = "${path.root}/../assets/bootstrap-provisioner/"
} }
provisioner "file" { provisioner "file" {
destination = "image-generation/toolset.json" destination = "${local.image_folder}/toolset.json"
source = "./toolsets/toolset-14.json" source = "${path.root}/../toolsets/toolset-14.json"
} }
provisioner "shell" { provisioner "shell" {
execute_command = "sudo sh -c '{{ .Vars }} {{ .Path }}'" execute_command = "sudo sh -c '{{ .Vars }} {{ .Path }}'"
inline = [ inline = [
"mv ~/image-generation/docs-gen ~/image-generation/software-report", "mv ${local.image_folder}/docs-gen ${local.image_folder}/software-report",
"mv ~/image-generation/xamarin-selector ~/image-generation/assets", "mv ${local.image_folder}/xamarin-selector ${local.image_folder}/assets",
"mkdir ~/utils", "mkdir ~/utils",
"mv ~/image-generation/helpers/confirm-identified-developers.scpt ~/utils", "mv ${local.image_folder}/helpers/confirm-identified-developers.scpt ~/utils",
"mv ~/image-generation/helpers/invoke-tests.sh ~/utils", "mv ${local.image_folder}/helpers/invoke-tests.sh ~/utils",
"mv ~/image-generation/helpers/utils.sh ~/utils", "mv ${local.image_folder}/helpers/utils.sh ~/utils",
"mv ~/image-generation/helpers/xamarin-utils.sh ~/utils" "mv ${local.image_folder}/helpers/xamarin-utils.sh ~/utils"
] ]
} }
provisioner "shell" { provisioner "shell" {
scripts = [
"./scripts/build/install-xcode-clt.sh",
"./scripts/build/install-homebrew.sh"
]
execute_command = "chmod +x {{ .Path }}; source $HOME/.bash_profile; {{ .Vars }} {{ .Path }}" execute_command = "chmod +x {{ .Path }}; source $HOME/.bash_profile; {{ .Vars }} {{ .Path }}"
}
provisioner "shell" {
scripts = [ scripts = [
"./scripts/build/configure-tccdb-macos.sh", "${path.root}/../scripts/build/install-xcode-clt.sh",
"./scripts/build/configure-auto-updates.sh", "${path.root}/../scripts/build/install-homebrew.sh"
"./scripts/build/configure-ntpconf.sh",
"./scripts/build/configure-shell.sh"
]
environment_vars = [
"PASSWORD=${var.vm_password}",
"USERNAME=${var.vm_username}"
] ]
}
provisioner "shell" {
environment_vars = ["PASSWORD=${var.vm_password}", "USERNAME=${var.vm_username}"]
execute_command = "chmod +x {{ .Path }}; source $HOME/.bash_profile; sudo {{ .Vars }} {{ .Path }}" execute_command = "chmod +x {{ .Path }}; source $HOME/.bash_profile; sudo {{ .Vars }} {{ .Path }}"
}
provisioner "shell" {
scripts = [ scripts = [
"./scripts/build/configure-preimagedata.sh", "${path.root}/../scripts/build/configure-tccdb-macos.sh",
"./scripts/build/configure-ssh.sh", "${path.root}/../scripts/build/configure-auto-updates.sh",
"./scripts/build/configure-machine.sh" "${path.root}/../scripts/build/configure-ntpconf.sh",
"${path.root}/../scripts/build/configure-shell.sh"
] ]
environment_vars = [
"IMAGE_VERSION=${var.build_id}",
"IMAGE_OS=${var.image_os}",
"PASSWORD=${var.vm_password}"
]
execute_command = "chmod +x {{ .Path }}; source $HOME/.bash_profile; {{ .Vars }} {{ .Path }}"
} }
provisioner "shell" {
environment_vars = ["IMAGE_VERSION=${var.build_id}", "IMAGE_OS=${var.image_os}", "PASSWORD=${var.vm_password}"]
execute_command = "chmod +x {{ .Path }}; source $HOME/.bash_profile; {{ .Vars }} {{ .Path }}"
scripts = [
"${path.root}/../scripts/build/configure-preimagedata.sh",
"${path.root}/../scripts/build/configure-ssh.sh",
"${path.root}/../scripts/build/configure-machine.sh"
]
}
provisioner "shell" { provisioner "shell" {
execute_command = "source $HOME/.bash_profile; sudo {{ .Vars }} {{ .Path }}" execute_command = "source $HOME/.bash_profile; sudo {{ .Vars }} {{ .Path }}"
expect_disconnect = true expect_disconnect = true
inline = ["echo 'Reboot VM'", "shutdown -r now"] inline = ["echo 'Reboot VM'", "shutdown -r now"]
} }
provisioner "shell" { provisioner "shell" {
environment_vars = ["API_PAT=${var.github_api_pat}", "USER_PASSWORD=${var.vm_password}", "IMAGE_FOLDER=${local.image_folder}"]
execute_command = "chmod +x {{ .Path }}; source $HOME/.bash_profile; {{ .Vars }} {{ .Path }}"
pause_before = "30s" pause_before = "30s"
scripts = [ scripts = [
"./scripts/build/configure-windows.sh", "${path.root}/../scripts/build/configure-windows.sh",
"./scripts/build/install-powershell.sh", "${path.root}/../scripts/build/install-powershell.sh",
"./scripts/build/install-mono.sh", "${path.root}/../scripts/build/install-mono.sh",
"./scripts/build/install-dotnet.sh", "${path.root}/../scripts/build/install-dotnet.sh",
"./scripts/build/install-python.sh", "${path.root}/../scripts/build/install-python.sh",
"./scripts/build/install-azcopy.sh", "${path.root}/../scripts/build/install-azcopy.sh",
"./scripts/build/install-openssl.sh", "${path.root}/../scripts/build/install-openssl.sh",
"./scripts/build/install-ruby.sh", "${path.root}/../scripts/build/install-ruby.sh",
"./scripts/build/install-rubygems.sh", "${path.root}/../scripts/build/install-rubygems.sh",
"./scripts/build/install-git.sh", "${path.root}/../scripts/build/install-git.sh",
"./scripts/build/install-node.sh", "${path.root}/../scripts/build/install-node.sh",
"./scripts/build/install-common-utils.sh" "${path.root}/../scripts/build/install-common-utils.sh"
] ]
environment_vars = [
"API_PAT=${var.github_api_pat}",
"USER_PASSWORD=${var.vm_password}"
]
execute_command = "chmod +x {{ .Path }}; source $HOME/.bash_profile; {{ .Vars }} {{ .Path }}"
} }
provisioner "shell" { provisioner "shell" {
script = "./scripts/build/Install-Xcode.ps1" environment_vars = ["XCODE_INSTALL_STORAGE_URL=${var.xcode_install_storage_url}", "XCODE_INSTALL_SAS=${var.xcode_install_sas}", "IMAGE_FOLDER=${local.image_folder}"]
environment_vars = [
"XCODE_INSTALL_STORAGE_URL=${var.xcode_install_storage_url}",
"XCODE_INSTALL_SAS=${var.xcode_install_sas}"
]
execute_command = "chmod +x {{ .Path }}; source $HOME/.bash_profile; {{ .Vars }} pwsh -f {{ .Path }}" execute_command = "chmod +x {{ .Path }}; source $HOME/.bash_profile; {{ .Vars }} pwsh -f {{ .Path }}"
script = "${path.root}/../scripts/build/Install-Xcode.ps1"
} }
provisioner "shell" { provisioner "shell" {
execute_command = "source $HOME/.bash_profile; sudo {{ .Vars }} {{ .Path }}" execute_command = "source $HOME/.bash_profile; sudo {{ .Vars }} {{ .Path }}"
expect_disconnect = true expect_disconnect = true
inline = ["echo 'Reboot VM'", "shutdown -r now"] inline = ["echo 'Reboot VM'", "shutdown -r now"]
} }
provisioner "shell" { provisioner "shell" {
scripts = [ environment_vars = ["API_PAT=${var.github_api_pat}", "IMAGE_FOLDER=${local.image_folder}"]
"./scripts/build/install-actions-cache.sh",
"./scripts/build/install-llvm.sh",
"./scripts/build/install-swiftlint.sh",
"./scripts/build/install-openjdk.sh",
"./scripts/build/install-php.sh",
"./scripts/build/install-aws-tools.sh",
"./scripts/build/install-rust.sh",
"./scripts/build/install-gcc.sh",
"./scripts/build/install-cocoapods.sh",
"./scripts/build/install-android-sdk.sh",
"./scripts/build/install-apache.sh",
"./scripts/build/install-vcpkg.sh",
"./scripts/build/install-safari.sh",
"./scripts/build/install-chrome.sh",
"./scripts/build/install-edge.sh",
"./scripts/build/install-firefox.sh",
"./scripts/build/install-pypy.sh",
"./scripts/build/install-bicep.sh",
"./scripts/build/install-codeql-bundle.sh"
]
environment_vars = [
"API_PAT=${var.github_api_pat}"
]
execute_command = "chmod +x {{ .Path }}; source $HOME/.bash_profile; {{ .Vars }} {{ .Path }}" execute_command = "chmod +x {{ .Path }}; source $HOME/.bash_profile; {{ .Vars }} {{ .Path }}"
scripts = [
"${path.root}/../scripts/build/install-actions-cache.sh",
"${path.root}/../scripts/build/install-llvm.sh",
"${path.root}/../scripts/build/install-swiftlint.sh",
"${path.root}/../scripts/build/install-openjdk.sh",
"${path.root}/../scripts/build/install-php.sh",
"${path.root}/../scripts/build/install-aws-tools.sh",
"${path.root}/../scripts/build/install-rust.sh",
"${path.root}/../scripts/build/install-gcc.sh",
"${path.root}/../scripts/build/install-cocoapods.sh",
"${path.root}/../scripts/build/install-android-sdk.sh",
"${path.root}/../scripts/build/install-apache.sh",
"${path.root}/../scripts/build/install-vcpkg.sh",
"${path.root}/../scripts/build/install-safari.sh",
"${path.root}/../scripts/build/install-chrome.sh",
"${path.root}/../scripts/build/install-edge.sh",
"${path.root}/../scripts/build/install-firefox.sh",
"${path.root}/../scripts/build/install-pypy.sh",
"${path.root}/../scripts/build/install-bicep.sh",
"${path.root}/../scripts/build/install-codeql-bundle.sh"
]
} }
provisioner "shell" { provisioner "shell" {
script = "./scripts/build/configure-xcode-simulators.rb"
execute_command = "source $HOME/.bash_profile; ruby {{ .Path }}" execute_command = "source $HOME/.bash_profile; ruby {{ .Path }}"
script = "${path.root}/../scripts/build/configure-xcode-simulators.rb"
} }
provisioner "shell" { provisioner "shell" {
inline = [ environment_vars = ["IMAGE_FOLDER=${local.image_folder}"]
"pwsh -File \"$HOME/image-generation/software-report/Generate-SoftwareReport.ps1\" -OutputDirectory \"$HOME/image-generation/output/software-report\" -ImageName ${var.build_id}"
]
execute_command = "source $HOME/.bash_profile; {{ .Vars }} {{ .Path }}" execute_command = "source $HOME/.bash_profile; {{ .Vars }} {{ .Path }}"
}
provisioner "file" {
destination = "../image-output/"
direction = "download"
source = "./image-generation/output/"
}
provisioner "shell" {
inline = [ inline = [
"rm -rf \"$(brew --cache)\"" "pwsh -File \"${local.image_folder}/software-report/Generate-SoftwareReport.ps1\" -OutputDirectory \"${local.image_folder}/output/software-report\" -ImageName ${var.build_id}"
] ]
} }
provisioner "file" {
destination = "${path.root}/../../image-output/"
direction = "download"
source = "${local.image_folder}/output/"
}
provisioner "shell" {
inline = ["rm -rf \"$(brew --cache)\""]
}
provisioner "shell" { provisioner "shell" {
scripts = [
"./scripts/build/configure-hostname.sh",
"./scripts/build/configure-system.sh"
]
execute_command = "chmod +x {{ .Path }}; source $HOME/.bash_profile; {{ .Vars }} {{ .Path }}" execute_command = "chmod +x {{ .Path }}; source $HOME/.bash_profile; {{ .Vars }} {{ .Path }}"
scripts = [
"${path.root}/../scripts/build/configure-hostname.sh",
"${path.root}/../scripts/build/configure-system.sh"
]
} }
} }

View File

@@ -7,6 +7,10 @@ packer {
} }
} }
locals {
image_folder = "/Users/${var.vm_username}/image-generation"
}
variable "source_vm_name" { variable "source_vm_name" {
type = string type = string
} }
@@ -70,176 +74,176 @@ source "veertu-anka-vm-clone" "template" {
} }
build { build {
sources = [ sources = ["source.veertu-anka-vm-clone.template"]
"source.veertu-anka-vm-clone.template"
]
provisioner "shell" { provisioner "shell" {
inline = [ inline = ["mkdir ${local.image_folder}"]
"mkdir ~/image-generation"
]
} }
provisioner "file" { provisioner "file" {
destination = "image-generation/" destination = "${local.image_folder}/"
sources = [ sources = [
"./assets/xamarin-selector", "${path.root}/../assets/xamarin-selector",
"./scripts/tests", "${path.root}/../scripts/tests",
"./scripts/docs-gen", "${path.root}/../scripts/docs-gen",
"./scripts/helpers" "${path.root}/../scripts/helpers"
] ]
} }
provisioner "file" { provisioner "file" {
destination = "image-generation/docs-gen/" destination = "${local.image_folder}/docs-gen/"
source = "../../helpers/software-report-base" source = "${path.root}/../../../helpers/software-report-base"
} }
provisioner "file" { provisioner "file" {
destination = "image-generation/add-certificate.swift" destination = "${local.image_folder}/add-certificate.swift"
source = "./assets/add-certificate.swift" source = "${path.root}/../assets/add-certificate.swift"
} }
provisioner "file" { provisioner "file" {
destination = ".bashrc" destination = ".bashrc"
source = "./assets/bashrc" source = "${path.root}/../assets/bashrc"
} }
provisioner "file" { provisioner "file" {
destination = ".bash_profile" destination = ".bash_profile"
source = "./assets/bashprofile" source = "${path.root}/../assets/bashprofile"
} }
provisioner "shell" { provisioner "shell" {
inline = [ inline = ["mkdir ~/bootstrap"]
"mkdir ~/bootstrap"
]
} }
provisioner "file" { provisioner "file" {
destination = "bootstrap" destination = "bootstrap"
source = "./assets/bootstrap-provisioner/" source = "${path.root}/../assets/bootstrap-provisioner/"
} }
provisioner "file" { provisioner "file" {
destination = "image-generation/toolset.json" destination = "${local.image_folder}/toolset.json"
source = "./toolsets/toolset-14.json" source = "${path.root}/../toolsets/toolset-14.json"
} }
provisioner "shell" { provisioner "shell" {
execute_command = "sudo sh -c '{{ .Vars }} {{ .Path }}'" execute_command = "sudo sh -c '{{ .Vars }} {{ .Path }}'"
inline = [ inline = [
"mv ~/image-generation/docs-gen ~/image-generation/software-report", "mv ${local.image_folder}/docs-gen ${local.image_folder}/software-report",
"mv ~/image-generation/xamarin-selector ~/image-generation/assets", "mv ${local.image_folder}/xamarin-selector ${local.image_folder}/assets",
"mkdir ~/utils", "mkdir ~/utils",
"mv ~/image-generation/helpers/confirm-identified-developers.scpt ~/utils", "mv ${local.image_folder}/helpers/confirm-identified-developers.scpt ~/utils",
"mv ~/image-generation/helpers/invoke-tests.sh ~/utils", "mv ${local.image_folder}/helpers/invoke-tests.sh ~/utils",
"mv ~/image-generation/helpers/utils.sh ~/utils", "mv ${local.image_folder}/helpers/utils.sh ~/utils",
"mv ~/image-generation/helpers/xamarin-utils.sh ~/utils" "mv ${local.image_folder}/helpers/xamarin-utils.sh ~/utils"
] ]
} }
provisioner "shell" { provisioner "shell" {
scripts = [
"./scripts/build/install-xcode-clt.sh",
"./scripts/build/install-homebrew.sh",
"./scripts/build/install-rosetta.sh"
]
execute_command = "chmod +x {{ .Path }}; source $HOME/.bash_profile; {{ .Vars }} {{ .Path }}" execute_command = "chmod +x {{ .Path }}; source $HOME/.bash_profile; {{ .Vars }} {{ .Path }}"
}
provisioner "shell" {
scripts = [ scripts = [
"./scripts/build/configure-tccdb-macos.sh", "${path.root}/../scripts/build/install-xcode-clt.sh",
"./scripts/build/configure-auto-updates.sh", "${path.root}/../scripts/build/install-homebrew.sh",
"./scripts/build/configure-ntpconf.sh", "${path.root}/../scripts/build/install-rosetta.sh"
"./scripts/build/configure-shell.sh"
]
environment_vars = [
"PASSWORD=${var.vm_password}",
"USERNAME=${var.vm_username}"
] ]
}
provisioner "shell" {
environment_vars = ["PASSWORD=${var.vm_password}", "USERNAME=${var.vm_username}"]
execute_command = "chmod +x {{ .Path }}; source $HOME/.bash_profile; sudo {{ .Vars }} {{ .Path }}" execute_command = "chmod +x {{ .Path }}; source $HOME/.bash_profile; sudo {{ .Vars }} {{ .Path }}"
}
provisioner "shell" {
scripts = [ scripts = [
"./scripts/build/configure-preimagedata.sh", "${path.root}/../scripts/build/configure-tccdb-macos.sh",
"./scripts/build/configure-ssh.sh", "${path.root}/../scripts/build/configure-auto-updates.sh",
"./scripts/build/configure-machine.sh" "${path.root}/../scripts/build/configure-ntpconf.sh",
"${path.root}/../scripts/build/configure-shell.sh"
] ]
environment_vars = [
"IMAGE_VERSION=${var.build_id}",
"IMAGE_OS=${var.image_os}",
"PASSWORD=${var.vm_password}"
]
execute_command = "chmod +x {{ .Path }}; source $HOME/.bash_profile; {{ .Vars }} {{ .Path }}"
} }
provisioner "shell" {
environment_vars = ["IMAGE_VERSION=${var.build_id}", "IMAGE_OS=${var.image_os}", "PASSWORD=${var.vm_password}"]
execute_command = "chmod +x {{ .Path }}; source $HOME/.bash_profile; {{ .Vars }} {{ .Path }}"
scripts = [
"${path.root}/../scripts/build/configure-preimagedata.sh",
"${path.root}/../scripts/build/configure-ssh.sh",
"${path.root}/../scripts/build/configure-machine.sh"
]
}
provisioner "shell" { provisioner "shell" {
execute_command = "source $HOME/.bash_profile; sudo {{ .Vars }} {{ .Path }}" execute_command = "source $HOME/.bash_profile; sudo {{ .Vars }} {{ .Path }}"
expect_disconnect = true expect_disconnect = true
inline = ["echo 'Reboot VM'", "shutdown -r now"] inline = ["echo 'Reboot VM'", "shutdown -r now"]
} }
provisioner "shell" { provisioner "shell" {
environment_vars = ["API_PAT=${var.github_api_pat}", "USER_PASSWORD=${var.vm_password}", "IMAGE_FOLDER=${local.image_folder}"]
execute_command = "chmod +x {{ .Path }}; source $HOME/.bash_profile; {{ .Vars }} {{ .Path }}"
pause_before = "30s" pause_before = "30s"
scripts = [ scripts = [
"./scripts/build/configure-windows.sh", "${path.root}/../scripts/build/configure-windows.sh",
"./scripts/build/install-powershell.sh", "${path.root}/../scripts/build/install-powershell.sh",
"./scripts/build/install-mono.sh", "${path.root}/../scripts/build/install-mono.sh",
"./scripts/build/install-dotnet.sh", "${path.root}/../scripts/build/install-dotnet.sh",
"./scripts/build/install-azcopy.sh", "${path.root}/../scripts/build/install-azcopy.sh",
"./scripts/build/install-openssl.sh", "${path.root}/../scripts/build/install-openssl.sh",
"./scripts/build/install-ruby.sh", "${path.root}/../scripts/build/install-ruby.sh",
"./scripts/build/install-rubygems.sh", "${path.root}/../scripts/build/install-rubygems.sh",
"./scripts/build/install-git.sh", "${path.root}/../scripts/build/install-git.sh",
"./scripts/build/install-node.sh", "${path.root}/../scripts/build/install-node.sh",
"./scripts/build/install-common-utils.sh" "${path.root}/../scripts/build/install-common-utils.sh"
] ]
environment_vars = [
"API_PAT=${var.github_api_pat}",
"USER_PASSWORD=${var.vm_password}"
]
execute_command = "chmod +x {{ .Path }}; source $HOME/.bash_profile; {{ .Vars }} {{ .Path }}"
} }
provisioner "shell" { provisioner "shell" {
script = "./scripts/build/Install-Xcode.ps1" environment_vars = ["XCODE_INSTALL_STORAGE_URL=${var.xcode_install_storage_url}", "XCODE_INSTALL_SAS=${var.xcode_install_sas}", "IMAGE_FOLDER=${local.image_folder}"]
environment_vars = [
"XCODE_INSTALL_STORAGE_URL=${var.xcode_install_storage_url}",
"XCODE_INSTALL_SAS=${var.xcode_install_sas}"
]
execute_command = "chmod +x {{ .Path }}; source $HOME/.bash_profile; {{ .Vars }} pwsh -f {{ .Path }}" execute_command = "chmod +x {{ .Path }}; source $HOME/.bash_profile; {{ .Vars }} pwsh -f {{ .Path }}"
script = "${path.root}/../scripts/build/Install-Xcode.ps1"
} }
provisioner "shell" { provisioner "shell" {
execute_command = "source $HOME/.bash_profile; sudo {{ .Vars }} {{ .Path }}" execute_command = "source $HOME/.bash_profile; sudo {{ .Vars }} {{ .Path }}"
expect_disconnect = true expect_disconnect = true
inline = ["echo 'Reboot VM'", "shutdown -r now"] inline = ["echo 'Reboot VM'", "shutdown -r now"]
} }
provisioner "shell" { provisioner "shell" {
scripts = [ environment_vars = ["API_PAT=${var.github_api_pat}", "IMAGE_FOLDER=${local.image_folder}"]
"./scripts/build/install-actions-cache.sh",
"./scripts/build/install-llvm.sh",
"./scripts/build/install-openjdk.sh",
"./scripts/build/install-aws-tools.sh",
"./scripts/build/install-rust.sh",
"./scripts/build/install-gcc.sh",
"./scripts/build/install-cocoapods.sh",
"./scripts/build/install-android-sdk.sh",
"./scripts/build/install-safari.sh",
"./scripts/build/install-chrome.sh",
"./scripts/build/install-bicep.sh",
"./scripts/build/install-codeql-bundle.sh"
]
environment_vars = [
"API_PAT=${var.github_api_pat}"
]
execute_command = "chmod +x {{ .Path }}; source $HOME/.bash_profile; {{ .Vars }} {{ .Path }}" execute_command = "chmod +x {{ .Path }}; source $HOME/.bash_profile; {{ .Vars }} {{ .Path }}"
scripts = [
"${path.root}/../scripts/build/install-actions-cache.sh",
"${path.root}/../scripts/build/install-llvm.sh",
"${path.root}/../scripts/build/install-openjdk.sh",
"${path.root}/../scripts/build/install-aws-tools.sh",
"${path.root}/../scripts/build/install-rust.sh",
"${path.root}/../scripts/build/install-gcc.sh",
"${path.root}/../scripts/build/install-cocoapods.sh",
"${path.root}/../scripts/build/install-android-sdk.sh",
"${path.root}/../scripts/build/install-safari.sh",
"${path.root}/../scripts/build/install-chrome.sh",
"${path.root}/../scripts/build/install-bicep.sh",
"${path.root}/../scripts/build/install-codeql-bundle.sh"
]
} }
provisioner "shell" { provisioner "shell" {
script = "./scripts/build/configure-xcode-simulators.rb"
execute_command = "source $HOME/.bash_profile; ruby {{ .Path }}" execute_command = "source $HOME/.bash_profile; ruby {{ .Path }}"
script = "${path.root}/../scripts/build/configure-xcode-simulators.rb"
} }
provisioner "shell" { provisioner "shell" {
inline = [ environment_vars = ["IMAGE_FOLDER=${local.image_folder}"]
"pwsh -File \"$HOME/image-generation/software-report/Generate-SoftwareReport.ps1\" -OutputDirectory \"$HOME/image-generation/output/software-report\" -ImageName ${var.build_id}"
]
execute_command = "source $HOME/.bash_profile; {{ .Vars }} {{ .Path }}" execute_command = "source $HOME/.bash_profile; {{ .Vars }} {{ .Path }}"
} inline = [
provisioner "file" { "pwsh -File \"${local.image_folder}/software-report/Generate-SoftwareReport.ps1\" -OutputDirectory \"${local.image_folder}/output/software-report\" -ImageName ${var.build_id}"
destination = "../image-output/"
direction = "download"
source = "./image-generation/output/"
}
provisioner "shell" {
scripts = [
"./scripts/build/configure-hostname.sh"
] ]
}
provisioner "file" {
destination = "${path.root}/../../image-output/"
direction = "download"
source = "${local.image_folder}/output/"
}
provisioner "shell" {
execute_command = "chmod +x {{ .Path }}; source $HOME/.bash_profile; {{ .Vars }} {{ .Path }}" execute_command = "chmod +x {{ .Path }}; source $HOME/.bash_profile; {{ .Vars }} {{ .Path }}"
scripts = ["${path.root}/../scripts/build/configure-hostname.sh"]
} }
} }