diff --git a/development/Vagrantfile b/development/Vagrantfile index 5fcb1c1..b4d44b5 100644 --- a/development/Vagrantfile +++ b/development/Vagrantfile @@ -48,7 +48,7 @@ Vagrant.configure("2") do |config| # Here we have the RubyGems cache bucket configured to the right path, so we # bundle the project debian.vm.provision :shell, inline: ' - sudo apt-get install git -y + sudo apt-get install -y git php5-cli HOME=/home/vagrant su -p vagrant -l -c "cd /vagrant && bundle" ' end @@ -86,5 +86,4 @@ Vagrant.configure("2") do |config| pacman -Syu --noconfirm libffi git HOME=/home/vagrant su -p vagrant -l -c "cd /vagrant && bundle"' end - end diff --git a/lib/vagrant-cachier/bucket.rb b/lib/vagrant-cachier/bucket.rb index 0e425a8..8b3e04f 100644 --- a/lib/vagrant-cachier/bucket.rb +++ b/lib/vagrant-cachier/bucket.rb @@ -40,3 +40,4 @@ require_relative "bucket/pacman" require_relative "bucket/yum" require_relative "bucket/rvm" require_relative "bucket/apt_cacher" +require_relative "bucket/composer" diff --git a/lib/vagrant-cachier/bucket/composer.rb b/lib/vagrant-cachier/bucket/composer.rb new file mode 100644 index 0000000..cb939ad --- /dev/null +++ b/lib/vagrant-cachier/bucket/composer.rb @@ -0,0 +1,34 @@ +module VagrantPlugins + module Cachier + class Bucket + class Composer < Bucket + def self.capability + :composer_path + end + + def install + machine = @env[:machine] + guest = machine.guest + + if guest.capability?(:composer_path) + if composer_path = guest.capability(:composer_path) + bucket_path = "/tmp/vagrant-cache/#{@name}" + @env[:cache_dirs] << composer_path + + machine.communicate.tap do |comm| + comm.execute("mkdir -p #{bucket_path}") + + unless comm.test("test -L #{composer_path}") + comm.sudo("rm -rf #{composer_path}") + comm.sudo("ln -s #{bucket_path} #{composer_path}") + end + end + end + else + @env[:ui].info I18n.t('vagrant_cachier.skipping_bucket', bucket: 'Composer') + end + end + end + end + end +end diff --git a/lib/vagrant-cachier/cap/linux/composer_path.rb b/lib/vagrant-cachier/cap/linux/composer_path.rb new file mode 100644 index 0000000..db89b7a --- /dev/null +++ b/lib/vagrant-cachier/cap/linux/composer_path.rb @@ -0,0 +1,20 @@ +module VagrantPlugins + module Cachier + module Cap + module Linux + module ComposerPath + def self.composer_path(machine) + composer_path = nil + machine.communicate.tap do |comm| + return unless comm.test('which php') + comm.execute 'echo $HOME' do |buffer, output| + composer_path = output.chomp if buffer == :stdout + end + end + return "#{composer_path}/.composer" + end + end + end + end + end +end diff --git a/lib/vagrant-cachier/plugin.rb b/lib/vagrant-cachier/plugin.rb index 29dc502..929e0f3 100644 --- a/lib/vagrant-cachier/plugin.rb +++ b/lib/vagrant-cachier/plugin.rb @@ -26,6 +26,11 @@ module VagrantPlugins Cap::Linux::RvmPath end + guest_capability 'linux', 'composer_path' do + require_relative 'cap/linux/composer_path' + Cap::Linux::ComposerPath + end + guest_capability 'linux', 'chef_file_cache_path' do require_relative 'cap/linux/chef_file_cache_path' Cap::Linux::ChefFileCachePath