forked from Kitura/Kitura
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvagrantfile
87 lines (68 loc) · 3.02 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
# -*- mode: ruby -*-
# vi: set ft=ruby :
BOX_URL = "https://cloud-images.ubuntu.com/vagrant/wily/current/wily-server-cloudimg-amd64-vagrant-disk1.box"
SWIFT_PATH = "https://swift.org/builds/development/ubuntu1510/swift-DEVELOPMENT-SNAPSHOT-2016-02-08-a"
SWIFT_DIRECTORY = "swift-DEVELOPMENT-SNAPSHOT-2016-02-08-a-ubuntu15.10"
SWIFT_FILE = "#{SWIFT_DIRECTORY}.tar.gz"
PCRE_PATH = "http://ftp.exim.org/pub/pcre"
PCRE_DIRECTORY = "pcre2-10.20"
PCRE_FILE = "#{PCRE_DIRECTORY}.tar.gz"
LIBDISPATCH_URL = "git://github.com/seabaylea/swift-corelibs-libdispatch"
LIBDISPATCH_BRANCH = "opaque-pointer"
MODULEMAP_URL = "https://raw.githubusercontent.com/IBM-Swift/Kitura/master/Sources/Modulemaps/module.modulemap"
KITURA_URL = "https://github.com/IBM-Swift/Kitura.git"
Vagrant.configure(2) do |config|
config.vm.box = BOX_URL
config.vm.network "forwarded_port", guest: 8090, host: 8090
# Prevents "stdin: is not a tty" on Ubuntu (https://github.com/mitchellh/vagrant/issues/1673)
config.vm.provision "fix-no-tty", type: "shell" do |s|
s.privileged = false
s.inline = "sudo sed -i '/tty/!s/mesg n/tty -s \\&\\& mesg n/' /root/.profile"
end
config.vm.provision "shell", inline: <<-SHELL
### Install packages
# 1. Install compiler, autotools
sudo apt-get --assume-yes install clang
sudo apt-get --assume-yes install autoconf libtool pkg-config
# 2. Install dtrace (to generate provider.h)
sudo apt-get --assume-yes install systemtap-sdt-dev
# 3. Install libdispatch pre-reqs
sudo apt-get --assume-yes install libblocksruntime-dev libkqueue-dev libpthread-workqueue-dev libbsd-dev
# 4. Kitura packages
sudo apt-get --assume-yes install libhttp-parser-dev libcurl4-openssl-dev libhiredis-dev
# 5. Git
sudo apt-get --assume-yes install git
### Download Swift binary if not found, install it, and add it to the path
if [ ! -f "#{SWIFT_FILE}" ]; then
curl -O "#{SWIFT_PATH}/#{SWIFT_FILE}"
fi
tar zxf #{SWIFT_FILE}
if [ $(grep -c "#{SWIFT_FILE}" .profile) -eq 0 ]; then
echo "export PATH=/home/vagrant/#{SWIFT_DIRECTORY}/usr/bin:\"${PATH}\"" >> .profile
source .profile
fi
### Download and build patched libdispatch
git clone -b #{LIBDISPATCH_BRANCH} #{LIBDISPATCH_URL}
cd swift-corelibs-libdispatch && sh ./autogen.sh && ./configure && make && sudo make install
cd ..
### Download module map and copy insto /usr/local/include/dispatch
mkdir -p /usr/local/include/dispatch
curl #{MODULEMAP_URL} -o /usr/local/include/dispatch/module.modulemap
### Download and build pcre
if [ ! -f "#{PCRE_FILE}" ]; then
curl -O "#{PCRE_PATH}/#{PCRE_FILE}"
fi
tar zxf #{PCRE_FILE}
cd #{PCRE_DIRECTORY} && ./configure && make && sudo make install && cd ..
### Download and install Kitura
git clone #{KITURA_URL}
cd Kitura
make
cd ..
### Export LD_LIBRARY_PATH
if [ $(grep -c "LD_LIBRARY_PATH=/usr/local/lib" .profile) -eq 0 ]; then
echo "export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH" >> .profile
source .profile
fi
SHELL
end