From b109e3c4ad763fdc130d780b47712d2c7dcf895d Mon Sep 17 00:00:00 2001 From: Fabio Rehm Date: Sat, 3 Aug 2013 14:26:10 -0300 Subject: [PATCH 01/13] Extract "skipping bucket" message out to a locale file --- lib/vagrant-cachier/bucket/apt.rb | 2 +- lib/vagrant-cachier/bucket/chef.rb | 2 +- lib/vagrant-cachier/bucket/gem.rb | 2 +- lib/vagrant-cachier/bucket/pacman.rb | 2 +- lib/vagrant-cachier/bucket/rvm.rb | 2 +- lib/vagrant-cachier/bucket/yum.rb | 2 +- lib/vagrant-cachier/plugin.rb | 3 +++ locales/en.yml | 4 ++++ 8 files changed, 13 insertions(+), 6 deletions(-) create mode 100644 locales/en.yml diff --git a/lib/vagrant-cachier/bucket/apt.rb b/lib/vagrant-cachier/bucket/apt.rb index f7f9165..d52219b 100644 --- a/lib/vagrant-cachier/bucket/apt.rb +++ b/lib/vagrant-cachier/bucket/apt.rb @@ -24,7 +24,7 @@ module VagrantPlugins end end else - @env[:ui].info "Skipping APT cache bucket as the guest machine does not support it" + @env[:ui].info I18n.t('vagrant_cachier.skipping_bucket', bucket: 'APT') end end end diff --git a/lib/vagrant-cachier/bucket/chef.rb b/lib/vagrant-cachier/bucket/chef.rb index 0ebe7df..b78bbe4 100644 --- a/lib/vagrant-cachier/bucket/chef.rb +++ b/lib/vagrant-cachier/bucket/chef.rb @@ -24,7 +24,7 @@ module VagrantPlugins end end else - @env[:ui].info "Skipping Chef cache bucket as the guest machine does not support it" + @env[:ui].info I18n.t('vagrant_cachier.skipping_bucket', bucket: 'Chef') end end end diff --git a/lib/vagrant-cachier/bucket/gem.rb b/lib/vagrant-cachier/bucket/gem.rb index 4919bb1..e166520 100644 --- a/lib/vagrant-cachier/bucket/gem.rb +++ b/lib/vagrant-cachier/bucket/gem.rb @@ -29,7 +29,7 @@ module VagrantPlugins end end else - @env[:ui].info "Skipping RubyGems cache bucket as the guest machine does not support it" + @env[:ui].info I18n.t('vagrant_cachier.skipping_bucket', bucket: 'RubyGems') end end end diff --git a/lib/vagrant-cachier/bucket/pacman.rb b/lib/vagrant-cachier/bucket/pacman.rb index 7b048f2..c9d9cdc 100644 --- a/lib/vagrant-cachier/bucket/pacman.rb +++ b/lib/vagrant-cachier/bucket/pacman.rb @@ -24,7 +24,7 @@ module VagrantPlugins end end else - @env[:ui].info "Skipping Pacman cache bucket as the guest machine does not support it" + @env[:ui].info I18n.t('vagrant_cachier.skipping_bucket', bucket: 'Pacman') end end end diff --git a/lib/vagrant-cachier/bucket/rvm.rb b/lib/vagrant-cachier/bucket/rvm.rb index b584b86..ce57ff8 100644 --- a/lib/vagrant-cachier/bucket/rvm.rb +++ b/lib/vagrant-cachier/bucket/rvm.rb @@ -29,7 +29,7 @@ module VagrantPlugins end end else - @env[:ui].info "Skipping RVM cache bucket as the guest machine does not support it" + @env[:ui].info I18n.t('vagrant_cachier.skipping_bucket', bucket: 'RVM') end end end diff --git a/lib/vagrant-cachier/bucket/yum.rb b/lib/vagrant-cachier/bucket/yum.rb index 3665d57..d43af7c 100644 --- a/lib/vagrant-cachier/bucket/yum.rb +++ b/lib/vagrant-cachier/bucket/yum.rb @@ -27,7 +27,7 @@ module VagrantPlugins end end else - @env[:ui].info "Skipping Yum cache bucket as the guest machine does not support it" + @env[:ui].info I18n.t('vagrant_cachier.skipping_bucket', bucket: 'Yum') end end end diff --git a/lib/vagrant-cachier/plugin.rb b/lib/vagrant-cachier/plugin.rb index c337090..597f338 100644 --- a/lib/vagrant-cachier/plugin.rb +++ b/lib/vagrant-cachier/plugin.rb @@ -3,6 +3,9 @@ Vagrant::Action::Builtin::Provision.class_eval do include VagrantPlugins::Cachier::Action::ProvisionExt end +# Add our custom translations to the load path +I18n.load_path << File.expand_path("../../../locales/en.yml", __FILE__) + module VagrantPlugins module Cachier class Plugin < Vagrant.plugin('2') diff --git a/locales/en.yml b/locales/en.yml new file mode 100644 index 0000000..0a9ed0c --- /dev/null +++ b/locales/en.yml @@ -0,0 +1,4 @@ +en: + vagrant_cachier: + skipping_bucket: |- + Skipping %{bucket} cache bucket as the guest machine does not support it From 18ff01907e62011f8eb0a1005baff1938a0ce57b Mon Sep 17 00:00:00 2001 From: Fabio Rehm Date: Sat, 3 Aug 2013 14:28:22 -0300 Subject: [PATCH 02/13] Extract "removing symlinks" message out to locale file --- lib/vagrant-cachier/action/clean.rb | 3 +-- locales/en.yml | 2 ++ 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/vagrant-cachier/action/clean.rb b/lib/vagrant-cachier/action/clean.rb index cd1fc0b..84702d0 100644 --- a/lib/vagrant-cachier/action/clean.rb +++ b/lib/vagrant-cachier/action/clean.rb @@ -11,7 +11,7 @@ module VagrantPlugins @env = env if env[:machine].state.id == :running && symlinks.any? - env[:ui].info 'Removing cache buckets symlinks...' + env[:ui].info I18n.t('vagrant_cachier.cleanup') symlinks.each do |symlink| remove_symlink symlink end @@ -37,4 +37,3 @@ module VagrantPlugins end end end - diff --git a/locales/en.yml b/locales/en.yml index 0a9ed0c..52dc977 100644 --- a/locales/en.yml +++ b/locales/en.yml @@ -1,4 +1,6 @@ en: vagrant_cachier: + cleanup: |- + Removing cache buckets symlinks... skipping_bucket: |- Skipping %{bucket} cache bucket as the guest machine does not support it From b50374162a9677fc90d2d027dfc6b849f2bd3ca8 Mon Sep 17 00:00:00 2001 From: Fabio Rehm Date: Sat, 3 Aug 2013 14:30:39 -0300 Subject: [PATCH 03/13] ProvisionExt is not an action! --- lib/vagrant-cachier/action/provision_ext.rb | 70 --------------------- lib/vagrant-cachier/plugin.rb | 4 +- lib/vagrant-cachier/provision_ext.rb | 68 ++++++++++++++++++++ 3 files changed, 70 insertions(+), 72 deletions(-) delete mode 100644 lib/vagrant-cachier/action/provision_ext.rb create mode 100644 lib/vagrant-cachier/provision_ext.rb diff --git a/lib/vagrant-cachier/action/provision_ext.rb b/lib/vagrant-cachier/action/provision_ext.rb deleted file mode 100644 index d03a307..0000000 --- a/lib/vagrant-cachier/action/provision_ext.rb +++ /dev/null @@ -1,70 +0,0 @@ -require_relative '../bucket' - -module VagrantPlugins - module Cachier - module Action - module ProvisionExt - def self.included(base) - base.class_eval do - def cachier_debug(msg) - @logger.debug "[CACHIER] #{msg}" - end - - alias :old_call :call - def call(env) - return old_call(env) unless env[:machine].config.cache.enabled? - - @env = env - - FileUtils.mkdir_p(cache_root.to_s) unless cache_root.exist? - - nfs_flag = env[:machine].config.cache.enable_nfs - env[:machine].config.vm.synced_folder cache_root, '/tmp/vagrant-cache', id: "vagrant-cache", nfs: nfs_flag - - env[:cache_dirs] = [] - - old_call(env) - - configure_cache_buckets - end - - alias :old_run_provisioner :run_provisioner - def run_provisioner(*args) - configure_cache_buckets - old_run_provisioner(*args) - end - - def configure_cache_buckets - if @env[:machine].config.cache.auto_detect - Bucket.auto_detect(@env) - end - - return unless @env[:machine].config.cache.buckets.any? - - @env[:ui].info 'Configuring cache buckets...' - cache_config = @env[:machine].config.cache - cache_config.buckets.each do |bucket_name, configs| - cachier_debug "Installing #{bucket_name} with configs #{configs.inspect}" - Bucket.install(bucket_name, @env, configs) - end - - data_file = @env[:machine].data_dir.join('cache_dirs') - data_file.open('w') { |f| f.print @env[:cache_dirs].uniq.join("\n") } - end - - def cache_root - @cache_root ||= case @env[:machine].config.cache.scope - when :box - @env[:home_path].join('cache', @env[:machine].box.name) - when :machine - @env[:machine].data_dir.join('cache') - else - raise "Unknown cache scope: '#{@env[:machine].config.cache.scope}'" - end - end - end - end - end - end - end -end diff --git a/lib/vagrant-cachier/plugin.rb b/lib/vagrant-cachier/plugin.rb index 597f338..8f8db3e 100644 --- a/lib/vagrant-cachier/plugin.rb +++ b/lib/vagrant-cachier/plugin.rb @@ -1,6 +1,6 @@ -require_relative 'action/provision_ext' +require_relative 'provision_ext' Vagrant::Action::Builtin::Provision.class_eval do - include VagrantPlugins::Cachier::Action::ProvisionExt + include VagrantPlugins::Cachier::ProvisionExt end # Add our custom translations to the load path diff --git a/lib/vagrant-cachier/provision_ext.rb b/lib/vagrant-cachier/provision_ext.rb new file mode 100644 index 0000000..e8cc8b3 --- /dev/null +++ b/lib/vagrant-cachier/provision_ext.rb @@ -0,0 +1,68 @@ +require_relative 'bucket' + +module VagrantPlugins + module Cachier + module ProvisionExt + def self.included(base) + base.class_eval do + def cachier_debug(msg) + @logger.debug "[CACHIER] #{msg}" + end + + alias :old_call :call + def call(env) + return old_call(env) unless env[:machine].config.cache.enabled? + + @env = env + + FileUtils.mkdir_p(cache_root.to_s) unless cache_root.exist? + + nfs_flag = env[:machine].config.cache.enable_nfs + env[:machine].config.vm.synced_folder cache_root, '/tmp/vagrant-cache', id: "vagrant-cache", nfs: nfs_flag + + env[:cache_dirs] = [] + + old_call(env) + + configure_cache_buckets + end + + alias :old_run_provisioner :run_provisioner + def run_provisioner(*args) + configure_cache_buckets + old_run_provisioner(*args) + end + + def configure_cache_buckets + if @env[:machine].config.cache.auto_detect + Bucket.auto_detect(@env) + end + + return unless @env[:machine].config.cache.buckets.any? + + @env[:ui].info 'Configuring cache buckets...' + cache_config = @env[:machine].config.cache + cache_config.buckets.each do |bucket_name, configs| + cachier_debug "Installing #{bucket_name} with configs #{configs.inspect}" + Bucket.install(bucket_name, @env, configs) + end + + data_file = @env[:machine].data_dir.join('cache_dirs') + data_file.open('w') { |f| f.print @env[:cache_dirs].uniq.join("\n") } + end + + def cache_root + @cache_root ||= case @env[:machine].config.cache.scope + when :box + @env[:home_path].join('cache', @env[:machine].box.name) + when :machine + @env[:machine].data_dir.join('cache') + else + raise "Unknown cache scope: '#{@env[:machine].config.cache.scope}'" + end + end + end + end + end + end +end From 20e1176a109a18c1d147560026f1bb8cd0b1a8f3 Mon Sep 17 00:00:00 2001 From: Fabio Rehm Date: Sat, 3 Aug 2013 14:36:29 -0300 Subject: [PATCH 04/13] Allow cache scopes to be set as either a symbol or a string --- lib/vagrant-cachier/provision_ext.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/vagrant-cachier/provision_ext.rb b/lib/vagrant-cachier/provision_ext.rb index e8cc8b3..ee14d10 100644 --- a/lib/vagrant-cachier/provision_ext.rb +++ b/lib/vagrant-cachier/provision_ext.rb @@ -52,7 +52,7 @@ module VagrantPlugins end def cache_root - @cache_root ||= case @env[:machine].config.cache.scope + @cache_root ||= case @env[:machine].config.cache.scope.to_sym when :box @env[:home_path].join('cache', @env[:machine].box.name) when :machine From 068d9cc8b8b651aaaabd3de71f6678f56c38917c Mon Sep 17 00:00:00 2001 From: Fabio Rehm Date: Sat, 3 Aug 2013 14:51:31 -0300 Subject: [PATCH 05/13] Validate machine scopes from config object and show a nice looking message instead of a stacktrace :) This should be enough to close #33 --- lib/vagrant-cachier/config.rb | 14 ++++++++++++++ locales/en.yml | 2 ++ 2 files changed, 16 insertions(+) diff --git a/lib/vagrant-cachier/config.rb b/lib/vagrant-cachier/config.rb index b3fcda0..a450505 100644 --- a/lib/vagrant-cachier/config.rb +++ b/lib/vagrant-cachier/config.rb @@ -4,6 +4,8 @@ module VagrantPlugins attr_accessor :scope, :auto_detect, :enable_nfs attr_reader :buckets + ALLOWED_SCOPES = %w( box machine ) + def initialize @scope = UNSET_VALUE @auto_detect = UNSET_VALUE @@ -14,6 +16,18 @@ module VagrantPlugins (@buckets ||= {})[bucket] = opts end + def validate(machine) + errors = _detected_errors + + if enabled? && ! ALLOWED_SCOPES.include?(@scope.to_s) + errors << I18n.t('vagrant_cachier.unknown_cache_scope', + allowed: ALLOWED_SCOPES.inspect, + cache_scope: @scope) + end + + { "vagrant cachier" => errors } + end + def finalize! return unless enabled? diff --git a/locales/en.yml b/locales/en.yml index 52dc977..ec6d39a 100644 --- a/locales/en.yml +++ b/locales/en.yml @@ -4,3 +4,5 @@ en: Removing cache buckets symlinks... skipping_bucket: |- Skipping %{bucket} cache bucket as the guest machine does not support it + unknown_cache_scope: |- + Unknown cache scope '%{cache_scope}' (allowed scopes: %{allowed}) From 7ad195776dcc895155dcaf77d91622bab35d2e9f Mon Sep 17 00:00:00 2001 From: Fabio Rehm Date: Sat, 3 Aug 2013 15:08:20 -0300 Subject: [PATCH 06/13] [GH-6] Setting things up for making sure a single cache root exists --- .../action/ensure_single_cache_root.rb | 16 ++++++++++++++++ lib/vagrant-cachier/plugin.rb | 15 +++++++++++++++ 2 files changed, 31 insertions(+) create mode 100644 lib/vagrant-cachier/action/ensure_single_cache_root.rb diff --git a/lib/vagrant-cachier/action/ensure_single_cache_root.rb b/lib/vagrant-cachier/action/ensure_single_cache_root.rb new file mode 100644 index 0000000..e4aa8c6 --- /dev/null +++ b/lib/vagrant-cachier/action/ensure_single_cache_root.rb @@ -0,0 +1,16 @@ +module VagrantPlugins + module Cachier + class Action + class EnsureSingleCacheRoot + def initialize(app, env) + @app = app + end + + def call(env) + raise 'Do our work' + @app.call(env) + end + end + end + end +end diff --git a/lib/vagrant-cachier/plugin.rb b/lib/vagrant-cachier/plugin.rb index 8f8db3e..c6f2a10 100644 --- a/lib/vagrant-cachier/plugin.rb +++ b/lib/vagrant-cachier/plugin.rb @@ -46,6 +46,21 @@ module VagrantPlugins Cap::Arch::PacmanCacheDir 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| + require_relative 'action/ensure_single_cache_root' + hook.after VagrantPlugins::ProviderVirtualBox::Action::Boot, Action::EnsureSingleCacheRoot + + if defined?(Vagrant::LXC) + # TODO: Require just the boot action file once its "require dependencies" are sorted out + require 'vagrant-lxc/action' + hook.after Vagrant::LXC::Action::Boot, Action::EnsureSingleCacheRoot + end + end + action_hook 'ensure-single-cache-root-exists-on-up', :machine_action_up, &ensure_single_cache_root + action_hook 'ensure-single-cache-root-exists-on-reload', :machine_action_reload, &ensure_single_cache_root + clean_action_hook = lambda do |hook| require_relative 'action/clean' hook.before Vagrant::Action::Builtin::GracefulHalt, VagrantPlugins::Cachier::Action::Clean From f8d8b2f9cf5f94151f49cbfef321a136ce88a2fe Mon Sep 17 00:00:00 2001 From: Fabio Rehm Date: Sat, 3 Aug 2013 16:07:42 -0300 Subject: [PATCH 07/13] [GH-6] Error out if multiple provider specific cache dirs are found and prepare to move dirs around in case a single cache dir exists --- .../action/ensure_single_cache_root.rb | 46 ++++++++++++++++++- lib/vagrant-cachier/errors.rb | 9 ++++ lib/vagrant-cachier/plugin.rb | 4 +- lib/vagrant-cachier/provision_ext.rb | 2 +- locales/en.yml | 12 +++++ 5 files changed, 69 insertions(+), 4 deletions(-) create mode 100644 lib/vagrant-cachier/errors.rb diff --git a/lib/vagrant-cachier/action/ensure_single_cache_root.rb b/lib/vagrant-cachier/action/ensure_single_cache_root.rb index e4aa8c6..6834780 100644 --- a/lib/vagrant-cachier/action/ensure_single_cache_root.rb +++ b/lib/vagrant-cachier/action/ensure_single_cache_root.rb @@ -1,3 +1,5 @@ +require_relative '../errors' + module VagrantPlugins module Cachier class Action @@ -7,9 +9,51 @@ module VagrantPlugins end def call(env) - raise 'Do our work' + @env = env + + # If the cache is scoped to boxes or the existing cache dirs are not + # provider specific, there's nothing we need to do + if cache_scoped_to_machine? && provider_specific_cache_dirs.any? + ensure_single_cache_root_exists! + end + @app.call(env) end + + def cache_scoped_to_machine? + @env[:machine].config.cache.scope.to_sym == :machine + end + + def ensure_single_cache_root_exists! + if provider_specific_cache_dirs.size > 1 + cache_dirs = provider_specific_cache_dirs.map do |dir| + " - #{dir.to_s.gsub(/^#{@env[:root_path]}\//, '')}" + end + machine_path = @env[:machine].data_dir.parent.to_s.gsub(/^#{@env[:root_path]}\//, '') + raise Cachier::Errors::MultipleProviderSpecificCacheDirsFound, + machine: @env[:machine].name, + machine_path: machine_path, + dirs: cache_dirs.join("\n") + else + current_path = provider_specific_cache_dirs.first.to_s.gsub(/^#{@env[:root_path]}\//, '') + new_path = @env[:machine].data_dir.parent.join('cache').to_s.gsub(/^#{@env[:root_path]}\//, '') + # If we got here there is a single provider specific cacher dir, so + # let's be nice with users and just fix it ;) + @env[:ui].warn I18n.t('vagrant_cachier.will_fix_machine_cache_dir', + current_path: current_path, + new_path: new_path) + raise 'Move cache dir around' + end + end + + def provider_specific_cache_dirs + return @provider_specific_cache_dirs if @provider_specific_cache_dirs + + # By default data_dir points to ./.vagrant/machines//, + # so we go one directory up + machine_dir = @env[:machine].data_dir.parent + @provider_specific_cache_dirs = Pathname.glob(machine_dir.join('*/cache')) + end end end end diff --git a/lib/vagrant-cachier/errors.rb b/lib/vagrant-cachier/errors.rb new file mode 100644 index 0000000..0f11696 --- /dev/null +++ b/lib/vagrant-cachier/errors.rb @@ -0,0 +1,9 @@ +module VagrantPlugins + module Cachier + module Errors + class MultipleProviderSpecificCacheDirsFound < Vagrant::Errors::VagrantError + error_key(:multiple_provider_specific_cache_dirs_found) + end + end + end +end diff --git a/lib/vagrant-cachier/plugin.rb b/lib/vagrant-cachier/plugin.rb index c6f2a10..b24df90 100644 --- a/lib/vagrant-cachier/plugin.rb +++ b/lib/vagrant-cachier/plugin.rb @@ -50,12 +50,12 @@ module VagrantPlugins # possible provider action class that Vagrant might have ensure_single_cache_root = lambda do |hook| require_relative 'action/ensure_single_cache_root' - hook.after VagrantPlugins::ProviderVirtualBox::Action::Boot, Action::EnsureSingleCacheRoot + hook.before VagrantPlugins::ProviderVirtualBox::Action::Boot, Action::EnsureSingleCacheRoot if defined?(Vagrant::LXC) # TODO: Require just the boot action file once its "require dependencies" are sorted out require 'vagrant-lxc/action' - hook.after Vagrant::LXC::Action::Boot, Action::EnsureSingleCacheRoot + hook.before Vagrant::LXC::Action::Boot, Action::EnsureSingleCacheRoot end end action_hook 'ensure-single-cache-root-exists-on-up', :machine_action_up, &ensure_single_cache_root diff --git a/lib/vagrant-cachier/provision_ext.rb b/lib/vagrant-cachier/provision_ext.rb index ee14d10..21e094e 100644 --- a/lib/vagrant-cachier/provision_ext.rb +++ b/lib/vagrant-cachier/provision_ext.rb @@ -56,7 +56,7 @@ module VagrantPlugins when :box @env[:home_path].join('cache', @env[:machine].box.name) when :machine - @env[:machine].data_dir.join('cache') + @env[:machine].data_dir.parent.join('cache') else raise "Unknown cache scope: '#{@env[:machine].config.cache.scope}'" end diff --git a/locales/en.yml b/locales/en.yml index ec6d39a..fe5dd5b 100644 --- a/locales/en.yml +++ b/locales/en.yml @@ -6,3 +6,15 @@ en: Skipping %{bucket} cache bucket as the guest machine does not support it unknown_cache_scope: |- Unknown cache scope '%{cache_scope}' (allowed scopes: %{allowed}) + will_fix_machine_cache_dir: |- + A vagrant-cachier provider specific cache dir was found under + '%{current_path}' and it will be + moved to '%{new_path}' as it is the new path for keeping machine + scoped cache dirs starting with the 0.3.0 version of the plugin. + vagrant: + errors: + multiple_provider_specific_cache_dirs_found: |- + There are multiple provider specific cache dirs for the '%{machine}' machine: + %{dirs} + Please move one of them up to `%{machine_path}/cache` and remove the others + before bringing the machine up again. From 9f90f43a215d6e8a5f344439e91663488d782163 Mon Sep 17 00:00:00 2001 From: Fabio Rehm Date: Sat, 3 Aug 2013 16:11:44 -0300 Subject: [PATCH 08/13] [GH-6] Move provider specific cache dir to the right path if a single cache dir exists --- lib/vagrant-cachier/action/ensure_single_cache_root.rb | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/vagrant-cachier/action/ensure_single_cache_root.rb b/lib/vagrant-cachier/action/ensure_single_cache_root.rb index 6834780..ae46b1e 100644 --- a/lib/vagrant-cachier/action/ensure_single_cache_root.rb +++ b/lib/vagrant-cachier/action/ensure_single_cache_root.rb @@ -36,13 +36,16 @@ module VagrantPlugins dirs: cache_dirs.join("\n") else current_path = provider_specific_cache_dirs.first.to_s.gsub(/^#{@env[:root_path]}\//, '') - new_path = @env[:machine].data_dir.parent.join('cache').to_s.gsub(/^#{@env[:root_path]}\//, '') + new_path = @env[:machine].data_dir.parent.join('cache') + FileUtils.rm_rf new_path.to_s if new_path.directory? + + new_path = new_path.to_s.gsub(/^#{@env[:root_path]}\//, '') # If we got here there is a single provider specific cacher dir, so # let's be nice with users and just fix it ;) @env[:ui].warn I18n.t('vagrant_cachier.will_fix_machine_cache_dir', current_path: current_path, new_path: new_path) - raise 'Move cache dir around' + FileUtils.mv current_path, new_path end end From 6a8926d04aaa1328e4cee95a2139258512883289 Mon Sep 17 00:00:00 2001 From: Fabio Rehm Date: Sat, 3 Aug 2013 16:13:39 -0300 Subject: [PATCH 09/13] Improve formatting of the "moving dirs around" message and close #6 --- locales/en.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/locales/en.yml b/locales/en.yml index fe5dd5b..b54004d 100644 --- a/locales/en.yml +++ b/locales/en.yml @@ -8,8 +8,8 @@ en: Unknown cache scope '%{cache_scope}' (allowed scopes: %{allowed}) will_fix_machine_cache_dir: |- A vagrant-cachier provider specific cache dir was found under - '%{current_path}' and it will be - moved to '%{new_path}' as it is the new path for keeping machine + '%{current_path}' and it will be moved to + '%{new_path}' as it is the new path for keeping machine scoped cache dirs starting with the 0.3.0 version of the plugin. vagrant: errors: From 07d34726e2f3c69e74b16d0eb09a9af99de4e682 Mon Sep 17 00:00:00 2001 From: Fabio Rehm Date: Sat, 3 Aug 2013 16:13:57 -0300 Subject: [PATCH 10/13] Clean up plugin.rb --- lib/vagrant-cachier/plugin.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/vagrant-cachier/plugin.rb b/lib/vagrant-cachier/plugin.rb index b24df90..5625ff8 100644 --- a/lib/vagrant-cachier/plugin.rb +++ b/lib/vagrant-cachier/plugin.rb @@ -63,10 +63,10 @@ module VagrantPlugins clean_action_hook = lambda do |hook| require_relative 'action/clean' - hook.before Vagrant::Action::Builtin::GracefulHalt, VagrantPlugins::Cachier::Action::Clean + hook.before Vagrant::Action::Builtin::GracefulHalt, Action::Clean end - action_hook 'remove-guest-symlinks-on-machine-halt', :machine_action_halt, &clean_action_hook - action_hook 'remove-guest-symlinks-on-machine-package', :machine_action_package, &clean_action_hook + action_hook 'remove-guest-symlinks-on-halt', :machine_action_halt, &clean_action_hook + action_hook 'remove-guest-symlinks-on-package', :machine_action_package, &clean_action_hook end end end From 4a351965daf85960f9ca65e34dd0401b9ff58bf9 Mon Sep 17 00:00:00 2001 From: Fabio Rehm Date: Sat, 3 Aug 2013 16:21:20 -0300 Subject: [PATCH 11/13] Update changelog --- CHANGELOG.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index c10ccc4..af63b59 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,13 @@ ## [0.3.0](https://github.com/fgrehm/vagrant-cachier/compare/v0.2.0...master) (unreleased) +BACKWARDS INCOMPATIBILITIES: + + - Machine scoped cache dirs are now kept on `.vagrant/machines/MACHINE/cache` + to allow downloaded packages to be reused between providers. If a single cache + directory exists, the plugin will automatically move it to the right place, + if multiple directories are found, it will halt execution and will error out, + letting the user know what has to be done in order to fix things. + FEATURES: - Add `file_cache_path` support for Chef. [GH-14] From 5b5befaa26141940e6b6d2c489c38420ca60708b Mon Sep 17 00:00:00 2001 From: Fabio Rehm Date: Mon, 5 Aug 2013 13:14:44 -0300 Subject: [PATCH 12/13] Add VMware as a compatible provider with NFS heads up --- README.md | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 4aad8b2..c811008 100644 --- a/README.md +++ b/README.md @@ -36,10 +36,8 @@ For more information about available buckets, please see the [configuration sect * Vagrant's built in VirtualBox provider * [vagrant-lxc](https://github.com/fgrehm/vagrant-lxc) - -_It is possibly compatible with the [VMware providers](http://www.vagrantup.com/vmware) -as well but I haven't tried yet._ - +* [VMware providers](http://www.vagrantup.com/vmware) with NFS enabled (See + [GH-24](https://github.com/fgrehm/vagrant-cachier/issues/24) for more info) ## How does it work? From 71885845add31cbd35dbc030b5cdd65a833b5d5e Mon Sep 17 00:00:00 2001 From: Fabio Rehm Date: Sat, 3 Aug 2013 16:21:28 -0300 Subject: [PATCH 13/13] v0.3.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 af63b59..19ecaa2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,4 @@ -## [0.3.0](https://github.com/fgrehm/vagrant-cachier/compare/v0.2.0...master) (unreleased) +## [0.3.0](https://github.com/fgrehm/vagrant-cachier/compare/v0.2.0...v0.3.0) (Aug 5, 2013) BACKWARDS INCOMPATIBILITIES: diff --git a/Gemfile.lock b/Gemfile.lock index 81c77db..d6d6cff 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -25,7 +25,7 @@ GIT PATH remote: . specs: - vagrant-cachier (0.3.0.dev) + vagrant-cachier (0.3.0) GEM remote: https://rubygems.org/ diff --git a/lib/vagrant-cachier/version.rb b/lib/vagrant-cachier/version.rb index e892e3f..ee7cfba 100644 --- a/lib/vagrant-cachier/version.rb +++ b/lib/vagrant-cachier/version.rb @@ -1,5 +1,5 @@ module VagrantPlugins module Cachier - VERSION = "0.3.0.dev" + VERSION = "0.3.0" end end