Sha256: 63dea587961f5c8fa48b30e3ce7e1f87789bca029f080e7ba9788109c3332d3c

Contents?: true

Size: 1.14 KB

Versions: 7

Compression:

Stored size: 1.14 KB

Contents

require 'fileutils'

require 'vagrant/action/general/package'

module VagrantPlugins
  module ProviderVirtualBox
    module Action
      class Package < Vagrant::Action::General::Package
        # Doing this so that we can test that the parent is properly
        # called in the unit tests.
        alias_method :general_call, :call
        def call(env)
          # Setup the temporary directory
          @temp_dir = env[:tmp_path].join(Time.now.to_i.to_s)
          env["export.temp_dir"] = @temp_dir
          FileUtils.mkpath(env["export.temp_dir"])

          # Just match up a couple environmental variables so that
          # the superclass will do the right thing. Then, call the
          # superclass
          env["package.directory"] = env["export.temp_dir"]

          general_call(env)

          # Always call recover to clean up the temp dir
          clean_temp_dir
        end

        def recover(env)
          clean_temp_dir
          super
        end

        protected

        def clean_temp_dir
          if @temp_dir && File.exist?(@temp_dir)
            FileUtils.rm_rf(@temp_dir)
          end
        end
      end
    end
  end
end

Version data entries

7 entries across 4 versions & 3 rubygems

Version Path
vagrant-unbundled-1.8.1.2 plugins/providers/virtualbox/action/package.rb
vagrant-unbundled-1.8.1.1 plugins/providers/virtualbox/action/package.rb
vagrant-cloudstack-1.1.0 vendor/bundle/bundler/gems/vagrant-272fb27e0536/plugins/providers/virtualbox/action/package.rb
vagrant-cloudstack-1.1.0 vendor/bundle/bundler/gems/vagrant-b421af58e8b3/plugins/providers/virtualbox/action/package.rb
vagrant-cloudstack-1.1.0 vendor/bundle/bundler/gems/vagrant-309e896975d1/plugins/providers/virtualbox/action/package.rb
vagrant-cloudstack-1.1.0 vendor/bundle/bundler/gems/vagrant-1cf2a8db4ccb/plugins/providers/virtualbox/action/package.rb
vagrant-tiktalik-0.0.3 vendor/bundle/ruby/2.0.0/bundler/gems/vagrant-1e28f1ac31e7/plugins/providers/virtualbox/action/package.rb