From 93c0c7bf990a267a430f745f47be9d6e7c487758 Mon Sep 17 00:00:00 2001 From: Gordon Franke Date: Tue, 5 Nov 2013 15:00:39 +0100 Subject: [PATCH 1/6] add zypper support --- CHANGELOG.md | 4 +++ README.md | 15 +++++++- lib/vagrant-cachier/bucket.rb | 1 + lib/vagrant-cachier/bucket/zypper.rb | 36 +++++++++++++++++++ .../cap/suse/zypper_cache_dir.rb | 14 ++++++++ lib/vagrant-cachier/plugin.rb | 5 +++ 6 files changed, 74 insertions(+), 1 deletion(-) create mode 100644 lib/vagrant-cachier/bucket/zypper.rb create mode 100644 lib/vagrant-cachier/cap/suse/zypper_cache_dir.rb diff --git a/CHANGELOG.md b/CHANGELOG.md index 740828e..f023667 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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: diff --git a/README.md b/README.md index 5771af2..ef50506 100644 --- a/README.md +++ b/README.md @@ -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| diff --git a/lib/vagrant-cachier/bucket.rb b/lib/vagrant-cachier/bucket.rb index 93b067d..7f38131 100644 --- a/lib/vagrant-cachier/bucket.rb +++ b/lib/vagrant-cachier/bucket.rb @@ -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" diff --git a/lib/vagrant-cachier/bucket/zypper.rb b/lib/vagrant-cachier/bucket/zypper.rb new file mode 100644 index 0000000..f556b21 --- /dev/null +++ b/lib/vagrant-cachier/bucket/zypper.rb @@ -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 diff --git a/lib/vagrant-cachier/cap/suse/zypper_cache_dir.rb b/lib/vagrant-cachier/cap/suse/zypper_cache_dir.rb new file mode 100644 index 0000000..9d21047 --- /dev/null +++ b/lib/vagrant-cachier/cap/suse/zypper_cache_dir.rb @@ -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 diff --git a/lib/vagrant-cachier/plugin.rb b/lib/vagrant-cachier/plugin.rb index ec31076..01dfe0a 100644 --- a/lib/vagrant-cachier/plugin.rb +++ b/lib/vagrant-cachier/plugin.rb @@ -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| From 9e0e0d50b5f355dfadb6d9eb66eeb8767c613b0f Mon Sep 17 00:00:00 2001 From: Fabio Rehm Date: Wed, 6 Nov 2013 19:16:39 -0200 Subject: [PATCH 2/6] [GH-54] Fix zypper cache path --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index ef50506..570df33 100644 --- a/README.md +++ b/README.md @@ -151,7 +151,7 @@ Vagrant.configure("2") do |config| end ``` -Used by SuSE guests, will get configured under guest's `/var/cache/zypper/packages`. It will +Used by SuSE guests, will get configured under guest's `/var/cache/zypp/packages`. It will also [make sure](lib/vagrant-cachier/bucket/zypper.rb#L20) that `keep-packages` is enabled for all repositories. From 0704ca2ce2ff784dd84ad7db0a0659d78c3c2ce3 Mon Sep 17 00:00:00 2001 From: Fabio Rehm Date: Wed, 6 Nov 2013 19:42:24 -0200 Subject: [PATCH 3/6] Make sure dev VMs have different IPs --- development/Vagrantfile | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/development/Vagrantfile b/development/Vagrantfile index 8919230..4de31b0 100644 --- a/development/Vagrantfile +++ b/development/Vagrantfile @@ -14,9 +14,6 @@ Vagrant.configure("2") do |config| config.cache.auto_detect = true config.cache.enable_nfs = true - config.vm.provider :virtualbox do |_, vb| - vb.vm.network :private_network, ip: "192.168.50.123" - end config.omnibus.chef_version = :latest config.vm.provision :chef_solo do |chef| @@ -62,6 +59,10 @@ Vagrant.configure("2") do |config| fi ' + configure_private_network = lambda do |node, suffix| + node.vm.network :private_network, ip: "192.168.50.#{suffix}" + end + debian_like_configs = lambda do |debian| # Here we have the RubyGems cache bucket configured to the right path, so we # bundle the project @@ -74,22 +75,26 @@ Vagrant.configure("2") do |config| config.vm.define :ubuntu do |ubuntu| ubuntu.vm.box = "quantal64" debian_like_configs.call ubuntu + configure_private_network.call ubuntu, 10 end config.vm.define :lucid do |lucid| lucid.vm.box = "lucid64" debian_like_configs.call lucid + configure_private_network.call lucid, 11 end config.vm.define :debian do |debian| debian.vm.box = "squeeze64" debian.vm.box_url = 'http://f.willianfernandes.com.br/vagrant-boxes/DebianSqueeze64.box' debian_like_configs.call debian + configure_private_network.call debian, 12 end config.vm.define :centos do |centos| centos.vm.box = 'centos6_64' centos.vm.box_url = 'http://developer.nrel.gov/downloads/vagrant-boxes/CentOS-6.4-x86_64-v20130309.box' + configure_private_network.call centos, 13 # Here we have the RubyGems cache bucket configured to the right path, so we # bundle the project centos.vm.provision :shell, inline: ' @@ -100,6 +105,7 @@ Vagrant.configure("2") do |config| config.vm.define :arch do |arch| arch.vm.box = 'arch64' arch.vm.box_url = 'http://vagrant.pouss.in/archlinux_2012-07-02.box' + configure_private_network.call arch, 14 arch.vm.provision :shell, inline: ' pacman -Syu --noconfirm libffi git HOME=/home/vagrant su -p vagrant -l -c "cd /vagrant && bundle"' From 6a8d661e970ed5117fe31eb390d74dbb0a8b956b Mon Sep 17 00:00:00 2001 From: Fabio Rehm Date: Wed, 6 Nov 2013 19:43:12 -0200 Subject: [PATCH 4/6] [GH-54] Disable yum on suse guests --- lib/vagrant-cachier/plugin.rb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/vagrant-cachier/plugin.rb b/lib/vagrant-cachier/plugin.rb index 01dfe0a..c6c638f 100644 --- a/lib/vagrant-cachier/plugin.rb +++ b/lib/vagrant-cachier/plugin.rb @@ -56,6 +56,10 @@ module VagrantPlugins Cap::RedHat::YumCacheDir end + guest_capability 'suse', 'yum_cache_dir' do + # Disable Yum on suse guests + end + guest_capability 'arch', 'pacman_cache_dir' do require_relative 'cap/arch/pacman_cache_dir' Cap::Arch::PacmanCacheDir From 00c9cce50d3609e3b3b2f09d5e4ab5cccb3cfc57 Mon Sep 17 00:00:00 2001 From: Fabio Rehm Date: Wed, 6 Nov 2013 19:44:11 -0200 Subject: [PATCH 5/6] [GH-54] Add a suse VM to our dev Vagrantfile so we can try things out --- development/Vagrantfile | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/development/Vagrantfile b/development/Vagrantfile index 4de31b0..4286b0c 100644 --- a/development/Vagrantfile +++ b/development/Vagrantfile @@ -110,4 +110,19 @@ Vagrant.configure("2") do |config| pacman -Syu --noconfirm libffi git HOME=/home/vagrant su -p vagrant -l -c "cd /vagrant && bundle"' end + + # Please note that we are not able to install chef on the VM, so when bringing + # this up we should always pass in `--provision-with=shell` + # + # TODO: Find out how to install chef on this or other box or find one that has + # it pre installed + config.vm.define :opensuse do |suse| + suse.vm.box = 'opensuse-12' + suse.vm.box_url = 'http://sourceforge.net/projects/opensusevagrant/files/12.3/opensuse-12.3-64.box/download' + configure_private_network.call suse, 15 + suse.cache.enable_nfs = false + # This seems to not be working + suse.omnibus.chef_version = nil + suse.vm.provision :shell, inline: 'time zypper install -y git' + end end From 4d01bff390f036bf76b74f96a3f569e8308cf7b0 Mon Sep 17 00:00:00 2001 From: Fabio Rehm Date: Wed, 6 Nov 2013 19:45:20 -0200 Subject: [PATCH 6/6] v0.5.0 --- CHANGELOG.md | 2 +- Gemfile.lock | 2 +- lib/vagrant-cachier/version.rb | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f023667..92d04b0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,4 @@ -## [0.4.2](https://github.com/fgrehm/vagrant-cachier/compare/v0.4.1...master) (unreleased) +## [0.5.0](https://github.com/fgrehm/vagrant-cachier/compare/v0.4.1...v0.5.0) (Nov 6, 2013) FEATURES: diff --git a/Gemfile.lock b/Gemfile.lock index 36b2028..6fdaab9 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -31,7 +31,7 @@ GIT PATH remote: . specs: - vagrant-cachier (0.4.1) + vagrant-cachier (0.5.0) GEM remote: https://rubygems.org/ diff --git a/lib/vagrant-cachier/version.rb b/lib/vagrant-cachier/version.rb index b811195..2cf9731 100644 --- a/lib/vagrant-cachier/version.rb +++ b/lib/vagrant-cachier/version.rb @@ -1,5 +1,5 @@ module VagrantPlugins module Cachier - VERSION = "0.4.2.dev" + VERSION = "0.5.0" end end