class FPM::Scriptable::Script
Public Class Methods
attr_handler(*opts)
click to toggle source
# File lib/fpm/scriptable/script.rb, line 19 def self.attr_handler(*opts) opts.each do |opt| class_eval %Q{ def #{opt.to_s}(value=nil) value.nil? ? @#{opt.to_s} : @#{opt.to_s} = value end } end end
attr_list_handler(*opts)
click to toggle source
# File lib/fpm/scriptable/script.rb, line 29 def self.attr_list_handler(*opts) opts.each do |opt| class_eval %Q{ def #{opt.to_s}(*list) @#{opt.to_s} ||= [] @#{opt.to_s} << list @#{opt.to_s}.flatten! @#{opt.to_s}.uniq! @#{opt.to_s} end } end end
build(&block)
click to toggle source
# File lib/fpm/scriptable/script.rb, line 174 def self.build(&block) self.new.instance_eval(&block) end
new()
click to toggle source
# File lib/fpm/scriptable/script.rb, line 50 def initialize @log = FPM::Scriptable::Log.instance @config = FPM::Scriptable::Config.instance.config c = FPM::Scriptable::Constants.instance @log.debug 'FPM::Scriptable::Script - initializing Script' @version = c.script.version @iteration = c.script.iteration @description = c.script.description @dstdir = c.script.dstdir plugin_init end
Public Instance Methods
build_inputs()
click to toggle source
# File lib/fpm/scriptable/script.rb, line 79 def build_inputs end
config()
click to toggle source
# File lib/fpm/scriptable/script.rb, line 170 def config @config end
create()
click to toggle source
# File lib/fpm/scriptable/script.rb, line 82 def create begin ENV['TMP'] = workdir if !workdir.nil? @fpm = fpm_obj @fpm.name = name @fpm.url = url if !url.nil? @fpm.version = version @fpm.iteration = iteration @fpm.category = category if !category.nil? @fpm.description = description if !description.nil? @fpm.architecture = arch if !arch.nil? @fpm.license = license if !license.nil? @fpm.epoch = epoch if !epoch.nil? @fpm.maintainer = maintainer if !maintainer.nil? @fpm.vendor = vendor if !vendor.nil? @fpm.dependencies += depends @fpm.conflicts += conflicts @fpm.provides += provides @fpm.replaces += replaces @fpm.attributes[:excludes] = excludes if !before_install.nil? @fpm.scripts[:before_install] = expand_script(before_install) end if !after_install.nil? @fpm.scripts[:after_install] = expand_script(after_install) end if !before_remove.nil? @fpm.scripts[:before_remove] = expand_script(before_remove) end if !after_remove.nil? @fpm.scripts[:after_remove] = expand_script(after_remove) end plugin_setup build_inputs # TODO #@fpm.config_files += #@fpm.directories += #@fom.attributes[:excludes] rescue Exception => e @log.error "FPM::Scriptable::Script - #{e}" end package = nil begin package = fpm_convert if !package.nil? Dir.chdir(@dstdir) do if File.exists? package.to_s if !overwrite.nil? force = overwrite.to_s.downcase if force == 'true' @log.warn "FPM::Scriptable::Script - overwrite enabled - removing package: #{package.to_s}" FileUtils.rm_f(package.to_s) end end end @log.info "FPM::Scriptable::Script - building package: #{package.to_s}" package.output(package.to_s) end else @log.error 'FPM::Scriptable::Script - failed to convert - packaging object is invalid' end rescue Exception => e @log.error "FPM::Scriptable::Script - #{e}" end end
env()
click to toggle source
# File lib/fpm/scriptable/script.rb, line 162 def env @env ||= EnvHandler.new end
fpm_convert()
click to toggle source
# File lib/fpm/scriptable/script.rb, line 69 def fpm_convert @log.warn 'FPM::Scriptable::Script - fpm_convert method not implemented in plugin' end
fpm_obj()
click to toggle source
# File lib/fpm/scriptable/script.rb, line 65 def fpm_obj @log.warn 'FPM::Scriptable::Script - fpm_obj method not implemented in plugin' end
get_binding()
click to toggle source
# File lib/fpm/scriptable/script.rb, line 178 def get_binding binding end
log()
click to toggle source
# File lib/fpm/scriptable/script.rb, line 166 def log @log end
plugin_init()
click to toggle source
# File lib/fpm/scriptable/script.rb, line 73 def plugin_init end
plugin_setup()
click to toggle source
# File lib/fpm/scriptable/script.rb, line 76 def plugin_setup end
Private Instance Methods
expand_script(file=nil)
click to toggle source
# File lib/fpm/scriptable/script.rb, line 184 def expand_script(file=nil) if !file.nil? if File.exists? file File.read file end end end