Class: MCollective::PluginPackager::OspackagePackager

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

Overview

MCollective plugin packager general OS implementation.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(package, pluginpath = nil, signature = nil, verbose = false, keep_artifacts = false, module_template = nil) ⇒ OspackagePackager

Create packager object with package parameter containing list of files, dependencies and package metadata.



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/mcollective/pluginpackager/ospackage_packager.rb', line 10

def initialize(package, pluginpath = nil, signature = nil, verbose = false, keep_artifacts = false, module_template = nil)

  if File.exists?("/etc/redhat-release")
    @packager = PluginPackager["RpmpackagePackager"].new(package, pluginpath, signature, verbose, keep_artifacts, module_template)
    @package_type = "RPM"
  elsif File.exists?("/etc/debian_version")
    @packager = PluginPackager["DebpackagePackager"].new(package, pluginpath, signature, verbose, keep_artifacts, module_template)
    @package_type = "Deb"
  else
    raise "cannot identify operating system."
  end

  @package = package
  @verbose = verbose
end

Instance Attribute Details

#packageObject

Returns the value of attribute package.



6
7
8
# File 'lib/mcollective/pluginpackager/ospackage_packager.rb', line 6

def package
  @package
end

#package_typeObject

Returns the value of attribute package_type.



6
7
8
# File 'lib/mcollective/pluginpackager/ospackage_packager.rb', line 6

def package_type
  @package_type
end

#packagerObject

Returns the value of attribute packager.



6
7
8
# File 'lib/mcollective/pluginpackager/ospackage_packager.rb', line 6

def packager
  @packager
end

#verboseObject

Returns the value of attribute verbose.



6
7
8
# File 'lib/mcollective/pluginpackager/ospackage_packager.rb', line 6

def verbose
  @verbose
end

Instance Method Details

#create_packagesObject

Hands over package creation to the detected packager implementation based on operating system.



28
29
30
# File 'lib/mcollective/pluginpackager/ospackage_packager.rb', line 28

def create_packages
  @packager.create_packages
end

#package_informationObject

Displays the package metadata and detected files



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/mcollective/pluginpackager/ospackage_packager.rb', line 33

def package_information
  puts
  puts "%30s%s" % ["Plugin information : ", @package.[:name]]
  puts "%30s%s" % ["-" * 22, "-" * 22]
  puts "%30s%s" % ["Plugin Type : ", @package.plugintype.capitalize]
  puts "%30s%s" % ["Package Output Format : ", @package_type]
  puts "%30s%s" % ["Version : ", @package.[:version]]
  puts "%30s%s" % ["Revision : ", @package.revision]
  puts "%30s%s" % ["Vendor : ", @package.vendor]
  puts "%30s%s" % ["Post Install Script : ", @package.postinstall] if @package.postinstall
  puts "%30s%s" % ["Author : ", @package.[:author]]
  puts "%30s%s" % ["License : ", @package.[:license]]
  puts "%30s%s" % ["URL : ", @package.[:url]]

  if @package.packagedata.size > 0
    @package.packagedata.each_with_index do |values, i|
      if i == 0
        puts "%30s%s" % ["Identified Packages : ", values[0]]
      else
        puts "%30s%s" % [" ", values[0]]
      end
    end
  end
end