forked from bpftrace/bpftrace
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Vagrantfile
92 lines (87 loc) · 2.6 KB
/
Vagrantfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
# -*- mode: ruby -*-
# vi: set ft=ruby :
# Environment variables:
#
# SKIP_BCC_BUILD: Set to skip the building bcc from source
$ubuntu_deps = <<EOF
apt-get -qq update
apt-get -qq install linux-headers-$(uname -r) binutils-dev
apt-get -qq install bison cmake flex g++ git libelf-dev zlib1g-dev libfl-dev systemtap-sdt-dev
apt-get -qq install llvm-8-dev llvm-8-runtime libclang-8-dev clang-8
EOF
$fedora_deps = <<EOF
dnf builddep -q -y bpftrace
dnf install -q -y git
EOF
$build_bcc = <<EOF
if [ -e /usr/local/lib/libbcc.so ]; then
echo "libbcc already built, skipping"
exit 0
fi
git clone https://github.com/iovisor/bcc.git
mkdir -p bcc/build
cd bcc/build
cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX=/usr/local ..
make && sudo make install && sudo ldconfig
EOF
Vagrant.configure("2") do |config|
boxes = {
'ubuntu-16.04' => {
'image' => 'ubuntu/xenial64',
'scripts' => [ $ubuntu_deps, ],
},
'ubuntu-18.04' => {
'image' => 'ubuntu/bionic64',
'scripts' => [ $ubuntu_deps, ],
},
'ubuntu-20.04' => {
'image' => 'ubuntu/focal64',
'scripts' => [ $ubuntu_deps, ],
'fix_console' => 0,
},
'fedora-31' => {
'image' => 'fedora/31-cloud-base',
'scripts' => [ $fedora_deps, ],
'skip_bcc_build' => 1
},
'fedora-32' => {
'image' => 'fedora/32-cloud-base',
'scripts' => [ $fedora_deps, ],
'skip_bcc_build' => 1
},
'fedora-33' => {
'image' => 'fedora/33-cloud-base',
'scripts' => [ $fedora_deps, ],
'skip_bcc_build' => 1
}
}
boxes.each do | name, params |
config.vm.define name do |box|
box.vm.box = params['image']
box.vm.provider "virtualbox" do |v|
v.memory = 2048
v.cpus = 2
if params['fix_console'] == 1
v.customize ["modifyvm", :id, "--uart1", "0x3F8", "4"]
v.customize ["modifyvm", :id, "--uartmode1", "file", "./#{name}_ttyS0.log"]
end
end
box.vm.provider :libvirt do |v|
v.memory = 2048
v.cpus = 2
end
(params['scripts'] || []).each do |script|
box.vm.provision :shell, inline: script
end
unless ENV['SKIP_BCC_BUILD'] || (params['skip_bcc_build'] == 1)
box.vm.provision :shell, privileged: false, inline: $build_bcc
end
config.vm.post_up_message = <<-HEREDOC
#######
bpftrace source is available in /vagrant
Build command: cmake /vagrant -DCMAKE_INSTALL_PREFIX=/usr/local && make
#######
HEREDOC
end
end
end