Class: MCollective::PluginPackager::RpmpackagePackager

Inherits:
Object
  • Object
show all
Defined in:
lib/mcollective/pluginpackager/rpmpackage_packager.rb

Instance Method Summary collapse

Constructor Details

#initialize(plugin, pluginpath = nil, signature = nil, verbose = false, keep_artifacts = nil, module_template = nil) ⇒ RpmpackagePackager

Returns a new instance of RpmpackagePackager.



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# 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.[:name]}"
    @package_name_and_version = "#{@package_name}-#{@plugin.[: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

Instance Method Details

#create_packagesObject

Build Process :

  • create temporary buildroot

  • create the spec file

  • create the tarball

  • run the build script

  • move pacakges to cwd

  • clean up



48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# 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

#rpmdirObject



33
34
35
# File 'lib/mcollective/pluginpackager/rpmpackage_packager.rb', line 33

def rpmdir
  `rpm --eval '%_rpmdir'`.chomp
end

#select_commandObject

Determine the build tool present on the system



23
24
25
26
27
28
29
30
31
# 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

#srpmdirObject



37
38
39
# File 'lib/mcollective/pluginpackager/rpmpackage_packager.rb', line 37

def srpmdir
  `rpm --eval '%_srcrpmdir'`.chomp
end