Update HandleBoxMetadata action to not extract the rootfs and just set its path on metadata hash
This commit is contained in:
parent
d0867c3c1d
commit
efdcf035c3
2 changed files with 5 additions and 18 deletions
|
@ -28,19 +28,13 @@ module Vagrant
|
||||||
@logger.debug('Copying LXC template into place')
|
@logger.debug('Copying LXC template into place')
|
||||||
system(%Q[sudo su root -c "cp #{lxc_template_src} #{dest}"])
|
system(%Q[sudo su root -c "cp #{lxc_template_src} #{dest}"])
|
||||||
|
|
||||||
@logger.debug('Extracting rootfs')
|
@logger.debug('Merging metadata with template name and rootfs tarball')
|
||||||
# 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"])
|
|
||||||
|
|
||||||
box.metadata.merge!(
|
box.metadata.merge!(
|
||||||
'template-name' => template_name,
|
'template-name' => template_name,
|
||||||
'rootfs-cache-path' => rootfs_cache
|
'rootfs-tarball' => box.directory.join('rootfs.tar.gz')
|
||||||
)
|
)
|
||||||
|
|
||||||
@app.call(env)
|
@app.call(env)
|
||||||
|
|
||||||
ensure
|
|
||||||
system %Q[sudo su root -c "rm -rf #{rootfs_cache}"]
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -10,19 +10,17 @@ describe Vagrant::LXC::Action::HandleBoxMetadata do
|
||||||
let(:machine) { mock(:machine, box: box) }
|
let(:machine) { mock(:machine, box: box) }
|
||||||
let(:app) { mock(:app, call: true) }
|
let(:app) { mock(:app, call: true) }
|
||||||
let(:env) { {machine: machine, ui: stub(info: true)} }
|
let(:env) { {machine: machine, ui: stub(info: true)} }
|
||||||
let(:tmpdir) { '/tmp/rootfs/dir' }
|
|
||||||
|
|
||||||
subject { described_class.new(app, env) }
|
subject { described_class.new(app, env) }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
Dir.stub(mktmpdir: tmpdir)
|
|
||||||
File.stub(exists?: true)
|
File.stub(exists?: true)
|
||||||
subject.stub(:system)
|
subject.stub(:system)
|
||||||
subject.call(env)
|
subject.call(env)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'creates a tmp directory to store rootfs-cache-path' do
|
it 'sets the rootfs-tarball path on metadata hash' do
|
||||||
metadata['rootfs-cache-path'].should == tmpdir
|
metadata['rootfs-tarball'].should == box_directory.join('rootfs.tar.gz')
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'prepends vagrant and box name to template-name' do
|
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).
|
subject.should have_received(:system).
|
||||||
with("sudo su root -c \"cp #{src} #{dest}\"")
|
with("sudo su root -c \"cp #{src} #{dest}\"")
|
||||||
end
|
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
|
end
|
||||||
|
|
Loading…
Reference in a new issue