simp-rake-helpers 5.25.0 → 6.0.0

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 (129) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +26 -0
  3. data/Gemfile +13 -6
  4. data/lib/simp/command_utils.rb +6 -3
  5. data/lib/simp/componentinfo.rb +47 -33
  6. data/lib/simp/local_gpg_signing_key.rb +302 -303
  7. data/lib/simp/packer/iso_vars_json.rb +17 -15
  8. data/lib/simp/rake/build/auto.rb +415 -432
  9. data/lib/simp/rake/build/build.rb +119 -124
  10. data/lib/simp/rake/build/clean.rb +39 -39
  11. data/lib/simp/rake/build/code.rb +125 -128
  12. data/lib/simp/rake/build/constants.rb +7 -4
  13. data/lib/simp/rake/build/deps.rb +196 -207
  14. data/lib/simp/rake/build/helpers.rb +17 -13
  15. data/lib/simp/rake/build/iso.rb +404 -411
  16. data/lib/simp/rake/build/pkg.rb +752 -759
  17. data/lib/simp/rake/build/rpmdeps.rb +70 -70
  18. data/lib/simp/rake/build/spec.rb +44 -46
  19. data/lib/simp/rake/build/tar.rb +169 -173
  20. data/lib/simp/rake/build/unpack.rb +105 -107
  21. data/lib/simp/rake/build/upload.rb +93 -102
  22. data/lib/simp/rake/fixtures.rb +69 -66
  23. data/lib/simp/rake/helpers/rpm_spec.rb +10 -7
  24. data/lib/simp/rake/helpers/version.rb +3 -1
  25. data/lib/simp/rake/helpers.rb +12 -10
  26. data/lib/simp/rake/pkg.rb +417 -440
  27. data/lib/simp/rake/pupmod/helpers.rb +100 -87
  28. data/lib/simp/rake/pupmod/module_build.rb +39 -0
  29. data/lib/simp/rake/rubygem.rb +57 -56
  30. data/lib/simp/rake.rb +34 -29
  31. data/lib/simp/relchecks.rb +52 -43
  32. data/lib/simp/rpm.rb +123 -127
  33. data/lib/simp/rpm_signer.rb +57 -55
  34. data/lib/simp/yum.rb +54 -53
  35. data/spec/acceptance/nodesets/{default_ruby3_1.yml → almalinux10.yml} +4 -4
  36. data/spec/acceptance/nodesets/{default.yml → almalinux8.yml} +2 -2
  37. data/spec/acceptance/nodesets/almalinux9.yml +25 -0
  38. data/spec/acceptance/suites/default/00_pkg_rpm_custom_scriptlets_spec.rb +23 -28
  39. data/spec/acceptance/suites/default/10_pkg_rpm_spec.rb +54 -56
  40. data/spec/acceptance/suites/default/30_pkg_misc_spec.rb +17 -19
  41. data/spec/acceptance/suites/default/50_local_gpg_signing_key_spec.rb +5 -5
  42. data/spec/acceptance/suites/default/55_build_pkg_signing_spec.rb +109 -101
  43. data/spec/acceptance/suites/default/files/testpackage/spec/classes/init_spec.rb +1 -0
  44. data/spec/acceptance/suites/default/files/testpackage/spec/files/mock_something.rb +3 -1
  45. data/spec/acceptance/suites/default/files/testpackage/utils/convert_v1_to_v2.rb +2 -0
  46. data/spec/acceptance/suites/default/support/build_project_helpers.rb +20 -17
  47. data/spec/acceptance/suites/default/support/build_user_helpers.rb +4 -2
  48. data/spec/acceptance/suites/default/support/pkg_rpm_helpers.rb +30 -31
  49. data/spec/acceptance/support/simp_rake_helpers.rb +3 -1
  50. data/spec/lib/simp/command_utils_spec.rb +13 -10
  51. data/spec/lib/simp/componentinfo_changelog_regex_spec.rb +33 -33
  52. data/spec/lib/simp/componentinfo_spec.rb +99 -86
  53. data/spec/lib/simp/packer/iso_vars_json_spec.rb +16 -14
  54. data/spec/lib/simp/rake/build/helpers_spec.rb +7 -7
  55. data/spec/lib/simp/rake/build/rpmdeps_spec.rb +48 -46
  56. data/spec/lib/simp/rake/helpers_spec.rb +6 -5
  57. data/spec/lib/simp/rake/pkg_spec.rb +7 -5
  58. data/spec/lib/simp/rake/pupmod/fixtures/othermod/spec/classes/init_spec.rb +3 -1
  59. data/spec/lib/simp/rake/pupmod/fixtures/othermod/spec/spec_helper.rb +2 -0
  60. data/spec/lib/simp/rake/pupmod/fixtures/simpmod/spec/acceptance/suites/default/class_spec.rb +6 -5
  61. data/spec/lib/simp/rake/pupmod/fixtures/simpmod/spec/classes/init_spec.rb +51 -33
  62. data/spec/lib/simp/rake/pupmod/fixtures/simpmod/spec/spec_helper.rb +15 -16
  63. data/spec/lib/simp/rake/pupmod/fixtures/simpmod/spec/spec_helper_acceptance.rb +9 -9
  64. data/spec/lib/simp/rake/pupmod/helpers_spec.rb +20 -19
  65. data/spec/lib/simp/rake/pupmod/module_build_spec.rb +87 -0
  66. data/spec/lib/simp/rake_spec.rb +7 -6
  67. data/spec/lib/simp/relchecks_check_rpm_changelog_spec.rb +26 -31
  68. data/spec/lib/simp/relchecks_compare_latest_tag_spec.rb +32 -26
  69. data/spec/lib/simp/relchecks_create_tag_changelog_spec.rb +27 -19
  70. data/spec/lib/simp/rpm_signer_spec.rb +45 -39
  71. data/spec/lib/simp/rpm_spec.rb +190 -194
  72. data/spec/spec_helper.rb +4 -2
  73. data/spec/spec_helper_acceptance.rb +3 -5
  74. metadata +37 -72
  75. data/bin/simp_rake_helpers +0 -3
  76. data/lib/simp/ci/gitlab.rb +0 -226
  77. data/lib/simp/rake/ci.rb +0 -31
  78. data/spec/lib/simp/ci/files/global_nodesets_only/spec/acceptance/nodesets/default.yml +0 -41
  79. data/spec/lib/simp/ci/files/global_nodesets_only/spec/acceptance/nodesets/oel.yml +0 -41
  80. data/spec/lib/simp/ci/files/job_broken_link_nodeset/spec/acceptance/nodesets/centos.yml +0 -41
  81. data/spec/lib/simp/ci/files/job_broken_link_nodeset/spec/acceptance/nodesets/oel.yml +0 -41
  82. data/spec/lib/simp/ci/files/job_broken_link_nodeset/spec/acceptance/suites/default/class_spec.rb +0 -0
  83. data/spec/lib/simp/ci/files/job_invalid_nodeset/spec/acceptance/nodesets/default.yml +0 -41
  84. data/spec/lib/simp/ci/files/job_invalid_nodeset/spec/acceptance/nodesets/oel.yml +0 -41
  85. data/spec/lib/simp/ci/files/job_invalid_nodeset/spec/acceptance/suites/default/class_spec.rb +0 -0
  86. data/spec/lib/simp/ci/files/job_invalid_suite/spec/acceptance/nodesets/default.yml +0 -41
  87. data/spec/lib/simp/ci/files/job_invalid_suite/spec/acceptance/nodesets/oel.yml +0 -41
  88. data/spec/lib/simp/ci/files/job_invalid_suite/spec/acceptance/suites/default/class_spec.rb +0 -0
  89. data/spec/lib/simp/ci/files/job_missing_nodeset/spec/acceptance/nodesets/default.yml +0 -41
  90. data/spec/lib/simp/ci/files/job_missing_nodeset/spec/acceptance/nodesets/oel.yml +0 -41
  91. data/spec/lib/simp/ci/files/job_missing_nodeset/spec/acceptance/suites/default/class_spec.rb +0 -0
  92. data/spec/lib/simp/ci/files/job_missing_suite_and_nodeset/spec/acceptance/nodesets/default.yml +0 -41
  93. data/spec/lib/simp/ci/files/job_missing_suite_and_nodeset/spec/acceptance/nodesets/oel.yml +0 -41
  94. data/spec/lib/simp/ci/files/job_missing_suite_and_nodeset/spec/acceptance/suites/default/class_spec.rb +0 -0
  95. data/spec/lib/simp/ci/files/multiple_invalid_jobs/spec/acceptance/nodesets/default.yml +0 -41
  96. data/spec/lib/simp/ci/files/multiple_invalid_jobs/spec/acceptance/nodesets/oel.yml +0 -41
  97. data/spec/lib/simp/ci/files/multiple_invalid_jobs/spec/acceptance/suites/default/class_spec.rb +0 -0
  98. data/spec/lib/simp/ci/files/multiple_invalid_jobs/spec/acceptance/suites/feature-1/feature-1_spec.rb +0 -0
  99. data/spec/lib/simp/ci/files/multiple_invalid_jobs/spec/acceptance/suites/feature_2/feature_2_spec.rb +0 -0
  100. data/spec/lib/simp/ci/files/multiple_invalid_jobs/spec/acceptance/suites/feature_2/nodesets/default.yml +0 -35
  101. data/spec/lib/simp/ci/files/multiple_invalid_jobs/spec/acceptance/suites/feature_2/nodesets/oel.yml +0 -35
  102. data/spec/lib/simp/ci/files/multiple_valid_jobs/spec/acceptance/nodesets/default.yml +0 -41
  103. data/spec/lib/simp/ci/files/multiple_valid_jobs/spec/acceptance/nodesets/oel.yml +0 -41
  104. data/spec/lib/simp/ci/files/multiple_valid_jobs/spec/acceptance/suites/default/class_spec.rb +0 -0
  105. data/spec/lib/simp/ci/files/multiple_valid_jobs/spec/acceptance/suites/feature-1/feature-1_spec.rb +0 -0
  106. data/spec/lib/simp/ci/files/multiple_valid_jobs/spec/acceptance/suites/feature_2/feature_2_spec.rb +0 -0
  107. data/spec/lib/simp/ci/files/multiple_valid_jobs/spec/acceptance/suites/feature_2/nodesets/default.yml +0 -35
  108. data/spec/lib/simp/ci/files/multiple_valid_jobs/spec/acceptance/suites/feature_2/nodesets/oel.yml +0 -35
  109. data/spec/lib/simp/ci/files/no_acceptance_tests/spec/spec_helper.rb +0 -0
  110. data/spec/lib/simp/ci/files/no_gitlab_config_with_tests/spec/acceptance/nodesets/default.yml +0 -41
  111. data/spec/lib/simp/ci/files/no_gitlab_config_with_tests/spec/acceptance/nodesets/oel.yml +0 -41
  112. data/spec/lib/simp/ci/files/no_gitlab_config_with_tests/spec/acceptance/suites/default/class_spec.rb +0 -0
  113. data/spec/lib/simp/ci/files/no_gitlab_config_without_tests/spec/acceptance/nodesets/default.yml +0 -41
  114. data/spec/lib/simp/ci/files/no_gitlab_config_without_tests/spec/acceptance/nodesets/oel.yml +0 -41
  115. data/spec/lib/simp/ci/files/suite_skeleton_only/spec/acceptance/nodesets/centos.yml +0 -41
  116. data/spec/lib/simp/ci/files/suite_skeleton_only/spec/acceptance/nodesets/oel.yml +0 -41
  117. data/spec/lib/simp/ci/files/valid_job_global_nodeset/spec/acceptance/nodesets/default.yml +0 -41
  118. data/spec/lib/simp/ci/files/valid_job_global_nodeset/spec/acceptance/nodesets/oel.yml +0 -41
  119. data/spec/lib/simp/ci/files/valid_job_global_nodeset/spec/acceptance/suites/default/class_spec.rb +0 -0
  120. data/spec/lib/simp/ci/files/valid_job_nodeset_dir_link/spec/acceptance/nodesets/default.yml +0 -41
  121. data/spec/lib/simp/ci/files/valid_job_nodeset_dir_link/spec/acceptance/nodesets/oel.yml +0 -41
  122. data/spec/lib/simp/ci/files/valid_job_nodeset_dir_link/spec/acceptance/suites/default/class_spec.rb +0 -0
  123. data/spec/lib/simp/ci/files/valid_job_nodeset_link/spec/acceptance/suites/default/class_spec.rb +0 -0
  124. data/spec/lib/simp/ci/files/valid_job_nodeset_link/spec/acceptance/suites/default/nodesets/centos.yml +0 -41
  125. data/spec/lib/simp/ci/files/valid_job_nodeset_link/spec/acceptance/suites/default/nodesets/oel.yml +0 -41
  126. data/spec/lib/simp/ci/files/valid_job_suite_nodeset/spec/acceptance/suites/default/class_spec.rb +0 -0
  127. data/spec/lib/simp/ci/files/valid_job_suite_nodeset/spec/acceptance/suites/default/nodesets/default.yml +0 -41
  128. data/spec/lib/simp/ci/files/valid_job_suite_nodeset/spec/acceptance/suites/default/nodesets/oel.yml +0 -41
  129. data/spec/lib/simp/ci/gitlab_spec.rb +0 -245
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper_acceptance'
2
4
  require_relative 'support/build_user_helpers'
