Merge pull request #50 from fgrehm/composer-cache

Composer cache
This commit is contained in:
Fabio Rehm 2013-10-23 16:09:32 -07:00
commit 06d80b47f9
5 changed files with 61 additions and 2 deletions

View file

@ -48,7 +48,7 @@ Vagrant.configure("2") do |config|
# Here we have the RubyGems cache bucket configured to the right path, so we # Here we have the RubyGems cache bucket configured to the right path, so we
# bundle the project # bundle the project
debian.vm.provision :shell, inline: ' 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" HOME=/home/vagrant su -p vagrant -l -c "cd /vagrant && bundle"
' '
end end
@ -86,5 +86,4 @@ Vagrant.configure("2") do |config|
pacman -Syu --noconfirm libffi git pacman -Syu --noconfirm libffi git
HOME=/home/vagrant su -p vagrant -l -c "cd /vagrant && bundle"' HOME=/home/vagrant su -p vagrant -l -c "cd /vagrant && bundle"'
end end
end end

View file

@ -40,3 +40,4 @@ require_relative "bucket/pacman"
require_relative "bucket/yum" require_relative "bucket/yum"
require_relative "bucket/rvm" require_relative "bucket/rvm"
require_relative "bucket/apt_cacher" require_relative "bucket/apt_cacher"
require_relative "bucket/composer"

View file

@ -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

View file

@ -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

View file

@ -26,6 +26,11 @@ module VagrantPlugins
Cap::Linux::RvmPath Cap::Linux::RvmPath
end 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 guest_capability 'linux', 'chef_file_cache_path' do
require_relative 'cap/linux/chef_file_cache_path' require_relative 'cap/linux/chef_file_cache_path'
Cap::Linux::ChefFileCachePath Cap::Linux::ChefFileCachePath