Support 2-digit major versions pkgs, add tests
[integration/packaging.git] / packages / Vagrantfile
1 # -*- mode: ruby -*-
2 # vi: set ft=ruby :
3
4 # Vagrantfile API/syntax version.
5 VAGRANTFILE_API_VERSION = "2"
6
7 Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
8   # Configure VM RAM and CPU for VirtualBox. Change this to meet your needs.
9   config.vm.provider :virtualbox do |virtualbox, override|
10     virtualbox.memory = 2048
11     virtualbox.cpus = 2
12   end
13
14   # Configure VM RAM and CPU for LibVirt. Change this to meet your needs.
15   config.vm.provider :libvirt do |libvirt, override|
16     libvirt.memory = 2048
17     libvirt.cpus = 2
18   end
19
20   # NFS is fragile, use rsync
21   config.vm.synced_folder ".", "/home/vagrant/sync", disabled: true
22   config.vm.synced_folder ".", "/vagrant", type: "rsync",
23     rsync__exclude: [".git/", "*.rpm", "*.tar.gz", "*.zip", "karaf-*",
24                     "distribution-karaf-*"]
25
26   # Define RPM build env
27   config.vm.define :centos do |centos|
28     # Build Vagrant box based on CentOS 7
29     centos.vm.box = "centos/7"
30
31     # TODO: This doesn't work
32     centos.vm.provider "docker" do |docker, override|
33       docker.build_dir = "rpm"
34       docker.remains_running = false
35       override.vm.synced_folder ".", "/build"
36     end
37
38     # Add EPEL for access to fedora-packager and maybe others
39     centos.vm.provision "shell", inline: "yum install -y epel-release"
40
41     # Install required software
42     # fedora-packager: Basic RPM packaging software
43     centos.vm.provision "shell", inline: "yum install -y fedora-packager \
44                                                          python-pip"
45
46     # Use the distribution's version of pip to upgrade to the latest pip
47     centos.vm.provision "shell", inline: "pip install --upgrade pip"
48
49     # Install Python dependences system-wide via pip.
50     centos.vm.provision "shell", inline: "pip install -r /vagrant/requirements.txt"
51
52     # Add vagrant user to mock group for rpmbuild
53     centos.vm.provision "shell", inline: "sudo usermod -a -G mock vagrant"
54   end
55
56   # Define .deb build env
57   config.vm.define :debian do |debian|
58     # Build Vagrant box based on Debian 9
59     debian.vm.box = "debian/stretch64"
60
61     # TODO: This doesn't work
62     debian.vm.provider "docker" do |docker, override|
63       docker.build_dir = "deb"
64       docker.remains_running = false
65       override.vm.synced_folder ".", "/build"
66     end
67
68     # Update package info to prevent old info from causing 404s during install
69     debian.vm.provision "shell", inline: "apt-get update"
70
71     # Install pkg dev tools, Python libs for build scripts, gdebi to test install
72     debian.vm.provision "shell", inline: "apt-get install -y build-essential \
73                                                              devscripts \
74                                                              equivs \
75                                                              dh-systemd \
76                                                              git \
77                                                              python-pip \
78                                                              gdebi"
79
80     # Use the distribution's version of pip to upgrade to the latest pip
81     debian.vm.provision "shell", inline: "pip install --upgrade pip"
82
83     # Install Python dependences system-wide via pip
84     debian.vm.provision "shell", inline: "pip install -r /vagrant/requirements.txt"
85   end
86 end