3
5
  require_relative 'support/build_project_helpers'
@@ -17,7 +19,6 @@ def run_opts
17
19
  end
18
20
 
19
21
  describe 'rake pkg:signrpms and pkg:checksig' do
20
-
21
22
  # Clean out RPMs dir and copy in a fresh dummy RPM
22
23
  def prep_rpms_dir(rpms_dir, src_rpms, opts = {})
23
24
  copy_cmds = src_rpms.map { |_rpm| "cp -a '#{_rpm}' '#{rpms_dir}'" }.join('; ')
@@ -28,17 +29,16 @@ describe 'rake pkg:signrpms and pkg:checksig' do
28
29
  shared_context 'a freshly-scaffolded test project' do |dir, opts = {}|
29
30
  test__dir = "#{build_user_homedir}/test-#{dir}"
30
31
  rpms__dir = "#{test__dir}/test.rpms"
31
- src__rpm = "#{build_user_host_files}/spec/lib/simp/files/testpackage-1-0.noarch.rpm"
32
+ src__rpm = "#{build_user_host_files}/spec/lib/simp/files/testpackage-1-0.noarch.rpm"
32
33
  host__dirs = {}
33
- gpg__keysdir = opts[:gpg_keysdir] ? opts[:gpg_keysdir] : "#{test__dir}/.dev_gpgkeys"
34
+ gpg__keysdir = opts[:gpg_keysdir] || "#{test__dir}/.dev_gpgkeys"
34
35
  extra__env = opts[:gpg_keysdir] ? "SIMP_PKG_build_keys_dir=#{gpg__keysdir}" : ''
