first whack at rvm support in vagrant-cachier
This commit is contained in:
parent
6b2169f9d6
commit
e89bd1ca2e
2 changed files with 60 additions and 0 deletions
39
lib/vagrant-cachier/bucket/rvm.rb
Normal file
39
lib/vagrant-cachier/bucket/rvm.rb
Normal file
|
@ -0,0 +1,39 @@
|
|||
module VagrantPlugins
|
||||
module Cachier
|
||||
class Bucket
|
||||
class Rvm < Bucket
|
||||
def self.capability
|
||||
:rvmdir
|
||||
end
|
||||
|
||||
def install
|
||||
machine = @env[:machine]
|
||||
guest = machine.guest
|
||||
|
||||
if guest.capability?(:rvmdir)
|
||||
if rvmdir_path = guest.capability(:rvmdir)
|
||||
prefix = rvmdir_path.split('/').last
|
||||
bucket_path = "/tmp/vagrant-cache/#{@name}/#{prefix}"
|
||||
machine.communicate.tap do |comm|
|
||||
comm.execute("mkdir -p #{bucket_path}")
|
||||
|
||||
rvm_cache_path = "#{rvmdir_path}/archives"
|
||||
|
||||
@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
|
||||
# TODO: Raise a better error
|
||||
raise "You've configured a RVM cache for a guest machine that does not support it!"
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
21
lib/vagrant-cachier/cap/linux/rvmdir.rb
Normal file
21
lib/vagrant-cachier/cap/linux/rvmdir.rb
Normal file
|
@ -0,0 +1,21 @@
|
|||
module VagrantPlugins
|
||||
module Cachier
|
||||
module Cap
|
||||
module Linux
|
||||
module Rvmdir
|
||||
def self.rvmdir(machine)
|
||||
rvmdir = nil
|
||||
machine.communicate.tap do |comm|
|
||||
return unless comm.test('rvm info')
|
||||
comm.execute 'echo $rvm_path' do |buffer, output|
|
||||
rvmdir = output.chomp if buffer == :stdout
|
||||
end
|
||||
end
|
||||
return rvmdir
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Loading…
Reference in a new issue