Skip to content
This repository has been archived by the owner on Dec 5, 2022. It is now read-only.

Commit

Permalink
Yum is replaced by DNF in newer Fedora releases
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
rmohr committed Sep 26, 2016
1 parent e6bdfad commit edf735c
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 13 deletions.
13 changes: 7 additions & 6 deletions lib/vagrant-cachier/bucket/dnf.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,15 @@ def self.capability

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
Expand Down
11 changes: 6 additions & 5 deletions lib/vagrant-cachier/bucket/yum.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,14 @@ def self.capability

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
Expand Down
7 changes: 6 additions & 1 deletion lib/vagrant-cachier/cap/redhat/dnf_cache_dir.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,12 @@ module Cap
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
Expand Down
8 changes: 7 additions & 1 deletion lib/vagrant-cachier/cap/redhat/yum_cache_dir.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,13 @@ module Cap
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
Expand Down

0 comments on commit edf735c

Please sign in to comment.