35
- digest__algo = opts[:digest_algo] ? opts[:digest_algo] : nil
36
-
36
+ digest__algo = opts[:digest_algo] || nil
37
37
 
38
38
  hosts.each do |host|
39
- dist_dir = distribution_dir(host, test__dir, run_opts)
39
+ dist_dir = distribution_dir(host, test__dir)
40
40
  host__dirs[host] = {
41
- test_dir: test__dir,
41
+ test_dir: test__dir,
42
42
  dvd_dir: "#{dist_dir}/DVD"
43
43
  }
44
44
  host__dirs[host.name] = host__dirs[host]
@@ -65,14 +65,19 @@ describe 'rake pkg:signrpms and pkg:checksig' do
65
65
  let(:dev_keydir) { "#{gpg__keysdir}/dev" }
66
66
  let(:extra_env) { extra__env }
67
67
  let(:digest_algo_param) { digest__algo }
68
- let(:digest_algo_result) { digest__algo ? digest__algo.upcase : 'SHA256' }
69
- let(:signrpm_cmd) {
68
+ let(:digest_algo_result) { digest__algo ? digest__algo.upcase : 'SHA256' }
69
+ let(:signrpm_cmd) do
70
70
  extra_args = digest_algo_param ? ",false,#{digest_algo_param}" : ''
71
71
  "SIMP_PKG_verbose=yes #{extra_env} bundle exec rake pkg:signrpms[dev,'#{rpms_dir}'#{extra_args}]"
72
- }
72
+ end
73
73
  let(:checksig_cmd) { "#{extra_env} bundle exec rake pkg:checksig[#{rpms_dir}]" }
74
74
  end
75
75
 
76
+ # The signature is read with `rpm -qp --qf 'Signature : %{RSAHEADER:pgpsig}'`
77
+ # rather than `rpm -qi`. rpm >= 4.19 (EL10) signs the package header only, so
78
+ # the legacy SIGPGP/SIGGPG tags backing the `rpm -qi` "Signature" field are
79
+ # empty there; RSAHEADER holds the header signature and renders the same
80
+ # "<algo>, <date>, Key ID <id>" string (or "(none)") on EL8/9/10.
76
81
  let(:rpm_unsigned_regex) do
77
82
  %r{^Signature\s+:\s+\(none\)$}
78
83
  end
@@ -98,6 +103,7 @@ describe 'rake pkg:signrpms and pkg:checksig' do
98
103
 
99
104
  shared_examples 'it verifies RPM signatures' do
100
105
  let(:public_gpgkeys_dir) { 'src/assets/gpgkeys/GPGKEYS' }
106
+
101
107
  it 'verifies RPM signatures' do
102
108
  hosts.each do |host|
103
109
  # mock out the simp-gpgkeys project checkout so that the pkg:checksig
@@ -113,18 +119,18 @@ describe 'rake pkg:signrpms and pkg:checksig' do
113
119
  it 'creates a new GPG dev signing key' do
