choria-mcorpc-support 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (133) hide show
  1. checksums.yaml +7 -0
  2. data/bin/mco +64 -0
  3. data/lib/mcollective.rb +63 -0
  4. data/lib/mcollective/agent.rb +5 -0
  5. data/lib/mcollective/agents.rb +149 -0
  6. data/lib/mcollective/aggregate.rb +85 -0
  7. data/lib/mcollective/aggregate/average.ddl +33 -0
  8. data/lib/mcollective/aggregate/average.rb +29 -0
  9. data/lib/mcollective/aggregate/base.rb +40 -0
  10. data/lib/mcollective/aggregate/result.rb +9 -0
  11. data/lib/mcollective/aggregate/result/base.rb +25 -0
  12. data/lib/mcollective/aggregate/result/collection_result.rb +19 -0
  13. data/lib/mcollective/aggregate/result/numeric_result.rb +13 -0
  14. data/lib/mcollective/aggregate/sum.ddl +33 -0
  15. data/lib/mcollective/aggregate/sum.rb +18 -0
  16. data/lib/mcollective/aggregate/summary.ddl +33 -0
  17. data/lib/mcollective/aggregate/summary.rb +53 -0
  18. data/lib/mcollective/application.rb +365 -0
  19. data/lib/mcollective/application/completion.rb +104 -0
  20. data/lib/mcollective/application/describe_filter.rb +87 -0
  21. data/lib/mcollective/application/facts.rb +62 -0
  22. data/lib/mcollective/application/find.rb +23 -0
  23. data/lib/mcollective/application/help.rb +28 -0
  24. data/lib/mcollective/application/inventory.rb +344 -0
  25. data/lib/mcollective/application/ping.rb +82 -0
  26. data/lib/mcollective/application/plugin.rb +369 -0
  27. data/lib/mcollective/application/rpc.rb +111 -0
  28. data/lib/mcollective/applications.rb +134 -0
  29. data/lib/mcollective/cache.rb +145 -0
  30. data/lib/mcollective/client.rb +353 -0
  31. data/lib/mcollective/config.rb +245 -0
  32. data/lib/mcollective/connector.rb +18 -0
  33. data/lib/mcollective/connector/base.rb +26 -0
  34. data/lib/mcollective/data.rb +91 -0
  35. data/lib/mcollective/data/agent_data.ddl +22 -0
  36. data/lib/mcollective/data/agent_data.rb +17 -0
  37. data/lib/mcollective/data/base.rb +67 -0
  38. data/lib/mcollective/data/collective_data.ddl +20 -0
  39. data/lib/mcollective/data/collective_data.rb +9 -0
  40. data/lib/mcollective/data/fact_data.ddl +28 -0
  41. data/lib/mcollective/data/fact_data.rb +55 -0
  42. data/lib/mcollective/data/fstat_data.ddl +89 -0
  43. data/lib/mcollective/data/fstat_data.rb +56 -0
  44. data/lib/mcollective/data/result.rb +45 -0
  45. data/lib/mcollective/ddl.rb +113 -0
  46. data/lib/mcollective/ddl/agentddl.rb +253 -0
  47. data/lib/mcollective/ddl/base.rb +217 -0
  48. data/lib/mcollective/ddl/dataddl.rb +56 -0
  49. data/lib/mcollective/ddl/discoveryddl.rb +52 -0
  50. data/lib/mcollective/ddl/validatorddl.rb +6 -0
  51. data/lib/mcollective/discovery.rb +143 -0
  52. data/lib/mcollective/discovery/flatfile.ddl +11 -0
  53. data/lib/mcollective/discovery/flatfile.rb +48 -0
  54. data/lib/mcollective/discovery/mc.ddl +11 -0
  55. data/lib/mcollective/discovery/mc.rb +30 -0
  56. data/lib/mcollective/discovery/stdin.ddl +11 -0
  57. data/lib/mcollective/discovery/stdin.rb +68 -0
  58. data/lib/mcollective/exceptions.rb +28 -0
  59. data/lib/mcollective/facts.rb +39 -0
  60. data/lib/mcollective/facts/base.rb +100 -0
  61. data/lib/mcollective/facts/yaml_facts.rb +65 -0
  62. data/lib/mcollective/generators.rb +7 -0
  63. data/lib/mcollective/generators/agent_generator.rb +51 -0
  64. data/lib/mcollective/generators/base.rb +46 -0
  65. data/lib/mcollective/generators/data_generator.rb +51 -0
  66. data/lib/mcollective/generators/templates/action_snippet.erb +13 -0
  67. data/lib/mcollective/generators/templates/data_input_snippet.erb +7 -0
  68. data/lib/mcollective/generators/templates/ddl.erb +8 -0
  69. data/lib/mcollective/generators/templates/plugin.erb +7 -0
  70. data/lib/mcollective/log.rb +118 -0
  71. data/lib/mcollective/logger.rb +5 -0
  72. data/lib/mcollective/logger/base.rb +77 -0
  73. data/lib/mcollective/logger/console_logger.rb +61 -0
  74. data/lib/mcollective/logger/file_logger.rb +53 -0
  75. data/lib/mcollective/logger/syslog_logger.rb +53 -0
  76. data/lib/mcollective/matcher.rb +224 -0
  77. data/lib/mcollective/matcher/parser.rb +128 -0
  78. data/lib/mcollective/matcher/scanner.rb +241 -0
  79. data/lib/mcollective/message.rb +248 -0
  80. data/lib/mcollective/monkey_patches.rb +152 -0
  81. data/lib/mcollective/optionparser.rb +197 -0
  82. data/lib/mcollective/pluginmanager.rb +180 -0
  83. data/lib/mcollective/pluginpackager.rb +98 -0
  84. data/lib/mcollective/pluginpackager/agent_definition.rb +94 -0
  85. data/lib/mcollective/pluginpackager/debpackage_packager.rb +237 -0
  86. data/lib/mcollective/pluginpackager/modulepackage_packager.rb +127 -0
  87. data/lib/mcollective/pluginpackager/ospackage_packager.rb +59 -0
  88. data/lib/mcollective/pluginpackager/rpmpackage_packager.rb +180 -0
  89. data/lib/mcollective/pluginpackager/standard_definition.rb +69 -0
  90. data/lib/mcollective/pluginpackager/templates/debian/Makefile.erb +7 -0
  91. data/lib/mcollective/pluginpackager/templates/debian/changelog.erb +5 -0
  92. data/lib/mcollective/pluginpackager/templates/debian/compat.erb +1 -0
  93. data/lib/mcollective/pluginpackager/templates/debian/control.erb +15 -0
  94. data/lib/mcollective/pluginpackager/templates/debian/copyright.erb +8 -0
  95. data/lib/mcollective/pluginpackager/templates/debian/rules.erb +6 -0
  96. data/lib/mcollective/pluginpackager/templates/module/Modulefile.erb +5 -0
  97. data/lib/mcollective/pluginpackager/templates/module/README.md.erb +37 -0
  98. data/lib/mcollective/pluginpackager/templates/module/_manifest.pp.erb +9 -0
  99. data/lib/mcollective/pluginpackager/templates/redhat/rpm_spec.erb +63 -0
  100. data/lib/mcollective/registration/base.rb +91 -0
  101. data/lib/mcollective/rpc.rb +182 -0
  102. data/lib/mcollective/rpc/actionrunner.rb +158 -0
  103. data/lib/mcollective/rpc/agent.rb +374 -0
  104. data/lib/mcollective/rpc/audit.rb +38 -0
  105. data/lib/mcollective/rpc/client.rb +1066 -0
  106. data/lib/mcollective/rpc/helpers.rb +321 -0
  107. data/lib/mcollective/rpc/progress.rb +63 -0
  108. data/lib/mcollective/rpc/reply.rb +87 -0
  109. data/lib/mcollective/rpc/request.rb +86 -0
  110. data/lib/mcollective/rpc/result.rb +90 -0
  111. data/lib/mcollective/rpc/stats.rb +294 -0
  112. data/lib/mcollective/runnerstats.rb +90 -0
  113. data/lib/mcollective/security.rb +26 -0
  114. data/lib/mcollective/security/base.rb +244 -0
  115. data/lib/mcollective/shell.rb +126 -0
  116. data/lib/mcollective/ssl.rb +285 -0
  117. data/lib/mcollective/util.rb +579 -0
  118. data/lib/mcollective/validator.rb +85 -0
  119. data/lib/mcollective/validator/array_validator.ddl +7 -0
  120. data/lib/mcollective/validator/array_validator.rb +9 -0
  121. data/lib/mcollective/validator/ipv4address_validator.ddl +7 -0
  122. data/lib/mcollective/validator/ipv4address_validator.rb +16 -0
  123. data/lib/mcollective/validator/ipv6address_validator.ddl +7 -0
  124. data/lib/mcollective/validator/ipv6address_validator.rb +16 -0
  125. data/lib/mcollective/validator/length_validator.ddl +7 -0
  126. data/lib/mcollective/validator/length_validator.rb +11 -0
  127. data/lib/mcollective/validator/regex_validator.ddl +7 -0
  128. data/lib/mcollective/validator/regex_validator.rb +9 -0
  129. data/lib/mcollective/validator/shellsafe_validator.ddl +7 -0
  130. data/lib/mcollective/validator/shellsafe_validator.rb +13 -0
  131. data/lib/mcollective/validator/typecheck_validator.ddl +7 -0
  132. data/lib/mcollective/validator/typecheck_validator.rb +28 -0
  133. metadata +215 -0
