This repository has been archived by the owner on Jan 14, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
/
Vagrantfile
135 lines (110 loc) · 3.05 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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
# -*- 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"
Vagrant.require_version ">= 1.5.0"
GO_VERSION = "1.11"
def provision_linux
archive = "go#{GO_VERSION}.linux-amd64.tar.gz"
<<-SCRIPT
set -x
set -e
#{install_go_binary(archive)}
#{update_profile}
SCRIPT
end
def provision_bsd
archive = "go#{GO_VERSION}.freebsd-amd64.tar.gz"
<<-SCRIPT
set -x
set -e
pkg install -y wget
#{install_go_binary(archive)}
#{update_profile}
SCRIPT
end
def provision_solaris
<<-SCRIPT
set -x
# set -e
pfexec pkg install build-essential
#{install_go_source}
#{update_profile}
SCRIPT
end
# install Go from a binary
def install_go_binary(archive)
<<-SCRIPT
#{wget(archive)}
tar -C /usr/local -xzf #{archive}
SCRIPT
end
# install Go from a source
def install_go_source
source = "go#{GO_VERSION}.src.tar.gz"
bootstrap = "go1.4-bootstrap-20161024.tar.gz"
<<-SCRIPT
mkdir -p /usr/local/go/bootstrap
#{wget(bootstrap)}
tar -C /usr/local/go/bootstrap -xzf #{bootstrap}
bash -c "cd /usr/local/go/bootstrap/go/src && ./make.bash"
#{wget(source)}
tar -C /usr/local -xzf #{source}
bash -c "cd /usr/local/go/src && GOROOT_BOOTSTRAP=/usr/local/go/bootstrap/go ./make.bash"
SCRIPT
end
# update .profile
def update_profile
profile = <<-PROFILE
export GOPATH=$HOME
export PATH=$PATH:/usr/local/go/bin:$GOPATH/bin
export CDPATH=.:$GOPATH/src/github.com:$GOPATH/src/golang.org
PROFILE
<<-SCRIPT
echo '#{profile}' >> ~vagrant/.profile
SCRIPT
end
def wget(file)
url = "https://dl.google.com/go"
<<-SCRIPT
if ! [ -f #{file} ]; then
wget -nv #{url}/#{file}
fi
SCRIPT
end
# location of the Vagrantfile
def src_path
File.dirname(__FILE__)
end
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.define "linux" do |linux|
linux.vm.box = "ubuntu/bionic64"
linux.vm.synced_folder src_path, "/home/vagrant/src"
linux.vm.provision :shell, :inline => provision_linux
end
# Using NFS for synced/shared folders:
# * which is unsupported on Windows hosts (though maybe with freeNFS)
# * and requires a private host-only network
# * and will prompt for the administrator password of the host
# * but is said to be faster than VirtualBox shared folders
config.vm.define "bsd" do |bsd|
bsd.vm.box = "bento/freebsd-10.4"
bsd.vm.synced_folder ".", "/vagrant", disabled: true
bsd.vm.synced_folder src_path, "/home/vagrant/src", type: "nfs"
bsd.vm.network "private_network", type: "dhcp"
bsd.vm.provision :shell, :inline => provision_bsd
bsd.ssh.shell = "sh" # for provisioning
end
config.vm.define "solaris" do |solaris|
solaris.vm.box = "openindiana/hipster"
solaris.vm.synced_folder src_path, "/export/home/vagrant/src"
solaris.vm.provision :shell, :inline => provision_solaris
end
end