Add dnf bucket
This patchset adds dnf as a bucket. Adds the keepcache line if it is not found in dnf.conf. Signed-off-by: raghavendra talur <raghavendra.talur@gmail.com>
This commit is contained in:
parent
8615b7495e
commit
0af933d68a
4 changed files with 48 additions and 0 deletions
|
@ -102,3 +102,4 @@ require_relative "bucket/npm"
|
|||
require_relative "bucket/zypper"
|
||||
require_relative "bucket/generic"
|
||||
require_relative "bucket/pip"
|
||||
require_relative "bucket/dnf"
|
||||
|
|
29
lib/vagrant-cachier/bucket/dnf.rb
Normal file
29
lib/vagrant-cachier/bucket/dnf.rb
Normal file
|
@ -0,0 +1,29 @@
|
|||
module VagrantPlugins
|
||||
module Cachier
|
||||
class Bucket
|
||||
class Dnf < Bucket
|
||||
def self.capability
|
||||
:dnf_cache_dir
|
||||
end
|
||||
|
||||
def install
|
||||
if guest.capability?(:dnf_cache_dir)
|
||||
guest_path = guest.capability(:dnf_cache_dir)
|
||||
return if @env[:cache_dirs].include?(guest_path)
|
||||
|
||||
# Ensure caching is enabled
|
||||
if !comm.sudo("grep -q 'keepcache=' /etc/dnf/dnf.conf", error_check: false)
|
||||
comm.sudo("sed -i 's/keepcache=0/keepcache=1/g' /etc/dnf/dnf.conf")
|
||||
else
|
||||
comm.sudo("echo 'keepcache=1' >> /etc/dnf/dnf.conf")
|
||||
end
|
||||
|
||||
symlink(guest_path)
|
||||
else
|
||||
@env[:ui].info I18n.t('vagrant_cachier.skipping_bucket', bucket: 'Dnf')
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
13
lib/vagrant-cachier/cap/redhat/dnf_cache_dir.rb
Normal file
13
lib/vagrant-cachier/cap/redhat/dnf_cache_dir.rb
Normal file
|
@ -0,0 +1,13 @@
|
|||
module VagrantPlugins
|
||||
module Cachier
|
||||
module Cap
|
||||
module RedHat
|
||||
module DnfCacheDir
|
||||
def self.dnf_cache_dir(machine)
|
||||
'/var/cache/dnf'
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -61,6 +61,11 @@ module VagrantPlugins
|
|||
Cap::RedHat::YumCacheDir
|
||||
end
|
||||
|
||||
guest_capability 'redhat', 'dnf_cache_dir' do
|
||||
require_relative 'cap/redhat/dnf_cache_dir'
|
||||
Cap::RedHat::DnfCacheDir
|
||||
end
|
||||
|
||||
guest_capability 'suse', 'yum_cache_dir' do
|
||||
# Disable Yum on suse guests
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue