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 =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
['/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) ⇒ FPM::Package
(also: #apply)
private
Applies settings to output package.
-
#initialize ⇒ PackageRecipe
constructor
A new instance of PackageRecipe.
-
#lint ⇒ Array<String>
Lints the settings for some common problems.
Constructor Details
#initialize ⇒ PackageRecipe
Returns a new instance of PackageRecipe.
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/fpm/fry/recipe.rb', line 43 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.
27 28 29 |
# File 'lib/fpm/fry/recipe.rb', line 27 def conflicts @conflicts end |
#depends ⇒ Object Also known as: dependencies
Returns the value of attribute depends.
27 28 29 |
# File 'lib/fpm/fry/recipe.rb', line 27 def depends @depends end |
#files ⇒ Object
Returns the value of attribute files.
27 28 29 |
# File 'lib/fpm/fry/recipe.rb', line 27 def files @files end |
#iteration ⇒ Object
Returns the value of attribute iteration.
27 28 29 |
# File 'lib/fpm/fry/recipe.rb', line 27 def iteration @iteration end |
#maintainer ⇒ Object
Returns the value of attribute maintainer.
27 28 29 |
# File 'lib/fpm/fry/recipe.rb', line 27 def maintainer @maintainer end |
#name ⇒ Object
Returns the value of attribute name.
27 28 29 |
# File 'lib/fpm/fry/recipe.rb', line 27 def name @name end |
#output_hooks ⇒ Object
Returns the value of attribute output_hooks.
27 28 29 |
# File 'lib/fpm/fry/recipe.rb', line 27 def output_hooks @output_hooks end |
#provides ⇒ Object
Returns the value of attribute provides.
27 28 29 |
# File 'lib/fpm/fry/recipe.rb', line 27 def provides @provides end |
#recommends ⇒ Object
Returns the value of attribute recommends.
27 28 29 |
# File 'lib/fpm/fry/recipe.rb', line 27 def recommends @recommends end |
#replaces ⇒ Object
Returns the value of attribute replaces.
27 28 29 |
# File 'lib/fpm/fry/recipe.rb', line 27 def replaces @replaces end |
#scripts ⇒ Object
Returns the value of attribute scripts.
27 28 29 |
# File 'lib/fpm/fry/recipe.rb', line 27 def scripts @scripts end |
#suggests ⇒ Object
Returns the value of attribute suggests.
27 28 29 |
# File 'lib/fpm/fry/recipe.rb', line 27 def suggests @suggests end |
#vendor ⇒ Object
Returns the value of attribute vendor.
27 28 29 |
# File 'lib/fpm/fry/recipe.rb', line 27 def vendor @vendor end |
#version ⇒ Object
Returns the value of attribute version.
27 28 29 |
# File 'lib/fpm/fry/recipe.rb', line 27 def version @version end |
Instance Method Details
#apply_output(package) ⇒ FPM::Package Also known as: apply
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Applies settings to output package
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 |
# File 'lib/fpm/fry/recipe.rb', line 69 def apply_output( package ) output_hooks.each{|h| h.call(self, 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 return package end |
#lint ⇒ Array<String>
Lints the settings for some common problems
101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 |
# File 'lib/fpm/fry/recipe.rb', line 101 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] begin Exec::exec(args[0],'-n', stdin_data: s) rescue Exec::Failed => e problems << "#{type} script is not valid #{args[0]} code: #{e.stderr.chomp}" end end end return problems end |