Class: FPM::Cookery::ChainPackager

Inherits:
Object
  • Object
show all
Includes:
Utils
Defined in:
lib/fpm/cookery/chain_packager.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(packager, config) ⇒ ChainPackager

Returns a new instance of ChainPackager.



11
12
13
14
15
# File 'lib/fpm/cookery/chain_packager.rb', line 11

def initialize(packager, config)
  @packager = packager
  @recipe = packager.recipe
  @config = config
end

Instance Attribute Details

#configObject (readonly)

Returns the value of attribute config.



9
10
11
# File 'lib/fpm/cookery/chain_packager.rb', line 9

def config
  @config
end

#packagerObject (readonly)

Returns the value of attribute packager.



9
10
11
# File 'lib/fpm/cookery/chain_packager.rb', line 9

def packager
  @packager
end

#recipeObject (readonly)

Returns the value of attribute recipe.



9
10
11
# File 'lib/fpm/cookery/chain_packager.rb', line 9

def recipe
  @recipe
end

Instance Method Details

#runObject



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/fpm/cookery/chain_packager.rb', line 17

def run
  Log.info "Recipe #{recipe.name} is a chain package; looking for child recipes to build"

  recipe.chain_recipes.each do |name|
    recipe_file = build_recipe_file_path(name)

    unless File.exists?(recipe_file)
      Log.fatal "Cannot find a recipe for #{name} at #{recipe_file}"
      exit 1
    end

    Log.info "Located recipe at #{recipe_file} for child recipe #{name}; starting build"

    FPM::Cookery::Book.instance.load_recipe(recipe_file, config) do |dep_recipe|
      depPackager = FPM::Cookery::Packager.new(dep_recipe, config.to_hash)
      depPackager.target = FPM::Cookery::Facts.target.to_s

      #Chain, chain, chain ...
      if dep_recipe.omnibus_package == true
        FPM::Cookery::OmnibusPackager.new(depPackager, config).run
      elsif dep_recipe.chain_package == true
        FPM::Cookery::ChainPackager.new(depPackager, config).run
      else
        depPackager.dispense
      end
    end

    Log.info "Finished building #{name}, moving on to next recipe"
  end

  packager.dispense
end