Class: VagrantPlugins::Cachier::Bucket::Yum

Inherits:
VagrantPlugins::Cachier::Bucket show all
Defined in:
lib/vagrant-cachier/bucket/yum.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from VagrantPlugins::Cachier::Bucket

auto_detect, bucket_name, inherited, #initialize, install

Constructor Details

This class inherits a constructor from VagrantPlugins::Cachier::Bucket

Class Method Details

.capabilityObject



5
6
7
# File 'lib/vagrant-cachier/bucket/yum.rb', line 5

def self.capability
  :yum_cache_dir
end

Instance Method Details

#installObject



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/vagrant-cachier/bucket/yum.rb', line 9

def install
  machine = @env[:machine]
  guest   = machine.guest

  if guest.capability?(:yum_cache_dir)
    guest_path = guest.capability(:yum_cache_dir)

    @env[:cache_dirs] << guest_path

    machine.communicate.tap do |comm|
      # Ensure caching is enabled
      comm.sudo("sed -i 's/keepcache=0/keepcache=1/g' /etc/yum.conf")

      comm.execute("mkdir -p /tmp/vagrant-cache/#{@name}")
      unless comm.test("test -L #{guest_path}")
        comm.sudo("rm -rf #{guest_path}")
        comm.sudo("mkdir -p `dirname #{guest_path}`")
        comm.sudo("ln -s /tmp/vagrant-cache/#{@name} #{guest_path}")
      end
    end
  else
    @env[:ui].info I18n.t('vagrant_cachier.skipping_bucket', bucket: 'Yum')
  end
end