1# -*- mode: ruby -*-
2# vi: set ft=ruby :
3
4#
5# Licensed to the Apache Software Foundation (ASF) under one
6# or more contributor license agreements. See the NOTICE file
7# distributed with this work for additional information
8# regarding copyright ownership. The ASF licenses this file
9# to you under the Apache License, Version 2.0 (the
10# "License"); you may not use this file except in compliance
11# with the License. You may obtain a copy of the License at
12#
13#   http://www.apache.org/licenses/LICENSE-2.0
14#
15# Unless required by applicable law or agreed to in writing,
16# software distributed under the License is distributed on an
17# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
18# KIND, either express or implied. See the License for the
19# specific language governing permissions and limitations
20# under the License.
21#
22
23$build_and_test = <<SCRIPT
24echo "Provisioning system to compile and test Apache Thrift."
25
26# Create swap space
27sudo fallocate -l 2G /swapfile
28sudo chmod 600 /swapfile
29sudo mkswap /swapfile
30sudo swapon /swapfile
31sudo swapon -s
32
33# Update the system
34sudo DEBIAN_FRONTEND=noninteractive apt-get update -qq -y
35sudo DEBIAN_FRONTEND=noninteractive apt-get upgrade -qq -y
36
37# Install Dependencies
38# ---
39# General dependencies
40sudo apt-get install -qq automake libtool flex bison pkg-config g++ libssl-dev make git debhelper
41
42# C++ dependencies
43sudo apt-get install -qq libboost-dev libboost-test-dev libboost-program-options-dev libboost-filesystem-dev libboost-system-dev libevent-dev
44
45# Java dependencies
46sudo apt-get install -qq ant openjdk-8-jdk maven
47
48# Python dependencies
49sudo apt-get install -qq python-all python-all-dev python-all-dbg python-setuptools python-support python-six python3-six
50
51# Ruby dependencies
52sudo apt-get install -qq ruby ruby-dev
53sudo gem install bundler rake
54
55# Perl dependencies
56sudo apt-get install -qq libbit-vector-perl libclass-accessor-class-perl
57
58# Php dependencies
59sudo apt-get install -qq php5 php5-dev php5-cli php-pear re2c
60
61# GlibC dependencies
62sudo apt-get install -qq libglib2.0-dev
63
64# Erlang dependencies
65sudo apt-get install -qq erlang-base erlang-eunit erlang-dev erlang-tools
66
67# GO dependencies
68echo "golang-go golang-go/dashboard boolean false" | debconf-set-selections
69sudo apt-get -y install -qq golang golang-go
70
71# Lua dependencies
72sudo apt-get install -qq lua5.2 lua5.2-dev
73
74# Node.js dependencies
75sudo apt-get install -qq nodejs nodejs-dev nodejs-legacy npm
76
77# D dependencies
78sudo wget http://master.dl.sourceforge.net/project/d-apt/files/d-apt.list -O /etc/apt/sources.list.d/d-apt.list
79sudo apt-get update && sudo apt-get -y --allow-unauthenticated install --reinstall d-apt-keyring && sudo apt-get update
80sudo apt-get install -qq xdg-utils dmd-bin
81
82# Customize the system
83# ---
84# Default java to latest 1.8 version
85update-java-alternatives -s java-1.8.0-openjdk-amd64
86
87# PHPUnit package broken in ubuntu. see https://bugs.launchpad.net/ubuntu/+source/phpunit/+bug/701544
88sudo apt-get upgrade pear
89sudo pear channel-discover pear.phpunit.de
90sudo pear channel-discover pear.symfony.com
91sudo pear channel-discover components.ez.no
92sudo pear update-channels
93sudo pear upgrade-all
94sudo pear install --alldeps phpunit/PHPUnit
95
96date > /etc/vagrant.provisioned
97
98# Start the source build
99# ---
100echo "Starting Apache Thrift build..."
101cd /thrift
102sh bootstrap.sh
103sh configure
104make
105make check
106echo "Finished building Apache Thrift."
107
108SCRIPT
109
110Vagrant.configure("2") do |config|
111  # Ubuntu 14.04 LTS (Trusty Tahr)
112  config.vm.box = "trusty64"
113  config.vm.box_url = "https://cloud-images.ubuntu.com/vagrant/trusty/current/trusty-server-cloudimg-amd64-vagrant-disk1.box"
114
115  config.vm.synced_folder "../", "/thrift"
116
117  config.vm.provider :virtualbox do |vbox|
118    vbox.customize ["modifyvm", :id, "--memory", "1024"]
119    vbox.customize ["modifyvm", :id, "--cpus", "2"]
120    vbox.customize ["modifyvm", :id, "--rtcuseutc", "on"]
121  end
122
123  # Run the build script to configure the system
124  config.vm.provision :shell, :inline => $build_and_test
125end
126