Support for offline provisioning of apt-packages by caching /var/lib/apt/lists [GH-84]

This commit is contained in:
Fabio Rehm 2014-02-14 00:28:12 -02:00
parent d42e5a9886
commit b548637e4f
5 changed files with 53 additions and 0 deletions

View file

@ -20,6 +20,7 @@ BACKWARDS INCOMPATIBILITY:
FEATURES: FEATURES:
- Support for offline provisioning of apt-packages by caching `/var/lib/apt/lists` [GH-84]
- Support for specifying custom cache bucket synced folder opts - Support for specifying custom cache bucket synced folder opts
- Support to force disabe the plugin [GH-72] - Support to force disabe the plugin [GH-72]
- Automatically disable the plugin for cloud providers [GH-45] - Automatically disable the plugin for cloud providers [GH-45]

View file

@ -40,6 +40,7 @@ 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/apt_lists"
require_relative "bucket/composer" require_relative "bucket/composer"
require_relative "bucket/npm" require_relative "bucket/npm"
require_relative "bucket/zypper" require_relative "bucket/zypper"

View file

@ -0,0 +1,33 @@
module VagrantPlugins
module Cachier
class Bucket
class AptLists < Bucket
def self.capability
:apt_lists_dir
end
def install
machine = @env[:machine]
guest = machine.guest
if guest.capability?(:apt_lists_dir)
guest_path = guest.capability(:apt_lists_dir)
@env[:cache_dirs] << guest_path
machine.communicate.tap do |comm|
comm.execute("mkdir -p /tmp/vagrant-cache/#{@name}/partial")
unless comm.test("test -L #{guest_path}")
comm.sudo("rm -rf #{guest_path}")
comm.sudo("mkdir -p `dirname #{guest_path}`")
comm.sudo("ln -s /tmp/vagrant-cache/#{@name} #{guest_path}")
end
end
else
@env[:ui].info I18n.t('vagrant_cachier.skipping_bucket', bucket: 'apt-lists')
end
end
end
end
end
end

View file

@ -0,0 +1,13 @@
module VagrantPlugins
module Cachier
module Cap
module Debian
module AptListsDir
def self.apt_lists_dir(machine)
'/var/lib/apt/lists'
end
end
end
end
end
end

View file

@ -36,6 +36,11 @@ module VagrantPlugins
Cap::Debian::AptCacherDir Cap::Debian::AptCacherDir
end end
guest_capability 'debian', 'apt_lists_dir' do
require_relative 'cap/debian/apt_lists_dir'
Cap::Debian::AptListsDir
end
guest_capability 'redhat', 'yum_cache_dir' do guest_capability 'redhat', 'yum_cache_dir' do
require_relative 'cap/redhat/yum_cache_dir' require_relative 'cap/redhat/yum_cache_dir'
Cap::RedHat::YumCacheDir Cap::RedHat::YumCacheDir