Sha256: ae965dc4d6aa2eba9f5ab551b189ce564d2268a38b41ac076cc25f985edcf607
Contents?: true
Size: 1.49 KB
Versions: 40
Compression:
Stored size: 1.49 KB
Contents
require 'fileutils' require 'archive/tar/minitar' module Vagrant module Action module Box # Unpackages a downloaded box to a given directory with a given # name. # # # Required Variables # # * `download.temp_path` - A location for the downloaded box. This is # set by the {Download} action. # * `box` - A {Vagrant::Box} object. # class Unpackage attr_reader :box_directory def initialize(app, env) @app = app @env = env end def call(env) @env = env setup_box_directory decompress @app.call(@env) end def recover(env) if box_directory && File.directory?(box_directory) FileUtils.rm_rf(box_directory) end end def setup_box_directory if File.directory?(@env["box_directory"]) raise Errors::BoxAlreadyExists, :name => @env["box_name"] end FileUtils.mkdir_p(@env["box_directory"]) @box_directory = @env["box_directory"] end def decompress Dir.chdir(@env["box_directory"]) do @env[:ui].info I18n.t("vagrant.actions.box.unpackage.extracting") begin Archive::Tar::Minitar.unpack(@env["download.temp_path"], @env["box_directory"].to_s) rescue SystemCallError raise Errors::BoxUnpackageFailure end end end end end end end
Version data entries
40 entries across 40 versions & 6 rubygems