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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +26 -0
- data/Gemfile +13 -6
- data/lib/simp/command_utils.rb +6 -3
- data/lib/simp/componentinfo.rb +47 -33
- data/lib/simp/local_gpg_signing_key.rb +302 -303
- data/lib/simp/packer/iso_vars_json.rb +17 -15
- data/lib/simp/rake/build/auto.rb +415 -432
- data/lib/simp/rake/build/build.rb +119 -124
- data/lib/simp/rake/build/clean.rb +39 -39
- data/lib/simp/rake/build/code.rb +125 -128
- data/lib/simp/rake/build/constants.rb +7 -4
- data/lib/simp/rake/build/deps.rb +196 -207
- data/lib/simp/rake/build/helpers.rb +17 -13
- data/lib/simp/rake/build/iso.rb +404 -411
- data/lib/simp/rake/build/pkg.rb +752 -759
- data/lib/simp/rake/build/rpmdeps.rb +70 -70
- data/lib/simp/rake/build/spec.rb +44 -46
- data/lib/simp/rake/build/tar.rb +169 -173
- data/lib/simp/rake/build/unpack.rb +105 -107
- data/lib/simp/rake/build/upload.rb +93 -102
- data/lib/simp/rake/fixtures.rb +69 -66
- data/lib/simp/rake/helpers/rpm_spec.rb +10 -7
- data/lib/simp/rake/helpers/version.rb +3 -1
- data/lib/simp/rake/helpers.rb +12 -10
- data/lib/simp/rake/pkg.rb +417 -440
- data/lib/simp/rake/pupmod/helpers.rb +100 -87
- data/lib/simp/rake/pupmod/module_build.rb +39 -0
- data/lib/simp/rake/rubygem.rb +57 -56
- data/lib/simp/rake.rb +34 -29
- data/lib/simp/relchecks.rb +52 -43
- data/lib/simp/rpm.rb +123 -127
- data/lib/simp/rpm_signer.rb +57 -55
- data/lib/simp/yum.rb +54 -53
- data/spec/acceptance/nodesets/{default_ruby3_1.yml → almalinux10.yml} +4 -4
- data/spec/acceptance/nodesets/{default.yml → almalinux8.yml} +2 -2
- data/spec/acceptance/nodesets/almalinux9.yml +25 -0
- data/spec/acceptance/suites/default/00_pkg_rpm_custom_scriptlets_spec.rb +23 -28
- data/spec/acceptance/suites/default/10_pkg_rpm_spec.rb +54 -56
- data/spec/acceptance/suites/default/30_pkg_misc_spec.rb +17 -19
- data/spec/acceptance/suites/default/50_local_gpg_signing_key_spec.rb +5 -5
- data/spec/acceptance/suites/default/55_build_pkg_signing_spec.rb +109 -101
- data/spec/acceptance/suites/default/files/testpackage/spec/classes/init_spec.rb +1 -0
- data/spec/acceptance/suites/default/files/testpackage/spec/files/mock_something.rb +3 -1
- data/spec/acceptance/suites/default/files/testpackage/utils/convert_v1_to_v2.rb +2 -0
- data/spec/acceptance/suites/default/support/build_project_helpers.rb +20 -17
- data/spec/acceptance/suites/default/support/build_user_helpers.rb +4 -2
- data/spec/acceptance/suites/default/support/pkg_rpm_helpers.rb +30 -31
- data/spec/acceptance/support/simp_rake_helpers.rb +3 -1
- data/spec/lib/simp/command_utils_spec.rb +13 -10
- data/spec/lib/simp/componentinfo_changelog_regex_spec.rb +33 -33
- data/spec/lib/simp/componentinfo_spec.rb +99 -86
- data/spec/lib/simp/packer/iso_vars_json_spec.rb +16 -14
- data/spec/lib/simp/rake/build/helpers_spec.rb +7 -7
- data/spec/lib/simp/rake/build/rpmdeps_spec.rb +48 -46
- data/spec/lib/simp/rake/helpers_spec.rb +6 -5
- data/spec/lib/simp/rake/pkg_spec.rb +7 -5
- data/spec/lib/simp/rake/pupmod/fixtures/othermod/spec/classes/init_spec.rb +3 -1
- data/spec/lib/simp/rake/pupmod/fixtures/othermod/spec/spec_helper.rb +2 -0
- data/spec/lib/simp/rake/pupmod/fixtures/simpmod/spec/acceptance/suites/default/class_spec.rb +6 -5
- data/spec/lib/simp/rake/pupmod/fixtures/simpmod/spec/classes/init_spec.rb +51 -33
- data/spec/lib/simp/rake/pupmod/fixtures/simpmod/spec/spec_helper.rb +15 -16
- data/spec/lib/simp/rake/pupmod/fixtures/simpmod/spec/spec_helper_acceptance.rb +9 -9
- data/spec/lib/simp/rake/pupmod/helpers_spec.rb +20 -19
- data/spec/lib/simp/rake/pupmod/module_build_spec.rb +87 -0
- data/spec/lib/simp/rake_spec.rb +7 -6
- data/spec/lib/simp/relchecks_check_rpm_changelog_spec.rb +26 -31
- data/spec/lib/simp/relchecks_compare_latest_tag_spec.rb +32 -26
- data/spec/lib/simp/relchecks_create_tag_changelog_spec.rb +27 -19
- data/spec/lib/simp/rpm_signer_spec.rb +45 -39
- data/spec/lib/simp/rpm_spec.rb +190 -194
- data/spec/spec_helper.rb +4 -2
- data/spec/spec_helper_acceptance.rb +3 -5
- metadata +37 -72
- data/bin/simp_rake_helpers +0 -3
- data/lib/simp/ci/gitlab.rb +0 -226
- data/lib/simp/rake/ci.rb +0 -31
- data/spec/lib/simp/ci/files/global_nodesets_only/spec/acceptance/nodesets/default.yml +0 -41
- data/spec/lib/simp/ci/files/global_nodesets_only/spec/acceptance/nodesets/oel.yml +0 -41
- data/spec/lib/simp/ci/files/job_broken_link_nodeset/spec/acceptance/nodesets/centos.yml +0 -41
- data/spec/lib/simp/ci/files/job_broken_link_nodeset/spec/acceptance/nodesets/oel.yml +0 -41
- data/spec/lib/simp/ci/files/job_broken_link_nodeset/spec/acceptance/suites/default/class_spec.rb +0 -0
- data/spec/lib/simp/ci/files/job_invalid_nodeset/spec/acceptance/nodesets/default.yml +0 -41
- data/spec/lib/simp/ci/files/job_invalid_nodeset/spec/acceptance/nodesets/oel.yml +0 -41
- data/spec/lib/simp/ci/files/job_invalid_nodeset/spec/acceptance/suites/default/class_spec.rb +0 -0
- data/spec/lib/simp/ci/files/job_invalid_suite/spec/acceptance/nodesets/default.yml +0 -41
- data/spec/lib/simp/ci/files/job_invalid_suite/spec/acceptance/nodesets/oel.yml +0 -41
- data/spec/lib/simp/ci/files/job_invalid_suite/spec/acceptance/suites/default/class_spec.rb +0 -0
- data/spec/lib/simp/ci/files/job_missing_nodeset/spec/acceptance/nodesets/default.yml +0 -41
- data/spec/lib/simp/ci/files/job_missing_nodeset/spec/acceptance/nodesets/oel.yml +0 -41
- data/spec/lib/simp/ci/files/job_missing_nodeset/spec/acceptance/suites/default/class_spec.rb +0 -0
- data/spec/lib/simp/ci/files/job_missing_suite_and_nodeset/spec/acceptance/nodesets/default.yml +0 -41
- data/spec/lib/simp/ci/files/job_missing_suite_and_nodeset/spec/acceptance/nodesets/oel.yml +0 -41
- data/spec/lib/simp/ci/files/job_missing_suite_and_nodeset/spec/acceptance/suites/default/class_spec.rb +0 -0
- data/spec/lib/simp/ci/files/multiple_invalid_jobs/spec/acceptance/nodesets/default.yml +0 -41
- data/spec/lib/simp/ci/files/multiple_invalid_jobs/spec/acceptance/nodesets/oel.yml +0 -41
- data/spec/lib/simp/ci/files/multiple_invalid_jobs/spec/acceptance/suites/default/class_spec.rb +0 -0
- data/spec/lib/simp/ci/files/multiple_invalid_jobs/spec/acceptance/suites/feature-1/feature-1_spec.rb +0 -0
- data/spec/lib/simp/ci/files/multiple_invalid_jobs/spec/acceptance/suites/feature_2/feature_2_spec.rb +0 -0
- data/spec/lib/simp/ci/files/multiple_invalid_jobs/spec/acceptance/suites/feature_2/nodesets/default.yml +0 -35
- data/spec/lib/simp/ci/files/multiple_invalid_jobs/spec/acceptance/suites/feature_2/nodesets/oel.yml +0 -35
- data/spec/lib/simp/ci/files/multiple_valid_jobs/spec/acceptance/nodesets/default.yml +0 -41
- data/spec/lib/simp/ci/files/multiple_valid_jobs/spec/acceptance/nodesets/oel.yml +0 -41
- data/spec/lib/simp/ci/files/multiple_valid_jobs/spec/acceptance/suites/default/class_spec.rb +0 -0
- data/spec/lib/simp/ci/files/multiple_valid_jobs/spec/acceptance/suites/feature-1/feature-1_spec.rb +0 -0
- data/spec/lib/simp/ci/files/multiple_valid_jobs/spec/acceptance/suites/feature_2/feature_2_spec.rb +0 -0
- data/spec/lib/simp/ci/files/multiple_valid_jobs/spec/acceptance/suites/feature_2/nodesets/default.yml +0 -35
- data/spec/lib/simp/ci/files/multiple_valid_jobs/spec/acceptance/suites/feature_2/nodesets/oel.yml +0 -35
- data/spec/lib/simp/ci/files/no_acceptance_tests/spec/spec_helper.rb +0 -0
- data/spec/lib/simp/ci/files/no_gitlab_config_with_tests/spec/acceptance/nodesets/default.yml +0 -41
- data/spec/lib/simp/ci/files/no_gitlab_config_with_tests/spec/acceptance/nodesets/oel.yml +0 -41
- data/spec/lib/simp/ci/files/no_gitlab_config_with_tests/spec/acceptance/suites/default/class_spec.rb +0 -0
- data/spec/lib/simp/ci/files/no_gitlab_config_without_tests/spec/acceptance/nodesets/default.yml +0 -41
- data/spec/lib/simp/ci/files/no_gitlab_config_without_tests/spec/acceptance/nodesets/oel.yml +0 -41
- data/spec/lib/simp/ci/files/suite_skeleton_only/spec/acceptance/nodesets/centos.yml +0 -41
- data/spec/lib/simp/ci/files/suite_skeleton_only/spec/acceptance/nodesets/oel.yml +0 -41
- data/spec/lib/simp/ci/files/valid_job_global_nodeset/spec/acceptance/nodesets/default.yml +0 -41
- data/spec/lib/simp/ci/files/valid_job_global_nodeset/spec/acceptance/nodesets/oel.yml +0 -41
- data/spec/lib/simp/ci/files/valid_job_global_nodeset/spec/acceptance/suites/default/class_spec.rb +0 -0
- data/spec/lib/simp/ci/files/valid_job_nodeset_dir_link/spec/acceptance/nodesets/default.yml +0 -41
- data/spec/lib/simp/ci/files/valid_job_nodeset_dir_link/spec/acceptance/nodesets/oel.yml +0 -41
- data/spec/lib/simp/ci/files/valid_job_nodeset_dir_link/spec/acceptance/suites/default/class_spec.rb +0 -0
- data/spec/lib/simp/ci/files/valid_job_nodeset_link/spec/acceptance/suites/default/class_spec.rb +0 -0
- data/spec/lib/simp/ci/files/valid_job_nodeset_link/spec/acceptance/suites/default/nodesets/centos.yml +0 -41
- data/spec/lib/simp/ci/files/valid_job_nodeset_link/spec/acceptance/suites/default/nodesets/oel.yml +0 -41
- data/spec/lib/simp/ci/files/valid_job_suite_nodeset/spec/acceptance/suites/default/class_spec.rb +0 -0
- data/spec/lib/simp/ci/files/valid_job_suite_nodeset/spec/acceptance/suites/default/nodesets/default.yml +0 -41
- data/spec/lib/simp/ci/files/valid_job_suite_nodeset/spec/acceptance/suites/default/nodesets/oel.yml +0 -41
- data/spec/lib/simp/ci/gitlab_spec.rb +0 -245
data/lib/simp/rpm_signer.rb
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'English'
|
|
1
4
|
require 'find'
|
|
2
5
|
require 'parallel'
|
|
3
6
|
require 'simp/rpm'
|
|
@@ -12,7 +15,7 @@ class Simp::RpmSigner
|
|
|
12
15
|
|
|
13
16
|
extend Simp::CommandUtils
|
|
14
17
|
|
|
15
|
-
@@gpg_keys =
|
|
18
|
+
@@gpg_keys = {}
|
|
16
19
|
|
|
17
20
|
# Kill the GPG agent operating with the specified key dir, if
|
|
18
21
|
# rpm version 4.13.0 or later.
|
|
@@ -22,19 +25,19 @@ class Simp::RpmSigner
|
|
|
22
25
|
def self.kill_gpg_agent(gpg_keydir)
|
|
23
26
|
return if Gem::Version.new(Simp::RPM.version) < Gem::Version.new('4.13.0')
|
|
24
27
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
28
|
+
`gpg-agent --homedir #{gpg_keydir} -q >& /dev/null`
|
|
29
|
+
return unless $CHILD_STATUS&.exitstatus&.zero?
|
|
30
|
+
|
|
31
|
+
# gpg-agent is running for specified keydir, so query it for its pid
|
|
32
|
+
output = `echo 'GETINFO pid' | gpg-connect-agent --homedir=#{gpg_keydir}`
|
|
33
|
+
return unless $CHILD_STATUS&.exitstatus&.zero?
|
|
34
|
+
|
|
35
|
+
pid = output.lines.first[1..].strip.to_i
|
|
36
|
+
begin
|
|
37
|
+
Process.kill(0, pid)
|
|
38
|
+
Process.kill(15, pid)
|
|
39
|
+
rescue Errno::ESRCH
|
|
40
|
+
# No longer running, so nothing to do!
|
|
38
41
|
end
|
|
39
42
|
end
|
|
40
43
|
|
|
@@ -64,12 +67,12 @@ class Simp::RpmSigner
|
|
|
64
67
|
gpg_password = nil
|
|
65
68
|
begin
|
|
66
69
|
File.read("#{gpg_keydir}/gengpgkey").each_line do |ln|
|
|
67
|
-
name_line = ln.split(
|
|
70
|
+
name_line = ln.split(%r{^\s*Name-Email:})
|
|
68
71
|
if name_line.length > 1
|
|
69
72
|
gpg_name = name_line.last.strip
|
|
70
73
|
end
|
|
71
74
|
|
|
72
|
-
passwd_line = ln.split(
|
|
75
|
+
passwd_line = ln.split(%r{^\s*Passphrase:})
|
|
73
76
|
if passwd_line.length > 1
|
|
74
77
|
gpg_password = passwd_line.last.strip
|
|
75
78
|
end
|
|
@@ -78,8 +81,8 @@ class Simp::RpmSigner
|
|
|
78
81
|
end
|
|
79
82
|
|
|
80
83
|
if gpg_name.nil?
|
|
81
|
-
puts
|
|
82
|
-
puts
|
|
84
|
+
puts 'Warning: Could not find valid e-mail address for use with GPG.'
|
|
85
|
+
puts 'Please enter e-mail address to use:'
|
|
83
86
|
gpg_name = $stdin.gets.strip
|
|
84
87
|
end
|
|
85
88
|
|
|
@@ -90,7 +93,7 @@ class Simp::RpmSigner
|
|
|
90
93
|
|
|
91
94
|
if gpg_password.nil?
|
|
92
95
|
puts "Warning: Could not find a password in '#{gpg_keydir}/password'!"
|
|
93
|
-
puts
|
|
96
|
+
puts 'Please enter your GPG key password:'
|
|
94
97
|
system 'stty -echo'
|
|
95
98
|
gpg_password = $stdin.gets.strip
|
|
96
99
|
system 'stty echo'
|
|
@@ -101,18 +104,18 @@ class Simp::RpmSigner
|
|
|
101
104
|
gpg_key_id = nil
|
|
102
105
|
cmd = "gpg --with-colons --homedir=#{gpg_keydir} --list-keys '<#{gpg_name}>' 2>&1"
|
|
103
106
|
puts "Executing: #{cmd}" if verbose
|
|
104
|
-
|
|
107
|
+
`#{cmd}`.each_line do |line|
|
|
105
108
|
# See https://github.com/CSNW/gnupg/blob/master/doc/DETAILS
|
|
106
109
|
# Index Content
|
|
107
110
|
# 0 record type
|
|
108
111
|
# 2 key length
|
|
109
112
|
# 4 keyID
|
|
110
113
|
fields = line.split(':')
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
114
|
+
next unless fields[0] && (fields[0] == 'pub')
|
|
115
|
+
|
|
116
|
+
gpg_key_size = fields[2].to_i
|
|
117
|
+
gpg_key_id = fields[4]
|
|
118
|
+
break
|
|
116
119
|
end
|
|
117
120
|
|
|
118
121
|
if !gpg_key_size || !gpg_key_id
|
|
@@ -120,9 +123,9 @@ class Simp::RpmSigner
|
|
|
120
123
|
end
|
|
121
124
|
|
|
122
125
|
@@gpg_keys[gpg_key] = {
|
|
123
|
-
:dir
|
|
124
|
-
:name
|
|
125
|
-
:key_id
|
|
126
|
+
:dir => gpg_keydir,
|
|
127
|
+
:name => gpg_name,
|
|
128
|
+
:key_id => gpg_key_id,
|
|
126
129
|
:key_size => gpg_key_size,
|
|
127
130
|
:password => gpg_password
|
|
128
131
|
}
|
|
@@ -145,16 +148,16 @@ class Simp::RpmSigner
|
|
|
145
148
|
# @raise RuntimeError if 'rpmsign' executable cannot be found, the 'gpg
|
|
146
149
|
# 'executable cannot be found, the GPG key directory does not exist or
|
|
147
150
|
# the GPG key metadata cannot be determined via 'gpg'
|
|
148
|
-
def self.sign_rpm(rpm, gpg_keydir, options={})
|
|
151
|
+
def self.sign_rpm(rpm, gpg_keydir, options = {})
|
|
149
152
|
# This may be a little confusing...Although we're using 'rpm --resign'
|
|
150
153
|
# in lieu of 'rpmsign --addsign', they are equivalent and the presence
|
|
151
154
|
# of 'rpmsign' is a legitimate check that the 'rpm --resign' capability
|
|
152
155
|
# is available (i.e., rpm-sign package has been installed).
|
|
153
156
|
which('rpmsign') || raise("ERROR: Cannot sign RPMs without 'rpmsign'.")
|
|
154
157
|
|
|
155
|
-
digest_algo = options.key?(:digest_algo) ?
|
|
156
|
-
timeout_seconds = options.key?(:timeout_seconds) ?
|
|
157
|
-
verbose = options.key?(:verbose) ?
|
|
158
|
+
digest_algo = options.key?(:digest_algo) ? options[:digest_algo] : 'sha256'
|
|
159
|
+
timeout_seconds = options.key?(:timeout_seconds) ? options[:timeout_seconds] : 60
|
|
160
|
+
verbose = options.key?(:verbose) ? options[:verbose] : false
|
|
158
161
|
|
|
159
162
|
gpgkey = load_key(gpg_keydir, verbose)
|
|
160
163
|
|
|
@@ -171,7 +174,7 @@ class Simp::RpmSigner
|
|
|
171
174
|
"--define '%_gpg_path #{gpgkey[:dir]}'",
|
|
172
175
|
"--define '%_gpg_digest_algo #{digest_algo}'",
|
|
173
176
|
gpg_sign_cmd_extra_args,
|
|
174
|
-
"--resign #{rpm}"
|
|
177
|
+
"--resign #{rpm}",
|
|
175
178
|
].compact.join(' ')
|
|
176
179
|
|
|
177
180
|
success = false
|
|
@@ -184,18 +187,17 @@ class Simp::RpmSigner
|
|
|
184
187
|
# With rpm-sign-4.14.2-11.el8_0 (EL 8.0), if rpm cannot start the
|
|
185
188
|
# gpg-agent daemon, it will just hang. We need to be able to detect
|
|
186
189
|
# the problem and report the failure.
|
|
187
|
-
Timeout
|
|
188
|
-
|
|
190
|
+
Timeout.timeout(timeout_seconds) do
|
|
189
191
|
status = nil
|
|
190
192
|
PTY.spawn(signcommand) do |read, write, pid|
|
|
191
193
|
begin
|
|
192
|
-
|
|
194
|
+
until read.eof?
|
|
193
195
|
# rpm version >= 4.13.0 will stand up a gpg-agent and so the
|
|
194
196
|
# prompt for the passphrase will only actually happen if this is
|
|
195
197
|
# the first RPM to be signed with the key after the gpg-agent is
|
|
196
198
|
# started and the key's passphrase has not been cleared from the
|
|
197
199
|
# agent's cache.
|
|
198
|
-
read.expect(
|
|
200
|
+
read.expect(%r{(pass\s?phrase:|verwrite).*}) do |text|
|
|
199
201
|
if text.last.include?('verwrite')
|
|
200
202
|
write.puts('y')
|
|
201
203
|
else
|
|
@@ -212,7 +214,7 @@ class Simp::RpmSigner
|
|
|
212
214
|
end
|
|
213
215
|
|
|
214
216
|
Process.wait(pid)
|
|
215
|
-
status =
|
|
217
|
+
status = $CHILD_STATUS
|
|
216
218
|
end
|
|
217
219
|
|
|
218
220
|
if status && !status.success?
|
|
@@ -222,12 +224,11 @@ class Simp::RpmSigner
|
|
|
222
224
|
|
|
223
225
|
puts "Successfully signed #{rpm}" if verbose
|
|
224
226
|
success = true
|
|
225
|
-
|
|
226
227
|
rescue Timeout::Error
|
|
227
|
-
|
|
228
|
+
warn "Failed to sign #{rpm} in #{timeout_seconds} seconds."
|
|
228
229
|
rescue Exception => e
|
|
229
|
-
|
|
230
|
-
|
|
230
|
+
warn "Error occurred while attempting to sign #{rpm}:"
|
|
231
|
+
warn e
|
|
231
232
|
end
|
|
232
233
|
|
|
233
234
|
success
|
|
@@ -267,13 +268,13 @@ class Simp::RpmSigner
|
|
|
267
268
|
# operation failed
|
|
268
269
|
#
|
|
269
270
|
def self.sign_rpms(rpm_dir, gpg_keydir, options = {})
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
271
|
+
opts = {
|
|
272
|
+
:digest_algo => 'sha256',
|
|
273
|
+
:force => false,
|
|
274
|
+
:max_concurrent => 1,
|
|
275
|
+
:progress_bar_title => 'sign_rpms',
|
|
276
|
+
:timeout_seconds => 60,
|
|
277
|
+
:verbose => false
|
|
277
278
|
}.merge(options)
|
|
278
279
|
|
|
279
280
|
rpm_dirs = Dir.glob(rpm_dir)
|
|
@@ -282,7 +283,8 @@ class Simp::RpmSigner
|
|
|
282
283
|
rpm_dirs.each do |rpm_dir|
|
|
283
284
|
Find.find(rpm_dir) do |rpm|
|
|
284
285
|
next unless File.readable?(rpm)
|
|
285
|
-
|
|
286
|
+
|
|
287
|
+
to_sign << rpm if %r{\.rpm$}.match?(rpm)
|
|
286
288
|
end
|
|
287
289
|
end
|
|
288
290
|
|
|
@@ -293,22 +295,22 @@ class Simp::RpmSigner
|
|
|
293
295
|
results = Parallel.map(
|
|
294
296
|
to_sign,
|
|
295
297
|
:in_processes => 1,
|
|
296
|
-
:progress => opts[:progress_bar_title]
|
|
298
|
+
:progress => opts[:progress_bar_title],
|
|
297
299
|
) do |rpm|
|
|
298
300
|
_result = nil
|
|
299
301
|
|
|
300
302
|
begin
|
|
301
303
|
if opts[:force] || !Simp::RPM.new(rpm).signature
|
|
302
|
-
_result = [
|
|
304
|
+
_result = [rpm, sign_rpm(rpm, gpg_keydir, opts)]
|
|
303
305
|
_result[1] = _result[1] ? :signed : :unsigned
|
|
304
306
|
else
|
|
305
307
|
puts "Skipping signed package #{rpm}" if opts[:verbose]
|
|
306
|
-
_result = [
|
|
308
|
+
_result = [rpm, :skipped_already_signed]
|
|
307
309
|
end
|
|
308
310
|
rescue Exception => e
|
|
309
311
|
# can get here if rpm is malformed and Simp::RPM.new fails
|
|
310
|
-
|
|
311
|
-
_result = [
|
|
312
|
+
warn "Failed to sign #{rpm}:\n#{e.message}"
|
|
313
|
+
_result = [rpm, :unsigned]
|
|
312
314
|
end
|
|
313
315
|
|
|
314
316
|
_result
|
data/lib/simp/yum.rb
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'English'
|
|
4
|
+
|
|
1
5
|
module Simp
|
|
2
6
|
# Various utilities for dealing with YUM repos
|
|
3
7
|
class Simp::YUM
|
|
4
|
-
|
|
5
8
|
class Error < StandardError
|
|
6
9
|
end
|
|
7
10
|
|
|
@@ -12,14 +15,12 @@ module Simp
|
|
|
12
15
|
attr_reader :yum_conf
|
|
13
16
|
|
|
14
17
|
def initialize(yum_conf, initialize_cache = false)
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
raise(Error, "Could not find yum configuration at '#{yum_conf}'")
|
|
19
|
-
end
|
|
18
|
+
raise(Error, "Could not find yum configuration at '#{yum_conf}'") unless File.exist?(yum_conf)
|
|
19
|
+
|
|
20
|
+
@yum_conf = File.absolute_path(yum_conf)
|
|
20
21
|
|
|
21
22
|
# Only need to look these up once!
|
|
22
|
-
@@yum_cmd ||=
|
|
23
|
+
@@yum_cmd ||= `which yum`.strip
|
|
23
24
|
raise(Error, "Error: Could not find 'yum'. Please install and try again.") if @@yum_cmd.empty?
|
|
24
25
|
|
|
25
26
|
tmp_dir = ENV['TMPDIR'] || '/tmp'
|
|
@@ -34,15 +35,15 @@ module Simp
|
|
|
34
35
|
|
|
35
36
|
@@yum ||= "TMPDIR=#{@@yum_cache} #{@@yum_cmd} -c #{@yum_conf}"
|
|
36
37
|
|
|
37
|
-
@@yumdownloader_cmd ||=
|
|
38
|
+
@@yumdownloader_cmd ||= `which yumdownloader`.strip
|
|
38
39
|
raise(Error, "Error: Could not find 'yumdownloader'. Please install and try again.") if @@yumdownloader_cmd.empty?
|
|
39
40
|
|
|
40
41
|
@@yumdownloader ||= "TMPDIR=#{@@yum_cache} #{@@yumdownloader_cmd} -c #{@yum_conf}"
|
|
41
42
|
|
|
42
|
-
@@curl ||=
|
|
43
|
+
@@curl ||= `which curl`.strip
|
|
43
44
|
raise(Error, "Error: Could not find 'curl'. Please install and try again.") if @@curl.empty?
|
|
44
45
|
|
|
45
|
-
@@file ||=
|
|
46
|
+
@@file ||= `which file`.strip
|
|
46
47
|
raise(Error, "Error: Could not find 'file'. Please install and try again.") if @@file.empty?
|
|
47
48
|
|
|
48
49
|
generate_cache if initialize_cache
|
|
@@ -50,27 +51,27 @@ module Simp
|
|
|
50
51
|
|
|
51
52
|
def clean_yum_cache_dir
|
|
52
53
|
# Make this as safe as we can
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
54
|
+
return unless @@yum_cache.include?('yum_cache')
|
|
55
|
+
|
|
56
|
+
FileUtils.remove_entry(@@yum_cache)
|
|
56
57
|
end
|
|
57
58
|
|
|
58
59
|
def generate_cache
|
|
59
60
|
puts "Attempting to generate build-specific YUM cache from\n #{@yum_conf}"
|
|
60
61
|
|
|
61
|
-
|
|
62
|
-
|
|
62
|
+
`#{@@yum} clean all 2>/dev/null`
|
|
63
|
+
`#{@@yum} makecache 2>/dev/null`
|
|
63
64
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
65
|
+
return if $CHILD_STATUS.success?
|
|
66
|
+
|
|
67
|
+
puts "WARNING: Unable to generate build-specific YUM cache from #{@yum_conf}"
|
|
67
68
|
end
|
|
68
69
|
|
|
69
70
|
# Create a reasonable YUM config file
|
|
70
71
|
# * yum_tmp => The directory in which to store the YUM DB and any other temporary files
|
|
71
72
|
#
|
|
72
73
|
# Returns the location of the YUM configuration
|
|
73
|
-
def self.generate_yum_conf(yum_dir=nil)
|
|
74
|
+
def self.generate_yum_conf(yum_dir = nil)
|
|
74
75
|
yum_dir ||= Dir.pwd
|
|
75
76
|
|
|
76
77
|
raise(Error, "Could not find YUM data dir at '#{yum_dir}'") unless File.directory?(yum_dir)
|
|
@@ -78,7 +79,7 @@ module Simp
|
|
|
78
79
|
yum_conf = nil
|
|
79
80
|
Dir.chdir(yum_dir) do
|
|
80
81
|
# Create the target directory
|
|
81
|
-
yum_tmp = File.join('packages','yum_tmp')
|
|
82
|
+
yum_tmp = File.join('packages', 'yum_tmp')
|
|
82
83
|
|
|
83
84
|
FileUtils.mkdir_p(yum_tmp) unless File.directory?(yum_tmp)
|
|
84
85
|
|
|
@@ -92,19 +93,19 @@ module Simp
|
|
|
92
93
|
# Add the global directory
|
|
93
94
|
repo_dirs << File.expand_path('../my_repos')
|
|
94
95
|
|
|
95
|
-
if File.directory?('my_repos')
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
96
|
+
repo_dirs << if File.directory?('my_repos')
|
|
97
|
+
# Add the local user repos if they exist
|
|
98
|
+
File.expand_path('my_repos')
|
|
99
|
+
else
|
|
100
|
+
# Add the default Internet repos otherwise
|
|
101
|
+
File.expand_path('repos')
|
|
102
|
+
end
|
|
102
103
|
|
|
103
104
|
# Create our YUM config file
|
|
104
105
|
yum_conf = File.expand_path('yum.conf', yum_tmp)
|
|
105
106
|
|
|
106
107
|
File.open(yum_conf, 'w') do |fh|
|
|
107
|
-
fh.puts <<-EOM.gsub(
|
|
108
|
+
fh.puts <<-EOM.gsub(%r{^\s+}, '')
|
|
108
109
|
[main]
|
|
109
110
|
keepcache = 0
|
|
110
111
|
persistdir = #{yum_cache}
|
|
@@ -119,32 +120,32 @@ module Simp
|
|
|
119
120
|
end
|
|
120
121
|
end
|
|
121
122
|
|
|
122
|
-
|
|
123
|
+
yum_conf
|
|
123
124
|
end
|
|
124
125
|
|
|
125
126
|
# Returns the full name of the latest package of the given name
|
|
126
127
|
#
|
|
127
128
|
# Returns nil if nothing found
|
|
128
129
|
def available_package(rpm)
|
|
129
|
-
yum_output =
|
|
130
|
+
yum_output = `#{@@yum} list #{rpm} 2>/dev/null`
|
|
130
131
|
|
|
131
132
|
found_rpm = nil
|
|
132
|
-
if
|
|
133
|
-
pkg_name, pkg_version = yum_output.lines.last.strip.split(
|
|
133
|
+
if $CHILD_STATUS.success?
|
|
134
|
+
pkg_name, pkg_version = yum_output.lines.last.strip.split(%r{\s+})
|
|
134
135
|
pkg_name, pkg_arch = pkg_name.split('.')
|
|
135
136
|
|
|
136
137
|
found_rpm = %(#{pkg_name}-#{pkg_version}.#{pkg_arch}.rpm)
|
|
137
138
|
end
|
|
138
139
|
|
|
139
|
-
|
|
140
|
+
found_rpm
|
|
140
141
|
end
|
|
141
142
|
|
|
142
143
|
def get_sources(rpm)
|
|
143
|
-
Dir.mktmpdir do |
|
|
144
|
-
output =
|
|
145
|
-
sources = output.grep(%r
|
|
144
|
+
Dir.mktmpdir do |_dir|
|
|
145
|
+
output = `#{@@yumdownloader} --urls #{File.basename(rpm, '.rpm')} 2>/dev/null`.lines
|
|
146
|
+
sources = output.grep(%r{\.rpm$})
|
|
146
147
|
|
|
147
|
-
unless
|
|
148
|
+
unless output.grep(%r{Error}).empty? || sources.empty?
|
|
148
149
|
err_msg = "\n-- YUMDOWNLOADER ERROR --\n" + output.join("\n")
|
|
149
150
|
raise(Error, "No sources found for '#{rpm}'" + err_msg)
|
|
150
151
|
end
|
|
@@ -153,11 +154,11 @@ module Simp
|
|
|
153
154
|
end
|
|
154
155
|
end
|
|
155
156
|
|
|
156
|
-
def get_source(rpm, arch=nil)
|
|
157
|
+
def get_source(rpm, arch = nil)
|
|
157
158
|
sources = get_sources(rpm)
|
|
158
159
|
|
|
159
160
|
if arch
|
|
160
|
-
native_sources = sources.grep(%r(
|
|
161
|
+
native_sources = sources.grep(%r{(#{arch}|noarch)\.rpm$})
|
|
161
162
|
|
|
162
163
|
if native_sources.size > 1
|
|
163
164
|
# We can't have more than one native source
|
|
@@ -165,10 +166,10 @@ module Simp
|
|
|
165
166
|
end
|
|
166
167
|
end
|
|
167
168
|
|
|
168
|
-
|
|
169
|
+
sources.first
|
|
169
170
|
end
|
|
170
171
|
|
|
171
|
-
def download(rpm, opts={:target_dir => nil})
|
|
172
|
+
def download(rpm, opts = { :target_dir => nil })
|
|
172
173
|
rpm.strip!
|
|
173
174
|
|
|
174
175
|
downloaded_rpm_name = nil
|
|
@@ -182,25 +183,18 @@ module Simp
|
|
|
182
183
|
Dir.mktmpdir do |dir|
|
|
183
184
|
Dir.chdir(dir) do
|
|
184
185
|
# If just passed an RPM name, use yumdownloader
|
|
185
|
-
if rpm
|
|
186
|
-
# In case someone passed a path
|
|
187
|
-
rpm_name = rpm.split(File::SEPARATOR).last
|
|
188
|
-
|
|
189
|
-
err_msg = %x(#{@@yumdownloader} #{File.basename(rpm_name, '.rpm')} 2>/dev/null)
|
|
190
|
-
|
|
191
|
-
downloaded_rpm_name = rpm_name
|
|
192
|
-
else
|
|
186
|
+
if rpm.include?('://')
|
|
193
187
|
# If passed a URL, curl it and fall back to yumdownloader
|
|
194
188
|
rpm_name = rpm.split('/').last
|
|
195
189
|
|
|
196
|
-
|
|
190
|
+
`#{@@curl} -L --max-redirs 10 -s -o #{rpm_name} -k #{rpm}`
|
|
197
191
|
|
|
198
192
|
# Check what we've just downloaded
|
|
199
|
-
|
|
193
|
+
unless File.exist?(rpm_name) && `#{@@file} #{rpm_name}`.include?('RPM')
|
|
200
194
|
# Fall back on yumdownloader
|
|
201
195
|
FileUtils.rm_f(rpm_name)
|
|
202
196
|
|
|
203
|
-
|
|
197
|
+
`#{@@yumdownloader} #{File.basename(rpm_name, '.rpm')} 2>/dev/null`
|
|
204
198
|
end
|
|
205
199
|
|
|
206
200
|
# We might get a filename that doesn't make sense so we need to
|
|
@@ -212,6 +206,13 @@ module Simp
|
|
|
212
206
|
end
|
|
213
207
|
|
|
214
208
|
downloaded_rpm_name = rpm_info.rpm_name
|
|
209
|
+
else
|
|
210
|
+
# In case someone passed a path
|
|
211
|
+
rpm_name = rpm.split(File::SEPARATOR).last
|
|
212
|
+
|
|
213
|
+
`#{@@yumdownloader} #{File.basename(rpm_name, '.rpm')} 2>/dev/null`
|
|
214
|
+
|
|
215
|
+
downloaded_rpm_name = rpm_name
|
|
215
216
|
end
|
|
216
217
|
|
|
217
218
|
rpms = Dir.glob('*.rpm')
|
|
@@ -228,7 +229,7 @@ module Simp
|
|
|
228
229
|
end
|
|
229
230
|
end
|
|
230
231
|
|
|
231
|
-
|
|
232
|
+
downloaded_rpm_name
|
|
232
233
|
end
|
|
233
234
|
end
|
|
234
235
|
end
|
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
---
|
|
2
2
|
HOSTS:
|
|
3
|
-
|
|
3
|
+
el10-build-server:
|
|
4
4
|
roles:
|
|
5
5
|
- default
|
|
6
6
|
- build_server
|
|
7
|
-
platform: el-
|
|
7
|
+
platform: el-10-x86_64
|
|
8
8
|
hypervisor: docker
|
|
9
|
-
image:
|
|
9
|
+
image: ghcr.io/simp/simp-el10-build:latest
|
|
10
10
|
docker_cmd: '["/sbin/init"]'
|
|
11
11
|
docker_preserve_image: true
|
|
12
12
|
|
|
13
13
|
CONFIG:
|
|
14
14
|
log_level: verbose
|
|
15
15
|
type: aio
|
|
16
|
-
puppet_collection: "<%= ENV.fetch('BEAKER_PUPPET_COLLECTION', '
|
|
16
|
+
puppet_collection: "<%= ENV.fetch('BEAKER_PUPPET_COLLECTION', 'openvox8') %>"
|
|
17
17
|
ssh:
|
|
18
18
|
password: root
|
|
19
19
|
auth_methods:
|
|
@@ -6,14 +6,14 @@ HOSTS:
|
|
|
6
6
|
- build_server
|
|
7
7
|
platform: el-8-x86_64
|
|
8
8
|
hypervisor: docker
|
|
9
|
-
image:
|
|
9
|
+
image: ghcr.io/simp/simp-el8-build:latest
|
|
10
10
|
docker_cmd: '["/sbin/init"]'
|
|
11
11
|
docker_preserve_image: true
|
|
12
12
|
|
|
13
13
|
CONFIG:
|
|
14
14
|
log_level: verbose
|
|
15
15
|
type: aio
|
|
16
|
-
puppet_collection: "<%= ENV.fetch('BEAKER_PUPPET_COLLECTION', '
|
|
16
|
+
puppet_collection: "<%= ENV.fetch('BEAKER_PUPPET_COLLECTION', 'openvox8') %>"
|
|
17
17
|
ssh:
|
|
18
18
|
password: root
|
|
19
19
|
auth_methods:
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
---
|
|
2
|
+
HOSTS:
|
|
3
|
+
el9-build-server:
|
|
4
|
+
roles:
|
|
5
|
+
- default
|
|
6
|
+
- build_server
|
|
7
|
+
platform: el-9-x86_64
|
|
8
|
+
hypervisor: docker
|
|
9
|
+
image: ghcr.io/simp/simp-el9-build:latest
|
|
10
|
+
docker_cmd: '["/sbin/init"]'
|
|
11
|
+
docker_preserve_image: true
|
|
12
|
+
|
|
13
|
+
CONFIG:
|
|
14
|
+
log_level: verbose
|
|
15
|
+
type: aio
|
|
16
|
+
puppet_collection: "<%= ENV.fetch('BEAKER_PUPPET_COLLECTION', 'openvox8') %>"
|
|
17
|
+
ssh:
|
|
18
|
+
password: root
|
|
19
|
+
auth_methods:
|
|
20
|
+
- password
|
|
21
|
+
docker_preserve_image: true
|
|
22
|
+
mount_folders:
|
|
23
|
+
host_files:
|
|
24
|
+
host_path: ./
|
|
25
|
+
container_path: /host_files
|