From 89ff86121f5f765e695cdc1263f1eaeae035b2d9 Mon Sep 17 00:00:00 2001 From: Fabio Rehm Date: Sat, 20 Apr 2013 19:17:51 -0300 Subject: [PATCH] Cache apt packages used on acceptance specs to make them run faster --- spec/Vagrantfile | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/spec/Vagrantfile b/spec/Vagrantfile index ca98915..6a72bb2 100644 --- a/spec/Vagrantfile +++ b/spec/Vagrantfile @@ -1,6 +1,16 @@ # -*- mode: ruby -*- # vi: set ft=ruby : +def local_apt_cache(box_name) + cache_dir = File.join(File.expand_path(Vagrant::Environment::DEFAULT_HOME), + 'cache', + 'apt', + box_name) + partial_dir = File.join(cache_dir, 'partial') + FileUtils.mkdir_p(partial_dir) unless File.exists? partial_dir + cache_dir +end + Vagrant.require_plugin 'vagrant-lxc' Vagrant.configure("2") do |config| @@ -10,4 +20,7 @@ Vagrant.configure("2") do |config| config.vm.box_url = 'http://dl.dropbox.com/u/13510779/lxc-quantal64-2013-04-10.box' # Uncomment to test boxes built locally: # config.vm.box_url = '../boxes/output/lxc-quantal64.box' + + cache_dir = local_apt_cache(config.vm.box) + config.vm.synced_folder cache_dir, "/var/cache/apt/archives", id: "vagrant-apt-cache" end