Sha256: e68697eed2d8228d094245926b90c58f44e601c27c50d9267574caca12a0114d

Contents?: true

Size: 1.48 KB

Versions: 40

Compression:

Stored size: 1.48 KB

Contents

require 'pathname'

module Vagrant
  module Action
    module VM
      # Sets up the mapping of files to copy into the package and verifies
      # that the files can be properly copied.
      class SetupPackageFiles
        def initialize(app, env)
          @app = app

          env["package.include"] ||= []
          env["package.vagrantfile"] ||= nil
        end

        def call(env)
          files = {}
          env["package.include"].each do |file|
            source = Pathname.new(file)
            dest   = nil

            # If the source is relative then we add the file as-is to the include
            # directory. Otherwise, we copy only the file into the root of the
            # include directory. Kind of strange, but seems to match what people
            # expect based on history.
            if source.relative?
              dest = source
            else
              dest = source.basename
            end

            # Assign the mapping
            files[file] = dest
          end

          if env["package.vagrantfile"]
            # Vagrantfiles are treated special and mapped to a specific file
            files[env["package.vagrantfile"]] = "_Vagrantfile"
          end

          # Verify the mapping
          files.each do |from, _|
            raise Errors::PackageIncludeMissing, :file => from if !File.exist?(from)
          end

          # Save the mapping
          env["package.files"] = files

          @app.call(env)
        end
      end
    end
  end
end

Version data entries

40 entries across 40 versions & 6 rubygems

Version Path
bmhatfield-vagrant-1.0.10 lib/vagrant/action/vm/setup_package_files.rb
bmhatfield-vagrant-1.0.9 lib/vagrant/action/vm/setup_package_files.rb
bmhatfield-vagrant-1.0.8 lib/vagrant/action/vm/setup_package_files.rb
bmhatfield-vagrant-1.0.7 lib/vagrant/action/vm/setup_package_files.rb
vagrantup-1.0.7 lib/vagrant/action/vm/setup_package_files.rb
vagrantup-1.0.6 lib/vagrant/action/vm/setup_package_files.rb
vagrantup-1.0.5 lib/vagrant/action/vm/setup_package_files.rb
vagrantup-1.0.4 lib/vagrant/action/vm/setup_package_files.rb
vagrantup-1.0.3 lib/vagrant/action/vm/setup_package_files.rb
vagrantup-1.0.2 lib/vagrant/action/vm/setup_package_files.rb
vagrantup-1.0.1 lib/vagrant/action/vm/setup_package_files.rb
vagrantup-1.0.0 lib/vagrant/action/vm/setup_package_files.rb
vagrantup-0.9.99.2 lib/vagrant/action/vm/setup_package_files.rb
vagrantup-0.9.99.1 lib/vagrant/action/vm/setup_package_files.rb
vagrantup-0.9.7 lib/vagrant/action/vm/setup_package_files.rb
vagrantup-0.9.6 lib/vagrant/action/vm/setup_package_files.rb
vagrantup-0.9.5 lib/vagrant/action/vm/setup_package_files.rb
vagrantup-0.9.4 lib/vagrant/action/vm/setup_package_files.rb
vagrantup-0.9.3 lib/vagrant/action/vm/setup_package_files.rb
vagrantup-0.9.2 lib/vagrant/action/vm/setup_package_files.rb