2013-06-17 21:17:31 +00:00
|
|
|
module VagrantPlugins
|
|
|
|
module Cachier
|
|
|
|
class Bucket
|
|
|
|
class Rvm < Bucket
|
|
|
|
def self.capability
|
2013-06-25 19:51:59 +00:00
|
|
|
:rvm_path
|
2013-06-17 21:17:31 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def install
|
|
|
|
machine = @env[:machine]
|
|
|
|
guest = machine.guest
|
|
|
|
|
2013-06-25 19:51:59 +00:00
|
|
|
if guest.capability?(:rvm_path)
|
|
|
|
if rvm_path = guest.capability(:rvm_path)
|
|
|
|
prefix = rvm_path.split('/').last
|
2013-06-17 21:17:31 +00:00
|
|
|
bucket_path = "/tmp/vagrant-cache/#{@name}/#{prefix}"
|
|
|
|
machine.communicate.tap do |comm|
|
|
|
|
comm.execute("mkdir -p #{bucket_path}")
|
|
|
|
|
2013-06-25 19:51:59 +00:00
|
|
|
rvm_cache_path = "#{rvm_path}/archives"
|
2013-06-17 21:17:31 +00:00
|
|
|
|
|
|
|
@env[:cache_dirs] << rvm_cache_path
|
|
|
|
|
|
|
|
unless comm.test("test -L #{rvm_cache_path}")
|
|
|
|
comm.sudo("rm -rf #{rvm_cache_path}")
|
|
|
|
comm.sudo("mkdir -p `dirname #{rvm_cache_path}`")
|
|
|
|
comm.sudo("ln -s #{bucket_path} #{rvm_cache_path}")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
else
|
2013-08-01 19:35:12 +00:00
|
|
|
@env[:ui].info "Skipping RVM cache bucket as the guest machine does not support it"
|
2013-06-17 21:17:31 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|