~lynxman/ubuntu/quantal/mcollective/mcollective20

« back to all changes in this revision

Viewing changes to lib/mcollective/pluginpackager/standard_definition.rb

  • Committer: Marc Cluet
  • Date: 2012-05-31 16:00:44 UTC
  • mfrom: (1.1.5 upstream)
  • Revision ID: marc.cluet@ubuntu.com-20120531160044-chsjlh1as0urgbd9
Merging shared upstream rev into target branch.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
module MCollective
 
2
  module PluginPackager
 
3
    class StandardDefinition
 
4
      attr_accessor :path, :packagedata, :metadata, :target_path, :vendor, :iteration
 
5
      attr_accessor :plugintype, :preinstall, :postinstall, :dependencies, :mcserver
 
6
      attr_accessor :mccommon
 
7
 
 
8
      def initialize(path, name, vendor, preinstall, postinstall, iteration, dependencies, mcodependency, plugintype)
 
9
        @plugintype = plugintype
 
10
        @path = path
 
11
        @packagedata = {}
 
12
        @iteration = iteration || 1
 
13
        @preinstall = preinstall
 
14
        @postinstall = postinstall
 
15
        @vendor = vendor || "Puppet Labs"
 
16
        @dependencies = dependencies || []
 
17
        @mcserver = mcodependency[:server] || "mcollective"
 
18
        @mccommon = mcodependency[:common] || "mcollective-common"
 
19
        @target_path = File.expand_path(@path)
 
20
        @metadata = PluginPackager.get_metadata(@path, @plugintype)
 
21
        @metadata[:name] = (name || @metadata[:name]).downcase.gsub(" ", "-")
 
22
        identify_packages
 
23
      end
 
24
 
 
25
      # Identify present packages and populate the packagedata hash
 
26
      def identify_packages
 
27
        common_package = common
 
28
        @packagedata[:common] = common_package if common_package
 
29
        plugin_package = plugin
 
30
        @packagedata[@plugintype] = plugin_package if plugin_package
 
31
      end
 
32
 
 
33
      # Obtain standard plugin files and dependencies
 
34
      def plugin
 
35
        plugindata = {:files => [],
 
36
                      :dependencies => @dependencies.clone << @mcserver,
 
37
                      :description => "#{@name} #{@plugintype} plugin for the Marionette Collective."}
 
38
 
 
39
        plugindir = File.join(@path, @plugintype.to_s)
 
40
        if PluginPackager.check_dir_present plugindir
 
41
          plugindata[:files] = Dir.glob(File.join(plugindir, "*"))
 
42
        else
 
43
          return nil
 
44
        end
 
45
 
 
46
        plugindata[:dependencies] <<"mcollective-#{@metadata[:name]}-common" if @packagedata[:common]
 
47
        plugindata
 
48
      end
 
49
 
 
50
      # Obtain list of common files
 
51
      def common
 
52
        common = {:files => [],
 
53
                  :dependencies => @dependencies.clone << @mccommon,
 
54
                  :description => "Common libraries for #{@name} connector plugin"}
 
55
 
 
56
        commondir = File.join(@path, "util")
 
57
        if PluginPackager.check_dir_present commondir
 
58
          common[:files] = Dir.glob(File.join(commondir, "*"))
 
59
          return common
 
60
        else
 
61
          return nil
 
62
        end
 
63
      end
 
64
    end
 
65
  end
 
66
end