class Albacore::FpmAppSpec

An object that is capable of generating FPM commands - use by giving it a spec and then calling execute or generate_flags. You may use this object to package a directory.

Public Class Methods

new(app_spec, output_dir_path = '.') click to toggle source

Initialize the object with an ::Albacore::AppSpec

@param [::Albacore::AppSpec] app_spec The required package metadata. @param [PathWrap, String] output_dir_path The output path of the rpm/deb

package.
# File lib/albacore/fpm_app_spec.rb, line 18
def initialize app_spec, output_dir_path = '.'
  raise ArgumentError, 'missing app_spec parameter' unless app_spec
  @spec = app_spec
  @out  = output_dir_path
end

Public Instance Methods

filename(flags = nil) click to toggle source

gets the filename that the resulting file will have, based on the flags to be passed to fpm

# File lib/albacore/fpm_app_spec.rb, line 53
def filename flags = nil
  flags ||= generate_flags
  # TODO: handle OS architecture properly by taking from context
  "#{flags['--name']}-#{flags['--version']}-#{flags['--epoch']}.x86_64.rpm"
end
generate() click to toggle source

Calls FPM with the flags generated

# File lib/albacore/fpm_app_spec.rb, line 60
def generate
  ::Albacore::CrossPlatformCmd.system 'fpm', generate_flags_flat
end
generate_flags(overrides = {}) click to toggle source

Generate flags for FPM - if you don't want to execute directly with the object you can use this method to generate what you should give to FPM yourself

# File lib/albacore/fpm_app_spec.rb, line 27
def generate_flags overrides = {}
  { '-s'            => 'dir',
    '-t'            => 'rpm',
    '--name'        => @spec.title,
    '--description' => @spec.description,
    '--url'         => @spec.uri,
    '--category'    => @spec.category,
    '--version'     => @spec.version,
    '--epoch'       => 1,
    '--license'     => @spec.license,
    '-C'            => @spec.dir_path,
    '--depends'     => 'mono',
    '--rpm-digest'  => 'sha256',
    '--package'     => @out
  }.merge(overrides).reject { |_, v| v.nil? }
end
generate_flags_flat(overrides = {}) click to toggle source

Generates the flags and flatten them to an array that is possible to feed into the system command

# File lib/albacore/fpm_app_spec.rb, line 47
def generate_flags_flat overrides = {}
  generate_flags(overrides).map { |k, v| [k, v] }.concat(%w|--force .|).flatten
end