diff --git a/lib/vagrant-lxc/action/setup_package_files.rb b/lib/vagrant-lxc/action/setup_package_files.rb index 0132035..a453300 100644 --- a/lib/vagrant-lxc/action/setup_package_files.rb +++ b/lib/vagrant-lxc/action/setup_package_files.rb @@ -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 diff --git a/spec/unit/action/setup_package_files_spec.rb b/spec/unit/action/setup_package_files_spec.rb index 44db639..d427660 100644 --- a/spec/unit/action/setup_package_files_spec.rb +++ b/spec/unit/action/setup_package_files_spec.rb @@ -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