From efdcf035c31d17935f438c6020a8fac1b4a78d0a Mon Sep 17 00:00:00 2001 From: Fabio Rehm Date: Thu, 4 Apr 2013 22:31:09 -0300 Subject: [PATCH] Update HandleBoxMetadata action to not extract the rootfs and just set its path on metadata hash --- lib/vagrant-lxc/action/handle_box_metadata.rb | 12 +++--------- spec/unit/action/handle_box_metadata_spec.rb | 11 ++--------- 2 files changed, 5 insertions(+), 18 deletions(-) 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