@@ -0,0 +1,127 @@
1
+ module MCollective
2
+ module PluginPackager
3
+ class ModulepackagePackager
4
+ require 'erb'
5
+
6
+ def initialize(plugin, pluginpath = nil, signature = nil, verbose = false, keep_artifacts = nil, module_template = nil)
7
+ assert_new_enough_puppet
8
+ @plugin = plugin
9
+ @package_name = "#{@plugin.mcname}_#{@plugin.metadata[:name]}".gsub(/-/, '_')
10
+ @verbose = verbose
11
+ @keep_artifacts = keep_artifacts
12
+ @module_template = module_template || File.join(File.dirname(__FILE__), 'templates', 'module')
13
+ end
14
+
15
+ # Build Process :
16
+ # - create module directory
17
+ # - run 'puppet module build'
18
+ # - move generated package back to cwd
19
+ def create_packages
20
+ begin
21
+ puts "Building module for #{@package_name} plugin."
22
+
23
+ @tmpdir = Dir.mktmpdir('mcollective_packager')
24
+ make_module
25
+ run_build
26
+ move_package
27
+
28
+ puts "Completed building module for #{@package_name} plugin."
29
+ ensure
30
+ if @keep_artifacts
31
+ puts 'Keeping build artifacts'
32
+ puts "Build artifacts saved - #{@tmpdir}"
33
+ else
34
+ cleanup_tmpdirs
35
+ end
36
+ end
37
+ end
38
+
39
+ private
40
+
41
+ def assert_new_enough_puppet
42
+ unless PluginPackager.command_available?('puppet')
43
+ raise("Cannot build package. 'puppet' is not present on the system.")
44
+ end
45
+
46
+ s = Shell.new('puppet --version')
47
+ s.runcommand
48
+ actual_version = s.stdout.chomp
49
+
50
+ required_version = '3.3.0'
51
+ if Util.versioncmp(actual_version, required_version) < 0
52
+ raise("Cannot build package. puppet #{required_version} or greater required. We have #{actual_version}.")
53
+ end
54
+ end
55
+
56
+ def make_module
57
+ targetdir = File.join(@tmpdir, 'manifests')
58
+ FileUtils.mkdir_p(targetdir) unless File.directory?(targetdir)
59
+
60
+ # for each subpackage make a subclass
61
+ @plugin.packagedata.each do |klass,data|
62
+ data[:files].each do |file|
63
+ relative_path = File.expand_path(file).gsub(/#{@plugin.target_path}|^\.\//, '')
64
+ targetdir = File.join(@tmpdir, 'files', klass.to_s, 'mcollective', File.dirname(relative_path))
65
+ FileUtils.mkdir_p(targetdir) unless File.directory?(targetdir)
66
+ FileUtils.cp_r(file, targetdir)
67
+ end
68
+
69
+ @klass = klass.to_s
70
+ render_template('_manifest.pp.erb', File.join(@tmpdir, 'manifests', "#{klass}.pp"))
71
+ end
72
+
73
+ # render all the templates we have
74
+ Dir.glob(File.join(@module_template, '*.erb')).each do |template|
75
+ filename = File.basename(template, '.erb')
76
+ next if filename =~ /^_/ # starting with underscore makes it private
77
+ render_template("#{filename}.erb", File.join(@tmpdir, filename))
78
+ end
79
+ end
80
+
81
+ def render_template(template, path)
82
+ begin
83
+ erb = ERB.new(File.read(File.join(@module_template, template)), nil, '-')
84
+ File.open(path, 'w') do |f|
85
+ f.puts erb.result(binding)
86
+ end
87
+ rescue => e
88
+ puts "Could not render template to path - '#{path}'"
89
+ raise e
90
+ end
91
+ end
92
+
93
+ def run_build
94
+ begin
95
+ PluginPackager.execute_verbosely(@verbose) do
96
+ Dir.chdir(@tmpdir) do
97
+ PluginPackager.safe_system('puppet module build')
98
+ end
99
+ end
100
+ rescue => e
101
+ puts 'Build process has failed'
102
+ raise e
103
+ end
104
+ end
105
+
106
+ # Move built package to cwd
107
+ def move_package
108
+ begin
109
+ package_file = File.join(@tmpdir, 'pkg', "#{@plugin.vendor}-#{@package_name}-#{@plugin.metadata[:version]}.tar.gz")
110
+ FileUtils.cp(package_file, '.')
111
+ rescue => e
112
+ puts 'Could not copy package to working directory'
113
+ raise e
114
+ end
115
+ end
116
+
117
+ def cleanup_tmpdirs
118
+ begin
119
+ FileUtils.rm_r(@tmpdir) if File.directory?(@tmpdir)
120
+ rescue => e
121
+ puts "Could not remove temporary build directory - '#{@tmpdir}'"
122
+ raise e
123
+ end
124
+ end
125
+ end
126
+ end
127
+ end
@@ -0,0 +1,59 @@
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, module_template = nil)
11
+
12
+ if File.exists?("/etc/redhat-release")
13
+ @packager = PluginPackager["RpmpackagePackager"].new(package, pluginpath, signature, verbose, keep_artifacts, module_template)
14
+ @package_type = "RPM"
15
+ elsif File.exists?("/etc/debian_version")
16
+ @packager = PluginPackager["DebpackagePackager"].new(package, pluginpath, signature, verbose, keep_artifacts, module_template)
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" % ["Revision : ", @package.revision]
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
@@ -0,0 +1,180 @@
1
+ module MCollective
2
+ module PluginPackager
3
+ class RpmpackagePackager
4
+ require 'erb'
5
+
6
+ def initialize(plugin, pluginpath = nil, signature = nil, verbose = false, keep_artifacts = nil, module_template = nil)
7
+ if @buildtool = select_command
8
+ @plugin = plugin
9
+ @package_name = "#{@plugin.mcname}-#{@plugin.metadata[:name]}"
10
+ @package_name_and_version = "#{@package_name}-#{@plugin.metadata[:version]}"
11
+ @verbose = verbose
12
+ @libdir = pluginpath || '/usr/libexec/mcollective/mcollective/'
13
+ @signature = signature
14
+ @rpmdir = rpmdir
15
+ @srpmdir = srpmdir
16
+ @keep_artifacts = keep_artifacts
17
+ else
18
+ raise("Cannot build package. 'rpmbuild' or 'rpmbuild-md5' is not present on the system")
19
+ end
20
+ end
21
+
22
+ # Determine the build tool present on the system
23
+ def select_command
24
+ if PluginPackager.command_available?('rpmbuild-md5')
25
+ return 'rpmbuild-md5'
26
+ elsif PluginPackager.command_available?('rpmbuild')
27
+ return 'rpmbuild'
28
+ else
29
+ return nil
30
+ end
31
+ end
32
+
33
+ def rpmdir
34
+ `rpm --eval '%_rpmdir'`.chomp
35
+ end
36
+
37
+ def srpmdir
38
+ `rpm --eval '%_srcrpmdir'`.chomp
39
+ end
40
+
41
+ # Build Process :
42
+ # - create temporary buildroot
43
+ # - create the spec file
44
+ # - create the tarball
45
+ # - run the build script
46
+ # - move pacakges to cwd
47
+ # - clean up
48
+ def create_packages
49
+ begin
50
+ puts "Building packages for #{@package_name} plugin."
51
+
52
+ @tmpdir = Dir.mktmpdir('mcollective_packager')
53
+ prepare_tmpdirs
54
+
55
+ make_spec_file
56
+ run_build
57
+ move_packages
58
+
59
+ puts "Completed building all packages for #{@package_name} plugin."
60
+ ensure
61
+ if @keep_artifacts
62
+ puts 'Keeping build artifacts'
63
+ puts "Build artifacts saved - #{@tmpdir}"
64
+ else
65
+ cleanup_tmpdirs
66
+ end
67
+ end
68
+ end
69
+
70
+ private
71
+
72
+ def run_build
73
+ begin
74
+ tarfile = create_tar
75
+ PluginPackager.execute_verbosely(@verbose) do
76
+ PluginPackager.safe_system("#{@buildtool} -ta#{" --quiet" unless @verbose}#{" --sign" if @signature} #{tarfile}")
77
+ end
78
+ rescue => e
79
+ puts 'Build process has failed'
80
+ raise e
81
+ end
82
+ end
83
+
84
+ # Tar up source
85
+ # Expects directory $mcollective-$agent-$version
86
+ # Creates file : $tmpbuildroot/$mcollective-$agent-$version
87
+ def create_tar
88
+ tarfile = File.join(@tmpdir, "#{@package_name_and_version}.tgz")
89
+ begin
90
+ PluginPackager.execute_verbosely(@verbose) do
91
+ Dir.chdir(@tmpdir) do
92
+ PluginPackager.safe_system("tar -cvzf #{tarfile} #{@package_name_and_version}")
93
+ end
94
+ end
95
+ rescue => e
96
+ puts "Could not create tarball - '#{tarfile}'"
97
+ raise e
98
+ end
99
+ tarfile
100
+ end
101
+
102
+ # Move rpm's and srpm's to cwd
103
+ def move_packages
104
+ begin
105
+ files_to_copy = []
106
+ files_to_copy += Dir.glob(File.join(@rpmdir, 'noarch', "#{@package_name}-*-#{@plugin.metadata[:version]}-#{@plugin.revision}*.noarch.rpm"))
107
+ files_to_copy += Dir.glob(File.join(@srpmdir, "#{@package_name}-#{@plugin.metadata[:version]}-#{@plugin.revision}*.src.rpm"))
108
+ FileUtils.cp(files_to_copy, '.')
109
+ rescue => e
110
+ puts 'Could not copy packages to working directory'
111
+ raise e
112
+ end
113
+ end
114
+
115
+ # Create the specfile and place as $tmpbuildroot/$mcollective-$agent-$version/$mcollective-$agent-$version.spec
116
+ def make_spec_file
117
+ spec_file = File.join(@tmpdir, @package_name_and_version, "#{@package_name_and_version}.spec")
118
+ begin
119
+ spec_template = ERB.new(File.read(File.join(File.dirname(__FILE__), 'templates', 'redhat', 'rpm_spec.erb')), nil, '-')
120
+ File.open(spec_file, 'w') do |f|
121
+ f.puts spec_template.result(binding)
122
+ end
123
+ rescue => e
124
+ puts "Could not create specfile - '#{spec_file}'"
125
+ raise e
126
+ end
127
+ end
128
+
129
+ # Move files contained in the plugin to the correct directory
130
+ # relative to the build root.
131
+ def prepare_tmpdirs
132
+ plugin_files.each do |file|
133
+ begin
134
+ targetdir = File.join(@tmpdir, @package_name_and_version, @libdir, File.dirname(File.expand_path(file)).gsub(@plugin.target_path, ""))
135
+ FileUtils.mkdir_p(targetdir) unless File.directory?(targetdir)
136
+ FileUtils.cp_r(file, targetdir)
137
+ rescue Errno::EACCES => e
138
+ puts "Could not create directory '#{targetdir}'. Permission denied"
139
+ raise e
140
+ rescue Errno::ENOENT => e
141
+ puts "Could not copy file '#{file}' to '#{targetdir}'. File does not exist"
142
+ raise e
143
+ rescue => e
144
+ puts 'Could not prepare temporary build directory'
145
+ raise e
146
+ end
147
+ end
148
+ end
149
+
150
+ # Extract all the package files from the plugin's package data hash
151
+ def plugin_files
152
+ files = []
153
+ @plugin.packagedata.each do |name, data|
154
+ files += data[:files].reject{ |f| File.directory?(f) }
155
+ end
156
+ files
157
+ end
158
+
159
+ # Extract the package specific files from the file list and omits directories
160
+ def package_files(files)
161
+ package_files = []
162
+ files.each do |f|
163
+ if !File.directory?(f)
164
+ package_files << File.join(@libdir, File.expand_path(f).gsub(/#{@plugin.target_path}|\.\//, ''))
165
+ end
166
+ end
167
+ package_files
168
+ end
169
+
170
+ def cleanup_tmpdirs
171
+ begin
172
+ FileUtils.rm_r(@tmpdir) if File.directory?(@tmpdir)
173
+ rescue => e
174
+ puts "Could not remove temporary build directory - '#{@tmpdir}'"
175
+ raise e
176
+ end
177
+ end
178
+ end
179
+ end
180
+ end
@@ -0,0 +1,69 @@
1
+ module MCollective
2
+ module PluginPackager
3
+ class StandardDefinition
4
+ attr_accessor :path, :packagedata, :metadata, :target_path, :vendor, :revision
5
+ attr_accessor :plugintype, :preinstall, :postinstall, :dependencies, :mcname, :mcversion
6
+
7
+ def initialize(configuration, mcdependency, plugintype)
8
+ @plugintype = plugintype
9
+ @path = PluginPackager.get_plugin_path(configuration[:target])
10
+ @packagedata = {}
11
+ @revision = configuration[:revision] || 1
12
+ @preinstall = configuration[:preinstall]
13
+ @postinstall = configuration[:postinstall]
14
+ @vendor = configuration[:vendor] || "Puppet Labs"
15
+ @dependencies = configuration[:dependency] || []
16
+ @target_path = File.expand_path(@path)
17
+ @metadata, mcversion = PluginPackager.get_metadata(@path, @plugintype)
18
+ @mcname = mcdependency[:mcname] || "mcollective"
19
+ @mcversion = mcdependency[:mcversion] || mcversion
20
+ @dependencies << {:name => "#{mcname}-common", :version => @mcversion}
21
+ @metadata[:name] = (configuration[:pluginname] || @metadata[:name]).downcase.gsub(/\s+|_/, "-")
22
+ @metadata[:version] = (configuration[:version] || @metadata[:version])
23
+ identify_packages
24
+ end
25
+
26
+ # Identify present packages and populate the packagedata hash
27
+ def identify_packages
28
+ common_package = common
29
+ @packagedata[:common] = common_package if common_package
30
+ plugin_package = plugin
31
+ @packagedata[@plugintype.to_sym] = plugin_package if plugin_package
32
+ end
33
+
34
+ # Obtain standard plugin files and dependencies
35
+ def plugin
36
+ plugindata = {:files => [],
37
+ :dependencies => @dependencies.clone,
38
+ :description => "#{@name} #{@plugintype} plugin for the Marionette Collective."}
39
+
40
+ plugindir = File.join(@path, @plugintype.to_s)
41
+ if PluginPackager.check_dir_present plugindir
42
+ plugindata[:files] = Dir.glob(File.join(plugindir, "*"))
43
+ else
44
+ return nil
45
+ end
46
+
47
+ plugindata[:plugindependency] = {:name => "#{@mcname}-#{@metadata[:name]}-common",
48
+ :version => @metadata[:version],
49
+ :revision => @revision} if @packagedata[:common]
50
+ plugindata
51
+ end
52
+
53
+ # Obtain list of common files
54
+ def common
55
+ common = {:files => [],
56
+ :dependencies => @dependencies.clone,
57
+ :description => "Common libraries for #{@name} connector plugin"}
58
+
59
+ commondir = File.join(@path, "util")
60
+ if PluginPackager.check_dir_present commondir
61
+ common[:files] = Dir.glob(File.join(commondir, "*"))
62
+ return common
63
+ else
64
+ return nil
65
+ end
66
+ end
67
+ end
68
+ end
69
+ end
@@ -0,0 +1,7 @@
1
+ DESTDIR=
2
+
3
+ build:
4
+
5
+ clean:
6
+
7
+ install:
@@ -0,0 +1,5 @@
1
+ <%= @package_name -%> (<%= @plugin.metadata[:version]-%>-<%= @plugin.revision-%>) unstable; urgency=low
2
+
3
+ * Automated release for <%= @package_name -%> by mco plugin packager.
4
+
5
+ -- The Marionette Collective <mcollective-dev@googlegroups.com> <%= Time.new.strftime('%a, %d %b %Y %H:%M:%S %z') %>