-
Notifications
You must be signed in to change notification settings - Fork 2
/
Vagrantfile
138 lines (113 loc) · 4.65 KB
/
Vagrantfile
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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
# -*- mode: ruby -*-
# vi: set ft=ruby :
required_plugins = %w( vagrant-disksize vagrant-vbguest)
$new_plugin = false
required_plugins.each do |plugin|
# if not installed, attempt to install
unless Vagrant.has_plugin? plugin
system "vagrant plugin install #{plugin}"
$new_plugin = true
end
end
# restart vagrant if new plugin
if $new_plugin
exec "vagrant #{ARGV.join''}"
end
if !File.file?("./downloads/petalinux-v2017.4-final-installer.run")
raise "Error: Petalinux Tools v2017.4 is required for provisioning."
end
# load provision config
require './provision/config.rb'
# Use the current Git SHA1 as the VM version number.
$vm_version = `git rev-parse HEAD`
################################################################################
# VM Configuration
################################################################################
# Note: There is currently an issue in the xenial64 image where disk access
# times out during the boot process, extending the boot time up to a minute.
# The solution is to switch the virtual machine from using a SCSI disk
# controller to a SATA disk controller.
#
# To do so:
# 1. In VirtualBox, open Settings for your VM and go to Storage.
# 2. Remove all disk images under the SCSI controller.
# 3. Click "Add a new storage controller" and choose SATA.
# 4. For each disk image, click "Add a new storage attachment", select "Add Hard
# Disk", and navigate to the image file.
#
# Reference:
# https://bugs.launchpad.net/cloud-images/+bug/1616794
# Note: The default disk for xenial64 has a size of 10 GB. To resize the disk:
# 1. Navigate to the VM's storage directory (e.g., ~/VirtualBox VMs/gnssta).
# 2. Convert the VMDK image to VDI format (VMDK images cannot be resized):
# VBoxManage clonehd ubuntu-...vmdk ubuntu-...vdi --format vdi
# 3. Resize the disk (where N is the desired size in MB):
# VBoxManage modifyhd ubuntu-...vdi --resize N
# 4. In VirtualBox, open Settings for your VM and go to Storage.
# 1. Remove the VMDK image from the list of disks.
# 2. Click "Add a new storage attachment", select "Add Hard Disk", and
# navigate to the image file.
#
# Note that VBoxManage.exe is in C:/Program Files/Oracle/VirtualBox/ by default.
def provisionFile(path, config)
if File.exist?(path)
if File.directory?(path)
config.vm.provision "shell", privileged: false, inline: "mkdir #{path}"
for file in Dir[File.expand_path(path) + "/*"]
privisionFile(file, config)
end
else
config.vm.provision "file", source: path, destination: path
end
end
end
Vagrant.configure(2) do |config|
# Every Vagrant development environment requires a box. You can search for
# boxes at https://atlas.hashicorp.com/search.
config.vm.box = "bento/ubuntu-16.04"
config.vm.hostname = $hostname
config.ssh.shell = "bash"
# Enable X11 forwarding.
config.ssh.forward_x11 = true
config.ssh.forward_agent = true
# Configure the VM network settings.
if $network_bridged
if $network_ip == ""
config.vm.network "public_network"
else
config.vm.network "public_network", ip: "#{$network_ip}"
end
else
# Configure port forwarding.
config.vm.network "forwarded_port", guest: 9999, host: 9999, protocol: 'tcp'
config.vm.network "forwarded_port", guest: 8080, host: 8080, protocol: 'udp'
config.vm.network "forwarded_port", guest: 8080, host: 8080, protocol: 'tcp'
end
# VirtualBox-specific configuration.
config.vm.provider "virtualbox" do |v|
v.name = $vm_name
v.gui = $enable_gui_mode
v.cpus = $num_cpus
v.memory = $memory_size
config.disksize.size = '100GB'
# set video ram to something useful
v.customize ["modifyvm", :id, "--vram", "64"]
# enable usb
v.customize ["modifyvm", :id, "--usbxhci", "on"]
end
# sync folder
config.vm.synced_folder "./", "/vagrant"
# configure setup ssh agent
config.vm.provision "shell", privileged: false, path: "./provision/scripts/ssh_agent.sh"
# provision scripts
config.vm.provision "shell", privileged: false, path: "./provision/scripts/system_setup.sh"
config.vm.provision "shell", privileged: false,
path: "./provision/scripts/petalinux_install.sh"
config.vm.provision "shell", path: "./team/customizations.sh"
# Store the version of the Vagrant configuration used to provision the VM.
config.vm.provision "shell",
inline: "echo -n \"#{$vm_version}\" > /home/vagrant/.vm_version"
# pull git repo
config.vm.provision "shell", privileged: false, path: "./provision/scripts/git_clone.sh", args: "#{$petalinux_git} ~/MES"
config.vm.provision "shell", inline: "echo 'Provisioning complete, please reboot the machine now.'"
end