Class: FPM::Package::Dir

Inherits:
FPM::Package show all
Defined in:
lib/fpm/package/dir.rb

Overview

A directory package.

This class supports both input and output. As a note, ‘output’ will only emit the files, not any metadata. This is an effective way to extract another package type.

Instance Attribute Summary

Attributes inherited from FPM::Package

#architecture, #attributes, #category, #config_files, #conflicts, #dependencies, #description, #epoch, #excludes, #iteration, #license, #maintainer, #name, #provides, #replaces, #scripts, #url, #vendor, #version

Instance Method Summary collapse

Methods inherited from FPM::Package

apply_options, #cleanup, #cleanup_build, #cleanup_staging, #convert, #converted_from, default_attributes, #edit_file, #files, inherited, #initialize, option, #script, #staging_path, #to_s, #type, type, types

Methods included from Util

#program_in_path?, #safesystem, #tar_cmd, #with

Constructor Details

This class inherits a constructor from FPM::Package

Instance Method Details

#input(path) ⇒ Object

Add a new path to this package.

If the path is a directory, it is copied recursively. The behavior of the copying is modified by the :chdir and :prefix attributes.

If :prefix is set, the destination path is prefixed with that value. If :chdir is set, the current directory is changed to that value during the copy.

Example: Copy /etc/X11 into this package as /opt/xorg/X11:

package.attributes[:prefix] = "/opt/xorg"
package.attributes[:chdir] = "/etc"
package.input("X11")


29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/fpm/package/dir.rb', line 29

def input(path)
  @logger.debug("Copying", :input => path)
  @logger["method"] = "input"
  ::Dir.chdir(@attributes[:chdir] || ".") do
    if @attributes[:prefix]
      clone(path, File.join(staging_path, @attributes[:prefix]))
    else
      clone(path, staging_path)
    end
  end

  # Set some defaults. This is useful because other package types
  # can include license data from themselves (rpms, gems, etc),
  # but to make sure a simple dir -> rpm works without having
  # to specify a license.
  self.license = "unknown"
  self.vendor = [ENV["USER"], Socket.gethostname].join("@")
ensure
  # Clean up any logger context we added.
  @logger.remove("method")
end

#output(output_path) ⇒ Object

Output this package to the given directory.



52
53
54
55
56
57
58
59
60
61
62
# File 'lib/fpm/package/dir.rb', line 52

def output(output_path)
  output_check(output_path)

  output_path = File.expand_path(output_path)
  ::Dir.chdir(staging_path) do
    @logger["method"] = "output"
    clone(".", output_path)
  end
ensure
  @logger.remove("method")
end