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