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:
parent
5141e1305a
commit
fad6bbf6a0
4 changed files with 26 additions and 13 deletions
|
@ -8,7 +8,7 @@ module VagrantPlugins
|
|||
|
||||
def install
|
||||
if guest.capability?(:dnf_cache_dir)
|
||||
guest_path = guest.capability(:dnf_cache_dir)
|
||||
if guest_path = guest.capability(:dnf_cache_dir)
|
||||
return if @env[:cache_dirs].include?(guest_path)
|
||||
|
||||
# Ensure caching is enabled
|
||||
|
@ -16,6 +16,7 @@ module VagrantPlugins
|
|||
comm.sudo("sed -i '/^[main]/a keepcache=1' /etc/dnf/dnf.conf")
|
||||
|
||||
symlink(guest_path)
|
||||
end
|
||||
else
|
||||
@env[:ui].info I18n.t('vagrant_cachier.skipping_bucket', bucket: 'DNF')
|
||||
end
|
||||
|
|
|
@ -8,13 +8,14 @@ module VagrantPlugins
|
|||
|
||||
def install
|
||||
if guest.capability?(:yum_cache_dir)
|
||||
guest_path = guest.capability(:yum_cache_dir)
|
||||
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")
|
||||
|
||||
symlink(guest_path)
|
||||
end
|
||||
else
|
||||
@env[:ui].info I18n.t('vagrant_cachier.skipping_bucket', bucket: 'Yum')
|
||||
end
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue