vagrant-cachier 0.5.1 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +33 -0
  3. data/Gemfile +1 -1
  4. data/Gemfile.lock +59 -34
  5. data/LICENSE.txt +1 -1
  6. data/README.md +27 -10
  7. data/development/Cheffile.lock +1 -5
  8. data/development/Vagrantfile +81 -71
  9. data/docs/buckets/apt-lists.md +18 -0
  10. data/docs/how-does-it-work.md +5 -6
  11. data/docs/index.md +24 -5
  12. data/docs/template.html +1 -0
  13. data/docs/usage.md +81 -28
  14. data/lib/vagrant-cachier/action/clean.rb +1 -1
  15. data/lib/vagrant-cachier/action/configure_bucket_root.rb +46 -0
  16. data/lib/vagrant-cachier/action/install_buckets.rb +47 -0
  17. data/lib/vagrant-cachier/bucket.rb +55 -0
  18. data/lib/vagrant-cachier/bucket/apt.rb +3 -12
  19. data/lib/vagrant-cachier/bucket/apt_cacher.rb +1 -13
  20. data/lib/vagrant-cachier/bucket/apt_lists.rb +24 -0
  21. data/lib/vagrant-cachier/bucket/chef.rb +1 -14
  22. data/lib/vagrant-cachier/bucket/composer.rb +1 -14
  23. data/lib/vagrant-cachier/bucket/gem.rb +4 -17
  24. data/lib/vagrant-cachier/bucket/npm.rb +1 -14
  25. data/lib/vagrant-cachier/bucket/pacman.rb +1 -14
  26. data/lib/vagrant-cachier/bucket/rvm.rb +4 -17
  27. data/lib/vagrant-cachier/bucket/yum.rb +4 -15
  28. data/lib/vagrant-cachier/bucket/zypper.rb +4 -15
  29. data/lib/vagrant-cachier/cap/debian/apt_lists_dir.rb +13 -0
  30. data/lib/vagrant-cachier/capabilities.rb +64 -0
  31. data/lib/vagrant-cachier/config.rb +35 -10
  32. data/lib/vagrant-cachier/hooks.rb +27 -0
  33. data/lib/vagrant-cachier/plugin.rb +12 -80
  34. data/lib/vagrant-cachier/version.rb +1 -1
  35. data/locales/en.yml +3 -7
  36. data/vagrant-cachier.gemspec +11 -1
  37. metadata +20 -12
  38. data/lib/vagrant-cachier/action/ensure_single_cache_root.rb +0 -64
  39. data/lib/vagrant-cachier/errors.rb +0 -9
  40. data/lib/vagrant-cachier/provision_ext.rb +0 -74
@@ -1,6 +1,7 @@
1
- require_relative 'provision_ext'
2
- Vagrant::Action::Builtin::Provision.class_eval do
3
- include VagrantPlugins::Cachier::ProvisionExt
1
+ # TODO: Switch to Vagrant.require_version before 1.0.0
2
+ # see: https://github.com/mitchellh/vagrant/blob/bc55081e9ffaa6820113e449a9f76b293a29b27d/lib/vagrant.rb#L202-L228
3
+ unless Gem::Requirement.new('>= 1.4.0').satisfied_by?(Gem::Version.new(Vagrant::VERSION))
4
+ raise 'vagrant-cachier requires Vagrant >= 1.4.0 in order to work!'
4
5
  end
5
6
 
6
7
  # Add our custom translations to the load path
@@ -10,87 +11,18 @@ module VagrantPlugins
10
11
  module Cachier
11
12
  class Plugin < Vagrant.plugin('2')
12
13
  name 'vagrant-cachier'
13
-
14
14
  config 'cache' do
15
15
  require_relative "config"
16
16
  Config
17
17
  end
18
-
19
- guest_capability 'linux', 'gemdir' do
20
- require_relative 'cap/linux/gemdir'
21
- Cap::Linux::Gemdir
22
- end
23
-
24
- guest_capability 'linux', 'rvm_path' do
25
- require_relative 'cap/linux/rvm_path'
26
- Cap::Linux::RvmPath
27
- end
28
-
29
- guest_capability 'linux', 'composer_path' do
30
- require_relative 'cap/linux/composer_path'
31
- Cap::Linux::ComposerPath
32
- end
33
-
34
- guest_capability 'linux', 'chef_file_cache_path' do
35
- require_relative 'cap/linux/chef_file_cache_path'
36
- Cap::Linux::ChefFileCachePath
37
- end
38
-
39
- guest_capability 'linux', 'npm_cache_dir' do
40
- require_relative 'cap/linux/npm_cache_dir'
41
- Cap::Linux::NpmCacheDir
42
- end
43
-
44
- guest_capability 'debian', 'apt_cache_dir' do
45
- require_relative 'cap/debian/apt_cache_dir'
46
- Cap::Debian::AptCacheDir
47
- end
48
-
49
- guest_capability 'debian', 'apt_cacher_dir' do
50
- require_relative 'cap/debian/apt_cacher_dir'
51
- Cap::Debian::AptCacherDir
52
- end
53
-
54
- guest_capability 'redhat', 'yum_cache_dir' do
55
- require_relative 'cap/redhat/yum_cache_dir'
56
- Cap::RedHat::YumCacheDir
57
- end
58
-
59
- guest_capability 'suse', 'yum_cache_dir' do
60
- # Disable Yum on suse guests
61
- end
62
-
63
- guest_capability 'arch', 'pacman_cache_dir' do
64
- require_relative 'cap/arch/pacman_cache_dir'
65
- Cap::Arch::PacmanCacheDir
66
- end
67
-
68
- guest_capability 'suse', 'zypper_cache_dir' do
69
- require_relative 'cap/suse/zypper_cache_dir'
70
- Cap::SuSE::ZypperCacheDir
71
- end
72
-
73
- # TODO: This should be generic, we don't want to hard code every single
74
- # possible provider action class that Vagrant might have
75
- ensure_single_cache_root = lambda do |hook|
76
- require_relative 'action/ensure_single_cache_root'
77
- hook.before VagrantPlugins::ProviderVirtualBox::Action::Boot, Action::EnsureSingleCacheRoot
78
-
79
- if defined?(Vagrant::LXC)
80
- # TODO: Require just the boot action file once its "require dependencies" are sorted out
81
- require 'vagrant-lxc/action'
82
- hook.before Vagrant::LXC::Action::Boot, Action::EnsureSingleCacheRoot
83
- end
84
- end
85
- action_hook 'ensure-single-cache-root-exists-on-up', :machine_action_up, &ensure_single_cache_root
86
- action_hook 'ensure-single-cache-root-exists-on-reload', :machine_action_reload, &ensure_single_cache_root
87
-
88
- clean_action_hook = lambda do |hook|
89
- require_relative 'action/clean'
90
- hook.before Vagrant::Action::Builtin::GracefulHalt, Action::Clean
91
- end
92
- action_hook 'remove-guest-symlinks-on-halt', :machine_action_halt, &clean_action_hook
93
- action_hook 'remove-guest-symlinks-on-package', :machine_action_package, &clean_action_hook
94
18
  end
19
+
20
+ # Keep an eye on https://github.com/mitchellh/vagrant/wiki/Available-Vagrant-Plugins#wiki-providers
21
+ # for more.
22
+ CLOUD_PROVIDERS = %w( aws cloudstack digitalocean hp joyent openstack rackspace
23
+ softlayer proxmox managed )
95
24
  end
96
25
  end
26
+
27
+ require_relative "hooks"
28
+ require_relative "capabilities"
@@ -1,5 +1,5 @@
1
1
  module VagrantPlugins
2
2
  module Cachier
3
- VERSION = "0.5.1"
3
+ VERSION = "0.6.0"
4
4
  end
5
5
  end
data/locales/en.yml CHANGED
@@ -16,10 +16,6 @@ en:
16
16
  scoped cache dirs starting with the 0.3.0 version of the plugin.
17
17
  unable_to_ssh: |-
18
18
  vagrant-cachier was unable to SSH into the VM to remove symlinks!
19
- vagrant:
20
- errors:
21
- multiple_provider_specific_cache_dirs_found: |-
22
- There are multiple provider specific cache dirs for the '%{machine}' machine:
23
- %{dirs}
24
- Please move one of them up to `%{machine_path}/cache` and remove the others
25
- before bringing the machine up again.
19
+ backed_by_cloud_provider: |-
20
+ The machine is backed by a cloud provider (%{provider}), caching
21
+ will be disabled.
@@ -8,7 +8,7 @@ Gem::Specification.new do |spec|
8
8
  spec.version = VagrantPlugins::Cachier::VERSION
9
9
  spec.authors = ["Fabio Rehm"]
10
10
  spec.email = ["fgrehm@gmail.com"]
11
- spec.description = %q{Speed up vagrant boxes provisioning}
11
+ spec.description = %q{Caffeine reducer}
12
12
  spec.summary = spec.description
13
13
  spec.homepage = "https://github.com/fgrehm/vagrant-cachier"
14
14
  spec.license = "MIT"
@@ -17,4 +17,14 @@ Gem::Specification.new do |spec|
17
17
  spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
18
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
19
  spec.require_paths = ["lib"]
20
+
21
+ spec.post_install_message = %q{
22
+ If you are new to vagrant-cachier just follow along with the docs available
23
+ at http://fgrehm.viewdocs.io/vagrant-cachier.
24
+
25
+ If you are a long time user, please note that plugin has gone through many
26
+ backwards incompatible changes since 0.6.0 so checkout
27
+ https://github.com/fgrehm/vagrant-cachier/blob/master/CHANGELOG.md
28
+ before continuing and caching all the things :)
29
+ }
20
30
  end
metadata CHANGED
@@ -1,23 +1,23 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vagrant-cachier
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.1
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Fabio Rehm
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-12-20 00:00:00.000000000 Z
11
+ date: 2014-02-27 00:00:00.000000000 Z
12
12
  dependencies: []
13
- description: Speed up vagrant boxes provisioning
13
+ description: Caffeine reducer
14
14
  email:
15
15
  - fgrehm@gmail.com
16
16
  executables: []
17
17
  extensions: []
18
18
  extra_rdoc_files: []
19
19
  files:
20
- - .gitignore
20
+ - ".gitignore"
21
21
  - CHANGELOG.md
22
22
  - Gemfile
23
23
  - Gemfile.lock
@@ -29,6 +29,7 @@ files:
29
29
  - development/Vagrantfile
30
30
  - docs/benchmarks.md
31
31
  - docs/buckets/apt-cacher.md
32
+ - docs/buckets/apt-lists.md
32
33
  - docs/buckets/apt.md
33
34
  - docs/buckets/chef.md
34
35
  - docs/buckets/composer.md
@@ -45,10 +46,12 @@ files:
45
46
  - docs/usage.md
46
47
  - lib/vagrant-cachier.rb
47
48
  - lib/vagrant-cachier/action/clean.rb
48
- - lib/vagrant-cachier/action/ensure_single_cache_root.rb
49
+ - lib/vagrant-cachier/action/configure_bucket_root.rb
50
+ - lib/vagrant-cachier/action/install_buckets.rb
49
51
  - lib/vagrant-cachier/bucket.rb
50
52
  - lib/vagrant-cachier/bucket/apt.rb
51
53
  - lib/vagrant-cachier/bucket/apt_cacher.rb
54
+ - lib/vagrant-cachier/bucket/apt_lists.rb
52
55
  - lib/vagrant-cachier/bucket/chef.rb
53
56
  - lib/vagrant-cachier/bucket/composer.rb
54
57
  - lib/vagrant-cachier/bucket/gem.rb
@@ -60,6 +63,7 @@ files:
60
63
  - lib/vagrant-cachier/cap/arch/pacman_cache_dir.rb
61
64
  - lib/vagrant-cachier/cap/debian/apt_cache_dir.rb
62
65
  - lib/vagrant-cachier/cap/debian/apt_cacher_dir.rb
66
+ - lib/vagrant-cachier/cap/debian/apt_lists_dir.rb
63
67
  - lib/vagrant-cachier/cap/linux/chef_file_cache_path.rb
64
68
  - lib/vagrant-cachier/cap/linux/composer_path.rb
65
69
  - lib/vagrant-cachier/cap/linux/gemdir.rb
@@ -67,10 +71,10 @@ files:
67
71
  - lib/vagrant-cachier/cap/linux/rvm_path.rb
68
72
  - lib/vagrant-cachier/cap/redhat/yum_cache_dir.rb
69
73
  - lib/vagrant-cachier/cap/suse/zypper_cache_dir.rb
74
+ - lib/vagrant-cachier/capabilities.rb
70
75
  - lib/vagrant-cachier/config.rb
71
- - lib/vagrant-cachier/errors.rb
76
+ - lib/vagrant-cachier/hooks.rb
72
77
  - lib/vagrant-cachier/plugin.rb
73
- - lib/vagrant-cachier/provision_ext.rb
74
78
  - lib/vagrant-cachier/version.rb
75
79
  - locales/en.yml
76
80
  - spec/acceptance/fixtures/auto-detect-with-provisioning.rb
@@ -84,26 +88,30 @@ homepage: https://github.com/fgrehm/vagrant-cachier
84
88
  licenses:
85
89
  - MIT
86
90
  metadata: {}
87
- post_install_message:
91
+ post_install_message: "\n If you are new to vagrant-cachier just follow along with
92
+ the docs available\n at http://fgrehm.viewdocs.io/vagrant-cachier.\n\n If you
93
+ are a long time user, please note that plugin has gone through many\n backwards
94
+ incompatible changes since 0.6.0 so checkout\n https://github.com/fgrehm/vagrant-cachier/blob/master/CHANGELOG.md\n
95
+ \ before continuing and caching all the things :)\n "
88
96
  rdoc_options: []
89
97
  require_paths:
90
98
  - lib
91
99
  required_ruby_version: !ruby/object:Gem::Requirement
92
100
  requirements:
93
- - - '>='
101
+ - - ">="
94
102
  - !ruby/object:Gem::Version
95
103
  version: '0'
96
104
  required_rubygems_version: !ruby/object:Gem::Requirement
97
105
  requirements:
98
- - - '>='
106
+ - - ">="
99
107
  - !ruby/object:Gem::Version
100
108
  version: '0'
101
109
  requirements: []
102
110
  rubyforge_project:
103
- rubygems_version: 2.1.5
111
+ rubygems_version: 2.2.2
104
112
  signing_key:
105
113
  specification_version: 4
106
- summary: Speed up vagrant boxes provisioning
114
+ summary: Caffeine reducer
107
115
  test_files:
108
116
  - spec/acceptance/fixtures/auto-detect-with-provisioning.rb
109
117
  - spec/acceptance/fixtures/auto-detect.rb
@@ -1,64 +0,0 @@
1
- require_relative '../errors'
2
-
3
- module VagrantPlugins
4
- module Cachier
5
- class Action
6
- class EnsureSingleCacheRoot
7
- def initialize(app, env)
8
- @app = app
9
- end
10
-
11
- def call(env)
12
- @env = env
13
-
14
- # If the cache is scoped to boxes or the existing cache dirs are not
15
- # provider specific, there's nothing we need to do
16
- if cache_scoped_to_machine? && provider_specific_cache_dirs.any?
17
- ensure_single_cache_root_exists!
18
- end
19
-
20
- @app.call(env)
21
- end
22
-
23
- def cache_scoped_to_machine?
24
- @env[:machine].config.cache.enabled? &&
25
- @env[:machine].config.cache.scope.to_sym == :machine
26
- end
27
-
28
- def ensure_single_cache_root_exists!
29
- if provider_specific_cache_dirs.size > 1
30
- cache_dirs = provider_specific_cache_dirs.map do |dir|
31
- " - #{dir.to_s.gsub(/^#{@env[:root_path]}\//, '')}"
32
- end
33
- machine_path = @env[:machine].data_dir.parent.to_s.gsub(/^#{@env[:root_path]}\//, '')
34
- raise Cachier::Errors::MultipleProviderSpecificCacheDirsFound,
35
- machine: @env[:machine].name,
36
- machine_path: machine_path,
37
- dirs: cache_dirs.join("\n")
38
- else
39
- current_path = provider_specific_cache_dirs.first.to_s.gsub(/^#{@env[:root_path]}\//, '')
40
- new_path = @env[:machine].data_dir.parent.join('cache')
41
- FileUtils.rm_rf new_path.to_s if new_path.directory?
42
-
43
- new_path = new_path.to_s.gsub(/^#{@env[:root_path]}\//, '')
44
- # If we got here there is a single provider specific cacher dir, so
45
- # let's be nice with users and just fix it ;)
46
- @env[:ui].warn I18n.t('vagrant_cachier.will_fix_machine_cache_dir',
47
- current_path: current_path,
48
- new_path: new_path)
49
- FileUtils.mv current_path, new_path
50
- end
51
- end
52
-
53
- def provider_specific_cache_dirs
54
- return @provider_specific_cache_dirs if @provider_specific_cache_dirs
55
-
56
- # By default data_dir points to ./.vagrant/machines/<NAME>/<PROVIDER>,
57
- # so we go one directory up
58
- machine_dir = @env[:machine].data_dir.parent
59
- @provider_specific_cache_dirs = Pathname.glob(machine_dir.join('*/cache'))
60
- end
61
- end
62
- end
63
- end
64
- end
@@ -1,9 +0,0 @@
1
- module VagrantPlugins
2
- module Cachier
3
- module Errors
4
- class MultipleProviderSpecificCacheDirsFound < Vagrant::Errors::VagrantError
5
- error_key(:multiple_provider_specific_cache_dirs_found)
6
- end
7
- end
8
- end
9
- end
@@ -1,74 +0,0 @@
1
- require_relative 'bucket'
2
-
3
- module VagrantPlugins
4
- module Cachier
5
- module ProvisionExt
6
- def self.included(base)
7
- base.class_eval do
8
- def cachier_debug(msg)
9
- @logger.debug "[CACHIER] #{msg}"
10
- end
11
-
12
- alias :old_call :call
13
- def call(env)
14
- @env = env
15
-
16
- return old_call(env) unless env[:machine].config.cache.enabled?
17
-
18
- FileUtils.mkdir_p(cache_root.to_s) unless cache_root.exist?
19
-
20
- synced_folder_opts = {id: "vagrant-cache"}
21
- if env[:machine].config.cache.enable_nfs
22
- # REFACTOR: Drop the `nfs: true` argument once we drop support for Vagrant < 1.4
23
- synced_folder_opts.merge!({ nfs: true, type: 'nfs' })
24
- end
25
- env[:machine].config.vm.synced_folder cache_root, '/tmp/vagrant-cache', synced_folder_opts
26
-
27
- env[:cache_dirs] = []
28
-
29
- old_call(env)
30
-
31
- configure_cache_buckets
32
- end
33
-
34
- alias :old_run_provisioner :run_provisioner
35
- def run_provisioner(*args)
36
- configure_cache_buckets
37
- old_run_provisioner(*args)
38
- end
39
-
40
- def configure_cache_buckets
41
- return unless @env[:machine].config.cache.enabled?
42
-
43
- if @env[:machine].config.cache.auto_detect
44
- Bucket.auto_detect(@env)
45
- end
46
-
47
- return unless @env[:machine].config.cache.buckets.any?
48
-
49
- @env[:ui].info 'Configuring cache buckets...'
50
- cache_config = @env[:machine].config.cache
51
- cache_config.buckets.each do |bucket_name, configs|
52
- cachier_debug "Installing #{bucket_name} with configs #{configs.inspect}"
53
- Bucket.install(bucket_name, @env, configs)
54
- end
55
-
56
- data_file = @env[:machine].data_dir.join('cache_dirs')
57
- data_file.open('w') { |f| f.print @env[:cache_dirs].uniq.join("\n") }
58
- end
59
-
60
- def cache_root
61
- @cache_root ||= case @env[:machine].config.cache.scope.to_sym
62
- when :box
63
- @env[:home_path].join('cache', @env[:machine].box.name)
64
- when :machine
65
- @env[:machine].data_dir.parent.join('cache')
66
- else
67
- raise "Unknown cache scope: '#{@env[:machine].config.cache.scope}'"
68
- end
69
- end
70
- end
71
- end
72
- end
73
- end
74
- end