Adding support for composer cache - http://getcomposer.org/

This commit is contained in:
fh 2013-10-21 11:17:59 +02:00
parent fa8c59a16c
commit 817d964b8e
4 changed files with 56 additions and 0 deletions

View file

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

View file

@ -0,0 +1,36 @@
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}/"
#remove trailing slash, or symlink will fail
composer_path = composer_path.chomp('/')
@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,14 @@
module VagrantPlugins
module Cachier
module Cap
module Linux
module ComposerPath
def self.composer_path(machine)
composer_path = '/home/vagrant/.composer/'
return composer_path
end
end
end
end
end
end

View file

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