choria-mcorpc-support 2.20.5 → 2.21.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/mcollective.rb +1 -1
- data/lib/mcollective/application/facts.rb +8 -0
- data/lib/mcollective/application/plugin.rb +19 -7
- data/lib/mcollective/applications.rb +2 -1
- data/lib/mcollective/ddl/agentddl.rb +17 -11
- data/lib/mcollective/ddl/base.rb +34 -20
- data/lib/mcollective/ddl/dataddl.rb +5 -5
- data/lib/mcollective/ddl/discoveryddl.rb +2 -2
- data/lib/mcollective/ddl/validatorddl.rb +1 -1
- data/lib/mcollective/pluginpackager/agent_definition.rb +33 -19
- data/lib/mcollective/pluginpackager/{puppet_module_packager.rb → forge_packager.rb} +57 -50
- data/lib/mcollective/pluginpackager/standard_definition.rb +23 -12
- data/lib/mcollective/pluginpackager/templates/{puppet_module → forge}/README.md.erb +1 -1
- data/lib/mcollective/pluginpackager/templates/{puppet_module → forge}/data/defaults.yaml.erb +0 -0
- data/lib/mcollective/pluginpackager/templates/{puppet_module → forge}/data/plugin.yaml.erb +0 -0
- data/lib/mcollective/pluginpackager/templates/{puppet_module → forge}/hiera.yaml.erb +0 -0
- data/lib/mcollective/pluginpackager/templates/{puppet_module → forge}/manifests/init.pp.erb +2 -0
- data/lib/mcollective/pluginpackager/templates/{puppet_module → forge}/metadata.json.erb +2 -2
- data/lib/mcollective/validator.rb +2 -2
- data/lib/mcollective/validator/array_validator.rb +1 -1
- data/lib/mcollective/validator/ipv4address_validator.rb +5 -7
- data/lib/mcollective/validator/ipv6address_validator.rb +5 -7
- data/lib/mcollective/validator/shellsafe_validator.rb +1 -1
- data/lib/mcollective/validator/typecheck_validator.rb +19 -15
- metadata +11 -25
- data/lib/mcollective/pluginpackager/debpackage_packager.rb +0 -237
- data/lib/mcollective/pluginpackager/modulepackage_packager.rb +0 -127
- data/lib/mcollective/pluginpackager/ospackage_packager.rb +0 -59
- data/lib/mcollective/pluginpackager/rpmpackage_packager.rb +0 -180
- data/lib/mcollective/pluginpackager/templates/debian/Makefile.erb +0 -7
- data/lib/mcollective/pluginpackager/templates/debian/changelog.erb +0 -5
- data/lib/mcollective/pluginpackager/templates/debian/compat.erb +0 -1
- data/lib/mcollective/pluginpackager/templates/debian/control.erb +0 -15
- data/lib/mcollective/pluginpackager/templates/debian/copyright.erb +0 -8
- data/lib/mcollective/pluginpackager/templates/debian/rules.erb +0 -6
- data/lib/mcollective/pluginpackager/templates/module/Modulefile.erb +0 -5
- data/lib/mcollective/pluginpackager/templates/module/README.md.erb +0 -37
- data/lib/mcollective/pluginpackager/templates/module/_manifest.pp.erb +0 -9
- data/lib/mcollective/pluginpackager/templates/redhat/rpm_spec.erb +0 -63
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: choria-mcorpc-support
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.21.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- R.I.Pienaar
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-07-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: systemu
|
@@ -36,14 +36,14 @@ dependencies:
|
|
36
36
|
requirements:
|
37
37
|
- - "~>"
|
38
38
|
- !ruby/object:Gem::Version
|
39
|
-
version: 0.
|
39
|
+
version: '0.6'
|
40
40
|
type: :runtime
|
41
41
|
prerelease: false
|
42
42
|
version_requirements: !ruby/object:Gem::Requirement
|
43
43
|
requirements:
|
44
44
|
- - "~>"
|
45
45
|
- !ruby/object:Gem::Version
|
46
|
-
version: 0.
|
46
|
+
version: '0.6'
|
47
47
|
description: Libraries enabling Ruby support for the Choria Orchestration Server
|
48
48
|
email: rip@devco.net
|
49
49
|
executables:
|
@@ -135,28 +135,14 @@ files:
|
|
135
135
|
- lib/mcollective/pluginmanager.rb
|
136
136
|
- lib/mcollective/pluginpackager.rb
|
137
137
|
- lib/mcollective/pluginpackager/agent_definition.rb
|
138
|
-
- lib/mcollective/pluginpackager/
|
139
|
-
- lib/mcollective/pluginpackager/modulepackage_packager.rb
|
140
|
-
- lib/mcollective/pluginpackager/ospackage_packager.rb
|
141
|
-
- lib/mcollective/pluginpackager/puppet_module_packager.rb
|
142
|
-
- lib/mcollective/pluginpackager/rpmpackage_packager.rb
|
138
|
+
- lib/mcollective/pluginpackager/forge_packager.rb
|
143
139
|
- lib/mcollective/pluginpackager/standard_definition.rb
|
144
|
-
- lib/mcollective/pluginpackager/templates/
|
145
|
-
- lib/mcollective/pluginpackager/templates/
|
146
|
-
- lib/mcollective/pluginpackager/templates/
|
147
|
-
- lib/mcollective/pluginpackager/templates/
|
148
|
-
- lib/mcollective/pluginpackager/templates/
|
149
|
-
- lib/mcollective/pluginpackager/templates/
|
150
|
-
- lib/mcollective/pluginpackager/templates/module/Modulefile.erb
|
151
|
-
- lib/mcollective/pluginpackager/templates/module/README.md.erb
|
152
|
-
- lib/mcollective/pluginpackager/templates/module/_manifest.pp.erb
|
153
|
-
- lib/mcollective/pluginpackager/templates/puppet_module/README.md.erb
|
154
|
-
- lib/mcollective/pluginpackager/templates/puppet_module/data/defaults.yaml.erb
|
155
|
-
- lib/mcollective/pluginpackager/templates/puppet_module/data/plugin.yaml.erb
|
156
|
-
- lib/mcollective/pluginpackager/templates/puppet_module/hiera.yaml.erb
|
157
|
-
- lib/mcollective/pluginpackager/templates/puppet_module/manifests/init.pp.erb
|
158
|
-
- lib/mcollective/pluginpackager/templates/puppet_module/metadata.json.erb
|
159
|
-
- lib/mcollective/pluginpackager/templates/redhat/rpm_spec.erb
|
140
|
+
- lib/mcollective/pluginpackager/templates/forge/README.md.erb
|
141
|
+
- lib/mcollective/pluginpackager/templates/forge/data/defaults.yaml.erb
|
142
|
+
- lib/mcollective/pluginpackager/templates/forge/data/plugin.yaml.erb
|
143
|
+
- lib/mcollective/pluginpackager/templates/forge/hiera.yaml.erb
|
144
|
+
- lib/mcollective/pluginpackager/templates/forge/manifests/init.pp.erb
|
145
|
+
- lib/mcollective/pluginpackager/templates/forge/metadata.json.erb
|
160
146
|
- lib/mcollective/registration/base.rb
|
161
147
|
- lib/mcollective/rpc.rb
|
162
148
|
- lib/mcollective/rpc/actionrunner.rb
|
@@ -1,237 +0,0 @@
|
|
1
|
-
module MCollective
|
2
|
-
module PluginPackager
|
3
|
-
class DebpackagePackager
|
4
|
-
require 'erb'
|
5
|
-
|
6
|
-
def initialize(plugin, pluginpath = nil, signature = nil, verbose = false, keep_artifacts = nil, module_template = nil)
|
7
|
-
if PluginPackager.command_available?('debuild')
|
8
|
-
@plugin = plugin
|
9
|
-
@verbose = verbose
|
10
|
-
@libdir = pluginpath || '/usr/share/mcollective/plugins/mcollective/'
|
11
|
-
@signature = signature
|
12
|
-
@package_name = "#{@plugin.mcname}-#{@plugin.metadata[:name]}"
|
13
|
-
@keep_artifacts = keep_artifacts
|
14
|
-
else
|
15
|
-
raise("Cannot build package. 'debuild' is not present on the system.")
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
# Build process :
|
20
|
-
# - create buildroot
|
21
|
-
# - craete buildroot/debian
|
22
|
-
# - create the relative directories with package contents
|
23
|
-
# - create install files for each of the plugins that are going to be built
|
24
|
-
# - create debian build files
|
25
|
-
# - create tarball
|
26
|
-
# - create pre and post install files
|
27
|
-
# - run the build script
|
28
|
-
# - move packages to cwd
|
29
|
-
# - clean up
|
30
|
-
def create_packages
|
31
|
-
begin
|
32
|
-
puts "Building packages for #{@package_name} plugin."
|
33
|
-
|
34
|
-
@tmpdir = Dir.mktmpdir('mcollective_packager')
|
35
|
-
@build_dir = File.join(@tmpdir, "#{@package_name}_#{@plugin.metadata[:version]}")
|
36
|
-
Dir.mkdir(@build_dir)
|
37
|
-
|
38
|
-
create_debian_dir
|
39
|
-
@plugin.packagedata.each do |type, data|
|
40
|
-
prepare_tmpdirs(data)
|
41
|
-
create_install_file(type, data)
|
42
|
-
create_pre_and_post_install(type)
|
43
|
-
end
|
44
|
-
create_debian_files
|
45
|
-
create_tar
|
46
|
-
run_build
|
47
|
-
move_packages
|
48
|
-
|
49
|
-
puts "Completed building all packages for #{@package_name} plugin."
|
50
|
-
ensure
|
51
|
-
if @keep_artifacts
|
52
|
-
puts 'Keeping build artifacts.'
|
53
|
-
puts "Build artifacts saved - #{@tmpdir}"
|
54
|
-
else
|
55
|
-
puts 'Removing build artifacts.'
|
56
|
-
cleanup_tmpdirs
|
57
|
-
end
|
58
|
-
end
|
59
|
-
end
|
60
|
-
|
61
|
-
private
|
62
|
-
|
63
|
-
def create_debian_files
|
64
|
-
['control', 'Makefile', 'compat', 'rules', 'copyright', 'changelog'].each do |f|
|
65
|
-
create_file(f)
|
66
|
-
end
|
67
|
-
end
|
68
|
-
|
69
|
-
def run_build
|
70
|
-
FileUtils.cd(@build_dir) do
|
71
|
-
PluginPackager.execute_verbosely(@verbose) do
|
72
|
-
if @signature
|
73
|
-
if @signature.is_a?(String)
|
74
|
-
PluginPackager.safe_system("debuild --no-lintian -i -k#{@signature}")
|
75
|
-
else
|
76
|
-
PluginPackager.safe_system("debuild --no-lintian -i")
|
77
|
-
end
|
78
|
-
else
|
79
|
-
PluginPackager.safe_system("debuild --no-lintian -i -us -uc")
|
80
|
-
end
|
81
|
-
end
|
82
|
-
end
|
83
|
-
end
|
84
|
-
|
85
|
-
# Creates a string used by the control file to specify dependencies
|
86
|
-
# Dependencies can be formatted as :
|
87
|
-
# foo (>= x.x-x)
|
88
|
-
# foo (>= x.x)
|
89
|
-
# foo
|
90
|
-
def build_dependency_string(data)
|
91
|
-
dependencies = []
|
92
|
-
PluginPackager.filter_dependencies('debian', data[:dependencies]).each do |dep|
|
93
|
-
if dep[:version] && dep[:revision]
|
94
|
-
dependencies << "#{dep[:name]} (>=#{dep[:version]}-#{dep[:revision]}) | puppet-agent"
|
95
|
-
elsif dep[:version]
|
96
|
-
dependencies << "#{dep[:name]} (>=#{dep[:version]}) | puppet-agent"
|
97
|
-
else
|
98
|
-
dependencies << "#{dep[:name]} | puppet-agent"
|
99
|
-
end
|
100
|
-
end
|
101
|
-
|
102
|
-
if data[:plugindependency]
|
103
|
-
dependencies << "#{data[:plugindependency][:name]} (= ${binary:Version})"
|
104
|
-
end
|
105
|
-
|
106
|
-
dependencies.join(', ')
|
107
|
-
end
|
108
|
-
|
109
|
-
# Creates an install file for each of the packages that are going to be created
|
110
|
-
# for the plugin
|
111
|
-
def create_install_file(type, data)
|
112
|
-
install_file = "#{@package_name}-#{type}"
|
113
|
-
begin
|
114
|
-
install_file = File.join(@build_dir, 'debian', "#{install_file}.install")
|
115
|
-
File.open(install_file, 'w') do |file|
|
116
|
-
data[:files].each do |f|
|
117
|
-
extended_filename = File.join(@libdir, File.expand_path(f).gsub(/^#{@plugin.target_path}/, ''))
|
118
|
-
file.puts "#{extended_filename} #{File.dirname(extended_filename)}"
|
119
|
-
end
|
120
|
-
end
|
121
|
-
rescue Errno::EACCES => e
|
122
|
-
puts "Could not create install file '#{install_file}'. Permission denied"
|
123
|
-
raise e
|
124
|
-
rescue => e
|
125
|
-
puts "Could not create install file '#{install_file}'."
|
126
|
-
raise e
|
127
|
-
end
|
128
|
-
end
|
129
|
-
|
130
|
-
# Move source package and debs to cwd
|
131
|
-
def move_packages
|
132
|
-
begin
|
133
|
-
files_to_copy = Dir.glob(File.join(@tmpdir, '*.{deb,dsc,diff.gz,orig.tar.gz,changes}'))
|
134
|
-
FileUtils.cp(files_to_copy, '.')
|
135
|
-
rescue => e
|
136
|
-
puts 'Could not copy packages to working directory.'
|
137
|
-
raise e
|
138
|
-
end
|
139
|
-
end
|
140
|
-
|
141
|
-
# Create pre and post install files in $buildroot/debian
|
142
|
-
# from supplied scripts.
|
143
|
-
# Note that all packages built for the plugin will invoke
|
144
|
-
# the same pre and post install scripts.
|
145
|
-
def create_pre_and_post_install(type)
|
146
|
-
if @plugin.preinstall
|
147
|
-
if !File.exists?(@plugin.preinstall)
|
148
|
-
puts "pre-install script '#{@plugin.preinstall}' not found."
|
149
|
-
raise(Errno::ENOENT, @plugin.preinstall)
|
150
|
-
else
|
151
|
-
FileUtils.cp(@plugin.preinstall, File.join(@build_dir, 'debian', "#{@package_name}-#{type}.preinst"))
|
152
|
-
end
|
153
|
-
end
|
154
|
-
|
155
|
-
if @plugin.postinstall
|
156
|
-
if !File.exists?(@plugin.postinstall)
|
157
|
-
puts "post-install script '#{@plugin.postinstall}' not found."
|
158
|
-
raise(Errno::ENOENT, @plugin.postinstall)
|
159
|
-
else
|
160
|
-
FileUtils.cp(@plugin.postinstall, File.join(@build_dir, 'debian', "#{@package_name}-#{type}.postinst"))
|
161
|
-
end
|
162
|
-
end
|
163
|
-
end
|
164
|
-
|
165
|
-
# Tar up source
|
166
|
-
# Expects directory : $mcollective-$agent_$version
|
167
|
-
# Creates file : $buildroot/$mcollective-$agent_$version.orig.tar.gz
|
168
|
-
def create_tar
|
169
|
-
name_and_version = "#{@package_name}_#{@plugin.metadata[:version]}"
|
170
|
-
tarfile = "#{name_and_version}.orig.tar.gz"
|
171
|
-
begin
|
172
|
-
PluginPackager.execute_verbosely(@verbose) do
|
173
|
-
Dir.chdir(@tmpdir) do
|
174
|
-
PluginPackager.safe_system("tar -Pcvzf #{File.join(@tmpdir, tarfile)} #{name_and_version}")
|
175
|
-
end
|
176
|
-
end
|
177
|
-
rescue Exception => e
|
178
|
-
puts "Could not create tarball - #{tarfile}"
|
179
|
-
raise e
|
180
|
-
end
|
181
|
-
end
|
182
|
-
|
183
|
-
def create_file(filename)
|
184
|
-
begin
|
185
|
-
file = ERB.new(File.read(File.join(File.dirname(__FILE__), 'templates', 'debian', "#{filename}.erb")), nil, '-')
|
186
|
-
File.open(File.join(@build_dir, 'debian', filename), 'w') do |f|
|
187
|
-
f.puts file.result(binding)
|
188
|
-
end
|
189
|
-
rescue => e
|
190
|
-
puts "Could not create file - '#{filename}'"
|
191
|
-
raise e
|
192
|
-
end
|
193
|
-
end
|
194
|
-
|
195
|
-
# Move files contained in the plugin to the correct directory
|
196
|
-
# relative to the build root.
|
197
|
-
def prepare_tmpdirs(data)
|
198
|
-
data[:files].each do |file|
|
199
|
-
begin
|
200
|
-
targetdir = File.join(@build_dir, @libdir, File.dirname(File.expand_path(file)).gsub(/^#{@plugin.target_path}/, ""))
|
201
|
-
FileUtils.mkdir_p(targetdir) unless File.directory?(targetdir)
|
202
|
-
FileUtils.cp_r(file, targetdir)
|
203
|
-
rescue Errno::EACCES => e
|
204
|
-
puts "Could not create directory '#{targetdir}'. Permission denied"
|
205
|
-
raise e
|
206
|
-
rescue Errno::ENOENT => e
|
207
|
-
puts "Could not copy file '#{file}' to '#{targetdir}'. File does not exist"
|
208
|
-
raise e
|
209
|
-
rescue => e
|
210
|
-
puts 'Could not prepare build directory'
|
211
|
-
raise e
|
212
|
-
end
|
213
|
-
end
|
214
|
-
end
|
215
|
-
|
216
|
-
# Create the $buildroot/debian directory
|
217
|
-
def create_debian_dir
|
218
|
-
deb_dir = File.join(@build_dir, 'debian')
|
219
|
-
begin
|
220
|
-
FileUtils.mkdir_p(deb_dir)
|
221
|
-
rescue => e
|
222
|
-
puts "Could not create directory '#{deb_dir}'"
|
223
|
-
raise e
|
224
|
-
end
|
225
|
-
end
|
226
|
-
|
227
|
-
def cleanup_tmpdirs
|
228
|
-
begin
|
229
|
-
FileUtils.rm_r(@tmpdir) if File.directory?(@tmpdir)
|
230
|
-
rescue => e
|
231
|
-
puts "Could not remove temporary build directory - '#{@tmpdir}'"
|
232
|
-
raise e
|
233
|
-
end
|
234
|
-
end
|
235
|
-
end
|
236
|
-
end
|
237
|
-
end
|
@@ -1,127 +0,0 @@
|
|
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
|
@@ -1,59 +0,0 @@
|
|
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
|