summaryrefslogtreecommitdiffhomepage
path: root/ci/ios/create-vm/install-build-dependencies.pkr.hcl
blob: deeacf609f2373603074fcb45320a7e8a4539979 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
packer {
  required_plugins {
    tart = {
      version = ">= 1.2.0"
      source  = "github.com/cirruslabs/tart"
    }
  }
}

variable "shared_folder_path" { type = string }

variable "xcode_version" {
  type = string

  validation {
    condition = can(regex("(\\d)+(\\.)?((\\d)+)?(\\.)?((\\d)+)?", var.xcode_version))
    error_message = "Invalid Xcode version number. Example of a valid number: '15.0.1'."
  }
}

variable "vm_name" { type = string }

variable "user_name" { type = string }

variable "xcode_xip_name" {
  type = string

  validation {
    condition = can(regex("Xcode_(\\d)+(\\.)?((\\d)+)?(\\.)?((\\d)+)?\\.xip", var.xcode_xip_name))
    error_message = "Invalid Xcode file name. Example of a valid file name: 'Xcode_15.0.1.xip'."
  }
}

source "tart-cli" "tart" {
  vm_name      = "${var.vm_name}"
  ssh_password = "admin"
  ssh_username = "admin"
  ssh_timeout  = "120s"
  disk_size_gb = 80
}

build {
  sources = ["source.tart-cli.tart"]


  // Create a symlink for bash compatibility
  provisioner "shell" {
    script = "scripts/link-zprofile.sh"
  }

  // Install brew
  provisioner "shell" {
    environment_vars = [
    "USER=${var.user_name}"
    ]
    script = "scripts/install-brew.sh"
  }


  // Install required brew dependencies
  provisioner "shell" {
    script = "scripts/install-brew-dependencies.sh"
  }

  // Install rustup
  provisioner "shell" {
    script = "scripts/install-rustup.sh"
  }

  // Install go
  provisioner "shell" {
    script = "scripts/install-go.sh"
  }

  // Copy the local Xcode xip file to the VM
  provisioner "file" {
    source      = "${var.shared_folder_path}/${var.xcode_xip_name}"
    destination = "/tmp/${var.xcode_xip_name}"
  }

  // Install Xcode via xcodes.app
  provisioner "shell" {

    environment_vars = [
    "XCODE_VERSION=${var.xcode_version}",
    "XCODE_XIP_NAME=${var.xcode_xip_name}",
    "XCODE_SHARED_PATH=/tmp",
    ]
    script = "scripts/install-xcode.sh"
  }

  // Delete the Xcode xip file to save some space
  provisioner "shell" {
    inline = [
      "rm -f /tmp/${var.xcode_xip_name}"
    ]
  }

  // Run the xcodebuild first launch prompt to automatically accept terms and conditions, and download the iOS runtime simulator
  provisioner "shell" {
    script = "scripts/run-xcode-first-launch.sh"
  }

  // Add Apple root certs
  provisioner "shell" {
    script = "scripts/add-apple-certs.sh"
  }

  // Remove everything in case of error
  error-cleanup-provisioner "shell" {
    script = "scripts/cleanup.sh"
  }
}