Class: FPM::Cookery::BaseRecipe

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

Direct Known Subclasses

NPMRecipe, 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) ⇒ BaseRecipe

Returns a new instance of BaseRecipe.



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

def initialize(filename)
  @filename = Path.new(filename).expand_path

  # Set some defaults.
  revision || self.class.revision(1)
end

Instance Attribute Details

#filenameObject (readonly)

Returns the value of attribute filename.



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

def filename
  @filename
end

Class Method Details

.architectures(archs) ⇒ Object



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

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

.attr_rw(*attrs) ⇒ Object



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

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



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

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



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

def depends_all
  (depends + build_depends).uniq
end

.platformObject



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

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

.platforms(valid_platforms) ⇒ Object



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

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

Instance Method Details

#builddir(path = nil) ⇒ Object



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

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

#builddir=(value) ⇒ Object



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

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

#cachedir(path = nil) ⇒ Object



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

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

#cachedir=(value) ⇒ Object



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

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

#depends_allObject

Resolve dependencies from omnibus package.



100
101
102
103
104
105
106
107
108
109
110
111
# File 'lib/fpm/cookery/recipe.rb', line 100

def depends_all
  pkg_depends = self.class.depends_all
  if self.class.omnibus_package
    self.class.omnibus_recipes.each { |omni_recipe|
      Book.instance.load_recipe(File.expand_path(omni_recipe + '.rb', File.dirname(filename))) do |recipe|
        pkg_depends << recipe.depends_all
      end
    }
  end

  pkg_depends.flatten.uniq
end

#destdir(path = nil) ⇒ Object



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

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

#destdir=(value) ⇒ Object



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

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

#pkgdir(path = nil) ⇒ Object



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

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

#pkgdir=(value) ⇒ Object



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

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

#workdir(path = nil) ⇒ Object



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

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

#workdir=(value) ⇒ Object



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

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