2013-10-20 17:38:22 +04:00
|
|
|
# -*- mode: ruby -*-
|
|
|
|
# vi: set ft=ruby :
|
|
|
|
|
|
|
|
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
|
|
|
#
|
|
|
|
# Place this Vagrantfile in your src folder and run:
|
|
|
|
#
|
|
|
|
# vagrant up
|
|
|
|
#
|
|
|
|
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
|
|
|
|
|
|
|
GO_ARCHIVES = {
|
2014-09-26 19:40:54 +04:00
|
|
|
"linux" => "go1.3.1.linux-amd64.tar.gz",
|
2013-10-20 17:38:22 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
INSTALL = {
|
|
|
|
"linux" => "apt-get update -qq; apt-get install -qq -y git mercurial bzr curl",
|
|
|
|
}
|
|
|
|
|
|
|
|
# location of the Vagrantfile
|
|
|
|
def src_path
|
2013-12-02 10:57:22 +04:00
|
|
|
ENV["GOPATH"]
|
2013-10-20 17:38:22 +04:00
|
|
|
end
|
|
|
|
|
|
|
|
# shell script to bootstrap Go
|
|
|
|
def bootstrap(box)
|
|
|
|
install = INSTALL[box]
|
|
|
|
archive = GO_ARCHIVES[box]
|
2014-01-07 19:47:39 +04:00
|
|
|
vagrant_home = "/home/vagrant"
|
2013-10-20 17:38:22 +04:00
|
|
|
|
|
|
|
profile = <<-PROFILE
|
2014-01-07 19:47:39 +04:00
|
|
|
export GOROOT=#{vagrant_home}/go
|
|
|
|
export GOPATH=#{vagrant_home}/gocode
|
2014-09-26 19:40:54 +04:00
|
|
|
export PATH=$GOPATH/bin:$GOROOT/bin:$PATH
|
2013-10-20 17:38:22 +04:00
|
|
|
PROFILE
|
2014-01-07 19:47:39 +04:00
|
|
|
|
2013-10-20 17:38:22 +04:00
|
|
|
<<-SCRIPT
|
|
|
|
#{install}
|
|
|
|
|
|
|
|
if ! [ -f /home/vagrant/#{archive} ]; then
|
2014-09-26 19:40:54 +04:00
|
|
|
curl -O# https://storage.googleapis.com/golang/#{archive}
|
2013-10-20 17:38:22 +04:00
|
|
|
fi
|
|
|
|
tar -C /home/vagrant -xzf #{archive}
|
2014-01-07 19:47:39 +04:00
|
|
|
chown -R vagrant:vagrant #{vagrant_home}/go
|
2013-10-20 17:38:22 +04:00
|
|
|
|
2014-09-26 19:40:54 +04:00
|
|
|
if ! grep -q GOPATH #{vagrant_home}/.bashrc; then
|
|
|
|
echo '#{profile}' >> #{vagrant_home}/.bashrc
|
2014-01-07 19:47:39 +04:00
|
|
|
fi
|
2014-09-26 19:40:54 +04:00
|
|
|
source #{vagrant_home}/.bashrc
|
2013-10-20 17:38:22 +04:00
|
|
|
|
2014-01-07 19:47:39 +04:00
|
|
|
chown -R vagrant:vagrant #{vagrant_home}/gocode
|
2013-10-20 17:38:22 +04:00
|
|
|
|
|
|
|
echo "\nRun: vagrant ssh #{box} -c 'cd project/path; go test ./...'"
|
|
|
|
SCRIPT
|
|
|
|
end
|
|
|
|
|
2014-09-26 19:40:54 +04:00
|
|
|
Vagrant.configure("2") do |config|
|
2013-10-20 17:38:22 +04:00
|
|
|
config.vm.define "linux" do |linux|
|
2014-09-26 19:40:54 +04:00
|
|
|
linux.vm.box = "ubuntu/trusty64"
|
|
|
|
linux.vm.synced_folder "#{src_path}/src/github.com/github/hub", "/home/vagrant/gocode/src/github.com/github/hub"
|
2013-10-20 17:38:22 +04:00
|
|
|
linux.vm.provision :shell, :inline => bootstrap("linux")
|
|
|
|
end
|
|
|
|
end
|