class MCollective::PluginPackager::RpmpackagePackager

Public Class Methods

new(plugin, pluginpath = nil, signature = nil, verbose = false, keep_artifacts = nil, module_template = nil) click to toggle source
# File lib/mcollective/pluginpackager/rpmpackage_packager.rb, line 6
def initialize(plugin, pluginpath = nil, signature = nil, verbose = false, keep_artifacts = nil, module_template = nil)
  if @buildtool = select_command
    @plugin = plugin
    @package_name = "#{@plugin.mcname}-#{@plugin.metadata[:name]}"
    @package_name_and_version = "#{@package_name}-#{@plugin.metadata[:version]}"
    @verbose = verbose
    @libdir = pluginpath || '/usr/libexec/mcollective/mcollective/'
    @signature = signature
    @rpmdir = rpmdir
    @srpmdir = srpmdir
    @keep_artifacts = keep_artifacts
  else
    raise("Cannot build package. 'rpmbuild' or 'rpmbuild-md5' is not present on the system")
  end
end

Public Instance Methods

create_packages() click to toggle source

Build Process :

  • create temporary buildroot

  • create the spec file

  • create the tarball

  • run the build script

  • move pacakges to cwd

  • clean up

# File lib/mcollective/pluginpackager/rpmpackage_packager.rb, line 48
def create_packages
  begin
    puts "Building packages for #{@package_name} plugin."

    @tmpdir = Dir.mktmpdir('mcollective_packager')
    prepare_tmpdirs

    make_spec_file
    run_build
    move_packages

    puts "Completed building all packages for #{@package_name} plugin."
  ensure
    if @keep_artifacts
      puts 'Keeping build artifacts'
      puts "Build artifacts saved - #{@tmpdir}"
    else
      cleanup_tmpdirs
    end
  end
end
rpmdir() click to toggle source
# File lib/mcollective/pluginpackager/rpmpackage_packager.rb, line 33
def rpmdir
  %x`rpm --eval '%_rpmdir'`.chomp
end
select_command() click to toggle source

Determine the build tool present on the system

# File lib/mcollective/pluginpackager/rpmpackage_packager.rb, line 23
def select_command
  if PluginPackager.command_available?('rpmbuild-md5')
    return 'rpmbuild-md5'
  elsif PluginPackager.command_available?('rpmbuild')
    return 'rpmbuild'
  else
    return nil
  end
end
srpmdir() click to toggle source
# File lib/mcollective/pluginpackager/rpmpackage_packager.rb, line 37
def srpmdir
  %x`rpm --eval '%_srcrpmdir'`.chomp
end