simp-rake-helpers 5.3.0 → 5.4.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.
- checksums.yaml +4 -4
- data/.gitignore +8 -2
- data/.travis.yml +54 -37
- data/CHANGELOG.md +40 -2
- data/Gemfile +1 -0
- data/README.md +70 -82
- data/lib/simp/rake/build/auto.rb +6 -0
- data/lib/simp/rake/build/pkg.rb +2 -2
- data/lib/simp/rake/build/rpmdeps.rb +6 -3
- data/lib/simp/rake/helpers/assets/rpm_spec/simpdefault.spec +284 -71
- data/lib/simp/rake/helpers/version.rb +1 -1
- data/lib/simp/rake/pkg.rb +38 -18
- data/lib/simp/rake/rubygem.rb +1 -1
- data/lib/simp/rpm.rb +49 -6
- data/spec/acceptance/00_pkg_rpm_custom_scriptlets_spec.rb +117 -0
- data/spec/acceptance/10_pkg_rpm_spec.rb +153 -0
- data/spec/acceptance/20_pkg_rpm_safely_upgrading_obsolete_modules_spec.rb +175 -0
- data/spec/acceptance/development/docker_env.sh +29 -0
- data/spec/acceptance/development/rerun_acceptance_tests.sh +15 -0
- data/spec/acceptance/development/vagrant_rsync.sh +23 -0
- data/spec/acceptance/files/custom_scriptlet_triggers/pupmod-new-package-2.1/CHANGELOG +2 -0
- data/spec/acceptance/files/custom_scriptlet_triggers/pupmod-new-package-2.1/Rakefile +3 -0
- data/spec/acceptance/files/custom_scriptlet_triggers/pupmod-new-package-2.1/build/rpm_metadata/custom/overrides +14 -0
- data/spec/acceptance/files/custom_scriptlet_triggers/pupmod-new-package-2.1/build/rpm_metadata/requires +1 -0
- data/spec/acceptance/files/custom_scriptlet_triggers/pupmod-new-package-2.1/metadata.json +33 -0
- data/spec/acceptance/files/custom_scriptlet_triggers/pupmod-new-package-3.0/CHANGELOG +2 -0
- data/spec/acceptance/files/custom_scriptlet_triggers/pupmod-new-package-3.0/Rakefile +3 -0
- data/spec/acceptance/files/custom_scriptlet_triggers/pupmod-new-package-3.0/build/rpm_metadata/custom/overrides +14 -0
- data/spec/acceptance/files/custom_scriptlet_triggers/pupmod-new-package-3.0/build/rpm_metadata/requires +1 -0
- data/spec/acceptance/files/custom_scriptlet_triggers/pupmod-new-package-3.0/metadata.json +33 -0
- data/spec/acceptance/files/custom_scriptlet_triggers/pupmod-old-package-1.0/CHANGELOG +2 -0
- data/spec/acceptance/files/custom_scriptlet_triggers/pupmod-old-package-1.0/Rakefile +3 -0
- data/spec/acceptance/files/custom_scriptlet_triggers/pupmod-old-package-1.0/build/rpm_metadata/requires +1 -0
- data/spec/acceptance/files/custom_scriptlet_triggers/pupmod-old-package-1.0/metadata.json +33 -0
- data/spec/acceptance/files/custom_scriptlet_triggers/pupmod-old-package-2.0/CHANGELOG +2 -0
- data/spec/acceptance/files/custom_scriptlet_triggers/pupmod-old-package-2.0/Rakefile +3 -0
- data/spec/acceptance/files/custom_scriptlet_triggers/pupmod-old-package-2.0/build/rpm_metadata/requires +1 -0
- data/spec/acceptance/files/custom_scriptlet_triggers/pupmod-old-package-2.0/metadata.json +33 -0
- data/spec/acceptance/files/custom_scriptlet_triggers/pupmod-old-package-2.2/CHANGELOG +2 -0
- data/spec/acceptance/files/custom_scriptlet_triggers/pupmod-old-package-2.2/Rakefile +3 -0
- data/spec/acceptance/files/custom_scriptlet_triggers/pupmod-old-package-2.2/build/rpm_metadata/custom/overrides +14 -0
- data/spec/acceptance/files/custom_scriptlet_triggers/pupmod-old-package-2.2/build/rpm_metadata/requires +1 -0
- data/spec/acceptance/files/custom_scriptlet_triggers/pupmod-old-package-2.2/metadata.json +33 -0
- data/spec/acceptance/files/mock_packages/pupmod-puppetlabs-stdlib.spec +32 -0
- data/spec/acceptance/files/mock_packages/pupmod-simp-foo.spec +32 -0
- data/spec/acceptance/files/mock_packages/pupmod-simp-simplib.spec +32 -0
- data/spec/acceptance/files/mock_packages/rpmbuild.sh +25 -0
- data/spec/acceptance/files/mock_packages/simp-adapter/etc/simp/adapter_config.yaml +3 -0
- data/spec/acceptance/files/mock_packages/simp-adapter/usr/local/sbin/simp_rpm_helper +406 -0
- data/spec/acceptance/files/mock_packages/simp-adapter.spec +43 -0
- data/spec/acceptance/files/testpackage_custom_scriptlet/CHANGELOG +2 -0
- data/spec/acceptance/files/testpackage_custom_scriptlet/Rakefile +3 -0
- data/spec/acceptance/files/testpackage_custom_scriptlet/build/rpm_metadata/custom/overrides +18 -0
- data/spec/acceptance/files/testpackage_custom_scriptlet/build/rpm_metadata/requires +1 -0
- data/spec/acceptance/files/testpackage_custom_scriptlet/metadata.json +33 -0
- data/spec/acceptance/nodesets/default.yml +2 -4
- data/spec/acceptance/support/pkg_rpm_helpers.rb +81 -0
- data/spec/lib/simp/rake/build/files/unmanaged_mod/build/rpm_metadata/requires +2 -1
- data/spec/lib/simp/rake/build/rpmdeps_spec.rb +2 -1
- data/spec/spec_helper_acceptance.rb +20 -1
- metadata +44 -17
- data/spec/acceptance/pkg_rpm_spec.rb +0 -164
data/lib/simp/rpm.rb
CHANGED
@@ -12,7 +12,7 @@ module Simp
|
|
12
12
|
require 'rake'
|
13
13
|
|
14
14
|
@@gpg_keys = Hash.new
|
15
|
-
attr_reader :verbose, :packages
|
15
|
+
attr_reader :verbose, :lua_debug, :packages
|
16
16
|
|
17
17
|
if Gem.loaded_specs['rake'].version >= Gem::Version.new('0.9')
|
18
18
|
def self.sh(args)
|
@@ -20,6 +20,10 @@ module Simp
|
|
20
20
|
end
|
21
21
|
end
|
22
22
|
|
23
|
+
def self.rpm_cmd
|
24
|
+
@rpm_cmd ||= (ENV.fetch('SIMP_RPM_LUA_debug','no') =='yes') ? "rpm -D 'lua_debug 1'" : 'rpm'
|
25
|
+
end
|
26
|
+
|
23
27
|
# Constructs a new Simp::RPM object. Requires the path to the spec file, or
|
24
28
|
# RPM, from which information will be gathered.
|
25
29
|
#
|
@@ -38,6 +42,8 @@ module Simp
|
|
38
42
|
# apply when +rpm_source+ is an RPM spec file.
|
39
43
|
# [rpm_name] The full name of the rpm
|
40
44
|
def initialize(rpm_source)
|
45
|
+
@verbose = ENV.fetch('SIMP_RPM_verbose','no') =='yes'
|
46
|
+
|
41
47
|
update_rpmmacros
|
42
48
|
|
43
49
|
# Simp::RPM.get_info returns a Hash or an Array of Hashes.
|
@@ -52,7 +58,14 @@ module Simp
|
|
52
58
|
@info[package_info[:basename]] = package_info
|
53
59
|
end
|
54
60
|
|
61
|
+
|
55
62
|
@packages = @info.keys
|
63
|
+
|
64
|
+
if @verbose
|
65
|
+
require 'pp'
|
66
|
+
puts "== Simp::RPM @packages"
|
67
|
+
puts @packages.pretty_inspect
|
68
|
+
end
|
56
69
|
end
|
57
70
|
|
58
71
|
# @returns The RPM '.dist' of the system. 'nil' will be will be returned if
|
@@ -60,7 +73,13 @@ module Simp
|
|
60
73
|
def self.system_dist
|
61
74
|
# We can only have one of these
|
62
75
|
unless defined?(@@system_dist)
|
63
|
-
|
76
|
+
cmd = %Q(#{rpm_cmd} -E '%{dist}' 2> /dev/null)
|
77
|
+
if @verbose
|
78
|
+
puts "== Simp::RPM.system_dist"
|
79
|
+
puts " #{cmd} "
|
80
|
+
end
|
81
|
+
dist = %x{#{cmd}}.strip.split('.')
|
82
|
+
puts " result = '#{dist}'" if @verbose
|
64
83
|
|
65
84
|
if dist.size > 1
|
66
85
|
@@system_dist = '.' + dist[1]
|
@@ -106,6 +125,13 @@ module Simp
|
|
106
125
|
fh.flush
|
107
126
|
end
|
108
127
|
|
128
|
+
if @verbose
|
129
|
+
puts "== SIMP::RPM#update_rpmmacros:"
|
130
|
+
puts " wrote to '#{rpmmacros_file}': "
|
131
|
+
puts " #{'-'*20}"
|
132
|
+
puts rpmmacros.map{|x| " #{x}\n"}.join
|
133
|
+
puts
|
134
|
+
end
|
109
135
|
@@macros_updated = true
|
110
136
|
end
|
111
137
|
end
|
@@ -259,7 +285,11 @@ module Simp
|
|
259
285
|
# stdout output and stderr output.
|
260
286
|
# cmd:: command to be executed
|
261
287
|
def self.execute(cmd)
|
262
|
-
|
288
|
+
if @verbose ||= ENV.fetch('SIMP_RPM_verbose','no') =='yes'
|
289
|
+
puts "== Simp::RPM.execute(#{cmd})"
|
290
|
+
puts " #{cmd}"
|
291
|
+
end
|
292
|
+
|
263
293
|
outfile = File.join('/tmp', "#{ENV['USER']}_#{SecureRandom.hex}")
|
264
294
|
errfile = File.join('/tmp', "#{ENV['USER']}_#{SecureRandom.hex}")
|
265
295
|
pid = spawn(cmd, :out=>outfile, :err=>errfile)
|
@@ -276,6 +306,13 @@ module Simp
|
|
276
306
|
|
277
307
|
{ :exit_status => exit_status, :stdout => stdout, :stderr => stderr }
|
278
308
|
ensure
|
309
|
+
if @verbose
|
310
|
+
puts " -------- exit_status: #{exit_status}"
|
311
|
+
puts " -------- stdout ",''
|
312
|
+
puts File.readlines(outfile).map{|x| " #{x}"}.join
|
313
|
+
puts ''," -------- stderr ",''
|
314
|
+
puts File.readlines(errfile).map{|x| " #{x}"}.join
|
315
|
+
end
|
279
316
|
FileUtils.rm_f([outfile, errfile])
|
280
317
|
end
|
281
318
|
|
@@ -313,9 +350,9 @@ module Simp
|
|
313
350
|
:dist => system_dist
|
314
351
|
}
|
315
352
|
|
316
|
-
rpm_version_query = %(
|
353
|
+
rpm_version_query = %Q(#{rpm_cmd} -q --queryformat '%{NAME} %{VERSION} %{RELEASE} %{ARCH}\\n')
|
317
354
|
|
318
|
-
rpm_signature_query = %(
|
355
|
+
rpm_signature_query = %Q(#{rpm_cmd} -q --queryformat '%|DSAHEADER?{%{DSAHEADER:pgpsig}}:{%|RSAHEADER?{%{RSAHEADER:pgpsig}}:{%|SIGGPG?{%{SIGGPG:pgpsig}}:{%|SIGPGP?{%{SIGPGP:pgpsig}}:{(none)}|}|}|}|\\n')
|
319
356
|
|
320
357
|
source_is_rpm = rpm_source.split('.').last == 'rpm'
|
321
358
|
if source_is_rpm
|
@@ -373,6 +410,12 @@ EOE
|
|
373
410
|
info_array << info
|
374
411
|
end
|
375
412
|
|
413
|
+
if @verbose
|
414
|
+
puts "== SIMP::RPM.get_info"
|
415
|
+
require 'pp'
|
416
|
+
pp info_array
|
417
|
+
end
|
418
|
+
|
376
419
|
if info_array.size == 1
|
377
420
|
return info_array[0]
|
378
421
|
else
|
@@ -387,7 +430,7 @@ EOE
|
|
387
430
|
end
|
388
431
|
|
389
432
|
def self.create_rpm_build_metadata(project_dir, srpms=nil, rpms=nil)
|
390
|
-
require 'yaml'
|
433
|
+
require 'yaml'
|
391
434
|
|
392
435
|
last_build = {
|
393
436
|
'git_hash' => %x(git rev-list --max-count=1 HEAD).chomp,
|
@@ -0,0 +1,117 @@
|
|
1
|
+
require 'spec_helper_acceptance'
|
2
|
+
require_relative 'support/pkg_rpm_helpers'
|
3
|
+
|
4
|
+
RSpec.configure do |c|
|
5
|
+
c.include Simp::BeakerHelpers::SimpRakeHelpers::PkgRpmHelpers
|
6
|
+
c.extend Simp::BeakerHelpers::SimpRakeHelpers::PkgRpmHelpers
|
7
|
+
end
|
8
|
+
|
9
|
+
shared_examples_for 'an RPM generator with customized scriptlets' do
|
10
|
+
it 'should create an RPM with customized scriptlets' do
|
11
|
+
scriptlets = rpm_scriptlets_for(
|
12
|
+
host,
|
13
|
+
"#{pkg_root_dir}/testpackage_custom_scriptlet/dist/" +
|
14
|
+
'pupmod-simp-testpackage-0.0.1-0.noarch.rpm'
|
15
|
+
)
|
16
|
+
|
17
|
+
comment '...the expected scriptlet types are present'
|
18
|
+
expect(scriptlets.keys.sort).to eq [
|
19
|
+
'pretrans',
|
20
|
+
'preinstall',
|
21
|
+
'postinstall',
|
22
|
+
'preuninstall',
|
23
|
+
'postuninstall',
|
24
|
+
].sort
|
25
|
+
|
26
|
+
comment '...there are no duplicates' # this *should* be impossible
|
27
|
+
expect(scriptlets.map{|k,v| v[:count]}.max).to be == 1
|
28
|
+
|
29
|
+
comment '...pretrans scriptlet contains custom content'
|
30
|
+
expect(scriptlets['pretrans'][:content]).to eq '-- Custom scriptlet'
|
31
|
+
|
32
|
+
comment '...preinstall scriptlet has been overridden with custom content'
|
33
|
+
expect(scriptlets['preinstall'][:bare_content]).to eq(
|
34
|
+
"echo 'I override the default %%pre section provided by the spec file.'"
|
35
|
+
)
|
36
|
+
|
37
|
+
comment '...remaining default scriptlets call simp_rpm_helper with correct arguments'
|
38
|
+
expected_simp_rpm_helper_scriptlets = scriptlet_label_map.select{|k,v| %w(post preun postun).include? v }
|
39
|
+
expected_simp_rpm_helper_scriptlets.each do |rpm_label, simp_helper_label|
|
40
|
+
expect(scriptlets[rpm_label][:bare_content]).to eq(
|
41
|
+
"/usr/local/sbin/simp_rpm_helper --rpm_dir=/usr/share/simp/modules/testpackage --rpm_section='#{simp_helper_label}' --rpm_status=$1"
|
42
|
+
)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
|
48
|
+
shared_examples_for 'an RPM generator with customized triggers' do
|
49
|
+
|
50
|
+
it 'should create an RPM with customized triggers' do
|
51
|
+
triggers = rpm_triggers_for(
|
52
|
+
host,
|
53
|
+
"#{pkg_root_dir}/testpackage_custom_scriptlet/dist/" +
|
54
|
+
'pupmod-simp-testpackage-0.0.1-0.noarch.rpm'
|
55
|
+
)
|
56
|
+
|
57
|
+
|
58
|
+
comment '...the expected trigger types are present'
|
59
|
+
expect(triggers.keys.sort).to eq [
|
60
|
+
'triggerun scriptlet (using /bin/sh) -- bar',
|
61
|
+
'triggerun scriptlet (using /bin/sh) -- foo',
|
62
|
+
]
|
63
|
+
|
64
|
+
comment '...there are no duplicates' # <-- this also should be impossible
|
65
|
+
expect(triggers.map{|k,v| v[:count]}.max).to be == 1
|
66
|
+
|
67
|
+
comment '..."triggerun -- foo" contains the expected content'
|
68
|
+
expect(triggers['triggerun scriptlet (using /bin/sh) -- foo'][:bare_content]).to eq(
|
69
|
+
%q{echo "The 'foo' package is great; why would you uninstall it?"}
|
70
|
+
)
|
71
|
+
|
72
|
+
comment '..."triggerun -- bar" contains the expected content'
|
73
|
+
expect(triggers['triggerun scriptlet (using /bin/sh) -- bar'][:bare_content]).to eq(
|
74
|
+
%q{echo "This trigger runs just before the 'bar' package's %%preun"}
|
75
|
+
)
|
76
|
+
end
|
77
|
+
|
78
|
+
end
|
79
|
+
|
80
|
+
describe 'rake pkg:rpm with customized content' do
|
81
|
+
|
82
|
+
before :all do
|
83
|
+
copy_host_files_into_build_user_homedir(hosts)
|
84
|
+
end
|
85
|
+
|
86
|
+
let(:pkg_root_dir){'/home/build_user/host_files/spec/acceptance/files'}
|
87
|
+
let(:testpackage_dir){"#{pkg_root_dir}/testpackage"}
|
88
|
+
|
89
|
+
hosts.each do |_host|
|
90
|
+
context "on #{_host}" do
|
91
|
+
let!(:host){ _host }
|
92
|
+
|
93
|
+
it 'can prep the package directories' do
|
94
|
+
testpackages = [
|
95
|
+
'testpackage_custom_scriptlet',
|
96
|
+
]
|
97
|
+
|
98
|
+
testpackages.each do |package|
|
99
|
+
on hosts, %Q(#{run_cmd} "cd #{pkg_root_dir}/#{package}; ) +
|
100
|
+
%Q(rvm use default; bundle update --local || bundle update")
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
context 'when valid custom content is defined under rpm_metadata' do
|
105
|
+
|
106
|
+
it 'should create an RPM' do
|
107
|
+
on host, %(#{run_cmd} "cd #{pkg_root_dir}/testpackage_custom_scriptlet; #{rake_cmd} pkg:rpm")
|
108
|
+
end
|
109
|
+
|
110
|
+
it_should_behave_like 'an RPM generator with customized scriptlets'
|
111
|
+
it_should_behave_like 'an RPM generator with customized triggers'
|
112
|
+
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
116
|
+
end
|
117
|
+
end
|
@@ -0,0 +1,153 @@
|
|
1
|
+
require 'spec_helper_acceptance'
|
2
|
+
require_relative 'support/pkg_rpm_helpers'
|
3
|
+
|
4
|
+
RSpec.configure do |c|
|
5
|
+
c.include Simp::BeakerHelpers::SimpRakeHelpers::PkgRpmHelpers
|
6
|
+
c.extend Simp::BeakerHelpers::SimpRakeHelpers::PkgRpmHelpers
|
7
|
+
end
|
8
|
+
|
9
|
+
shared_examples_for "an RPM generator with edge cases" do
|
10
|
+
it 'should use specified release number for the RPM' do
|
11
|
+
on host, %(#{run_cmd} "cd #{pkg_root_dir}/testpackage_with_release; rake pkg:rpm")
|
12
|
+
release_test_rpm = File.join(pkg_root_dir, 'testpackage_with_release',
|
13
|
+
'dist', 'pupmod-simp-testpackage-0.0.1-42.noarch.rpm')
|
14
|
+
on host, %(test -f #{release_test_rpm})
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'should generate a changelog for the RPM when no CHANGELOG exists' do
|
18
|
+
on host, %(#{run_cmd} "cd #{pkg_root_dir}/testpackage_without_changelog; #{rake_cmd} pkg:rpm")
|
19
|
+
changelog_test_rpm = File.join(pkg_root_dir, 'testpackage_without_changelog',
|
20
|
+
'dist', File.basename(testpackage_rpm))
|
21
|
+
on host, %(rpm --changelog -qp #{changelog_test_rpm} | grep -q 'Auto Changelog')
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'should not require pupmod-simp-simplib for simp-simplib RPM' do
|
25
|
+
on host, %(#{run_cmd} "cd #{pkg_root_dir}/simplib; #{rake_cmd} pkg:rpm")
|
26
|
+
simplib_rpm = File.join(pkg_root_dir, 'simplib', 'dist',
|
27
|
+
File.basename(testpackage_rpm).gsub(/simp-testpackage-0.0.1/,'simp-simplib-1.2.3'))
|
28
|
+
on host, %(test -f #{simplib_rpm})
|
29
|
+
on host, %(rpm -qpR #{simplib_rpm} | grep -q pupmod-simp-simplib), {:acceptable_exit_codes => [1]}
|
30
|
+
end
|
31
|
+
|
32
|
+
it 'should not fail to create an RPM when the CHANGELOG has a bad date' do
|
33
|
+
on host,
|
34
|
+
%(#{run_cmd} "cd #{pkg_root_dir}/testpackage_with_bad_changelog_date; #{rake_cmd} pkg:rpm")
|
35
|
+
|
36
|
+
bad_date_test_rpm = File.join(pkg_root_dir, 'testpackage_with_bad_changelog_date',
|
37
|
+
'dist', File.basename(testpackage_rpm))
|
38
|
+
on host, %(test -f #{bad_date_test_rpm})
|
39
|
+
end
|
40
|
+
|
41
|
+
it 'should fail to create an RPM when metadata.json is missing' do
|
42
|
+
on host,
|
43
|
+
%(#{run_cmd} "cd #{pkg_root_dir}/testpackage_missing_metadata_file; #{rake_cmd} pkg:rpm"),
|
44
|
+
:acceptable_exit_codes => [1]
|
45
|
+
end
|
46
|
+
|
47
|
+
it 'should fail to create an RPM when license metadata is missing' do
|
48
|
+
on host,
|
49
|
+
%(#{run_cmd} "cd #{pkg_root_dir}/testpackage_missing_license; #{rake_cmd} pkg:rpm"),
|
50
|
+
:acceptable_exit_codes => [1]
|
51
|
+
end
|
52
|
+
|
53
|
+
it 'should fail to create an RPM when name metadata is missing' do
|
54
|
+
on host,
|
55
|
+
%(#{run_cmd} "cd #{pkg_root_dir}/testpackage_missing_name; #{rake_cmd} pkg:rpm"),
|
56
|
+
:acceptable_exit_codes => [1]
|
57
|
+
end
|
58
|
+
|
59
|
+
it 'should fail to create an RPM when source metadata is missing' do
|
60
|
+
on host,
|
61
|
+
%(#{run_cmd} "cd #{pkg_root_dir}/testpackage_missing_source; #{rake_cmd} pkg:rpm"),
|
62
|
+
:acceptable_exit_codes => [1]
|
63
|
+
end
|
64
|
+
|
65
|
+
it 'should fail to create an RPM when summary metadata is missing' do
|
66
|
+
on host,
|
67
|
+
%(#{run_cmd} "cd #{pkg_root_dir}/testpackage_missing_summary; #{rake_cmd} pkg:rpm"),
|
68
|
+
:acceptable_exit_codes => [1]
|
69
|
+
end
|
70
|
+
|
71
|
+
it 'should fail to create an RPM when version metadata is missing' do
|
72
|
+
on host,
|
73
|
+
%(#{run_cmd} "cd #{pkg_root_dir}/testpackage_missing_version; #{rake_cmd} pkg:rpm"),
|
74
|
+
:acceptable_exit_codes => [1]
|
75
|
+
end
|
76
|
+
|
77
|
+
end
|
78
|
+
|
79
|
+
describe 'rake pkg:rpm' do
|
80
|
+
before :all do
|
81
|
+
copy_host_files_into_build_user_homedir(hosts)
|
82
|
+
end
|
83
|
+
|
84
|
+
|
85
|
+
hosts.each do |_host|
|
86
|
+
context "on #{_host}" do
|
87
|
+
let!(:host){ _host }
|
88
|
+
|
89
|
+
context 'rpm building' do
|
90
|
+
|
91
|
+
let(:pkg_root_dir){'/home/build_user/host_files/spec/acceptance/files'}
|
92
|
+
let(:testpackage_dir){"#{pkg_root_dir}/testpackage"}
|
93
|
+
|
94
|
+
it 'can prep the package directories' do
|
95
|
+
testpackages = [
|
96
|
+
'simplib',
|
97
|
+
'testpackage',
|
98
|
+
'testpackage_missing_license',
|
99
|
+
'testpackage_missing_metadata_file',
|
100
|
+
'testpackage_missing_name',
|
101
|
+
'testpackage_missing_source',
|
102
|
+
'testpackage_missing_summary',
|
103
|
+
'testpackage_missing_version',
|
104
|
+
'testpackage_with_bad_changelog_date',
|
105
|
+
'testpackage_with_release',
|
106
|
+
'testpackage_without_changelog',
|
107
|
+
]
|
108
|
+
|
109
|
+
testpackages.each do |package|
|
110
|
+
on hosts, %Q(#{run_cmd} "cd #{pkg_root_dir}/#{package}; ) +
|
111
|
+
%Q(rvm use default; bundle update --local || bundle update")
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
115
|
+
context 'using simpdefault.spec' do
|
116
|
+
|
117
|
+
let(:build_type) {:default}
|
118
|
+
let(:testpackage_rpm) { File.join(testpackage_dir, 'dist/pupmod-simp-testpackage-0.0.1-0.noarch.rpm') }
|
119
|
+
|
120
|
+
it 'should create an RPM' do
|
121
|
+
comment "produces RPM on #{host}"
|
122
|
+
on host, %(#{run_cmd} "cd #{testpackage_dir}; #{rake_cmd} pkg:rpm")
|
123
|
+
on host, %(test -f #{testpackage_rpm})
|
124
|
+
|
125
|
+
comment 'produces RPM with appropriate dependencies'
|
126
|
+
on host, %(rpm -qpR #{testpackage_rpm} | grep -q simp-adapter)
|
127
|
+
on host, %(rpm -qpR #{testpackage_rpm} | grep -q pupmod-simp-foo)
|
128
|
+
on host, %(rpm -qpR #{testpackage_rpm} | grep -q pupmod-simp-simplib)
|
129
|
+
on host, %(rpm -qpR #{testpackage_rpm} | grep -q pupmod-puppetlabs-stdlib)
|
130
|
+
on host, %(rpm -qp --provides #{testpackage_rpm} | grep -q -x 'pupmod-testpackage = 0.0.1-0')
|
131
|
+
on host, %(rpm -qp --provides #{testpackage_rpm} | grep -q -x 'simp-testpackage = 0.0.1-0')
|
132
|
+
on host, %(rpm -qp --queryformat "[%{obsoletes}\\n]" #{testpackage_rpm} | grep -q "^pupmod-testpackage")
|
133
|
+
on host, %(rpm -qp --queryformat "[%{obsoletes}\\n]" #{testpackage_rpm} | grep -q "^simp-testpackage")
|
134
|
+
|
135
|
+
comment 'produces RPM with a sourced CHANGELOG'
|
136
|
+
on host, %(rpm --changelog -qp #{testpackage_rpm} | grep -q Stallman)
|
137
|
+
|
138
|
+
comment 'produces RPM with appropriate pre/post/preun/postun'
|
139
|
+
result = on host, %(rpm -qp --scripts #{testpackage_rpm})
|
140
|
+
scriptlets = result.stdout.scan( %r{^.*?scriptlet.*?/usr/local/sbin/simp_rpm_helper --rpm_dir=/usr/share/simp/modules/testpackage.*?$}m )
|
141
|
+
|
142
|
+
expect( scriptlets.grep( %r{\Apreinstall scriptlet.*\n/usr/local/sbin/simp_rpm_helper --rpm_dir=/usr/share/simp/modules/testpackage --rpm_section='pre' --rpm_status=\$1\Z}m )).not_to be_empty
|
143
|
+
expect( scriptlets.grep( %r{\Apostinstall scriptlet.*\n/usr/local/sbin/simp_rpm_helper --rpm_dir=/usr/share/simp/modules/testpackage --rpm_section='post' --rpm_status=\$1\Z}m )).not_to be_empty
|
144
|
+
expect( scriptlets.grep( %r{\Apreuninstall scriptlet.*\n/usr/local/sbin/simp_rpm_helper --rpm_dir=/usr/share/simp/modules/testpackage --rpm_section='preun' --rpm_status=\$1\Z}m )).not_to be_empty
|
145
|
+
expect( scriptlets.grep( %r{\Apostuninstall scriptlet.*\n/usr/local/sbin/simp_rpm_helper --rpm_dir=/usr/share/simp/modules/testpackage --rpm_section='postun' --rpm_status=\$1\Z}m )).not_to be_empty
|
146
|
+
end
|
147
|
+
|
148
|
+
it_should_behave_like 'an RPM generator with edge cases'
|
149
|
+
end
|
150
|
+
end
|
151
|
+
end
|
152
|
+
end
|
153
|
+
end
|
@@ -0,0 +1,175 @@
|
|
1
|
+
require 'spec_helper_acceptance'
|
2
|
+
require_relative 'support/pkg_rpm_helpers'
|
3
|
+
|
4
|
+
require 'beaker/puppet_install_helper'
|
5
|
+
require 'json'
|
6
|
+
|
7
|
+
RSpec.configure do |c|
|
8
|
+
c.include Simp::BeakerHelpers::SimpRakeHelpers::PkgRpmHelpers
|
9
|
+
c.extend Simp::BeakerHelpers::SimpRakeHelpers::PkgRpmHelpers
|
10
|
+
end
|
11
|
+
|
12
|
+
|
13
|
+
# These tests demonstrate custom RPM triggers that work around the obsolete
|
14
|
+
# module RPM upgrate + simp_rpm_helper problem described in SIMP-3895:
|
15
|
+
#
|
16
|
+
# https://simp-project.atlassian.net/browse/SIMP-3988
|
17
|
+
#
|
18
|
+
# The expected outcome is that simp_rpm_helper always ensures the correct
|
19
|
+
# content is installed after an upgrade, even during after a package has been
|
20
|
+
# obsoleted. This is accomplished via %triggerpostun -- <name of old package>
|
21
|
+
#
|
22
|
+
# old 1.0 -> old 2.0 = no need for a trigger
|
23
|
+
# old 1.0 -> new 2.0 = must re-run simp_rpm_helper
|
24
|
+
# old 1.0 -> new 3.0 = must re-run simp_rpm_helper
|
25
|
+
# old 2.0 -> new 2.0 = must re-run simp_rpm_helper
|
26
|
+
# old 2.0 -> new 3.0 = must re-run simp_rpm_helper
|
27
|
+
# new 2.0 -> new 3.0 = no need for a trigger
|
28
|
+
|
29
|
+
|
30
|
+
shared_examples_for 'an upgrade path that works safely with rpm_simp_helper' do |first_package_file, second_package_file|
|
31
|
+
let( :rpm_regex ) do
|
32
|
+
/^(?<name>pupmod-[a-z0-9_]+-[a-z0-9_]+)-(?<version>\d+\.\d+\.\d+)-(?<release>\d+)\..*\.rpm$/
|
33
|
+
end
|
34
|
+
|
35
|
+
let( :first_package_version ){ first_package_file.match(rpm_regex)['version'] }
|
36
|
+
let( :first_package_name ){ first_package_file.match(rpm_regex)['name'] }
|
37
|
+
let( :first_package_forge_name ){ first_package_name.sub(/^[^-]+-/,'') }
|
38
|
+
let( :first_package_module_name ){ first_package_forge_name.sub(/^[^-]+-/,'') }
|
39
|
+
let( :first_package_dir_name ){ first_package_name + '-' + first_package_version.sub(/\.\d+-\d+$/,'') }
|
40
|
+
|
41
|
+
let( :second_package_name ){ second_package_file.match(rpm_regex)['name'] }
|
42
|
+
let( :second_package_forge_name ){ second_package_name.sub(/^[^-]+-/,'') }
|
43
|
+
let( :second_package_module_name ){ second_package_forge_name.sub(/^[^-]+-/,'') }
|
44
|
+
let( :second_package_version ){ second_package_file.match(rpm_regex)['version'] }
|
45
|
+
let( :second_package_dir_name ){ second_package_name + '-' + second_package_version.sub(/\.\d+-\d+$/,'') }
|
46
|
+
|
47
|
+
context "When upgrading from #{first_package_file} to #{second_package_file}" do
|
48
|
+
it "should clean out any old installs" do
|
49
|
+
on host, "rpm -e #{first_package_name} &> /dev/null; " +
|
50
|
+
"rpm -e #{second_package_name} &> /dev/null ",
|
51
|
+
accept_all_exit_codes: true
|
52
|
+
end
|
53
|
+
|
54
|
+
it "should install #{first_package_file}" do
|
55
|
+
on host, "cd #{pkg_root_dir}/#{first_package_dir_name.gsub(/\.\d+$/,'')}; "+
|
56
|
+
"rpm -Uvh dist/#{first_package_file}"
|
57
|
+
end
|
58
|
+
|
59
|
+
it "should transfer contents of #{first_package_file} into the code directory" do
|
60
|
+
result = on host, "cat /opt/test/puppet/code/#{first_package_module_name}/metadata.json"
|
61
|
+
metadata = JSON.parse(result.stdout)
|
62
|
+
expect(metadata['name']).to eq first_package_forge_name
|
63
|
+
expect(metadata['version']).to eq first_package_version
|
64
|
+
end
|
65
|
+
|
66
|
+
it "should upgrade to #{second_package_file}" do
|
67
|
+
on host, "cd #{pkg_root_dir}/#{second_package_dir_name.gsub(/\.\d+$/,'')}; rpm -Uvh dist/#{second_package_file}"
|
68
|
+
end
|
69
|
+
|
70
|
+
it "should transfer contents of #{second_package_file} into the code directory" do
|
71
|
+
result = on host, "cat /opt/test/puppet/code/#{second_package_module_name}/metadata.json"
|
72
|
+
metadata = JSON.parse(result.stdout)
|
73
|
+
expect(metadata['name']).to eq second_package_forge_name
|
74
|
+
expect(metadata['version']).to eq second_package_version
|
75
|
+
end
|
76
|
+
|
77
|
+
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
describe 'rake pkg:rpm + modules with customized content to safely upgrade obsoleted packagess' do
|
82
|
+
|
83
|
+
let(:pkg_root_dir) do
|
84
|
+
'/home/build_user/host_files/spec/acceptance/files/custom_scriptlet_triggers'
|
85
|
+
end
|
86
|
+
|
87
|
+
before :all do
|
88
|
+
copy_host_files_into_build_user_homedir(hosts)
|
89
|
+
|
90
|
+
comment 'ensure the Puppet AIO is installed'
|
91
|
+
ENV['PUPPET_INSTALL_TYPE'] ||= 'agent'
|
92
|
+
ENV['PUPPET_INSTALL_VERSION'] ||= '1.10.6'
|
93
|
+
run_puppet_install_helper_on(hosts)
|
94
|
+
|
95
|
+
comment 'configure puppet agent to look like a Puppet server for simp_rpm_helper'
|
96
|
+
on hosts, '/opt/puppetlabs/bin/puppet config --section master set user root; ' +
|
97
|
+
'/opt/puppetlabs/bin/puppet config --section master set group root; ' +
|
98
|
+
'/opt/puppetlabs/bin/puppet config --section master set codedir /opt/test/puppet/code; ' +
|
99
|
+
'/opt/puppetlabs/bin/puppet config --section master set confdir /opt/test/puppet/code'
|
100
|
+
|
101
|
+
|
102
|
+
comment 'build and install mock RPMs'
|
103
|
+
mock_pkg_dir = '/home/build_user/host_files/spec/acceptance/files/mock_packages'
|
104
|
+
on hosts, %Q[#{run_cmd} "cd #{mock_pkg_dir}; rm -rf pkg"]
|
105
|
+
on hosts, %Q[#{run_cmd} "cd #{mock_pkg_dir}; bash rpmbuild.sh simp-adapter.spec"]
|
106
|
+
on hosts, %Q[#{run_cmd} "cd #{mock_pkg_dir}; bash rpmbuild.sh pupmod-puppetlabs-stdlib.spec"]
|
107
|
+
on hosts, %Q[#{run_cmd} "cd #{mock_pkg_dir}; bash rpmbuild.sh pupmod-simp-simplib.spec"]
|
108
|
+
on hosts, %Q[#{run_cmd} "cd #{mock_pkg_dir}; bash rpmbuild.sh pupmod-simp-foo.spec"]
|
109
|
+
|
110
|
+
on hosts, %Q[rpm -Uvh "#{mock_pkg_dir}/pkg/dist/*.noarch.rpm"], acceptable_exit_codes: [0,1]
|
111
|
+
end
|
112
|
+
|
113
|
+
hosts.each do |_host|
|
114
|
+
context "on #{_host}" do
|
115
|
+
let!(:host){ _host }
|
116
|
+
|
117
|
+
context 'with module RPMs that are suceptible to SIMP-3895' do
|
118
|
+
|
119
|
+
let(:testpackages) do
|
120
|
+
[
|
121
|
+
'pupmod-old-package-1.0',
|
122
|
+
'pupmod-old-package-2.0',
|
123
|
+
'pupmod-old-package-2.2',
|
124
|
+
'pupmod-new-package-2.1',
|
125
|
+
'pupmod-new-package-3.0',
|
126
|
+
]
|
127
|
+
end
|
128
|
+
|
129
|
+
it 'should create RPMs' do
|
130
|
+
testpackages.each do |package|
|
131
|
+
on host, %Q(#{run_cmd} "cd #{pkg_root_dir}/#{package}; ) +
|
132
|
+
%Q(rvm use default; bundle update --local || bundle update")
|
133
|
+
rpm_name = package.sub(/-[^-]+$/,'')
|
134
|
+
# In case previous tests haven't been clean
|
135
|
+
on host, "rpm -q #{rpm_name} && rpm -e #{rpm_name}; :"
|
136
|
+
|
137
|
+
on host, %(#{run_cmd} "cd #{pkg_root_dir}/#{package}; #{rake_cmd} pkg:rpm")
|
138
|
+
end
|
139
|
+
end
|
140
|
+
|
141
|
+
it_should_behave_like('an upgrade path that works safely with rpm_simp_helper',
|
142
|
+
'pupmod-old-package-1.0.0-0.noarch.rpm',
|
143
|
+
'pupmod-old-package-2.0.0-0.noarch.rpm')
|
144
|
+
|
145
|
+
it_should_behave_like('an upgrade path that works safely with rpm_simp_helper',
|
146
|
+
'pupmod-old-package-1.0.0-0.noarch.rpm',
|
147
|
+
'pupmod-new-package-2.1.0-0.noarch.rpm')
|
148
|
+
|
149
|
+
it_should_behave_like('an upgrade path that works safely with rpm_simp_helper',
|
150
|
+
'pupmod-new-package-2.1.0-0.noarch.rpm',
|
151
|
+
'pupmod-old-package-2.2.0-0.noarch.rpm')
|
152
|
+
|
153
|
+
it_should_behave_like('an upgrade path that works safely with rpm_simp_helper',
|
154
|
+
'pupmod-old-package-1.0.0-0.noarch.rpm',
|
155
|
+
'pupmod-new-package-3.0.0-0.noarch.rpm')
|
156
|
+
|
157
|
+
it_should_behave_like('an upgrade path that works safely with rpm_simp_helper',
|
158
|
+
'pupmod-old-package-2.0.0-0.noarch.rpm',
|
159
|
+
'pupmod-new-package-2.1.0-0.noarch.rpm')
|
160
|
+
|
161
|
+
it_should_behave_like('an upgrade path that works safely with rpm_simp_helper',
|
162
|
+
'pupmod-old-package-2.0.0-0.noarch.rpm',
|
163
|
+
'pupmod-new-package-3.0.0-0.noarch.rpm')
|
164
|
+
|
165
|
+
it_should_behave_like('an upgrade path that works safely with rpm_simp_helper',
|
166
|
+
'pupmod-old-package-2.2.0-0.noarch.rpm',
|
167
|
+
'pupmod-new-package-3.0.0-0.noarch.rpm')
|
168
|
+
|
169
|
+
it_should_behave_like('an upgrade path that works safely with rpm_simp_helper',
|
170
|
+
'pupmod-new-package-2.1.0-0.noarch.rpm',
|
171
|
+
'pupmod-new-package-3.0.0-0.noarch.rpm')
|
172
|
+
end
|
173
|
+
end
|
174
|
+
end
|
175
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# Source this file within a docker container to set up convenience shell
|
2
|
+
# variables & functions.
|
3
|
+
#
|
4
|
+
# Usage:
|
5
|
+
#
|
6
|
+
# source /host_files/spec/acceptance/development/docker_env.sh [DIR]
|
7
|
+
#
|
8
|
+
# # testing a particular
|
9
|
+
# source /host_files/spec/acceptance/development/docker_env.sh /home/build_user/host_files/spec/acceptance/files/testpackage_custom_scriptlet
|
10
|
+
|
11
|
+
|
12
|
+
export TERM=xterm
|
13
|
+
export TOPWD=/home/build_user/host_files
|
14
|
+
export TOPWD_FILES=${TOPWD}/spec/acceptance/files
|
15
|
+
export TWD=${1:-$TOPWD_FILES/testpackage}
|
16
|
+
export TW=$(basename ${TWD})
|
17
|
+
export TWSPEC="$TWD/dist/tmp/testpackage.spec"
|
18
|
+
alias twd="cd $TWD"
|
19
|
+
rug(){
|
20
|
+
runuser build_user -l -c "cd /$TOPWD; $@"
|
21
|
+
}
|
22
|
+
ru(){
|
23
|
+
runuser build_user -l -c "cd /$TWD; SIMP_RPM_LUA_debug=yes SIMP_RPM_verbose=yes SIMP_PKG_verbose=yes $@"
|
24
|
+
}
|
25
|
+
ru_specfile_rpm_q(){
|
26
|
+
ru "rpm -q -D 'pup_module_info_dir $TWD' --specfile $TWD/dist/tmp/testpackage.spec $@"
|
27
|
+
}
|
28
|
+
cd $TWD
|
29
|
+
(yum install -y vim-enhanced tree > /dev/null &)
|
@@ -0,0 +1,15 @@
|
|
1
|
+
#!/bin/bash
|
2
|
+
|
3
|
+
# Run this from your docker host to wipe out all containers and restart beaker
|
4
|
+
# tests.
|
5
|
+
|
6
|
+
# Find & kill running beaker containers
|
7
|
+
(docker ps -a | grep -v CONT | awk '{print "docker kill " $1 "; docker rm " $1}') > /tmp/x.$$
|
8
|
+
source /tmp/x.$$ && rm /tmp/x.$$
|
9
|
+
|
10
|
+
if [[ $# -gt 0 ]]; then
|
11
|
+
BEAKER_destroy=no SIMP_RPM_LUA_debug=yes SIMP_RAKE_PKG_verbose=yes SIMP_RPM_verbose=yes $@
|
12
|
+
else
|
13
|
+
# re-run acceptance tests
|
14
|
+
BEAKER_destroy=no SIMP_RPM_LUA_debug=yes SIMP_RAKE_PKG_verbose=yes SIMP_RPM_verbose=yes bundle exec rake acceptance
|
15
|
+
fi
|
@@ -0,0 +1,23 @@
|
|
1
|
+
vagrant rsync
|
2
|
+
vagrant ssh -c "cd /vagrant; bundle --local || bundle; ls -l; source /vagrant/spec/acceptance/development/rerun_acceptance_tests.sh" -- -v
|
3
|
+
|
4
|
+
|
5
|
+
[[ $? -eq 0 ]] && status=SUCCESS || status=FAILED
|
6
|
+
echo
|
7
|
+
echo ==================
|
8
|
+
echo $status
|
9
|
+
echo ==================
|
10
|
+
echo
|
11
|
+
echo 'In order to troubleshoot directly on a container:'
|
12
|
+
echo
|
13
|
+
echo ' vagrant ssh # enter vagrant VM'
|
14
|
+
echo ' docker ps # identify container to inspect'
|
15
|
+
echo ' docker exec -it el6-build-server bash # log into container (example: el6-build-server)'
|
16
|
+
echo
|
17
|
+
echo ' source /host_files/spec/acceptance/development/docker_env.sh '
|
18
|
+
echo
|
19
|
+
echo ' # or, to start testing a particular script'
|
20
|
+
echo
|
21
|
+
echo ' source /host_files/spec/acceptance/development/docker_env.sh /home/build_user/host_files/spec/acceptance/files/custom_scriptlet_triggers/pupmod-new-package-2.0'
|
22
|
+
echo
|
23
|
+
echo ' ru "rpm -q --queryformat '%{NAME} %{VERSION} %{RELEASE} %{ARCH}\n' --specfile $TWD/dist/tmp/testpackage_custom_scriptlet.spec"'
|
@@ -0,0 +1,14 @@
|
|
1
|
+
%triggerpostun -- pupmod-old-package
|
2
|
+
|
3
|
+
echo
|
4
|
+
echo "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@"
|
5
|
+
echo "@@@@@@ Executing SIMP-3895 workaround @@@@@@"
|
6
|
+
echo "@@@@@@ @@@@@@"
|
7
|
+
echo "@@@@@@ upgrading from obsoleted pkg @@@@@@"
|
8
|
+
echo "@@@@@@ 'pupmod-old-package' @@@@@@"
|
9
|
+
echo "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@"
|
10
|
+
echo
|
11
|
+
echo "pupmod-new-package: post 1=2 (triggered by: %triggerpostun -- pupmod-old-package)"
|
12
|
+
|
13
|
+
# re-send the 'post' message
|
14
|
+
/usr/local/sbin/simp_rpm_helper --rpm_dir=/usr/share/simp/modules/package --rpm_section='post' --rpm_status=2
|
@@ -0,0 +1 @@
|
|
1
|
+
Obsoletes: pupmod-old-package < 2.1.0
|