module MCollective::PluginPackager - mcollective version 2.12.5

# module MCollective::PluginPackager

### Public Class Methods

[](klass) click to toggle source

       # File lib/mcollective/pluginpackager.rb
    12 def self.[](klass)
    13   const_get("#{klass}")
    14 end

check_dir_present(path) click to toggle source

Checks if a directory is present and not empty

       # File lib/mcollective/pluginpackager.rb
    31 def self.check_dir_present(path)
    32   (File.directory?(path) && !Dir.glob(File.join(path, "*")).empty?)
    33 end

command_available?(build_tool) click to toggle source

Checks if a build tool is present on the system

       # File lib/mcollective/pluginpackager.rb
    54 def self.command_available?(build_tool)
    55   ENV["PATH"].split(File::PATH_SEPARATOR).each do |path|
    56     builder = File.join(path, build_tool)
    57     if File.exists?(builder)
    58       return true
    59     end
    60   end
    61   false
    62 end

execute_verbosely(verbose, &block) click to toggle source

Quietly calls a block if verbose parameter is false

       # File lib/mcollective/pluginpackager.rb
    36 def self.execute_verbosely(verbose, &block)
    37   unless verbose
    38     old_stdout = $stdout.clone
    39     $stdout.reopen(File.new("/dev/null", "w"))
    40     begin
    41       block.call
    42     rescue Exception => e
    43       $stdout.reopen old_stdout
    44       raise e
    45     ensure
    46       $stdout.reopen old_stdout
    47     end
    48   else
    49     block.call
    50   end
    51 end

filter_dependencies(prefix, dependencies) click to toggle source

Filter out platform specific dependencies Given a list of dependencies named - debian::foo redhat::bar `PluginPackager.filter_dependencies`('debian', dependencies) will return foo.

       # File lib/mcollective/pluginpackager.rb
    74 def self.filter_dependencies(prefix, dependencies)
    75   dependencies.map do |dependency|
    76     if dependency[:name] =~ /^(\w+)::(\w+)/
    77       if prefix == $1
    78         dependency[:name] = $2
    79         dependency
    80       else
    81         nil
    82       end
    83     else
    84       dependency
    85     end
    86   end.reject{ |dependency| dependency == nil }
    87 end

get_metadata(path, type) click to toggle source

Fetch and return metadata from plugin `DDL`

       # File lib/mcollective/pluginpackager.rb
    17 def self.get_metadata(path, type)
    18   ddl = DDL.new("package", type.to_sym, false)
    19
    20   begin
    21     ddl_file = File.read(Dir.glob(File.join(path, type, "*.ddl")).first)
    22   rescue Exception
    23     raise "failed to load ddl file in plugin directory : #{File.join(path, type)}"
    24   end
    25   ddl.instance_eval ddl_file
    26
    27   return ddl.meta, ddl.requirements[:mcollective]
    28 end

get_plugin_path(target) click to toggle source

Return the path to a plugin's core directories

       # File lib/mcollective/pluginpackager.rb
    90 def self.get_plugin_path(target)
    91   if (File.exists?(File.join(target, "lib", "mcollective")))
    92     return File.join(target, "lib", "mcollective")
    93   end
    94
    95   return target
    96 end

load_packagers() click to toggle source

Package implementation plugins

       # File lib/mcollective/pluginpackager.rb
     8 def self.load_packagers
     9   PluginManager.find_and_load("pluginpackager")
    10 end

safe_system(*args) click to toggle source

       # File lib/mcollective/pluginpackager.rb
    64 def self.safe_system(*args)
    65   raise(RuntimeError, "Failed: #{args.join(' ')}") unless system *args
    66 end