5 srvpath = Pathname.new(File.dirname(__FILE__)).realpath
6 configfile = YAML.load_file(File.join(srvpath, "/Vagrantfile.yaml"))
8 Vagrant.configure("2") do |config|
10 # these two caching methods conflict, so only use one at a time
11 if Vagrant.has_plugin?("vagrant-cachier") and not configfile.has_key? "aptcachedir"
12 config.cache.scope = :box
13 config.cache.auto_detect = false
14 config.cache.enable :apt
15 config.cache.enable :chef
18 config.vm.box = configfile['basebox']
19 config.vm.box_url = configfile['baseboxurl']
21 if not configfile.has_key? "vm_provider" or configfile["vm_provider"] == "virtualbox"
22 # default to VirtualBox if not set
23 config.vm.provider "virtualbox" do |v|
24 v.customize ["modifyvm", :id, "--memory", configfile['memory']]
25 v.customize ["modifyvm", :id, "--cpus", configfile['cpus']]
26 v.customize ["modifyvm", :id, "--hwvirtex", configfile['hwvirtex']]
28 synced_folder_type = 'virtualbox'
29 elsif configfile["vm_provider"] == "libvirt"
30 # use KVM/QEMU if this is running in KVM/QEMU
31 config.vm.provider :libvirt do |libvirt|
32 libvirt.driver = configfile["hwvirtex"] == "on" ? "kvm" : "qemu"
33 libvirt.host = "localhost"
34 libvirt.uri = "qemu:///system"
35 libvirt.cpus = configfile["cpus"]
36 libvirt.memory = configfile["memory"]
38 config.vm.synced_folder './', '/vagrant', type: '9p'
39 synced_folder_type = '9p'
41 abort("No supported VM Provider found, set vm_provider in Vagrantfile.yaml!")
44 config.vm.boot_timeout = configfile['boot_timeout']
46 if configfile.has_key? "aptproxy"
47 config.vm.provision :shell, path: "provision-apt-proxy",
48 args: [configfile["aptproxy"]]
51 # buildserver/ is shared to the VM's /vagrant by default so the old
52 # default does not need a custom mount
53 if configfile["cachedir"] != "buildserver/cache"
54 config.vm.synced_folder configfile["cachedir"], '/vagrant/cache',
55 create: true, type: synced_folder_type
57 # Make sure dir exists to mount to, since buildserver/ is
58 # automatically mounted as /vagrant in the guest VM. This is more
59 # necessary with 9p synced folders
60 Dir.mkdir('cache') unless File.exists?('cache')
62 # cache .deb packages on the host via a mount trick
63 if configfile.has_key? "aptcachedir"
64 config.vm.synced_folder configfile["aptcachedir"], "/var/cache/apt/archives",
65 owner: 'root', group: 'root', create: true
68 config.vm.provision "shell", path: "setup-env-vars",
69 args: ["/home/vagrant/android-sdk"]
70 config.vm.provision "shell", path: "provision-apt-get-install",
71 args: [configfile['debian_mirror']]
72 config.vm.provision "shell", path: "provision-android-sdk"
73 config.vm.provision "shell", path: "provision-android-ndk",
74 args: ["/home/vagrant/android-ndk"]
75 config.vm.provision "shell", path: "provision-pip",
76 args: ["compare-locales"]
77 config.vm.provision "shell", path: "provision-gradle"
78 config.vm.provision "file", source: "gradle",
79 destination: "/opt/gradle/bin/gradle"