2016-07-04 20:49:41 +02:00
|
|
|
|
|
|
|
require 'yaml'
|
2017-03-25 23:50:10 +01:00
|
|
|
require 'pathname'
|
|
|
|
|
|
|
|
srvpath = Pathname.new(File.dirname(__FILE__)).realpath
|
|
|
|
configfile = YAML.load_file(File.join(srvpath, "/Vagrantfile.yaml"))
|
2016-07-04 20:49:41 +02:00
|
|
|
|
|
|
|
Vagrant.configure("2") do |config|
|
|
|
|
|
2016-08-30 21:23:40 +02:00
|
|
|
# these two caching methods conflict, so only use one at a time
|
|
|
|
if Vagrant.has_plugin?("vagrant-cachier") and not configfile.has_key? "aptcachedir"
|
2016-07-04 20:49:41 +02:00
|
|
|
config.cache.scope = :box
|
|
|
|
config.cache.auto_detect = false
|
|
|
|
config.cache.enable :apt
|
|
|
|
config.cache.enable :chef
|
|
|
|
end
|
|
|
|
|
|
|
|
config.vm.box = configfile['basebox']
|
|
|
|
config.vm.box_url = configfile['baseboxurl']
|
|
|
|
|
2016-09-28 09:52:00 +02:00
|
|
|
if not configfile.has_key? "vm_provider" or configfile["vm_provider"] == "virtualbox"
|
|
|
|
# default to VirtualBox if not set
|
|
|
|
config.vm.provider "virtualbox" do |v|
|
|
|
|
v.customize ["modifyvm", :id, "--memory", configfile['memory']]
|
|
|
|
v.customize ["modifyvm", :id, "--cpus", configfile['cpus']]
|
|
|
|
v.customize ["modifyvm", :id, "--hwvirtex", configfile['hwvirtex']]
|
|
|
|
end
|
|
|
|
synced_folder_type = 'virtualbox'
|
|
|
|
elsif configfile["vm_provider"] == "libvirt"
|
2016-09-05 23:21:24 +02:00
|
|
|
# use KVM/QEMU if this is running in KVM/QEMU
|
|
|
|
config.vm.provider :libvirt do |libvirt|
|
2017-06-02 11:35:46 +02:00
|
|
|
libvirt.driver = configfile["hwvirtex"] == "on" ? "kvm" : "qemu"
|
2016-09-05 23:21:24 +02:00
|
|
|
libvirt.host = "localhost"
|
|
|
|
libvirt.uri = "qemu:///system"
|
|
|
|
libvirt.cpus = configfile["cpus"]
|
|
|
|
libvirt.memory = configfile["memory"]
|
|
|
|
end
|
|
|
|
config.vm.synced_folder './', '/vagrant', type: '9p'
|
|
|
|
synced_folder_type = '9p'
|
|
|
|
else
|
|
|
|
abort("No supported VM Provider found, set vm_provider in Vagrantfile.yaml!")
|
2016-07-04 20:49:41 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
config.vm.boot_timeout = configfile['boot_timeout']
|
|
|
|
|
|
|
|
if configfile.has_key? "aptproxy"
|
|
|
|
config.vm.provision :shell, path: "provision-apt-proxy",
|
|
|
|
args: [configfile["aptproxy"]]
|
|
|
|
end
|
|
|
|
|
|
|
|
# buildserver/ is shared to the VM's /vagrant by default so the old
|
|
|
|
# default does not need a custom mount
|
|
|
|
if configfile["cachedir"] != "buildserver/cache"
|
|
|
|
config.vm.synced_folder configfile["cachedir"], '/vagrant/cache',
|
2016-09-05 23:21:24 +02:00
|
|
|
create: true, type: synced_folder_type
|
2016-07-04 20:49:41 +02:00
|
|
|
end
|
2016-09-15 15:50:16 +02:00
|
|
|
# Make sure dir exists to mount to, since buildserver/ is
|
|
|
|
# automatically mounted as /vagrant in the guest VM. This is more
|
|
|
|
# necessary with 9p synced folders
|
|
|
|
Dir.mkdir('cache') unless File.exists?('cache')
|
2016-07-04 20:49:41 +02:00
|
|
|
|
|
|
|
# cache .deb packages on the host via a mount trick
|
|
|
|
if configfile.has_key? "aptcachedir"
|
|
|
|
config.vm.synced_folder configfile["aptcachedir"], "/var/cache/apt/archives",
|
|
|
|
owner: 'root', group: 'root', create: true
|
|
|
|
end
|
|
|
|
|
|
|
|
config.vm.provision "shell", path: "setup-env-vars",
|
|
|
|
args: ["/home/vagrant/android-sdk"]
|
|
|
|
config.vm.provision "shell", path: "provision-apt-get-install",
|
|
|
|
args: [configfile['debian_mirror']]
|
|
|
|
config.vm.provision "shell", path: "provision-android-sdk"
|
|
|
|
config.vm.provision "shell", path: "provision-android-ndk",
|
|
|
|
args: ["/home/vagrant/android-ndk"]
|
2016-09-24 14:10:55 +02:00
|
|
|
config.vm.provision "shell", path: "provision-qt-sdk",
|
|
|
|
args: ["/home/vagrant/qt-sdk"]
|
2016-07-04 20:49:41 +02:00
|
|
|
config.vm.provision "shell", path: "provision-pip",
|
|
|
|
args: ["compare-locales"]
|
|
|
|
config.vm.provision "shell", path: "provision-gradle"
|
|
|
|
config.vm.provision "file", source: "gradle",
|
|
|
|
destination: "/opt/gradle/bin/gradle"
|
|
|
|
|
|
|
|
end
|