class FPM::Fry::Recipe::PackageBuilder

Constants

Not

Attributes

inspector[R]

@return [FPM::Fry::Inspector,nil]

logger[R]

@return [Cabin::Channel]

package_recipe[R]

@return [FPM::Fry::PackageRecipe]

variables[R]

@return [Hash<Symbol,Object>]

Public Class Methods

new( variables, package_recipe, options = {}) click to toggle source

@api private

# File lib/fpm/fry/recipe/builder.rb, line 27
def initialize( variables, package_recipe, options = {})
  @variables = variables
  @package_recipe = package_recipe
  @logger = options.fetch(:logger){ Cabin::Channel.get }
  @inspector = options[:inspector]
end

Public Instance Methods

after_install(*args) click to toggle source
# File lib/fpm/fry/recipe/builder.rb, line 145
def after_install(*args)
  script(:after_install, *args)
end
Also aliased as: post_install, postinstall
after_remove(*args) click to toggle source
# File lib/fpm/fry/recipe/builder.rb, line 158
def after_remove(*args)
  script(:after_remove, *args)
end
after_uninstall(*args)
Alias for: after_remove
architecture() click to toggle source
# File lib/fpm/fry/recipe/builder.rb, line 58
def architecture
  variables[:architecture]
end
before_install(*args) click to toggle source
# File lib/fpm/fry/recipe/builder.rb, line 139
def before_install(*args)
  script(:before_install, *args)
end
Also aliased as: pre_install, preinstall
before_remove(*args) click to toggle source
# File lib/fpm/fry/recipe/builder.rb, line 151
def before_remove(*args)
  script(:before_remove, *args)
end
before_uninstall(*args)
Alias for: before_remove
codename() click to toggle source
# File lib/fpm/fry/recipe/builder.rb, line 54
def codename
  variables[:codename]
end
conflicts( name , options = {} ) click to toggle source
# File lib/fpm/fry/recipe/builder.rb, line 89
def conflicts( name , options = {} )
  name, options = parse_package(name, options)
  if package_recipe.conflicts.key? name
    raise Error.new("duplicate conflict",package: name)
  elsif package_recipe.depends.key? name
    raise Error.new("conflicting package is already a dependency",package: name)
  end
  package_recipe.conflicts[name] = options
end
depends( name , options = {} ) click to toggle source
# File lib/fpm/fry/recipe/builder.rb, line 79
def depends( name , options = {} )
  name, options = parse_package(name, options)
  if package_recipe.depends.key? name
    raise Error.new("duplicate dependency",package: name)
  elsif package_recipe.conflicts.key? name
    raise Error.new("depending package is already a conflicting package",package: name)
  end
  package_recipe.depends[name] = options
end
distribution() click to toggle source
# File lib/fpm/fry/recipe/builder.rb, line 40
def distribution
  variables[:distribution]
end
Also aliased as: platform
distribution_version()
Also aliased as: platform_version
Alias for: release
files( pattern ) click to toggle source
# File lib/fpm/fry/recipe/builder.rb, line 109
def files( pattern )
  package_recipe.files << pattern
end
flavour() click to toggle source

Returns the package type ( e.g. “debian” or “redhat” ). @return [String]

# File lib/fpm/fry/recipe/builder.rb, line 36
def flavour
  variables[:flavour]
end
iteration(value = Not) click to toggle source
# File lib/fpm/fry/recipe/builder.rb, line 62
def iteration(value = Not)
  get_or_set('@iteration',value)
end
Also aliased as: revision
name(value = Not) click to toggle source
# File lib/fpm/fry/recipe/builder.rb, line 71
def name(value = Not)
  get_or_set('@name',value)
end
output_hooks() click to toggle source
# File lib/fpm/fry/recipe/builder.rb, line 165
def output_hooks
  package_recipe.output_hooks
end
platform()
Alias for: distribution
platform_version()
plugin(name, *args, &block) click to toggle source
# File lib/fpm/fry/recipe/builder.rb, line 113
def plugin(name, *args, &block)
  logger.debug('Loading Plugin', name: name, args: args, block: block, load_path: $LOAD_PATH)
  if name =~ /\A\./
    require name
  else
    require File.join('fpm/fry/plugin',name)
  end
  module_name = File.basename(name,'.rb').gsub(/(?:\A|_)([a-z])/){ $1.upcase }
  mod = FPM::Fry::Plugin.const_get(module_name)
  if mod.respond_to? :apply
    mod.apply(self, *args, &block)
  else
    if args.any? or block_given?
      raise ArgumentError, "Simple plugins can't accept additional arguments and blocks."
    end
    extend(mod)
  end
end
post_install(*args)
Alias for: after_install
post_uninstall(*args)
Alias for: after_remove
postinstall(*args)
Alias for: after_install
postuninstall(*args)
Alias for: after_remove
pre_install(*args)
Alias for: before_install
pre_uninstall(*args)
Alias for: before_remove
preinstall(*args)
Alias for: before_install
preuninstall(*args)
Alias for: before_remove
provides( name , options = {} ) click to toggle source
# File lib/fpm/fry/recipe/builder.rb, line 99
def provides( name , options = {} )
  name, options = parse_package(name, options)
  package_recipe.provides[name] = options
end
release() click to toggle source

The release version of the distribution ( e.g. “12.04” or “6.0.7” ) @return [String]

# File lib/fpm/fry/recipe/builder.rb, line 47
def release
  variables[:release]
end
Also aliased as: distribution_version
replaces( name , options = {} ) click to toggle source
# File lib/fpm/fry/recipe/builder.rb, line 104
def replaces( name , options = {} )
  name, options = parse_package(name, options)
  package_recipe.replaces[name] = options
end
revision(value = Not)
Alias for: iteration
script(type, value = Not) click to toggle source
# File lib/fpm/fry/recipe/builder.rb, line 132
def script(type, value = Not)
  if value != Not
    package_recipe.scripts[type] << value
  end
  return package_recipe.scripts[type]
end
vendor(value = Not) click to toggle source
# File lib/fpm/fry/recipe/builder.rb, line 75
def vendor(value = Not)
  get_or_set('@vendor',value)
end
version(value = Not) click to toggle source
# File lib/fpm/fry/recipe/builder.rb, line 67
def version(value = Not)
  get_or_set('@version',value)
end

Protected Instance Methods

get_or_set(name, value = Not) click to toggle source
# File lib/fpm/fry/recipe/builder.rb, line 190
def get_or_set(name, value = Not)
  if value == Not
    return package_recipe.instance_variable_get(name)
  else
    return package_recipe.instance_variable_set(name, value)
  end
end
parse_package( name, options = {} ) click to toggle source
# File lib/fpm/fry/recipe/builder.rb, line 171
def parse_package( name, options = {} )
  if options.kind_of? String
    options = {constraints: options}
  end
  case(v = options[:constraints])
  when String
    options[:constraints] = v.split(',').map do |c|
      if c =~ /\A\s*(<=|<<|>=|>>|<>|=|>|<)(\s*)/
        $1 + ' ' + $'
      else
        '= ' + c
      end
    end
  end
  return name, options
end