Class: FPM::Fry::Recipe::Builder
Instance Attribute Summary collapse
#inspector, #logger, #package_recipe, #variables
Instance Method Summary
collapse
#after_install, #after_remove, #before_install, #before_remove, #codename, #conflicts, #depends, #distribution, #files, #flavour, #iteration, #name, #output_hooks, #plugin, #provides, #release, #replaces, #script, #vendor, #version
Constructor Details
#initialize(variables, options = {}) ⇒ Builder
Returns a new instance of Builder.
206
207
208
209
210
211
212
213
214
|
# File 'lib/fpm/fry/recipe/builder.rb', line 206
def initialize( variables, options = {} )
recipe = options.fetch(:recipe){ Recipe.new }
variables = variables.dup
variables.freeze
@recipe = recipe
@steps = :steps
register_default_source_types!
super(variables, recipe.packages[0], options)
end
|
Instance Attribute Details
#keep_modified_files ⇒ Object
Returns the value of attribute keep_modified_files.
305
306
307
|
# File 'lib/fpm/fry/recipe/builder.rb', line 305
def keep_modified_files
@keep_modified_files
end
|
199
200
201
|
# File 'lib/fpm/fry/recipe/builder.rb', line 199
def recipe
@recipe
end
|
Instance Method Details
#add(source, target) ⇒ Object
237
238
239
|
# File 'lib/fpm/fry/recipe/builder.rb', line 237
def add(source, target)
recipe.build_mounts << [source, target]
end
|
#apt_setup(cmd) ⇒ Object
241
242
243
244
245
|
# File 'lib/fpm/fry/recipe/builder.rb', line 241
def apt_setup(cmd)
before_dependencies do
bash cmd
end
end
|
#bash(name = nil, code) ⇒ Object
258
259
260
261
262
263
264
265
266
267
268
269
270
271
|
# File 'lib/fpm/fry/recipe/builder.rb', line 258
def bash( name = nil, code )
if name
code = Recipe::Step.new(name, code)
end
case(@steps)
when :before_dependencies
recipe.before_dependencies_steps << code
when :before_build
recipe.before_build_steps << code
else
recipe.steps << code
end
end
|
#before_build ⇒ Object
273
274
275
276
277
278
|
# File 'lib/fpm/fry/recipe/builder.rb', line 273
def before_build
steps, @steps = @steps, :before_build
yield
ensure
@steps = steps
end
|
#before_dependencies ⇒ Object
280
281
282
283
284
285
|
# File 'lib/fpm/fry/recipe/builder.rb', line 280
def before_dependencies
steps, @steps = @steps, :before_dependencies
yield
ensure
@steps = steps
end
|
#build_depends(name, options = {}) ⇒ Object
287
288
289
290
|
# File 'lib/fpm/fry/recipe/builder.rb', line 287
def build_depends( name , options = {} )
name, options = parse_package(name, options)
recipe.build_depends[name] = options
end
|
292
293
294
|
# File 'lib/fpm/fry/recipe/builder.rb', line 292
def input_hooks
recipe.input_hooks
end
|
#keep_modified_files! ⇒ Object
307
308
309
|
# File 'lib/fpm/fry/recipe/builder.rb', line 307
def keep_modified_files!
@keep_modified_files = true
end
|
#load_file(file) ⇒ Object
216
217
218
219
220
221
222
223
224
225
226
227
|
# File 'lib/fpm/fry/recipe/builder.rb', line 216
def load_file( file )
file = File.expand_path(file)
begin
content = IO.read(file)
rescue Errno::ENOENT => e
raise NotFound, e
end
basedir = File.dirname(file)
Dir.chdir(basedir) do
instance_eval(content,file,0)
end
end
|
#package(name, &block) ⇒ Object
296
297
298
299
300
301
302
303
|
# File 'lib/fpm/fry/recipe/builder.rb', line 296
def package(name, &block)
pr = PackageRecipe.new
pr.name = name
pr.version = package_recipe.version
pr.iteration = package_recipe.iteration
recipe.packages << pr
PackageBuilder.new(variables, pr, logger: logger, inspector: inspector).instance_eval(&block)
end
|
#run(*args) ⇒ Object
247
248
249
250
251
252
253
254
255
256
|
# File 'lib/fpm/fry/recipe/builder.rb', line 247
def run(*args)
if args.first.kind_of? Hash
options = args.shift
else
options = {}
end
command = args.shift
name = options.fetch(:name){ [command,*args].select{|c| c[0] != '-' }.join(' ') }
bash( name, Shellwords.join([command, *args]) )
end
|
#source(url, options = {}) ⇒ Object
229
230
231
232
233
234
235
|
# File 'lib/fpm/fry/recipe/builder.rb', line 229
def source( url , options = {} )
options = options.merge(logger: logger)
source = Source::Patched.decorate(options) do |options|
guess_source(url,options).new(url, options)
end
recipe.source = source
end
|