2016-05-27 20:05:50 +00:00
|
|
|
require "fileutils"
|
|
|
|
|
|
|
|
require_relative "../../../../lib/vagrant/action/general/package"
|
|
|
|
|
|
|
|
module VagrantPlugins
|
|
|
|
module ProviderVirtualBox
|
|
|
|
module Action
|
|
|
|
class PackageSetupFolders
|
|
|
|
include Vagrant::Util::Presence
|
|
|
|
|
|
|
|
def initialize(app, env)
|
|
|
|
@app = app
|
|
|
|
end
|
|
|
|
|
|
|
|
def call(env)
|
|
|
|
env["package.output"] ||= "package.box"
|
2016-05-29 03:11:14 +00:00
|
|
|
env["package.directory"] ||= Dir.mktmpdir("vagrant-package-", env[:tmp_path])
|
2016-05-27 20:05:50 +00:00
|
|
|
|
|
|
|
# Match up a couple environmental variables so that the other parts of
|
|
|
|
# Vagrant will do the right thing.
|
|
|
|
env["export.temp_dir"] = env["package.directory"]
|
|
|
|
|
|
|
|
Vagrant::Action::General::Package.validate!(
|
|
|
|
env["package.output"], env["package.directory"])
|
|
|
|
|
|
|
|
@app.call(env)
|
|
|
|
end
|
|
|
|
|
|
|
|
def recover(env)
|
|
|
|
dir = env["package.directory"]
|
|
|
|
if File.exist?(dir)
|
|
|
|
FileUtils.rm_rf(dir)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|