114
120
  on(hosts, %(#{run_cmd} "cd '#{test_dir}'; #{signrpm_cmd}"), run_opts)
115
121
  hosts.each do |host|
116
- expect(dev_signing_key_id(host, dev_keydir, run_opts)).to_not be_empty
117
- expect(file_exists_on(host,"#{dirs[host][:dvd_dir]}/RPM-GPG-KEY-SIMP-Dev")).to be true
122
+ expect(dev_signing_key_id(host, dev_keydir, run_opts)).not_to be_empty
123
+ expect(file_exists_on(host, "#{dirs[host][:dvd_dir]}/RPM-GPG-KEY-SIMP-Dev")).to be true
118
124
  end
119
125
  end
120
126
 
121
- include_examples('it does not leave the gpg-agent daemon running')
127
+ it_behaves_like('it does not leave the gpg-agent daemon running')
122
128
  end
123
129
 
124
130
  shared_examples 'it begins with unsigned RPMs' do
125
131
  it 'begins with unsigned RPMs' do
126
132
  prep_rpms_dir(rpms_dir, [src_rpm], run_opts)
127
- rpms_before_signing = on(hosts, "rpm -qip '#{test_rpm}' | grep ^Signature", run_opts)
133
+ rpms_before_signing = on(hosts, "rpm -qp --qf 'Signature : %{RSAHEADER:pgpsig}\\n' '#{test_rpm}'", run_opts)
128
134
  rpms_before_signing.each do |result|
129
135
  expect(result.stdout).to match rpm_unsigned_regex
130
136
  end
@@ -136,9 +142,9 @@ describe 'rake pkg:signrpms and pkg:checksig' do
136
142
  hosts.each do |host|
137
143
  # NOTE: pkg:signrpms will not actually fail if it can't sign a RPM
138
144
  on(hosts, %(#{run_cmd} "cd '#{test_dir}'; SIMP_PKG_verbose=yes #{signrpm_cmd}"), run_opts)
139
- expect(file_exists_on(host,"#{dirs[host][:dvd_dir]}/RPM-GPG-KEY-SIMP-Dev")).to be true
145
+ expect(file_exists_on(host, "#{dirs[host][:dvd_dir]}/RPM-GPG-KEY-SIMP-Dev")).to be true
140
146
 
141
- result = on(host, "rpm -qip '#{test_rpm}' | grep ^Signature", run_opts)
147
+ result = on(host, "rpm -qp --qf 'Signature : %{RSAHEADER:pgpsig}\\n' '#{test_rpm}'", run_opts)
142
148
  expect(result.stdout).to match rpm_signed_regex
143
149
  signed_rpm_data = rpm_signed_regex.match(result.stdout)
144
150
  expect(signed_rpm_data[:key_id]).to eql dev_signing_key_id(host, dev_keydir, run_opts)
@@ -146,7 +152,7 @@ describe 'rake pkg:signrpms and pkg:checksig' do
146
152
  end
147
153
  end
148
154
 
149
- include_examples('it does not leave the gpg-agent daemon running')
155
+ it_behaves_like('it does not leave the gpg-agent daemon running')
150
156
  end
151
157
 
152
158
  shared_examples 'it signs RPM packages using existing GPG dev signing key' do
@@ -156,7 +162,7 @@ describe 'rake pkg:signrpms and pkg:checksig' do
156
162
 
157
163
  on(hosts, %(#{run_cmd} "cd '#{test_dir}'; #{signrpm_cmd}"), run_opts)
158
164
 
159
- result = on(host, "rpm -qip '#{test_rpm}' | grep ^Signature", run_opts)
165
+ result = on(host, "rpm -qp --qf 'Signature : %{RSAHEADER:pgpsig}\\n' '#{test_rpm}'", run_opts)
160
166
  expect(result.stdout).to match rpm_signed_regex
161
167
  signed_rpm_data = rpm_signed_regex.match(result.stdout)
162
168
  expect(signed_rpm_data[:key_id]).to eql existing_key_id
@@ -164,25 +170,24 @@ describe 'rake pkg:signrpms and pkg:checksig' do
164
170
  end
165
171
  end
166
172
 
167
- include_examples('it does not leave the gpg-agent daemon running')
173
+ it_behaves_like('it does not leave the gpg-agent daemon running')
168
174
  end
169
175
 
170
-
171
176
  describe 'when starting without a dev key and no RPMs to sign' do
172
177
  include_context('a freshly-scaffolded test project', 'create-key')
173
- include_examples('it creates a new GPG dev signing key')
178
+ it_behaves_like('it creates a new GPG dev signing key')
174
179
  end
175
180
 
176
181
  describe 'when starting without a dev key and RPMs to sign' do
177
182
  include_context('a freshly-scaffolded test project', 'signrpms')
178
- include_examples('it begins with unsigned RPMs')
179
- include_examples('it creates GPG dev signing key and signs packages')
180
- include_examples('it verifies RPM signatures')
183
+ it_behaves_like('it begins with unsigned RPMs')
184
+ it_behaves_like('it creates GPG dev signing key and signs packages')
185
+ it_behaves_like('it verifies RPM signatures')
181
186
 
182
187
  context 'when there is an unexpired GPG dev signing key and the packages are unsigned' do
183
- include_examples('it begins with unsigned RPMs')
184
- include_examples('it signs RPM packages using existing GPG dev signing key')
185
- include_examples('it verifies RPM signatures')
188
+ it_behaves_like('it begins with unsigned RPMs')
189
+ it_behaves_like('it signs RPM packages using existing GPG dev signing key')
190
+ it_behaves_like('it verifies RPM signatures')
186
191
  end
187
192
  end
188
193
 
@@ -195,27 +200,27 @@ describe 'rake pkg:signrpms and pkg:checksig' do
195
200
  copy_expired_keydir_to_dev_cmds = [
196
201
  "mkdir -p '$(dirname '#{dev_keydir}')'",
197
202
  "cp -aT '#{expired_keydir}' '#{dev_keydir}'",
198
- "ls -lart '#{expired_keydir}'"
203
+ "ls -lart '#{expired_keydir}'",
199
204
  ].join(' && ')
200
205
  on(host, %(#{run_cmd} "#{copy_expired_keydir_to_dev_cmds}"), run_opts)
201
206
  result = on(host, %(#{run_cmd} "gpg --list-keys --homedir='#{dev_keydir}'"), run_opts)
202
- expect(result.stdout).to match(/expired: 2018-04-06/)
207
+ expect(result.stdout).to include('expired: 2018-04-06')
203
208
  end
204
209
  end
205
210
 
206
- include_examples('it begins with unsigned RPMs')
207
- include_examples('it creates GPG dev signing key and signs packages')
208
- include_examples('it verifies RPM signatures')
211
+ it_behaves_like('it begins with unsigned RPMs')
212
+ it_behaves_like('it creates GPG dev signing key and signs packages')
213
+ it_behaves_like('it verifies RPM signatures')
209
214
  end
210
215
 
211
216
  describe 'when packages are already signed' do
212
- let(:keysdir) { "#{test_dir}/.dev_gpgkeys" }
217
+ let(:keysdir) { "#{test_dir}/.dev_gpgkeys" }
213
218
 
214
219
  include_context('a freshly-scaffolded test project', 'force')
215
220
 
216
221
  context 'initial package signing' do
217
- include_examples('it begins with unsigned RPMs')
218
- include_examples('it creates GPG dev signing key and signs packages')
222
+ it_behaves_like('it begins with unsigned RPMs')
223
+ it_behaves_like('it creates GPG dev signing key and signs packages')
219
224
  end
220
225
 
221
226
  context 'when force is disabled' do
@@ -229,12 +234,12 @@ describe 'rake pkg:signrpms and pkg:checksig' do
229
234
  # force defaults to false
230
235
  on(host, %(#{run_cmd} "cd '#{test_dir}'; bundle exec rake pkg:signrpms[dev,'#{rpms_dir}']"), run_opts)
231
236
 
232
- result = on(host, "rpm -qip '#{test_rpm}' | grep ^Signature", run_opts)
237
+ result = on(host, "rpm -qp --qf 'Signature : %{RSAHEADER:pgpsig}\\n' '#{test_rpm}'", run_opts)
233
238
  expect(result.stdout).to match rpm_signed_regex
234
239
  signed_rpm_data = rpm_signed_regex.match(result.stdout)
235
240
 
236
241
  # verify RPM is not signed with the new signing key
237
- expect(signed_rpm_data[:key_id]).to_not eql dev_signing_key_id(host, dev_keydir, run_opts)
242
+ expect(signed_rpm_data[:key_id]).not_to eql dev_signing_key_id(host, dev_keydir, run_opts)
238
243
  end
239
244
  end
240
245
 
@@ -246,8 +251,7 @@ describe 'rake pkg:signrpms and pkg:checksig' do
246
251
  on(host, %(#{run_cmd} "cd '#{test_dir}'; mkdir -p #{public_gpgkeys_dir}"), run_opts)
247
252
  on(host, %(#{run_cmd} "cd '#{test_dir}'; touch #{public_gpgkeys_dir}/RPM-GPG-KEY-empty"), run_opts)
248
253
  result = on(host, %(#{run_cmd} "cd '#{test_dir}'; #{checksig_cmd}"),
249
- :acceptable_exit_codes => [1]
250
- )
254
+ :acceptable_exit_codes => [1])
251
255
 
252
256
  expect(result.stderr).to match('ERROR: Untrusted RPMs found in the repository')
253
257
  end
@@ -264,7 +268,7 @@ describe 'rake pkg:signrpms and pkg:checksig' do
264
268
  hosts.each do |host|
265
269
  on(host, %(#{run_cmd} "cd '#{test_dir}'; bundle exec rake pkg:signrpms[dev,'#{rpms_dir}',true]"), run_opts)
266
270
 
267
- result = on(host, "rpm -qip '#{test_rpm}' | grep ^Signature", run_opts)
271
+ result = on(host, "rpm -qp --qf 'Signature : %{RSAHEADER:pgpsig}\\n' '#{test_rpm}'", run_opts)
268
272
  expect(result.stdout).to match rpm_signed_regex
269
273
  signed_rpm_data = rpm_signed_regex.match(result.stdout)
270
274
 
@@ -278,36 +282,39 @@ describe 'rake pkg:signrpms and pkg:checksig' do
278
282
  describe 'when SIMP_PKG_build_keys_dir is set' do
279
283
  opts = { :gpg_keysdir => '/home/build_user/.dev_gpgpkeys' }
280
284
  include_context('a freshly-scaffolded test project', 'custom-keys-dir', opts)
281
- include_examples('it begins with unsigned RPMs')
282
- include_examples('it creates GPG dev signing key and signs packages')
285
+ it_behaves_like('it begins with unsigned RPMs')
286
+ it_behaves_like('it creates GPG dev signing key and signs packages')
283
287
  end
284
288
 
285
289
  describe 'when digest algorithm is specified' do
286
290
  opts = { :digest_algo => 'sha384' }
287
291
  include_context('a freshly-scaffolded test project', 'custom-digest-algo', opts)
288
- include_examples('it begins with unsigned RPMs')
289
- include_examples('it creates GPG dev signing key and signs packages')
290
- include_examples('it verifies RPM signatures')
292
+ it_behaves_like('it begins with unsigned RPMs')
293
+ it_behaves_like('it creates GPG dev signing key and signs packages')
294
+ it_behaves_like('it verifies RPM signatures')
291
295
  end
292
296
 
293
297
  describe 'when some rpm signing fails' do
294
298
  include_context('a freshly-scaffolded test project', 'signing-failure')
295
- include_examples('it begins with unsigned RPMs')
299
+ # NOTE: include_examples (not it_behaves_like) is required here so that
300
+ # 'begins with unsigned RPMs' runs before the standalone it blocks below.
301
+ # it_behaves_like creates a nested group that runs *after* all standalone
302
+ # it blocks in the same describe, which would break test ordering.
303
+ include_examples('it begins with unsigned RPMs') # rubocop:disable RSpec/IncludeExamples
296
304
 
297
- it 'should create a malformed RPM' do
305
+ it 'creates a malformed RPM' do
298
306
  on(hosts, %(#{run_cmd} "echo 'OOPS' > #{rpms_dir}/oops-test.rpm"))
299
307
  end
300
308
 
301
- it 'should sign all valid RPMs before failing' do
309
+ it 'signs all valid RPMs before failing' do
302
310
  hosts.each do |host|
303
311
  result = on(host,
304
- %(#{run_cmd} "cd '#{test_dir}'; SIMP_PKG_verbose="yes" #{signrpm_cmd}"),
305
- :acceptable_exit_codes => [1]
306
- )
312
+ %(#{run_cmd} "cd '#{test_dir}'; SIMP_PKG_verbose="yes" #{signrpm_cmd}"),
313
+ :acceptable_exit_codes => [1])
307
314
 
308
315
  expect(result.stderr).to match('ERROR: Failed to sign some RPMs')
309
316
 
310
- signature_check = on(host, "rpm -qip '#{test_rpm}' | grep ^Signature", run_opts)
317
+ signature_check = on(host, "rpm -qp --qf 'Signature : %{RSAHEADER:pgpsig}\\n' '#{test_rpm}'", run_opts)
311
318
  expect(signature_check.stdout).to match rpm_signed_regex
312
319
  end
313
320
  end
@@ -315,74 +322,75 @@ describe 'rake pkg:signrpms and pkg:checksig' do
315
322
 
316
323
  describe 'when wrong keyword password is specified' do
317
324
  include_context('a freshly-scaffolded test project', 'wrong-password')
318
- include_examples('it creates a new GPG dev signing key')
325
+ # NOTE: include_examples (not it_behaves_like) is required here so that
326
+ # shared examples run at their insertion point, before the standalone it
327
+ # blocks that depend on the state they set up.
328
+ include_examples('it creates a new GPG dev signing key') # rubocop:disable RSpec/IncludeExamples
319
329
 
320
- it 'should corrupt the password of new key' do
330
+ it 'corrupts the password of new key' do
321
331
  key_gen_file = File.join(dev_keydir, 'gengpgkey')
322
332
  on(hosts, "sed -ci -e \"s/^Passphrase: /Passphrase: OOPS/\" #{key_gen_file}")
323
333
  end
324
334
 
325
- include_examples('it begins with unsigned RPMs')
335
+ include_examples('it begins with unsigned RPMs') # rubocop:disable RSpec/IncludeExamples
326
336
 
327
- it 'should fail to sign any rpms and notify user of each failure' do
337
+ it 'fails to sign any rpms and notify user of each failure' do
328
338
  hosts.each do |host|
329
339
  result = on(host,
330
- %(#{run_cmd} "cd '#{test_dir}'; SIMP_PKG_verbose="yes" #{signrpm_cmd}"),
331
- :acceptable_exit_codes => [1]
332
- )
340
+ %(#{run_cmd} "cd '#{test_dir}'; SIMP_PKG_verbose="yes" #{signrpm_cmd}"),
341
+ :acceptable_exit_codes => [1])
333
342
 
334
- err_msg = %r(Error occurred while attempting to sign #{test_rpm})
343
+ err_msg = %r{Error occurred while attempting to sign #{test_rpm}}
335
344
  expect(result.stderr).to match(err_msg)
336
345
 
337
- signature_check = on(host, "rpm -qip '#{test_rpm}' | grep ^Signature", run_opts)
346
+ signature_check = on(host, "rpm -qp --qf 'Signature : %{RSAHEADER:pgpsig}\\n' '#{test_rpm}'", run_opts)
338
347
  expect(signature_check.stdout).to match rpm_unsigned_regex
339
348
  end
340
349
  end
341
350
  end
342
351
 
343
352
  hosts.each do |host|
344
- os_major = fact_on(host,'os.release.major')
345
- if os_major > '7'
346
- # this problem only happens on EL > 7 in a docker container
347
- describe "when gpg-agent's socket path is too long on #{host}" do
348
- opts = { :gpg_keysdir => '/home/build_user/this/results/in/a/gpg_agent/socket/path/that/is/longer/than/one/hundred/eight/characters' }
349
- include_context('a freshly-scaffolded test project', 'long-socket-path', opts)
350
-
351
- context 'when the gpg key needs to be created ' do
352
- it 'should fail to sign any rpms' do
353
- on(host,
354
- %(#{run_cmd} "cd '#{test_dir}'; SIMP_PKG_verbose="yes" #{signrpm_cmd}"),
355
- :acceptable_exit_codes => [1]
356
- )
357
- end
353
+ os_major = fact_on(host, 'os.release.major')
354
+ next unless os_major > '7'
355
+
356
+ # this problem only happens on EL > 7 in a docker container
357
+ describe "when gpg-agent's socket path is too long on #{host}" do
358
+ opts = { :gpg_keysdir => '/home/build_user/this/results/in/a/gpg_agent/socket/path/that/is/longer/than/one/hundred/eight/characters' }
359
+ include_context('a freshly-scaffolded test project', 'long-socket-path', opts)
360
+
361
+ context 'when the gpg key needs to be created' do
362
+ it 'fails to sign any rpms' do
363
+ on(host,
364
+ %(#{run_cmd} "cd '#{test_dir}'; SIMP_PKG_verbose="yes" #{signrpm_cmd}"),
365
+ :acceptable_exit_codes => [1])
358
366
  end
367
+ end
368
+
369
+ context 'when the gpg key already exists' do
370
+ # This would be when a GPG key dir was populated with keys generated elsewhere.
371
+ # Reuse the keys from an earlier test.
372
+ it 'copies existing key files into the gpg key dir' do
373
+ source_dir = '/home/build_user/test-create-key/.dev_gpgkeys/dev'
374
+ on(host, %(#{run_cmd} "cp -r #{source_dir}/* #{dev_keydir}"))
375
+ end
376
+
377
+ # NOTE: include_examples (not it_behaves_like) required for ordering.
378
+ include_examples('it begins with unsigned RPMs') # rubocop:disable RSpec/IncludeExamples
379
+
380
+ it 'fails to sign any rpms and notify user of each failure' do
381
+ # For rpm-sign-4.14.2-11.el8_0, 'rpm --resign' hangs instead of failing
382
+ # when gpg-agent fails to start.
383
+ # Set the default smaller than the 30 second default, so that we don't
384
+ # wait so long for the failure.
385
+ result = on(host,
386
+ %(#{run_cmd} "cd '#{test_dir}'; SIMP_PKG_rpmsign_timeout=5 SIMP_PKG_verbose="yes" #{signrpm_cmd}"),
387
+ :acceptable_exit_codes => [1])
388
+
389
+ err_msg = %r{Failed to sign}
390
+ expect(result.stderr).to match(err_msg)
359
391
 
360
- context 'when the gpg key already exists' do
361
- # This would be when a GPG key dir was populated with keys generated elsewhere.
362
- # Reuse the keys from an earlier test.
363
- it 'should copy existing key files into the gpg key dir' do
364
- source_dir = '/home/build_user/test-create-key/.dev_gpgkeys/dev'
365
- on(host, %(#{run_cmd} "cp -r #{source_dir}/* #{dev_keydir}"))
366
- end
367
-
368
- include_examples('it begins with unsigned RPMs')
369
-
370
- it 'should fail to sign any rpms and notify user of each failure' do
371
- # For rpm-sign-4.14.2-11.el8_0, 'rpm --resign' hangs instead of failing
372
- # when gpg-agent fails to start.
373
- # Set the default smaller than the 30 second default, so that we don't
374
- # wait so long for the failure.
375
- result = on(host,
376
- %(#{run_cmd} "cd '#{test_dir}'; SIMP_PKG_rpmsign_timeout=5 SIMP_PKG_verbose="yes" #{signrpm_cmd}"),
377
- :acceptable_exit_codes => [1]
378
- )
379
-
380
- err_msg = %r(Failed to sign)
381
- expect(result.stderr).to match(err_msg)
382
-
383
- signature_check = on(host, "rpm -qip '#{test_rpm}' | grep ^Signature", run_opts)
384
- expect(signature_check.stdout).to match rpm_unsigned_regex
385
- end
392
+ signature_check = on(host, "rpm -qp --qf 'Signature : %{RSAHEADER:pgpsig}\\n' '#{test_rpm}'", run_opts)
393
+ expect(signature_check.stdout).to match rpm_unsigned_regex
386
394
  end
387
395
  end
388
396
  end
@@ -1 +1,2 @@
1
1
  #!/usr/bin/env rspec
2
+ # frozen_string_literal: true
@@ -1,3 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
- #This is a mock executable for something
2
+ # frozen_string_literal: true
3
+
4
+ # This is a mock executable for something
3
5
  puts 'hello world'
@@ -1,3 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
2
4
  # convert from version 1 to version 2
3
5
  puts "Running #{File.basename(__FILE__)}"
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Simp::BeakerHelpers::SimpRakeHelpers::BuildProjectHelpers
2
4
  # Scaffolds _just_ enough of a super-release project to run `bundle exec rake
3
5
  # -T` using this repository's source code as the simp-rake-helper source
@@ -19,7 +21,7 @@ module Simp::BeakerHelpers::SimpRakeHelpers::BuildProjectHelpers
19
21
  GEMFILE
20
22
  create_remote_file(hosts, "#{test_dir}/Gemfile", gemfile, opts)
21
23
  on(hosts, "chown build_user:build_user #{test_dir}/Gemfile", opts)
22
- on(hosts, %(#{run_cmd} "cd '#{test_dir}'; rvm use default; bundle --local || bundle"), opts)
24
+ on(hosts, %(#{run_cmd} "cd '#{test_dir}'; bundle --local || bundle"), opts)
23
25
  end
24
26
 
25
27
  # Returns the distribution directory path appropriate for a given SUT
@@ -31,24 +33,24 @@ module Simp::BeakerHelpers::SimpRakeHelpers::BuildProjectHelpers
31
33
  # @param [Host, String, Symbol] host Beaker host
32
34
  # @param [String] proj_dir Absolute path to the parent project directory
33
35
  # If this is set, the returned path will be absolute as well.
34
- # @param [Hash{Symbol=>String}] opts Beaker options Hash for `#on` ({})
35
36
  # @return [String] distribution directory matching the SUT's properties
36
37
  #
37
- def distribution_dir(host, proj_dir, opts = {})
38
- opts ||= {}
38
+ def distribution_dir(host, proj_dir)
39
39
  @distribution_dirs ||= {}
40
40
  return @distribution_dirs[host.to_s] if @distribution_dirs.key?(host.to_s)
41
41
 
42
- result = on(host, %(#{run_cmd} 'facter --yaml'), opts.merge(silent: true))
43
- facts_string = result.stdout.lines[1..-1].join
44
- facts = YAML.load(facts_string)
45
-
46
- # This logic should work regardless of the version of facter
47
- name = facts['operatingsystem'] || facts['os']['name']
48
- maj_rel = facts['operatingsystemmajrelease'] ||
49
- facts.fetch('os', {}).fetch('release', {})['major'] ||
50
- facts['operatingsystemrelease'].split('.').first
51
- architecture = facts['architecture'] || facts.dig('os','architecture')
42
+ # Pull the OS facts straight from the SUT via Beaker rather than scraping
43
+ # `facter --yaml` through build_user's RVM login shell. That login shell
44
+ # can prepend warnings to (or otherwise empty out) the captured stdout,
45
+ # which made `result.stdout.lines[1..]` return nil and blow up parsing.
46
+ #
47
+ # NOTE: `fact_on` takes no Beaker `#on` opts here on purpose -- it renders
48
+ # unrecognized opts (e.g. run_in_parallel) into the `puppet facts show`
49
+ # command line, which puppet then rejects as an invalid option.
50
+ os = fact_on(host, 'os')
51
+ name = os['name']
52
+ maj_rel = os.dig('release', 'major')
53
+ architecture = os['architecture']
52
54
 
53
55
  dir = "#{proj_dir}/build/distributions/#{name}/#{maj_rel}/#{architecture}"
54
56
  @distribution_dirs[host.to_s] = dir
@@ -66,6 +68,7 @@ module Simp::BeakerHelpers::SimpRakeHelpers::BuildProjectHelpers
66
68
  res = on(host, %(#{run_cmd} "gpg --with-colons --fingerprint --homedir='#{key_dir}' 'SIMP Development'"), opts)
67
69
  pub_lines = res.stdout.lines.select { |x| x.start_with?('pub') }
68
70
  raise "No 'SIMP Development' GPG keys found in '#{key_dir}'" if pub_lines.empty?
71
+
69
72
  pub_lines.first.split(':')[4].downcase
70
73
  end
71
74
 
@@ -75,7 +78,6 @@ module Simp::BeakerHelpers::SimpRakeHelpers::BuildProjectHelpers
75
78
  # @param [Host, String, Symbol] host Beaker host
76
79
  # @param [String] gpg_homedir Absolute path to GPG home dir
77
80
  def gpg_agent_running?(host, gpg_homedir)
78
-
79
81
  # This check is being used in tests to verify no gpg-agent for gpg_homedir
80
82
  # is running. On slow VMs, the gpg-agent can take some time to shutdown.
81
83
  # So wait up to 20 seconds for gpg-agent to shutdown before finalizing
@@ -83,10 +85,11 @@ module Simp::BeakerHelpers::SimpRakeHelpers::BuildProjectHelpers
83
85
 
84
86
  retries = 20
85
87
  agent_exists = true
86
- while (agent_exists || (retries > 0))
88
+ while agent_exists || (retries > 0)
87
89
  result = on(host, "pgrep -c -f 'gpg-agent.*homedir.*#{gpg_homedir}'", :accept_all_exit_codes => true)
88
- agent_exists = (result.stdout.strip != '0')
90
+ agent_exists = (result.stdout.strip != '0')
89
91
  break unless agent_exists
92
+
90
93
  sleep 1
91
94
  retries -= 1
92
95
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Simp::BeakerHelpers::SimpRakeHelpers::BuildUserHelpers
2
4
  def build_user_homedir
3
5
  '/home/build_user'
@@ -8,13 +10,13 @@ module Simp::BeakerHelpers::SimpRakeHelpers::BuildUserHelpers
8
10
  end
9
11
 
10
12
  def copy_host_files_into_build_user_homedir(hosts, opts = {})
11
- commands = <<-COMMANDS.gsub(/^ {6}/,'')
13
+ commands = <<-COMMANDS.gsub(%r{^ {6}}, '')
12
14
  cp -aT /host_files #{build_user_host_files} ;
13
15
  find #{build_user_host_files} \\
14
16
  -type d -a \\( -name dist -o -name junit -o -name log \\) \\
15
17
  -exec chmod -R go=u-w {} \\; ;
16
18
  chown -R build_user:build_user #{build_user_host_files}
17
19
  COMMANDS
18
- on(hosts,commands,opts)
20
+ on(hosts, commands, opts)
19
21
  end
20
22
  end
@@ -1,5 +1,7 @@
1
- module Simp::BeakerHelpers::SimpRakeHelpers::PkgRpmHelpers
1
+ # frozen_string_literal: true
2
2
 
3
+ require 'English'
4
+ module Simp::BeakerHelpers::SimpRakeHelpers::PkgRpmHelpers
3
5
  require_relative 'build_user_helpers'
4
6
  include Simp::BeakerHelpers::SimpRakeHelpers::BuildUserHelpers
5
7
 
@@ -7,66 +9,63 @@ module Simp::BeakerHelpers::SimpRakeHelpers::PkgRpmHelpers
7
9
  # passes on useful troubleshooting env vars
8
10
  def rake_cmd
9
11
  cmd = 'bundle exec rake'
10
- %w(
11
- SIMP_RPM_LUA_debug
12
- SIMP_RAKE_PKG_verbose
13
- SIMP_RPM_verbose
14
- ).each do |env_var|
15
- if value = ENV[env_var]
16
- cmd = "#{env_var}=#{value} #{cmd}"
12
+ [
13
+ 'SIMP_RPM_LUA_debug',
14
+ 'SIMP_RAKE_PKG_verbose',
15
+ 'SIMP_RPM_verbose',
16
+ ].each do |env_var|
17
+ if (value = ENV.fetch(env_var, nil))
18
+ cmd = "#{env_var}=#{value} #{cmd}"
17
19
  end
18
20
  end
19
21
  cmd
20
22
  end
21
23
 
22
-
23
24
  # key = what `rpm -q --scripts` calls each scriptlet
24
25
  # value = the label passed to `simp_rpm_helper`
25
26
  def scriptlet_label_map
26
27
  {
27
- 'pretrans' => nil,
28
- 'preinstall' => 'pre',
29
- 'postinstall' => 'post',
30
- 'preuninstall' => 'preun',
28
+ 'pretrans' => nil,
29
+ 'preinstall' => 'pre',
30
+ 'postinstall' => 'post',
31
+ 'preuninstall' => 'preun',
31
32
  'postuninstall' => 'postun',
32
- 'posttrans' => 'posttrans',
33
+ 'posttrans' => 'posttrans'
33
34
  }
34
35
  end
35
36
 
36
-
37
37
  # returns a Hash of information about an RPM file's scriptlets
38
- def rpm_scriptlets_for( host, rpm_file )
39
- _labels = scriptlet_label_map.keys.join('|')
40
- rx_scriptlet_blocks = /^(?<block>(?<scriptlet>#{_labels}) scriptlet.*?(\r|\n)(?<content>.*?))(?=\n(#{_labels}) scriptlet|\Z)/m
38
+ def rpm_scriptlets_for(host, rpm_file)
39
+ _labels = scriptlet_label_map.keys.join('|')
40
+ rx_scriptlet_blocks = %r{^(?<block>(?<scriptlet>#{_labels}) scriptlet.*?(\r|\n)(?<content>.*?))(?=\n(#{_labels}) scriptlet|\Z)}m
41
41
 
42
- result = on host, %Q(rpm -qp --scripts #{rpm_file})
42
+ result = on host, %(rpm -qp --scripts #{rpm_file})
43
43
 
44
44
  scriptlets = {}
45
45
  result.stdout.to_s.scan(rx_scriptlet_blocks) do
46
- scriptlet = scriptlets[$~[:scriptlet]] ||= { :count => 0 }
46
+ scriptlet = scriptlets[$LAST_MATCH_INFO[:scriptlet]] ||= { :count => 0 }
47
47
  scriptlet[:count] += 1
48
- scriptlet[:content] = $~[:content].strip
49
- scriptlet[:full_block] = $~[:block]
50
- scriptlet[:bare_content] = scriptlet[:content].gsub(/^((--|#).*?[\r\n]+)/,'')
48
+ scriptlet[:content] = $LAST_MATCH_INFO[:content].strip
49
+ scriptlet[:full_block] = $LAST_MATCH_INFO[:block]
50
+ scriptlet[:bare_content] = scriptlet[:content].gsub(%r{^((--|#).*?[\r\n]+)}, '')
51
51
  end
52
52
  scriptlets
53
53
  end
54
54
 
55
-
56
55
  # returns a Hash of information about an RPM file's triggers
57
- def rpm_triggers_for( host, rpm_file )
56
+ def rpm_triggers_for(host, rpm_file)
58
57
  _trigger = 'trigger\\w+ scriptlet \\(using [\\/a-z0-9]+\\) --(!?\\p{Graph}|\\s)*?'
59
- rx_trigger_blocks = /^(?<block>(?<trigger>#{_trigger})[\r\n](?<content>.*?)(?=\n#{_trigger}|\Z))/m
58
+ rx_trigger_blocks = %r{^(?<block>(?<trigger>#{_trigger})[\r\n](?<content>.*?)(?=\n#{_trigger}|\Z))}m
60
59
 
61
- result = on host, %Q(rpm -qp --triggers #{rpm_file})
60
+ result = on host, %(rpm -qp --triggers #{rpm_file})
62
61
 
63
62
  triggers = {}
64
63
  result.stdout.to_s.scan(rx_trigger_blocks) do
65
- trigger= triggers[$~[:trigger]] ||= { :count => 0 }
64
+ trigger = triggers[$LAST_MATCH_INFO[:trigger]] ||= { :count => 0 }
66
65
  trigger[:count] += 1
67
- trigger[:content] = $~[:content].strip
68
- trigger[:full_block] = $~[:block]
69
- trigger[:bare_content] = trigger[:content].gsub(/^((--|#).*?[\r\n]+)/,'')
66
+ trigger[:content] = $LAST_MATCH_INFO[:content].strip
67
+ trigger[:full_block] = $LAST_MATCH_INFO[:block]
68
+ trigger[:bare_content] = trigger[:content].gsub(%r{^((--|#).*?[\r\n]+)}, '')
70
69
  end
71
70
  triggers
72
71
  end
@@ -1,7 +1,9 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Simp::BeakerHelpers::SimpRakeHelpers
2
4
  # Add RSpec log comments within examples ("it blocks")
3
5
  def comment(msg, indent = 10)
4
- logger.optionally_color(Beaker::Logger::MAGENTA, ' ' * indent + msg)
6
+ logger.optionally_color(Beaker::Logger::MAGENTA, (' ' * indent) + msg)
5
7
  end
6
8
 
7
9
  # basic command + arguments for executing `runuser` within an SUT