Class: FPM::Fry::Recipe::PackageRecipe
- Inherits:
-
Object
- Object
- FPM::Fry::Recipe::PackageRecipe
- Defined in:
- lib/fpm/fry/recipe.rb
Constant Summary collapse
- SYNTAX_CHECK_SHELLS =
['/bin/sh','/bin/bash', '/bin/dash']
Instance Attribute Summary collapse
-
#conflicts ⇒ Object
Returns the value of attribute conflicts.
-
#depends ⇒ Object
(also: #dependencies)
Returns the value of attribute depends.
-
#files ⇒ Object
Returns the value of attribute files.
-
#iteration ⇒ Object
Returns the value of attribute iteration.
-
#maintainer ⇒ Object
Returns the value of attribute maintainer.
-
#name ⇒ Object
Returns the value of attribute name.
-
#output_hooks ⇒ Object
Returns the value of attribute output_hooks.
-
#provides ⇒ Object
Returns the value of attribute provides.
-
#recommends ⇒ Object
Returns the value of attribute recommends.
-
#replaces ⇒ Object
Returns the value of attribute replaces.
-
#scripts ⇒ Object
Returns the value of attribute scripts.
-
#suggests ⇒ Object
Returns the value of attribute suggests.
-
#vendor ⇒ Object
Returns the value of attribute vendor.
-
#version ⇒ Object
Returns the value of attribute version.
Instance Method Summary collapse
- #apply_output(package) ⇒ Object (also: #apply)
-
#initialize ⇒ PackageRecipe
constructor
A new instance of PackageRecipe.
- #lint ⇒ Object
Constructor Details
#initialize ⇒ PackageRecipe
Returns a new instance of PackageRecipe.
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/fpm/fry/recipe.rb', line 41 def initialize @name = nil @iteration = nil @version = '0.0.0' @maintainer = nil @vendor = nil @depends = {} @provides = {} @conflicts = {} @replaces = {} @scripts = { before_install: [], after_install: [], before_remove: [], after_remove: [] } @output_hooks = [] @files = [] end |
Instance Attribute Details
#conflicts ⇒ Object
Returns the value of attribute conflicts.
25 26 27 |
# File 'lib/fpm/fry/recipe.rb', line 25 def conflicts @conflicts end |
#depends ⇒ Object Also known as: dependencies
Returns the value of attribute depends.
25 26 27 |
# File 'lib/fpm/fry/recipe.rb', line 25 def depends @depends end |
#files ⇒ Object
Returns the value of attribute files.
25 26 27 |
# File 'lib/fpm/fry/recipe.rb', line 25 def files @files end |
#iteration ⇒ Object
Returns the value of attribute iteration.
25 26 27 |
# File 'lib/fpm/fry/recipe.rb', line 25 def iteration @iteration end |
#maintainer ⇒ Object
Returns the value of attribute maintainer.
25 26 27 |
# File 'lib/fpm/fry/recipe.rb', line 25 def maintainer @maintainer end |
#name ⇒ Object
Returns the value of attribute name.
25 26 27 |
# File 'lib/fpm/fry/recipe.rb', line 25 def name @name end |
#output_hooks ⇒ Object
Returns the value of attribute output_hooks.
25 26 27 |
# File 'lib/fpm/fry/recipe.rb', line 25 def output_hooks @output_hooks end |
#provides ⇒ Object
Returns the value of attribute provides.
25 26 27 |
# File 'lib/fpm/fry/recipe.rb', line 25 def provides @provides end |
#recommends ⇒ Object
Returns the value of attribute recommends.
25 26 27 |
# File 'lib/fpm/fry/recipe.rb', line 25 def recommends @recommends end |
#replaces ⇒ Object
Returns the value of attribute replaces.
25 26 27 |
# File 'lib/fpm/fry/recipe.rb', line 25 def replaces @replaces end |
#scripts ⇒ Object
Returns the value of attribute scripts.
25 26 27 |
# File 'lib/fpm/fry/recipe.rb', line 25 def scripts @scripts end |
#suggests ⇒ Object
Returns the value of attribute suggests.
25 26 27 |
# File 'lib/fpm/fry/recipe.rb', line 25 def suggests @suggests end |
#vendor ⇒ Object
Returns the value of attribute vendor.
25 26 27 |
# File 'lib/fpm/fry/recipe.rb', line 25 def vendor @vendor end |
#version ⇒ Object
Returns the value of attribute version.
25 26 27 |
# File 'lib/fpm/fry/recipe.rb', line 25 def version @version end |
Instance Method Details
#apply_output(package) ⇒ Object Also known as: apply
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/fpm/fry/recipe.rb', line 63 def apply_output( package ) package.name = name package.version = version package.iteration = iteration package.maintainer = maintainer if maintainer package.vendor = vendor if vendor scripts.each do |type, scripts| package.scripts[type] = scripts.join("\n") if scripts.any? end [:dependencies, :conflicts, :replaces, :provides].each do |sym| send(sym).each do |name, | constr = Array([:constraints]) if constr.any? constr.each do | c | package.send(sym) << "#{name} #{c}" end else package.send(sym) << name end end end output_hooks.each{|h| h.call(self, package) } return package end |
#lint ⇒ Object
92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 |
# File 'lib/fpm/fry/recipe.rb', line 92 def lint problems = [] problems << "Name is empty." if name.to_s == '' scripts.each do |type,scripts| next if scripts.none? s = scripts.join("\n") if s == '' problems << "#{type} script is empty. This will produce broken packages." next end m = /\A#!([^\n]+)\n/.match(s) if !m problems << "#{type} script doesn't have a valid shebang" next end begin args = m[1].shellsplit rescue ArgumentError => e problems << "#{type} script doesn't have a valid command in shebang" end if SYNTAX_CHECK_SHELLS.include? args[0] sin, sout, serr, th = Open3.popen3(args[0],'-n') sin.write(s) sin.close if th.value.exitstatus != 0 problems << "#{type} script is not valid #{args[0]} code: #{serr.read.chomp}" end serr.close sout.close end end return problems end |