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
|
|
|
|
#
|
|
|
|
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
|
|
|
|
|
|
|
# Vagrantfile API/syntax version.
|
|
|
|
VAGRANTFILE_API_VERSION = "2"
|
|
|
|
|
|
|
|
GO_ARCHIVES = {
|
2013-12-02 10:57:22 +04:00
|
|
|
"linux" => "go1.2.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]
|
|
|
|
|
|
|
|
profile = <<-PROFILE
|
|
|
|
export GOROOT=$HOME/go
|
2013-12-02 10:57:22 +04:00
|
|
|
export GOPATH=$HOME/gocode
|
2013-10-20 17:38:22 +04:00
|
|
|
export PATH=$PATH:$HOME/go/bin:$GOPATH/bin
|
|
|
|
export CDPATH=.:$GOPATH/src/github.com:$GOPATH/src/code.google.com/p:$GOPATH/src/bitbucket.org:$GOPATH/src/launchpad.net
|
|
|
|
|
|
|
|
PROFILE
|
|
|
|
<<-SCRIPT
|
|
|
|
#{install}
|
|
|
|
|
|
|
|
if ! [ -f /home/vagrant/#{archive} ]; then
|
2013-12-02 10:57:22 +04:00
|
|
|
curl -O# https://go.googlecode.com/files/#{archive}
|
2013-10-20 17:38:22 +04:00
|
|
|
fi
|
|
|
|
tar -C /home/vagrant -xzf #{archive}
|
|
|
|
chown -R vagrant:vagrant /home/vagrant/go
|
|
|
|
|
|
|
|
echo '#{profile}' >> /home/vagrant/.profile
|
|
|
|
|
2013-12-02 10:57:22 +04:00
|
|
|
chown -R vagrant:vagrant /home/vagrant/gocode
|
2013-12-18 09:28:54 +04:00
|
|
|
go get github.com/jingweno/gotask
|
2013-10-20 17:38:22 +04:00
|
|
|
|
|
|
|
echo "\nRun: vagrant ssh #{box} -c 'cd project/path; go test ./...'"
|
|
|
|
SCRIPT
|
|
|
|
end
|
|
|
|
|
|
|
|
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
|
|
|
|
|
|
|
|
config.vm.define "linux" do |linux|
|
|
|
|
linux.vm.box = "precise64"
|
|
|
|
linux.vm.box_url = "http://files.vagrantup.com/precise64.box"
|
2013-12-18 09:28:54 +04:00
|
|
|
linux.vm.synced_folder "#{src_path}/src/github.com/jingweno/gh", "/home/vagrant/gocode/src/github.com/jingweno/gh"
|
2013-10-20 17:38:22 +04:00
|
|
|
linux.vm.provision :shell, :inline => bootstrap("linux")
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|