Class: FPM::Fry::Recipe::PackageBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/fpm/fry/recipe/builder.rb

Direct Known Subclasses

Builder

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(variables, package_recipe, options = {}) ⇒ PackageBuilder

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of PackageBuilder.



27
28
29
30
31
32
# 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

Instance Attribute Details

#inspectorFPM::Fry::Inspector? (readonly)

Returns:



24
25
26
# File 'lib/fpm/fry/recipe/builder.rb', line 24

def inspector
  @inspector
end

#loggerCabin::Channel (readonly)

Returns:

  • (Cabin::Channel)


21
22
23
# File 'lib/fpm/fry/recipe/builder.rb', line 21

def logger
  @logger
end

#package_recipeFPM::Fry::PackageRecipe (readonly)

Returns:

  • (FPM::Fry::PackageRecipe)


18
19
20
# File 'lib/fpm/fry/recipe/builder.rb', line 18

def package_recipe
  @package_recipe
end

#variablesHash<Symbol,Object> (readonly)

Returns:

  • (Hash<Symbol,Object>)


15
16
17
# File 'lib/fpm/fry/recipe/builder.rb', line 15

def variables
  @variables
end

Instance Method Details

#after_install(*args) ⇒ Object Also known as: post_install, postinstall



145
146
147
# File 'lib/fpm/fry/recipe/builder.rb', line 145

def after_install(*args)
  script(:after_install, *args)
end

#after_remove(*args) ⇒ Object Also known as: after_uninstall, post_uninstall, postuninstall



158
159
160
# File 'lib/fpm/fry/recipe/builder.rb', line 158

def after_remove(*args)
  script(:after_remove, *args)
end

#architectureObject



58
59
60
# File 'lib/fpm/fry/recipe/builder.rb', line 58

def architecture
  variables[:architecture]
end

#before_install(*args) ⇒ Object Also known as: pre_install, preinstall



139
140
141
# File 'lib/fpm/fry/recipe/builder.rb', line 139

def before_install(*args)
  script(:before_install, *args)
end

#before_remove(*args) ⇒ Object Also known as: before_uninstall, pre_uninstall, preuninstall



151
152
153
# File 'lib/fpm/fry/recipe/builder.rb', line 151

def before_remove(*args)
  script(:before_remove, *args)
end

#codenameObject



54
55
56
# File 'lib/fpm/fry/recipe/builder.rb', line 54

def codename
  variables[:codename]
end

#conflicts(name, options = {}) ⇒ Object



89
90
91
92
93
94
95
96
97
# 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 = {}) ⇒ Object



79
80
81
82
83
84
85
86
87
# 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

#distributionObject Also known as: platform



40
41
42
# File 'lib/fpm/fry/recipe/builder.rb', line 40

def distribution
  variables[:distribution]
end

#files(pattern) ⇒ Object



109
110
111
# File 'lib/fpm/fry/recipe/builder.rb', line 109

def files( pattern )
  package_recipe.files << pattern
end

#flavourString

Returns the package type ( e.g. “debian” or “redhat” ).

Returns:

  • (String)


36
37
38
# File 'lib/fpm/fry/recipe/builder.rb', line 36

def flavour
  variables[:flavour]
end

#iteration(value = Not) ⇒ Object Also known as: revision



62
63
64
# File 'lib/fpm/fry/recipe/builder.rb', line 62

def iteration(value = Not)
  get_or_set('@iteration',value)
end

#name(value = Not) ⇒ Object



71
72
73
# File 'lib/fpm/fry/recipe/builder.rb', line 71

def name(value = Not)
  get_or_set('@name',value)
end

#output_hooksObject



165
166
167
# File 'lib/fpm/fry/recipe/builder.rb', line 165

def output_hooks
  package_recipe.output_hooks
end

#plugin(name, *args, &block) ⇒ Object



113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
# 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

#provides(name, options = {}) ⇒ Object



99
100
101
102
# 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

#releaseString Also known as: distribution_version

The release version of the distribution ( e.g. “12.04” or “6.0.7” )

Returns:

  • (String)


47
48
49
# File 'lib/fpm/fry/recipe/builder.rb', line 47

def release
  variables[:release]
end

#replaces(name, options = {}) ⇒ Object



104
105
106
107
# 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

#script(type, value = Not) ⇒ Object



132
133
134
135
136
137
# 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) ⇒ Object



75
76
77
# File 'lib/fpm/fry/recipe/builder.rb', line 75

def vendor(value = Not)
  get_or_set('@vendor',value)
end

#version(value = Not) ⇒ Object



67
68
69
# File 'lib/fpm/fry/recipe/builder.rb', line 67

def version(value = Not)
  get_or_set('@version',value)
end