Class: FPM::Cookery::BaseRecipe

Inherits:
Object
  • Object
show all
Extended by:
InheritableAttr, Forwardable
Includes:
LifecycleHooks, PathHelper, Utils, FileUtils
Defined in:
lib/fpm/cookery/recipe.rb

Direct Known Subclasses

Recipe

Instance Attribute Summary

Attributes included from PathHelper

#installing, #omnibus_installing

Class Method Summary collapse

Instance Method Summary collapse

Methods included from InheritableAttr

attr_rw, attr_rw_hash, attr_rw_list, attr_rw_path, extended, inherit_for, register_attrs

Methods included from LifecycleHooks

#after_build, #after_dependency_installation, #after_install, #after_package_create, #after_source_download, #after_source_extraction, #before_build, #before_dependency_installation, #before_install, #before_package_create, #before_source_download, #before_source_extraction, #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

Class Method Details

.architectures(archs) ⇒ Object



63
64
65
# File 'lib/fpm/cookery/recipe.rb', line 63

def architectures(archs)
  Array(archs).member?(FPM::Cookery::Facts.arch) and block_given? ? yield : false
end

.builddir(path = nil) ⇒ Object



103
104
105
# File 'lib/fpm/cookery/recipe.rb', line 103

def builddir(path = nil)
  (@builddir ||= tmp_root('tmp-build'))/path
end

.cachedir(path = nil) ⇒ Object



91
92
93
# File 'lib/fpm/cookery/recipe.rb', line 91

def cachedir(path = nil)
  (@cachedir ||= config.cache_dir ? Path.new(config.cache_dir) : workdir('cache'))/path
end

.datadir(path = nil) ⇒ Object



95
96
97
# File 'lib/fpm/cookery/recipe.rb', line 95

def datadir(path = nil)
  (@datadir ||= config.data_dir ? Path.new(config.data_dir) : workdir('config'))/path
end

.depends_allObject



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

def depends_all
  (depends + build_depends).uniq
end

.destdir(path = nil) ⇒ Object



99
100
101
# File 'lib/fpm/cookery/recipe.rb', line 99

def destdir(path = nil)
  (@destdir ||= tmp_root('tmp-dest'))/path
end

.pkgdir(path = nil) ⇒ Object



87
88
89
# File 'lib/fpm/cookery/recipe.rb', line 87

def pkgdir(path = nil)
  (@pkgdir ||= config.pkg_dir ? Path.new(config.pkg_dir) : workdir('pkg'))/path
end

.platformObject



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

def platform
  FPM::Cookery::Facts.platform
end

.platforms(valid_platforms) ⇒ Object



59
60
61
# File 'lib/fpm/cookery/recipe.rb', line 59

def platforms(valid_platforms)
  Array(valid_platforms).member?(self.platform) and block_given? ? yield : false
end

.targets(valid_targets) ⇒ Object



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

def targets(valid_targets)
  Array(valid_targets).member?(FPM::Cookery::Facts.target) and block_given? ? yield : false
end

.tmp_root(path = nil) ⇒ Object



83
84
85
# File 'lib/fpm/cookery/recipe.rb', line 83

def tmp_root(path = nil)
  (@tmp_root ||= config.tmp_root ? Path.new(config.tmp_root) : workdir)/path
end

.workdir(path = nil) ⇒ Object



79
80
81
# File 'lib/fpm/cookery/recipe.rb', line 79

def workdir(path = nil)
  (@workdir  ||= Path.new(filename).dirname)/path
end

Instance Method Details

#depends_allObject

Resolve dependencies from omnibus package.



111
112
113
114
115
116
117
118
119
120
121
122
123
124
# File 'lib/fpm/cookery/recipe.rb', line 111

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