class FPM::Fry::Recipe::PackageRecipe
Constants
- SYNTAX_CHECK_SHELLS
@api private
Attributes
conflicts[RW]
dependencies[RW]
depends[RW]
files[RW]
iteration[RW]
maintainer[RW]
name[RW]
output_hooks[RW]
provides[RW]
recommends[RW]
replaces[RW]
scripts[RW]
suggests[RW]
vendor[RW]
version[RW]
Public Class Methods
new()
click to toggle source
# 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
Public Instance Methods
apply_output( package )
click to toggle source
Applies settings to output package @param [FPM::Package] package @return [FPM::Package] package @api private
# 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, options| constr = Array(options[: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
Also aliased as: apply
lint()
click to toggle source
Lints the settings for some common problems @return [Array<String>] problems
# 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