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,14 +8,15 @@ module VagrantPlugins
|
||||||
|
|
||||||
def install
|
def install
|
||||||
if guest.capability?(:dnf_cache_dir)
|
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)
|
return if @env[:cache_dirs].include?(guest_path)
|
||||||
|
|
||||||
# Ensure caching is enabled
|
# Ensure caching is enabled
|
||||||
comm.sudo("sed -i '/keepcache=/d' /etc/dnf/dnf.conf")
|
comm.sudo("sed -i '/keepcache=/d' /etc/dnf/dnf.conf")
|
||||||
comm.sudo("sed -i '/^[main]/a keepcache=1' /etc/dnf/dnf.conf")
|
comm.sudo("sed -i '/^[main]/a keepcache=1' /etc/dnf/dnf.conf")
|
||||||
|
|
||||||
symlink(guest_path)
|
symlink(guest_path)
|
||||||
|
end
|
||||||
else
|
else
|
||||||
@env[:ui].info I18n.t('vagrant_cachier.skipping_bucket', bucket: 'DNF')
|
@env[:ui].info I18n.t('vagrant_cachier.skipping_bucket', bucket: 'DNF')
|
||||||
end
|
end
|
||||||
|
|
|
@ -8,13 +8,14 @@ module VagrantPlugins
|
||||||
|
|
||||||
def install
|
def install
|
||||||
if guest.capability?(:yum_cache_dir)
|
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)
|
return if @env[:cache_dirs].include?(guest_path)
|
||||||
|
|
||||||
# Ensure caching is enabled
|
# Ensure caching is enabled
|
||||||
comm.sudo("sed -i 's/keepcache=0/keepcache=1/g' /etc/yum.conf")
|
comm.sudo("sed -i 's/keepcache=0/keepcache=1/g' /etc/yum.conf")
|
||||||
|
|
||||||
symlink(guest_path)
|
symlink(guest_path)
|
||||||
|
end
|
||||||
else
|
else
|
||||||
@env[:ui].info I18n.t('vagrant_cachier.skipping_bucket', bucket: 'Yum')
|
@env[:ui].info I18n.t('vagrant_cachier.skipping_bucket', bucket: 'Yum')
|
||||||
end
|
end
|
||||||
|
|
|
@ -4,7 +4,12 @@ module VagrantPlugins
|
||||||
module RedHat
|
module RedHat
|
||||||
module DnfCacheDir
|
module DnfCacheDir
|
||||||
def self.dnf_cache_dir(machine)
|
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
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -4,7 +4,13 @@ module VagrantPlugins
|
||||||
module RedHat
|
module RedHat
|
||||||
module YumCacheDir
|
module YumCacheDir
|
||||||
def self.yum_cache_dir(machine)
|
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
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue