Update HandleBoxMetadata action to not extract the rootfs and just set its path on metadata hash

This commit is contained in:
Fabio Rehm 2013-04-04 22:31:09 -03:00
parent d0867c3c1d
commit efdcf035c3
2 changed files with 5 additions and 18 deletions

View file

@ -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

View file

@ -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