mirror of
https://gitlab.com/fdroid/fdroidserver.git
synced 2024-11-04 22:40:12 +01:00
bb77d7a6d2
_/opt/android-sdk_ was chosen for a number of reasons: * _/opt_ is [standardized][1] for packages like the Android SDK, which has its own directory layout. * _android-sdk_ is used rather than the upstream directory name from the ZIP (e.g. _android-sdk-linux_) so that the path is the same on all platforms. * On platforms without official _/opt_ support ([macOS][2], [Windows][3], [FreeBSD][4], etc.), it does not conflict with any existing system directory. [1]: https://refspecs.linuxfoundation.org/FHS_3.0/fhs/ch03s13.html [2]: https://developer.apple.com/library/archive/documentation/FileManagement/Conceptual/FileSystemProgrammingGuide/FileSystemOverview/FileSystemOverview.html#//apple_ref/doc/uid/TP40010672-CH2-SW7 [3]: https://en.wikipedia.org/wiki/Directory_structure#Windows_10 [4]: https://www.freebsd.org/cgi/man.cgi?query=hier&sektion=7&format=html
91 lines
3.3 KiB
Ruby
91 lines
3.3 KiB
Ruby
|
|
require 'yaml'
|
|
require 'pathname'
|
|
|
|
srvpath = Pathname.new(File.dirname(__FILE__)).realpath
|
|
configfile = YAML.load_file(File.join(srvpath, "/Vagrantfile.yaml"))
|
|
|
|
Vagrant.configure("2") do |config|
|
|
|
|
# these two caching methods conflict, so only use one at a time
|
|
if Vagrant.has_plugin?("vagrant-cachier") and not configfile.has_key? "aptcachedir"
|
|
config.cache.scope = :box
|
|
config.cache.auto_detect = false
|
|
config.cache.enable :apt
|
|
config.cache.enable :chef
|
|
end
|
|
|
|
config.vm.box = configfile['basebox']
|
|
if configfile.has_key? "basebox_version"
|
|
config.vm.box_version = configfile['basebox_version']
|
|
end
|
|
|
|
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"
|
|
# use KVM/QEMU if this is running in KVM/QEMU
|
|
config.vm.provider :libvirt do |libvirt|
|
|
libvirt.driver = configfile["hwvirtex"] == "on" ? "kvm" : "qemu"
|
|
libvirt.host = "localhost"
|
|
libvirt.uri = "qemu:///system"
|
|
libvirt.cpus = configfile["cpus"]
|
|
libvirt.memory = configfile["memory"]
|
|
if configfile.has_key? "libvirt_disk_bus"
|
|
libvirt.disk_bus = configfile["libvirt_disk_bus"]
|
|
end
|
|
if configfile.has_key? "libvirt_nic_model_type"
|
|
libvirt.nic_model_type = configfile["libvirt_nic_model_type"]
|
|
end
|
|
end
|
|
if configfile.has_key? "synced_folder_type"
|
|
synced_folder_type = configfile["synced_folder_type"]
|
|
else
|
|
synced_folder_type = '9p'
|
|
end
|
|
config.vm.synced_folder './', '/vagrant', type: synced_folder_type,
|
|
SharedFoldersEnableSymlinksCreate: false
|
|
else
|
|
abort("No supported VM Provider found, set vm_provider in Vagrantfile.yaml!")
|
|
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',
|
|
create: true, type: synced_folder_type
|
|
end
|
|
# 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')
|
|
|
|
# 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: ["/opt/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"]
|
|
config.vm.provision "shell", path: "provision-gradle"
|
|
|
|
end
|