Class: FPM::Cookery::BaseRecipe

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

Direct Known Subclasses

NPMRecipe, PythonRecipe, Recipe, RubyGemRecipe

Instance Attribute Summary collapse

Attributes included from PathHelper

#installing, #omnibus_installing

Class Method Summary collapse

Instance Method Summary collapse

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.



81
82
83
84
85
86
87
88
89
# File 'lib/fpm/cookery/recipe.rb', line 81

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

#filenameObject (readonly)

Returns the value of attribute filename.



69
70
71
# File 'lib/fpm/cookery/recipe.rb', line 69

def filename
  @filename
end

Class Method Details

.architectures(archs) ⇒ Object



38
39
40
# File 'lib/fpm/cookery/recipe.rb', line 38

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

.attr_rw(*attrs) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/fpm/cookery/recipe.rb', line 20

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



42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/fpm/cookery/recipe.rb', line 42

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_allObject



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

def depends_all
  (depends + build_depends).uniq
end

.platformObject



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

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

.platforms(valid_platforms) ⇒ Object



34
35
36
# File 'lib/fpm/cookery/recipe.rb', line 34

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

Instance Method Details

#builddir(path = nil) ⇒ Object



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

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

#builddir=(value) ⇒ Object



94
# File 'lib/fpm/cookery/recipe.rb', line 94

def builddir=(value) @builddir = Path.new(value) end

#cachedir(path = nil) ⇒ Object



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

def cachedir(path = nil) (@cachedir || workdir('cache'))/path       end

#cachedir=(value) ⇒ Object



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

def cachedir=(value) @cachedir = Path.new(value) end

#depends_allObject

Resolve dependencies from omnibus package.



106
107
108
109
110
111
112
113
114
115
116
117
118
119
# File 'lib/fpm/cookery/recipe.rb', line 106

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



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

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

#destdir=(value) ⇒ Object



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

def destdir=(value)  @destdir  = Path.new(value) end

#pkgdir(path = nil) ⇒ Object



102
# File 'lib/fpm/cookery/recipe.rb', line 102

def pkgdir(path = nil)   (@pkgdir   || workdir('pkg'))/path         end

#pkgdir=(value) ⇒ Object



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

def pkgdir=(value)   @pkgdir   = Path.new(value) end

#tmp_root(path = nil) ⇒ Object



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

def tmp_root(path = nil) @tmp_root/path                              end

#tmp_root=(value) ⇒ Object



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

def tmp_root=(value) @tmp_root = Path.new(value) end

#workdir(path = nil) ⇒ Object



98
# File 'lib/fpm/cookery/recipe.rb', line 98

def workdir(path = nil)  @workdir/path                               end

#workdir=(value) ⇒ Object



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

def workdir=(value)  @workdir  = Path.new(value) end