package: Nicely handle optional lxc-template on base boxes when packaging

This commit is contained in:
Fabio Rehm 2014-03-21 19:30:28 -03:00
parent 44ad630db7
commit 164afc7839
2 changed files with 13 additions and 1 deletions

View file

@ -43,8 +43,10 @@ module Vagrant
def copy_box_files_to_pkg_dir
box_dir = @env[:machine].box.directory
FileUtils.cp box_dir.join('lxc-template').to_s, @env['package.directory'].to_s
FileUtils.cp box_dir.join('metadata.json').to_s, @env['package.directory'].to_s
if (template = box_dir.join('lxc-template')).exist?
FileUtils.cp template.to_s, @env['package.directory'].to_s
end
if (conf = box_dir.join('lxc.conf')).exist?
FileUtils.cp conf.to_s, @env['package.directory'].to_s
end

View file

@ -51,6 +51,16 @@ describe Vagrant::LXC::Action::SetupPackageFiles do
end
end
context 'when lxc-template file is not present' do
before do
box.directory.join('lxc-template').delete
end
it 'does not blow up' do
expect { subject.call(env) }.to_not raise_error
end
end
context 'when lxc.conf file is not present' do
before do
box.directory.join('lxc.conf').delete