Class: Vagrant::Actions::Box::Unpackage
Overview
This action unpackages a downloaded box file into its final box destination within the vagrant home folder.
Instance Attribute Summary
#runner
Instance Method Summary
collapse
#cleanup, #follows, #initialize, #precedes, #prepare
Methods included from Util
#error_and_exit, included, #logger, #wrap_output
Instance Method Details
#box_dir ⇒ Object
30
31
32
|
# File 'lib/vagrant/actions/box/unpackage.rb', line 30
def box_dir
@runner.directory
end
|
#decompress ⇒ Object
34
35
36
37
38
39
|
# File 'lib/vagrant/actions/box/unpackage.rb', line 34
def decompress
Dir.chdir(box_dir) do
logger.info "Extracting box to #{box_dir}..."
Archive::Tar::Minitar.unpack(@runner.temp_path, box_dir)
end
end
|
#execute! ⇒ Object
8
9
10
11
12
13
|
# File 'lib/vagrant/actions/box/unpackage.rb', line 8
def execute!
@runner.invoke_around_callback(:unpackage) do
setup_box_dir
decompress
end
end
|
#rescue(exception) ⇒ Object
15
16
17
18
19
20
|
# File 'lib/vagrant/actions/box/unpackage.rb', line 15
def rescue(exception)
if File.directory?(box_dir)
logger.info "An error occurred, rolling back box unpackaging..."
FileUtils.rm_rf(box_dir)
end
end
|
#setup_box_dir ⇒ Object
22
23
24
25
26
27
28
|
# File 'lib/vagrant/actions/box/unpackage.rb', line 22
def setup_box_dir
if File.directory?(box_dir)
error_and_exit(:box_already_exists, :box_name => @runner.name)
end
FileUtils.mkdir_p(box_dir)
end
|