diff --git a/lib/vagrant-lxc/action/handle_box_metadata.rb b/lib/vagrant-lxc/action/handle_box_metadata.rb index 92f1dad..d59a442 100644 --- a/lib/vagrant-lxc/action/handle_box_metadata.rb +++ b/lib/vagrant-lxc/action/handle_box_metadata.rb @@ -28,19 +28,13 @@ module Vagrant @logger.debug('Copying LXC template into place') system(%Q[sudo su root -c "cp #{lxc_template_src} #{dest}"]) - @logger.debug('Extracting rootfs') - # TODO: Ideally the compressed rootfs should not output errors... - system(%Q[sudo su root -c "cd #{box.directory} && tar xfz rootfs.tar.gz -C #{rootfs_cache} 2>/dev/null"]) - + @logger.debug('Merging metadata with template name and rootfs tarball') box.metadata.merge!( - 'template-name' => template_name, - 'rootfs-cache-path' => rootfs_cache + 'template-name' => template_name, + 'rootfs-tarball' => box.directory.join('rootfs.tar.gz') ) @app.call(env) - - ensure - system %Q[sudo su root -c "rm -rf #{rootfs_cache}"] end end end diff --git a/spec/unit/action/handle_box_metadata_spec.rb b/spec/unit/action/handle_box_metadata_spec.rb index 18c81aa..e70f309 100644 --- a/spec/unit/action/handle_box_metadata_spec.rb +++ b/spec/unit/action/handle_box_metadata_spec.rb @@ -10,19 +10,17 @@ describe Vagrant::LXC::Action::HandleBoxMetadata do let(:machine) { mock(:machine, box: box) } let(:app) { mock(:app, call: true) } let(:env) { {machine: machine, ui: stub(info: true)} } - let(:tmpdir) { '/tmp/rootfs/dir' } subject { described_class.new(app, env) } before do - Dir.stub(mktmpdir: tmpdir) File.stub(exists?: true) subject.stub(:system) subject.call(env) end - it 'creates a tmp directory to store rootfs-cache-path' do - metadata['rootfs-cache-path'].should == tmpdir + it 'sets the rootfs-tarball path on metadata hash' do + metadata['rootfs-tarball'].should == box_directory.join('rootfs.tar.gz') end it 'prepends vagrant and box name to template-name' do @@ -36,9 +34,4 @@ describe Vagrant::LXC::Action::HandleBoxMetadata do subject.should have_received(:system). with("sudo su root -c \"cp #{src} #{dest}\"") end - - it 'extracts rootfs into a tmp folder' do - subject.should have_received(:system). - with(%Q[sudo su root -c "cd #{box_directory} && tar xfz rootfs.tar.gz -C #{tmpdir} 2>/dev/null"]) - end end