|
| 1 | +packer { |
| 2 | + required_plugins { |
| 3 | + veertu-anka = { |
| 4 | + version = ">= v3.2.0" |
| 5 | + source = "github.com/veertuinc/veertu-anka" |
| 6 | + } |
| 7 | + } |
| 8 | +} |
| 9 | + |
| 10 | +variable "source_vm_name" { |
| 11 | + type = string |
| 12 | +} |
| 13 | + |
| 14 | +variable "source_vm_tag" { |
| 15 | + type = string |
| 16 | +} |
| 17 | + |
| 18 | +variable "build_id" { |
| 19 | + type = string |
| 20 | +} |
| 21 | + |
| 22 | +variable "vm_username" { |
| 23 | + type = string |
| 24 | + sensitive = true |
| 25 | +} |
| 26 | + |
| 27 | +variable "vm_password" { |
| 28 | + type = string |
| 29 | + sensitive = true |
| 30 | +} |
| 31 | + |
| 32 | +variable "github_api_pat" { |
| 33 | + type = string |
| 34 | + default = "" |
| 35 | +} |
| 36 | + |
| 37 | +variable "xcode_install_storage_url" { |
| 38 | + type = string |
| 39 | + sensitive = true |
| 40 | +} |
| 41 | + |
| 42 | +variable "xcode_install_sas" { |
| 43 | + type = string |
| 44 | + sensitive = true |
| 45 | +} |
| 46 | + |
| 47 | +variable "vcpu_count" { |
| 48 | + type = string |
| 49 | + default = "6" |
| 50 | +} |
| 51 | + |
| 52 | +variable "ram_size" { |
| 53 | + type = string |
| 54 | + default = "24G" |
| 55 | +} |
| 56 | + |
| 57 | +variable "image_os" { |
| 58 | + type = string |
| 59 | + default = "macos14" |
| 60 | +} |
| 61 | + |
| 62 | +source "veertu-anka-vm-clone" "template" { |
| 63 | + vm_name = "${var.build_id}" |
| 64 | + source_vm_name = "${var.source_vm_name}" |
| 65 | + source_vm_tag = "${var.source_vm_tag}" |
| 66 | + vcpu_count = "${var.vcpu_count}" |
| 67 | + ram_size = "${var.ram_size}" |
| 68 | + stop_vm = "true" |
| 69 | +} |
| 70 | + |
| 71 | +build { |
| 72 | + sources = [ |
| 73 | + "source.veertu-anka-vm-clone.template" |
| 74 | + ] |
| 75 | + provisioner "shell" { |
| 76 | + inline = [ |
| 77 | + "mkdir ~/image-generation" |
| 78 | + ] |
| 79 | + } |
| 80 | + provisioner "file" { |
| 81 | + destination = "image-generation/" |
| 82 | + sources = [ |
| 83 | + "./provision/assets", |
| 84 | + "./tests", |
| 85 | + "./software-report", |
| 86 | + "./helpers" |
| 87 | + ] |
| 88 | + } |
| 89 | + provisioner "file" { |
| 90 | + destination = "image-generation/software-report/" |
| 91 | + source = "../../helpers/software-report-base" |
| 92 | + } |
| 93 | + provisioner "file" { |
| 94 | + destination = "image-generation/add-certificate.swift" |
| 95 | + source = "./provision/configuration/add-certificate.swift" |
| 96 | + } |
| 97 | + provisioner "file" { |
| 98 | + destination = ".bashrc" |
| 99 | + source = "./provision/configuration/environment/bashrc" |
| 100 | + } |
| 101 | + provisioner "file" { |
| 102 | + destination = ".bash_profile" |
| 103 | + source = "./provision/configuration/environment/bashprofile" |
| 104 | + } |
| 105 | + provisioner "file" { |
| 106 | + destination = "./" |
| 107 | + source = "./provision/utils" |
| 108 | + } |
| 109 | + provisioner "shell" { |
| 110 | + inline = [ |
| 111 | + "mkdir ~/bootstrap" |
| 112 | + ] |
| 113 | + } |
| 114 | + provisioner "file" { |
| 115 | + destination = "bootstrap" |
| 116 | + source = "./provision/bootstrap-provisioner/" |
| 117 | + } |
| 118 | + provisioner "file" { |
| 119 | + destination = "image-generation/toolset.json" |
| 120 | + source = "./toolsets/toolset-14.json" |
| 121 | + } |
| 122 | + provisioner "shell" { |
| 123 | + scripts = [ |
| 124 | + "./provision/core/xcode-clt.sh", |
| 125 | + "./provision/core/homebrew.sh" |
| 126 | + ] |
| 127 | + execute_command = "chmod +x {{ .Path }}; source $HOME/.bash_profile; {{ .Vars }} {{ .Path }}" |
| 128 | + } |
| 129 | + provisioner "shell" { |
| 130 | + scripts = [ |
| 131 | + "./provision/configuration/configure-tccdb-macos.sh", |
| 132 | + "./provision/configuration/disable-auto-updates.sh", |
| 133 | + "./provision/configuration/ntpconf.sh", |
| 134 | + "./provision/configuration/shell-change.sh" |
| 135 | + ] |
| 136 | + environment_vars = [ |
| 137 | + "PASSWORD=${var.vm_password}", |
| 138 | + "USERNAME=${var.vm_username}" |
| 139 | + ] |
| 140 | + execute_command = "chmod +x {{ .Path }}; source $HOME/.bash_profile; sudo {{ .Vars }} {{ .Path }}" |
| 141 | + } |
| 142 | + provisioner "shell" { |
| 143 | + scripts = [ |
| 144 | + "./provision/configuration/preimagedata.sh", |
| 145 | + "./provision/configuration/configure-ssh.sh", |
| 146 | + "./provision/configuration/configure-machine.sh" |
| 147 | + ] |
| 148 | + environment_vars = [ |
| 149 | + "IMAGE_VERSION=${var.build_id}", |
| 150 | + "IMAGE_OS=${var.image_os}", |
| 151 | + "PASSWORD=${var.vm_password}" |
| 152 | + ] |
| 153 | + execute_command = "chmod +x {{ .Path }}; source $HOME/.bash_profile; {{ .Vars }} {{ .Path }}" |
| 154 | + } |
| 155 | + provisioner "shell" { |
| 156 | + script = "./provision/core/reboot.sh" |
| 157 | + execute_command = "chmod +x {{ .Path }}; source $HOME/.bash_profile; sudo {{ .Vars }} {{ .Path }}" |
| 158 | + expect_disconnect = true |
| 159 | + } |
| 160 | + provisioner "shell" { |
| 161 | + pause_before = "30s" |
| 162 | + scripts = [ |
| 163 | + "./provision/core/open_windows_check.sh", |
| 164 | + "./provision/core/powershell.sh", |
| 165 | + "./provision/core/mono.sh", |
| 166 | + "./provision/core/dotnet.sh", |
| 167 | + "./provision/core/python.sh", |
| 168 | + "./provision/core/azcopy.sh", |
| 169 | + "./provision/core/openssl.sh", |
| 170 | + "./provision/core/ruby.sh", |
| 171 | + "./provision/core/rubygem.sh", |
| 172 | + "./provision/core/git.sh", |
| 173 | + "./provision/core/node.sh", |
| 174 | + "./provision/core/commonutils.sh" |
| 175 | + ] |
| 176 | + environment_vars = [ |
| 177 | + "API_PAT=${var.github_api_pat}", |
| 178 | + "USER_PASSWORD=${var.vm_password}" |
| 179 | + ] |
| 180 | + execute_command = "chmod +x {{ .Path }}; source $HOME/.bash_profile; {{ .Vars }} {{ .Path }}" |
| 181 | + } |
| 182 | + provisioner "shell" { |
| 183 | + script = "./provision/core/xcode.ps1" |
| 184 | + environment_vars = [ |
| 185 | + "XCODE_INSTALL_STORAGE_URL=${var.xcode_install_storage_url}", |
| 186 | + "XCODE_INSTALL_SAS=${var.xcode_install_sas}" |
| 187 | + ] |
| 188 | + execute_command = "chmod +x {{ .Path }}; source $HOME/.bash_profile; {{ .Vars }} pwsh -f {{ .Path }}" |
| 189 | + } |
| 190 | + provisioner "shell" { |
| 191 | + script = "./provision/core/reboot.sh" |
| 192 | + execute_command = "chmod +x {{ .Path }}; source $HOME/.bash_profile; sudo {{ .Vars }} {{ .Path }}" |
| 193 | + expect_disconnect = true |
| 194 | + } |
| 195 | + provisioner "shell" { |
| 196 | + scripts = [ |
| 197 | + "./provision/core/action-archive-cache.sh", |
| 198 | + "./provision/core/llvm.sh", |
| 199 | + "./provision/core/swiftlint.sh", |
| 200 | + "./provision/core/openjdk.sh", |
| 201 | + "./provision/core/php.sh", |
| 202 | + "./provision/core/aws.sh", |
| 203 | + "./provision/core/rust.sh", |
| 204 | + "./provision/core/gcc.sh", |
| 205 | + "./provision/core/haskell.sh", |
| 206 | + "./provision/core/cocoapods.sh", |
| 207 | + "./provision/core/android-toolsets.sh", |
| 208 | + "./provision/core/apache.sh", |
| 209 | + "./provision/core/vcpkg.sh", |
| 210 | + "./provision/core/safari.sh", |
| 211 | + "./provision/core/chrome.sh", |
| 212 | + "./provision/core/edge.sh", |
| 213 | + "./provision/core/firefox.sh", |
| 214 | + "./provision/core/pypy.sh", |
| 215 | + "./provision/core/bicep.sh", |
| 216 | + "./provision/core/codeql-bundle.sh" |
| 217 | + ] |
| 218 | + environment_vars = [ |
| 219 | + "API_PAT=${var.github_api_pat}" |
| 220 | + ] |
| 221 | + execute_command = "chmod +x {{ .Path }}; source $HOME/.bash_profile; {{ .Vars }} {{ .Path }}" |
| 222 | + } |
| 223 | + provisioner "shell" { |
| 224 | + script = "./provision/core/delete-duplicate-sims.rb" |
| 225 | + execute_command = "source $HOME/.bash_profile; ruby {{ .Path }}" |
| 226 | + } |
| 227 | + provisioner "shell" { |
| 228 | + inline = [ |
| 229 | + "pwsh -File \"$HOME/image-generation/software-report/SoftwareReport.Generator.ps1\" -OutputDirectory \"$HOME/image-generation/output/software-report\" -ImageName ${var.build_id}" |
| 230 | + ] |
| 231 | + execute_command = "source $HOME/.bash_profile; {{ .Vars }} {{ .Path }}" |
| 232 | + } |
| 233 | + provisioner "file" { |
| 234 | + destination = "../image-output/" |
| 235 | + direction = "download" |
| 236 | + source = "./image-generation/output/" |
| 237 | + } |
| 238 | + provisioner "shell" { |
| 239 | + scripts = [ |
| 240 | + "./provision/configuration/configure-hostname.sh", |
| 241 | + "./provision/configuration/cleanup-brew.sh", |
| 242 | + "./provision/configuration/finalize-vm.sh" |
| 243 | + ] |
| 244 | + execute_command = "chmod +x {{ .Path }}; source $HOME/.bash_profile; {{ .Vars }} {{ .Path }}" |
| 245 | + } |
| 246 | +} |
0 commit comments