X-Git-Url: https://review.fuel-infra.org/gitweb?a=blobdiff_plain;f=plugins%2Fmcollective%2Fpluginpackager%2Fospackage_packager.rb;fp=plugins%2Fmcollective%2Fpluginpackager%2Fospackage_packager.rb;h=c5edc188b29000b849f6443f4e1ea7f02fcced66;hb=b87d2f4e68281062df1913440ca5753ae63314a9;hp=0000000000000000000000000000000000000000;hpb=ab0ea530b8ac956091f17b104ab2311336cfc250;p=packages%2Fprecise%2Fmcollective.git diff --git a/plugins/mcollective/pluginpackager/ospackage_packager.rb b/plugins/mcollective/pluginpackager/ospackage_packager.rb new file mode 100644 index 0000000..c5edc18 --- /dev/null +++ b/plugins/mcollective/pluginpackager/ospackage_packager.rb @@ -0,0 +1,59 @@ +module MCollective + module PluginPackager + # MCollective plugin packager general OS implementation. + class OspackagePackager + + attr_accessor :package, :verbose, :packager, :package_type + + # Create packager object with package parameter containing list of files, + # dependencies and package metadata. + def initialize(package, pluginpath = nil, signature = nil, verbose = false) + + if File.exists?("/etc/redhat-release") + @packager = PluginPackager["RpmpackagePackager"].new(package, pluginpath, signature, verbose) + @package_type = "RPM" + elsif File.exists?("/etc/debian_version") + @packager = PluginPackager["DebpackagePackager"].new(package, pluginpath, signature, verbose) + @package_type = "Deb" + else + raise "cannot identify operating system." + end + + @package = package + @verbose = verbose + end + + # Hands over package creation to the detected packager implementation + # based on operating system. + def create_packages + @packager.create_packages + end + + # Displays the package metadata and detected files + def package_information + puts + puts "%30s%s" % ["Plugin information : ", @package.metadata[: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.metadata[:version]] + puts "%30s%s" % ["Iteration : ", @package.iteration] + puts "%30s%s" % ["Vendor : ", @package.vendor] + puts "%30s%s" % ["Post Install Script : ", @package.postinstall] if @package.postinstall + puts "%30s%s" % ["Author : ", @package.metadata[:author]] + puts "%30s%s" % ["License : ", @package.metadata[:license]] + puts "%30s%s" % ["URL : ", @package.metadata[: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 + end + end +end