Update version according to OSCI-856
[packages/precise/mcollective.git] / plugins / mcollective / pluginpackager / ospackage_packager.rb
1 module MCollective
2   module PluginPackager
3     # MCollective plugin packager general OS implementation.
4     class OspackagePackager
5
6       attr_accessor :package, :verbose, :packager, :package_type
7
8       # Create packager object with package parameter containing list of files,
9       # dependencies and package metadata.
10       def initialize(package, pluginpath = nil, signature = nil, verbose = false, keep_artifacts = false)
11
12         if File.exists?("/etc/redhat-release")
13           @packager = PluginPackager["RpmpackagePackager"].new(package, pluginpath, signature, verbose, keep_artifacts)
14           @package_type = "RPM"
15         elsif File.exists?("/etc/debian_version")
16           @packager = PluginPackager["DebpackagePackager"].new(package, pluginpath, signature, verbose, keep_artifacts)
17           @package_type = "Deb"
18         else
19           raise "cannot identify operating system."
20         end
21
22         @package = package
23         @verbose = verbose
24       end
25
26       # Hands over package creation to the detected packager implementation
27       # based on operating system.
28       def create_packages
29         @packager.create_packages
30       end
31
32       # Displays the package metadata and detected files
33       def package_information
34         puts
35         puts "%30s%s" % ["Plugin information : ", @package.metadata[:name]]
36         puts "%30s%s" % ["-" * 22, "-" * 22]
37         puts "%30s%s" % ["Plugin Type : ", @package.plugintype.capitalize]
38         puts "%30s%s" % ["Package Output Format : ", @package_type]
39         puts "%30s%s" % ["Version : ", @package.metadata[:version]]
40         puts "%30s%s" % ["Iteration : ", @package.iteration]
41         puts "%30s%s" % ["Vendor : ", @package.vendor]
42         puts "%30s%s" % ["Post Install Script : ", @package.postinstall] if @package.postinstall
43         puts "%30s%s" % ["Author : ", @package.metadata[:author]]
44         puts "%30s%s" % ["License : ", @package.metadata[:license]]
45         puts "%30s%s" % ["URL : ", @package.metadata[:url]]
46
47         if @package.packagedata.size > 0
48           @package.packagedata.each_with_index do |values, i|
49             if i == 0
50               puts "%30s%s" % ["Identified Packages : ", values[0]]
51             else
52               puts "%30s%s" % [" ", values[0]]
53             end
54           end
55         end
56       end
57     end
58   end
59 end