Class: FPM::Cookery::BaseRecipe
Instance Attribute Summary collapse
Attributes included from PathHelper
#installing, #omnibus_installing
Class Method Summary
collapse
Instance Method Summary
collapse
#after_dependency_installation, #before_dependency_installation, #run_lifecycle_hook
Methods included from PathHelper
#bin, #doc, #etc, #include, #info, #installing?, #lib, #libexec, #man, #man1, #man2, #man3, #man4, #man5, #man6, #man7, #man8, #omnibus_installing?, #opt, #prefix, #root, #sbin, #share, #var, #with_trueprefix
Constructor Details
#initialize(filename, config) ⇒ BaseRecipe
Returns a new instance of BaseRecipe.
111
112
113
114
115
116
117
118
119
|
# File 'lib/fpm/cookery/recipe.rb', line 111
def initialize(filename, config)
@filename = Path.new(filename).expand_path
@config = config
@workdir = @filename.dirname
@tmp_root = @config.tmp_root ? Path.new(@config.tmp_root) : @workdir
@pkgdir = @config.pkg_dir && Path.new(@config.pkg_dir)
@cachedir = @config.cache_dir && Path.new(@config.cache_dir)
end
|
Instance Attribute Details
#filename ⇒ Object
Returns the value of attribute filename.
83
84
85
|
# File 'lib/fpm/cookery/recipe.rb', line 83
def filename
@filename
end
|
Class Method Details
.architectures(archs) ⇒ Object
51
52
53
|
# File 'lib/fpm/cookery/recipe.rb', line 51
def self.architectures(archs)
Array(archs).member?(FPM::Cookery::Facts.arch) and block_given? ? yield : false
end
|
.attr_rw(*attrs) ⇒ Object
25
26
27
28
29
30
31
32
33
34
35
36
37
|
# File 'lib/fpm/cookery/recipe.rb', line 25
def self.attr_rw(*attrs)
attrs.each do |attr|
class_eval %Q{
def self.#{attr}(value = nil)
value.nil? ? @#{attr} : @#{attr} = value
end
def #{attr}
self.class.#{attr}
end
}
end
end
|
.attr_rw_list(*attrs) ⇒ Object
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
|
# File 'lib/fpm/cookery/recipe.rb', line 55
def self.attr_rw_list(*attrs)
attrs.each do |attr|
class_eval %Q{
def self.#{attr}(*list)
@#{attr} ||= []
@#{attr} << list
@#{attr}.flatten!
@#{attr}.uniq!
@#{attr}
end
def #{attr}
self.class.#{attr}
end
}
end
end
|
.depends_all ⇒ Object
90
91
92
|
# File 'lib/fpm/cookery/recipe.rb', line 90
def depends_all
(depends + build_depends).uniq
end
|
.environment ⇒ Object
104
105
106
|
# File 'lib/fpm/cookery/recipe.rb', line 104
def environment
@environment
end
|
.fpm_attributes(args = nil) ⇒ Object
Supports both hash and argument assignment
fpm_attributes[:attr1] = xxxx
fpm_attributes :xxxx=>1, :yyyy=>2
97
98
99
100
101
102
|
# File 'lib/fpm/cookery/recipe.rb', line 97
def fpm_attributes(args=nil)
if args.is_a?(Hash)
@fpm_attributes.merge!(args)
end
@fpm_attributes
end
|
.inherited(klass) ⇒ Object
39
40
41
42
43
44
45
|
# File 'lib/fpm/cookery/recipe.rb', line 39
def self.inherited(klass)
super
klass.instance_variable_set(:@fpm_attributes, self.fpm_attributes.dup)
klass.instance_variable_set(:@environment, self.environment.dup)
end
|
47
48
49
|
# File 'lib/fpm/cookery/recipe.rb', line 47
def self.platforms(valid_platforms)
Array(valid_platforms).member?(self.platform) and block_given? ? yield : false
end
|
Instance Method Details
#builddir(path = nil) ⇒ Object
131
|
# File 'lib/fpm/cookery/recipe.rb', line 131
def builddir(path = nil) (@builddir || tmp_root('tmp-build'))/path end
|
#builddir=(value) ⇒ Object
124
|
# File 'lib/fpm/cookery/recipe.rb', line 124
def builddir=(value) @builddir = Path.new(value) end
|
#cachedir(path = nil) ⇒ Object
133
|
# File 'lib/fpm/cookery/recipe.rb', line 133
def cachedir(path = nil) (@cachedir || workdir('cache'))/path end
|
#cachedir=(value) ⇒ Object
126
|
# File 'lib/fpm/cookery/recipe.rb', line 126
def cachedir=(value) @cachedir = Path.new(value) end
|
#depends_all ⇒ Object
Resolve dependencies from omnibus package.
138
139
140
141
142
143
144
145
146
147
148
149
150
151
|
# File 'lib/fpm/cookery/recipe.rb', line 138
def depends_all
pkg_depends = self.class.depends_all
if self.class.omnibus_package
self.class.omnibus_recipes.each { |omni_recipe|
recipe_file = File.expand_path(omni_recipe + '.rb', File.dirname(filename))
Book.instance.load_recipe(recipe_file, config) do |recipe|
pkg_depends << recipe.depends_all
end
}
end
pkg_depends.flatten.uniq
end
|
#destdir(path = nil) ⇒ Object
130
|
# File 'lib/fpm/cookery/recipe.rb', line 130
def destdir(path = nil) (@destdir || tmp_root('tmp-dest'))/path end
|
#destdir=(value) ⇒ Object
123
|
# File 'lib/fpm/cookery/recipe.rb', line 123
def destdir=(value) @destdir = Path.new(value) end
|
#environment ⇒ Object
135
|
# File 'lib/fpm/cookery/recipe.rb', line 135
def environment() self.class.environment end
|
#fpm_attributes ⇒ Object
134
|
# File 'lib/fpm/cookery/recipe.rb', line 134
def fpm_attributes() self.class.fpm_attributes end
|
#pkgdir(path = nil) ⇒ Object
132
|
# File 'lib/fpm/cookery/recipe.rb', line 132
def pkgdir(path = nil) (@pkgdir || workdir('pkg'))/path end
|
#pkgdir=(value) ⇒ Object
125
|
# File 'lib/fpm/cookery/recipe.rb', line 125
def pkgdir=(value) @pkgdir = Path.new(value) end
|
#tmp_root(path = nil) ⇒ Object
129
|
# File 'lib/fpm/cookery/recipe.rb', line 129
def tmp_root(path = nil) @tmp_root/path end
|
#tmp_root=(value) ⇒ Object
122
|
# File 'lib/fpm/cookery/recipe.rb', line 122
def tmp_root=(value) @tmp_root = Path.new(value) end
|
#workdir(path = nil) ⇒ Object
128
|
# File 'lib/fpm/cookery/recipe.rb', line 128
def workdir(path = nil) @workdir/path end
|
#workdir=(value) ⇒ Object
121
|
# File 'lib/fpm/cookery/recipe.rb', line 121
def workdir=(value) @workdir = Path.new(value) end
|