Yum is replaced by DNF in newer Fedora releases

Check if yum is really present on a 'redhat' machine.  Only if it is,
enable the Yum bucket. The same for DNF since older versions of CentOS
and Fedora do not ship DNF.
This commit is contained in:
Roman Mohr 2016-09-26 13:59:40 +02:00
parent 5141e1305a
commit fad6bbf6a0
4 changed files with 26 additions and 13 deletions

View File

@ -8,14 +8,15 @@ module VagrantPlugins
def install
if guest.capability?(:dnf_cache_dir)
guest_path = guest.capability(:dnf_cache_dir)
return if @env[:cache_dirs].include?(guest_path)
if guest_path = guest.capability(:dnf_cache_dir)
return if @env[:cache_dirs].include?(guest_path)
# Ensure caching is enabled
comm.sudo("sed -i '/keepcache=/d' /etc/dnf/dnf.conf")
comm.sudo("sed -i '/^[main]/a keepcache=1' /etc/dnf/dnf.conf")
# Ensure caching is enabled
comm.sudo("sed -i '/keepcache=/d' /etc/dnf/dnf.conf")
comm.sudo("sed -i '/^[main]/a keepcache=1' /etc/dnf/dnf.conf")
symlink(guest_path)
symlink(guest_path)
end
else
@env[:ui].info I18n.t('vagrant_cachier.skipping_bucket', bucket: 'DNF')
end

View File

@ -8,13 +8,14 @@ module VagrantPlugins
def install
if guest.capability?(:yum_cache_dir)
guest_path = guest.capability(:yum_cache_dir)
return if @env[:cache_dirs].include?(guest_path)
if guest_path = guest.capability(:yum_cache_dir)
return if @env[:cache_dirs].include?(guest_path)
# Ensure caching is enabled
comm.sudo("sed -i 's/keepcache=0/keepcache=1/g' /etc/yum.conf")
# Ensure caching is enabled
comm.sudo("sed -i 's/keepcache=0/keepcache=1/g' /etc/yum.conf")
symlink(guest_path)
symlink(guest_path)
end
else
@env[:ui].info I18n.t('vagrant_cachier.skipping_bucket', bucket: 'Yum')
end

View File

@ -4,7 +4,12 @@ module VagrantPlugins
module RedHat
module DnfCacheDir
def self.dnf_cache_dir(machine)
'/var/cache/dnf'
dnf_cache_dir = nil
machine.communicate.tap do |comm|
return unless comm.test('which dnf')
dnf_cache_dir = '/var/cache/dnf'
end
return dnf_cache_dir
end
end
end

View File

@ -4,7 +4,13 @@ module VagrantPlugins
module RedHat
module YumCacheDir
def self.yum_cache_dir(machine)
'/var/cache/yum'
yum_cache_dir = nil
machine.communicate.tap do |comm|
# In case yum is only forwarding to dnf do not cache
return unless not comm.test('yum --version 2>&1 | grep /usr/bin/dnf')
yum_cache_dir = '/var/cache/yum'
end
return yum_cache_dir
end
end
end