add zypper support

This commit is contained in:
Gordon Franke 2013-11-05 15:00:39 +01:00
parent 536ca7ad54
commit 93c0c7bf99
6 changed files with 74 additions and 1 deletions

View file

@ -1,5 +1,9 @@
## [0.4.2](https://github.com/fgrehm/vagrant-cachier/compare/v0.4.1...master) (unreleased)
FEATURES:
- Support for [zypper] [GH-54]
## [0.4.1](https://github.com/fgrehm/vagrant-cachier/compare/v0.4.0...v0.4.1) (Oct 27, 2013)
BUG FIXES:

View file

@ -142,7 +142,20 @@ _Please note that to avoid re-downloading packages, you should avoid `apt-get cl
as much as possible in order to make a better use of the cache, even if you are
packaging a box_
##### Yum
##### Zypper
```ruby
Vagrant.configure("2") do |config|
config.vm.box = 'some-suse-box'
config.cache.enable :zypper
end
```
Used by SuSE guests, will get configured under guest's `/var/cache/zypper/packages`. It will
also [make sure](lib/vagrant-cachier/bucket/zypper.rb#L20) that `keep-packages` is enabled
for all repositories.
###### Yum
```ruby
Vagrant.configure("2") do |config|

View file

@ -42,3 +42,4 @@ require_relative "bucket/rvm"
require_relative "bucket/apt_cacher"
require_relative "bucket/composer"
require_relative "bucket/npm"
require_relative "bucket/zypper"

View file

@ -0,0 +1,36 @@
module VagrantPlugins
module Cachier
class Bucket
class Zypper < Bucket
def self.capability
:zypper_cache_dir
end
def install
machine = @env[:machine]
guest = machine.guest
if guest.capability?(:zypper_cache_dir)
guest_path = guest.capability(:zypper_cache_dir)
@env[:cache_dirs] << guest_path
machine.communicate.tap do |comm|
# Ensure caching is enabled
comm.sudo("zypper modifyrepo --keep-packages --all")
comm.execute("mkdir -p /tmp/vagrant-cache/#{@name}")
unless comm.test("test -L #{guest_path}")
comm.sudo("rm -rf #{guest_path}")
comm.sudo("mkdir -p `dirname #{guest_path}`")
comm.sudo("ln -s /tmp/vagrant-cache/#{@name} #{guest_path}")
end
end
else
@env[:ui].info I18n.t('vagrant_cachier.skipping_bucket', bucket: 'Zypper')
end
end
end
end
end
end

View file

@ -0,0 +1,14 @@
module VagrantPlugins
module Cachier
module Cap
module SuSE
module ZypperCacheDir
def self.zypper_cache_dir(machine)
# TODO: Find out if there is a config file we can read from
'/var/cache/zypp/packages'
end
end
end
end
end
end

View file

@ -61,6 +61,11 @@ module VagrantPlugins
Cap::Arch::PacmanCacheDir
end
guest_capability 'suse', 'zypper_cache_dir' do
require_relative 'cap/suse/zypper_cache_dir'
Cap::SuSE::ZypperCacheDir
end
# TODO: This should be generic, we don't want to hard code every single
# possible provider action class that Vagrant might have
ensure_single_cache_root = lambda do |hook|