Module: VagrantPlugins::Ventriloquist::Cap::Debian::GoInstall

Defined in:
lib/ventriloquist/cap/platforms/debian/go_install.rb

Class Method Summary collapse

Class Method Details

.download_path(comm, version) ⇒ Object



37
38
39
40
41
42
43
44
# File 'lib/ventriloquist/cap/platforms/debian/go_install.rb', line 37

def self.download_path(comm, version)
  # If vagrant-cachier cache buckets are available, drop it there
  if comm.test("test -d /tmp/vagrant-cache")
    "/tmp/vagrant-cache/go-#{version}.tar.gz"
  else
    "/tmp/go-#{version}.tar.gz"
  end
end

.go_install(machine, version) ⇒ Object



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
# File 'lib/ventriloquist/cap/platforms/debian/go_install.rb', line 6

def self.go_install(machine, version)
  if machine.communicate.test('which go > /dev/null')
    machine.env.ui.info("Skipping go installation")
    return
  end

  src      = "https://go.googlecode.com/files/go#{version}.linux-amd64.tar.gz"
  bin_path = "/usr/local/go/bin"
  go_path  = "$HOME/go"

  machine.env.ui.info("Installing go #{version}")
  machine.communicate.tap do |comm|
    comm.sudo('apt-get install curl -y -q')
    path = download_path(comm, version)
    unless comm.test("test -f #{path}")
      machine.guest.capability(:download, src, path)
    end
    comm.sudo("tar xzfv #{path} -C /usr/local")

    if ! comm.test("grep -q '#{bin_path}' /etc/profile.d/ventriloquist.sh 2>/dev/null")
      comm.sudo("echo 'export PATH=$PATH:#{bin_path}' >> /etc/profile.d/ventriloquist.sh")
    end

    comm.execute("mkdir -p #{go_path}") if ! comm.test("test -d #{go_path}")

    if ! comm.test("grep -q '#{go_path}' /etc/profile.d/ventriloquist.sh 2>/dev/null")
      comm.sudo("echo 'export GOPATH=#{go_path}' >> /etc/profile.d/ventriloquist.sh")
    end
  end
end