github.com/trevoraustin/hub@v2.2.0-preview1.0.20141105230840-96d8bfc654cc+incompatible/Vagrantfile (about) 1 # -*- mode: ruby -*- 2 # vi: set ft=ruby : 3 4 # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # 5 # 6 # Place this Vagrantfile in your src folder and run: 7 # 8 # vagrant up 9 # 10 # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # 11 12 GO_ARCHIVES = { 13 "linux" => "go1.3.3.linux-amd64.tar.gz", 14 } 15 16 INSTALL = { 17 "linux" => "apt-get update -qq; apt-get install -qq -y git mercurial bzr curl", 18 } 19 20 # location of the Vagrantfile 21 def src_path 22 ENV["GOPATH"] 23 end 24 25 # shell script to bootstrap Go 26 def bootstrap(box) 27 install = INSTALL[box] 28 archive = GO_ARCHIVES[box] 29 vagrant_home = "/home/vagrant" 30 31 profile = <<-PROFILE 32 export GOROOT=#{vagrant_home}/go 33 export GOPATH=#{vagrant_home}/gocode 34 export PATH=$GOPATH/bin:$GOROOT/bin:$PATH 35 PROFILE 36 37 <<-SCRIPT 38 #{install} 39 40 if ! [ -f /home/vagrant/#{archive} ]; then 41 curl -O# https://storage.googleapis.com/golang/#{archive} 42 fi 43 tar -C /home/vagrant -xzf #{archive} 44 chown -R vagrant:vagrant #{vagrant_home}/go 45 46 if ! grep -q GOPATH #{vagrant_home}/.bashrc; then 47 echo '#{profile}' >> #{vagrant_home}/.bashrc 48 fi 49 source #{vagrant_home}/.bashrc 50 51 chown -R vagrant:vagrant #{vagrant_home}/gocode 52 53 apt-get update -qq 54 apt-get install -qq ruby1.9.1-dev tmux zsh git 55 gem install bundler 56 57 echo "\nRun: vagrant ssh #{box} -c 'cd project/path; go test ./...'" 58 SCRIPT 59 end 60 61 Vagrant.configure("2") do |config| 62 config.vm.define "linux" do |linux| 63 linux.vm.box = "ubuntu/trusty64" 64 linux.vm.synced_folder "#{src_path}/src/github.com/github/hub", "/home/vagrant/gocode/src/github.com/github/hub" 65 linux.vm.provision :shell, :inline => bootstrap("linux") 66 end 67 end