simp-rake-helpers 5.24.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/.gitignore +20 -1
- data/CHANGELOG.md +33 -0
- data/Gemfile +14 -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 +47 -76
- 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.rb
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
require 'securerandom'
|
|
2
4
|
|
|
3
5
|
module Simp
|
|
@@ -23,7 +25,7 @@ module Simp
|
|
|
23
25
|
end
|
|
24
26
|
|
|
25
27
|
def self.rpm_cmd
|
|
26
|
-
@rpm_cmd ||= (ENV.fetch('SIMP_RPM_LUA_debug','no') =='yes') ? "rpm -D 'lua_debug 1'" : 'rpm'
|
|
28
|
+
@rpm_cmd ||= (ENV.fetch('SIMP_RPM_LUA_debug', 'no') == 'yes') ? "rpm -D 'lua_debug 1'" : 'rpm'
|
|
27
29
|
end
|
|
28
30
|
|
|
29
31
|
# Constructs a new Simp::RPM object. Requires the path to the spec file, or
|
|
@@ -44,7 +46,7 @@ module Simp
|
|
|
44
46
|
# apply when +rpm_source+ is an RPM spec file.
|
|
45
47
|
# [rpm_name] The full name of the rpm
|
|
46
48
|
def initialize(rpm_source)
|
|
47
|
-
@verbose = ENV.fetch('SIMP_RPM_verbose','no') =='yes'
|
|
49
|
+
@verbose = ENV.fetch('SIMP_RPM_verbose', 'no') == 'yes'
|
|
48
50
|
|
|
49
51
|
update_rpmmacros
|
|
50
52
|
|
|
@@ -62,11 +64,11 @@ module Simp
|
|
|
62
64
|
|
|
63
65
|
@packages = @info.keys
|
|
64
66
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
67
|
+
return unless @verbose
|
|
68
|
+
|
|
69
|
+
require 'pp'
|
|
70
|
+
puts '== Simp::RPM @packages'
|
|
71
|
+
puts @packages.pretty_inspect
|
|
70
72
|
end
|
|
71
73
|
|
|
72
74
|
# @returns The RPM '.dist' of the system. 'nil' will be will be
|
|
@@ -77,72 +79,71 @@ module Simp
|
|
|
77
79
|
def self.system_dist
|
|
78
80
|
# We can only have one of these
|
|
79
81
|
unless defined?(@@system_dist)
|
|
80
|
-
cmd = %
|
|
82
|
+
cmd = %(#{rpm_cmd} -E '%{dist}' 2> /dev/null)
|
|
81
83
|
if @verbose
|
|
82
|
-
puts
|
|
84
|
+
puts '== Simp::RPM.system_dist'
|
|
83
85
|
puts " #{cmd} "
|
|
84
86
|
end
|
|
85
|
-
dist =
|
|
87
|
+
dist = `#{cmd}`.strip.split('.')
|
|
86
88
|
puts " result = '#{dist}'" if @verbose
|
|
87
89
|
|
|
88
|
-
if dist.size > 1
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
puts " @@system_dist = #{@@system_dist ||'nil'}" if @verbose
|
|
90
|
+
@@system_dist = if dist.size > 1
|
|
91
|
+
(dist[1] =~ %r{^\.}) ? dist[1] : ('.' + dist[1])
|
|
92
|
+
else
|
|
93
|
+
nil
|
|
94
|
+
end
|
|
95
|
+
puts " @@system_dist = #{@@system_dist || 'nil'}" if @verbose
|
|
94
96
|
end
|
|
95
97
|
|
|
96
|
-
|
|
98
|
+
@@system_dist
|
|
97
99
|
end
|
|
98
100
|
|
|
99
101
|
def system_dist
|
|
100
|
-
|
|
102
|
+
Simp::RPM.system_dist
|
|
101
103
|
end
|
|
102
104
|
|
|
103
105
|
# Work around the silliness with 'centos' being tacked onto things via the
|
|
104
106
|
# 'dist' flag
|
|
105
107
|
def update_rpmmacros
|
|
106
|
-
|
|
108
|
+
return if defined?(@@macros_updated)
|
|
107
109
|
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
110
|
+
# Workaround for CentOS system builds
|
|
111
|
+
dist = ENV['SIMP_RPM_dist'] || system_dist
|
|
112
|
+
dist_macro = %(%dist #{dist})
|
|
113
|
+
rpmmacros = [dist_macro]
|
|
114
|
+
rpmmacros_file = File.join(Dir.home, '.rpmmacros')
|
|
113
115
|
|
|
114
|
-
|
|
115
|
-
|
|
116
|
+
if File.exist?(rpmmacros_file)
|
|
117
|
+
rpmmacros = File.read(rpmmacros_file).split("\n")
|
|
116
118
|
|
|
117
|
-
|
|
119
|
+
dist_index = rpmmacros.each_index.find { |i| rpmmacros[i] =~ %r{^%dist\s+} }
|
|
118
120
|
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
end
|
|
121
|
+
if dist_index
|
|
122
|
+
rpmmacros[dist_index] = dist_macro
|
|
123
|
+
else
|
|
124
|
+
rpmmacros << dist_macro
|
|
124
125
|
end
|
|
126
|
+
end
|
|
125
127
|
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
128
|
+
File.open(rpmmacros_file, 'w') do |fh|
|
|
129
|
+
fh.puts rpmmacros.join("\n")
|
|
130
|
+
fh.flush
|
|
131
|
+
end
|
|
130
132
|
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
end
|
|
138
|
-
@@macros_updated = true
|
|
133
|
+
if @verbose
|
|
134
|
+
puts '== SIMP::RPM#update_rpmmacros:'
|
|
135
|
+
puts " wrote to '#{rpmmacros_file}': "
|
|
136
|
+
puts " #{'-' * 20}"
|
|
137
|
+
puts rpmmacros.map { |x| " #{x}\n" }.join
|
|
138
|
+
puts
|
|
139
139
|
end
|
|
140
|
+
@@macros_updated = true
|
|
140
141
|
end
|
|
141
142
|
|
|
142
143
|
# @returns The name of the package (as it would be queried in yum)
|
|
143
144
|
#
|
|
144
145
|
# @fails if package is invalid
|
|
145
|
-
def basename(package
|
|
146
|
+
def basename(package = @packages.first)
|
|
146
147
|
valid_package?(package)
|
|
147
148
|
@info[package][:basename]
|
|
148
149
|
end
|
|
@@ -150,7 +151,7 @@ module Simp
|
|
|
150
151
|
# @returns The version of the package
|
|
151
152
|
#
|
|
152
153
|
# @fails if package is invalid
|
|
153
|
-
def version(package
|
|
154
|
+
def version(package = @packages.first)
|
|
154
155
|
valid_package?(package)
|
|
155
156
|
@info[package][:version]
|
|
156
157
|
end
|
|
@@ -158,7 +159,7 @@ module Simp
|
|
|
158
159
|
# @returns The release version of the package
|
|
159
160
|
#
|
|
160
161
|
# @fails if package is invalid
|
|
161
|
-
def release(package
|
|
162
|
+
def release(package = @packages.first)
|
|
162
163
|
valid_package?(package)
|
|
163
164
|
@info[package][:release]
|
|
164
165
|
end
|
|
@@ -166,14 +167,14 @@ module Simp
|
|
|
166
167
|
# @returns The full version of the package: [version]-[release]
|
|
167
168
|
#
|
|
168
169
|
# @fails if package is invalid
|
|
169
|
-
def full_version(package
|
|
170
|
+
def full_version(package = @packages.first)
|
|
170
171
|
valid_package?(package)
|
|
171
172
|
@info[package][:full_version]
|
|
172
173
|
end
|
|
173
174
|
|
|
174
175
|
# @returns The full name of the package: [basename]-[full_version]
|
|
175
176
|
# @fails if package is invalid
|
|
176
|
-
def name(package
|
|
177
|
+
def name(package = @packages.first)
|
|
177
178
|
valid_package?(package)
|
|
178
179
|
@info[package][:name]
|
|
179
180
|
end
|
|
@@ -181,7 +182,7 @@ module Simp
|
|
|
181
182
|
# @returns The machine architecture of the package
|
|
182
183
|
#
|
|
183
184
|
# @fails if package is invalid
|
|
184
|
-
def arch(package
|
|
185
|
+
def arch(package = @packages.first)
|
|
185
186
|
valid_package?(package)
|
|
186
187
|
@info[package][:arch]
|
|
187
188
|
end
|
|
@@ -191,7 +192,7 @@ module Simp
|
|
|
191
192
|
# object was derived from an RPM spec file.
|
|
192
193
|
#
|
|
193
194
|
# @fails if package is invalid
|
|
194
|
-
def signature(package
|
|
195
|
+
def signature(package = @packages.first)
|
|
195
196
|
valid_package?(package)
|
|
196
197
|
@info[package][:signature]
|
|
197
198
|
end
|
|
@@ -199,7 +200,7 @@ module Simp
|
|
|
199
200
|
# @returns The full name of the RPM
|
|
200
201
|
#
|
|
201
202
|
# @fails if package is invalid
|
|
202
|
-
def rpm_name(package
|
|
203
|
+
def rpm_name(package = @packages.first)
|
|
203
204
|
valid_package?(package)
|
|
204
205
|
@info[package][:rpm_name]
|
|
205
206
|
end
|
|
@@ -207,7 +208,7 @@ module Simp
|
|
|
207
208
|
# @returns Whether or not the package has a `dist` tag
|
|
208
209
|
#
|
|
209
210
|
# @fails if package is invalid
|
|
210
|
-
def has_dist_tag?(package
|
|
211
|
+
def has_dist_tag?(package = @packages.first)
|
|
211
212
|
valid_package?(package)
|
|
212
213
|
@info[package][:has_dist_tag]
|
|
213
214
|
end
|
|
@@ -217,7 +218,7 @@ module Simp
|
|
|
217
218
|
# `dist`
|
|
218
219
|
#
|
|
219
220
|
# @fails if package is invalid
|
|
220
|
-
def dist(package
|
|
221
|
+
def dist(package = @packages.first)
|
|
221
222
|
valid_package?(package)
|
|
222
223
|
@info[package][:dist]
|
|
223
224
|
end
|
|
@@ -237,8 +238,8 @@ module Simp
|
|
|
237
238
|
valid_package?(package)
|
|
238
239
|
return true if other_rpm.nil? || other_rpm.empty?
|
|
239
240
|
|
|
240
|
-
unless
|
|
241
|
-
raise ArgumentError
|
|
241
|
+
unless %r{\.rpm$}.match?(other_rpm)
|
|
242
|
+
raise ArgumentError, "You must pass valid RPM name! Got: '#{other_rpm}'"
|
|
242
243
|
end
|
|
243
244
|
|
|
244
245
|
if File.readable?(other_rpm)
|
|
@@ -246,38 +247,36 @@ module Simp
|
|
|
246
247
|
else
|
|
247
248
|
# determine RPM info in a hacky way, ASSUMING, the other RPM has the
|
|
248
249
|
# same basename and arch
|
|
249
|
-
other_full_version = other_rpm.gsub(
|
|
250
|
+
other_full_version = other_rpm.gsub(%r{#{package}-}, '').gsub(%r{.rpm$}, '')
|
|
250
251
|
package_arch = arch(package)
|
|
251
|
-
unless package_arch.nil?
|
|
252
|
-
other_full_version.gsub!(
|
|
252
|
+
unless package_arch.nil? || package_arch.empty?
|
|
253
|
+
other_full_version.gsub!(%r{.#{package_arch}}, '')
|
|
253
254
|
end
|
|
254
255
|
end
|
|
255
256
|
|
|
256
257
|
begin
|
|
257
|
-
|
|
258
|
-
return Gem::Version.new(full_version(package)) > Gem::Version.new(other_full_version)
|
|
259
|
-
|
|
258
|
+
Gem::Version.new(full_version(package)) > Gem::Version.new(other_full_version)
|
|
260
259
|
rescue ArgumentError, NoMethodError
|
|
261
|
-
|
|
260
|
+
raise("Could not compare RPMs '#{rpm_name(package)}' and '#{other_rpm}'")
|
|
262
261
|
end
|
|
263
262
|
end
|
|
264
263
|
|
|
265
264
|
def valid_package?(package)
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
265
|
+
return false if @packages.include?(package)
|
|
266
|
+
|
|
267
|
+
raise ArgumentError, "'#{package}' is not a valid sub-package"
|
|
269
268
|
end
|
|
270
269
|
|
|
271
270
|
# Copies specific content from one directory to another.
|
|
272
271
|
# start_dir:: the root directory where the original files are located within
|
|
273
272
|
# src:: a pattern given to find(1) to match against the desired files to copy
|
|
274
273
|
# dest:: the destination directory to receive the copies
|
|
275
|
-
def self.copy_wo_vcs(start_dir, src, dest, dereference=true)
|
|
276
|
-
if dereference.nil? || dereference
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
274
|
+
def self.copy_wo_vcs(start_dir, src, dest, dereference = true)
|
|
275
|
+
dereference = if dereference.nil? || dereference
|
|
276
|
+
'--dereference'
|
|
277
|
+
else
|
|
278
|
+
''
|
|
279
|
+
end
|
|
281
280
|
|
|
282
281
|
Dir.chdir(start_dir) do
|
|
283
282
|
sh %{find #{src} \\( -path "*/.svn" -a -type d -o -path "*/.git*" \\) -prune -o -print | cpio -u --warning none --quiet --make-directories #{dereference} -p "#{dest}" 2>&1 > /dev/null}
|
|
@@ -288,33 +287,33 @@ module Simp
|
|
|
288
287
|
# stdout output and stderr output.
|
|
289
288
|
# cmd:: command to be executed
|
|
290
289
|
def self.execute(cmd)
|
|
291
|
-
if @verbose ||= ENV.fetch('SIMP_RPM_verbose','no') =='yes'
|
|
290
|
+
if @verbose ||= ENV.fetch('SIMP_RPM_verbose', 'no') == 'yes'
|
|
292
291
|
puts "== Simp::RPM.execute(#{cmd})"
|
|
293
292
|
puts " #{cmd}"
|
|
294
293
|
end
|
|
295
294
|
|
|
296
|
-
outfile = File.join('/tmp', "#{ENV
|
|
297
|
-
errfile = File.join('/tmp', "#{ENV
|
|
298
|
-
pid = spawn(cmd, :out=>outfile, :err=>errfile)
|
|
295
|
+
outfile = File.join('/tmp', "#{ENV.fetch('USER', nil)}_#{SecureRandom.hex}")
|
|
296
|
+
errfile = File.join('/tmp', "#{ENV.fetch('USER', nil)}_#{SecureRandom.hex}")
|
|
297
|
+
pid = spawn(cmd, :out => outfile, :err => errfile)
|
|
299
298
|
|
|
300
299
|
begin
|
|
301
|
-
|
|
300
|
+
_, status = Process.wait2(pid)
|
|
302
301
|
rescue Errno::ECHILD
|
|
303
302
|
# process exited before status could be determined
|
|
304
303
|
end
|
|
305
304
|
|
|
306
|
-
exit_status = status
|
|
307
|
-
stdout =
|
|
308
|
-
stderr =
|
|
305
|
+
exit_status = status&.exitstatus
|
|
306
|
+
stdout = File.read(outfile)
|
|
307
|
+
stderr = File.read(errfile)
|
|
309
308
|
|
|
310
309
|
{ :exit_status => exit_status, :stdout => stdout, :stderr => stderr }
|
|
311
310
|
ensure
|
|
312
311
|
if @verbose
|
|
313
312
|
puts " -------- exit_status: #{exit_status}"
|
|
314
|
-
puts
|
|
315
|
-
puts File.readlines(outfile).map{|x| " #{x}"}.join
|
|
316
|
-
puts '',
|
|
317
|
-
puts File.readlines(errfile).map{|x| " #{x}"}.join
|
|
313
|
+
puts ' -------- stdout ', ''
|
|
314
|
+
puts File.readlines(outfile).map { |x| " #{x}" }.join
|
|
315
|
+
puts '', ' -------- stderr ', ''
|
|
316
|
+
puts File.readlines(errfile).map { |x| " #{x}" }.join
|
|
318
317
|
end
|
|
319
318
|
FileUtils.rm_f([outfile, errfile])
|
|
320
319
|
end
|
|
@@ -347,49 +346,48 @@ module Simp
|
|
|
347
346
|
def self.get_info(rpm_source)
|
|
348
347
|
raise "Error: unable to read '#{rpm_source}'" unless File.readable?(rpm_source)
|
|
349
348
|
|
|
350
|
-
if ENV['SIMP_RPM_dist']
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
349
|
+
target_dist = if ENV['SIMP_RPM_dist']
|
|
350
|
+
(ENV.fetch('SIMP_RPM_dist', nil) =~ %r{^\.}) ? ENV.fetch('SIMP_RPM_dist', nil) : ('.' + ENV.fetch('SIMP_RPM_dist', nil))
|
|
351
|
+
else
|
|
352
|
+
system_dist
|
|
353
|
+
end
|
|
355
354
|
|
|
356
355
|
info_array = []
|
|
357
356
|
common_info = {}
|
|
358
357
|
|
|
359
|
-
rpm_version_query = %
|
|
358
|
+
rpm_version_query = %(#{rpm_cmd} -q --queryformat '%{NAME} %{VERSION} %{RELEASE} %{ARCH}\\n')
|
|
360
359
|
|
|
361
|
-
rpm_signature_query = %
|
|
360
|
+
rpm_signature_query = %(#{rpm_cmd} -q --queryformat '%|DSAHEADER?{%{DSAHEADER:pgpsig}}:{%|RSAHEADER?{%{RSAHEADER:pgpsig}}:{%|SIGGPG?{%{SIGGPG:pgpsig}}:{%|SIGPGP?{%{SIGPGP:pgpsig}}:{(none)}|}|}|}|\\n') # rubocop:disable Layout/LineLength
|
|
362
361
|
|
|
363
362
|
source_is_rpm = rpm_source.split('.').last == 'rpm'
|
|
364
363
|
if source_is_rpm
|
|
365
364
|
dist_info = rpm_source.split('-').last.split('.')[1..-3]
|
|
366
365
|
|
|
367
|
-
|
|
368
|
-
common_info[:has_dist_tag] = true
|
|
369
|
-
common_info[:dist] = '.' + dist_info.first
|
|
370
|
-
else
|
|
366
|
+
if dist_info.empty?
|
|
371
367
|
common_info[:has_dist_tag] = false
|
|
372
368
|
common_info[:dist] = target_dist
|
|
369
|
+
else
|
|
370
|
+
common_info[:has_dist_tag] = true
|
|
371
|
+
common_info[:dist] = '.' + dist_info.first
|
|
373
372
|
end
|
|
374
373
|
elsif File.read(rpm_source).include?('%{?dist}')
|
|
375
|
-
common_info[:dist] =target_dist
|
|
374
|
+
common_info[:dist] = target_dist
|
|
376
375
|
common_info[:has_dist_tag] = true
|
|
377
376
|
else
|
|
378
377
|
common_info[:has_dist_tag] = false
|
|
379
|
-
common_info[:dist]
|
|
378
|
+
common_info[:dist] = target_dist
|
|
380
379
|
end
|
|
381
380
|
|
|
382
381
|
unless source_is_rpm
|
|
383
382
|
macros = {
|
|
384
383
|
'dist' => target_dist
|
|
385
384
|
}
|
|
386
|
-
macros.each do |k,v|
|
|
387
|
-
rpm_version_query += %
|
|
385
|
+
macros.each do |k, v|
|
|
386
|
+
rpm_version_query += %( -D '#{k} #{v}')
|
|
388
387
|
end
|
|
389
388
|
|
|
390
389
|
end
|
|
391
390
|
|
|
392
|
-
|
|
393
391
|
if source_is_rpm
|
|
394
392
|
query_source = "-p #{rpm_source}"
|
|
395
393
|
version_results = execute("#{rpm_version_query} #{query_source}")
|
|
@@ -404,28 +402,26 @@ module Simp
|
|
|
404
402
|
raise <<~EOE
|
|
405
403
|
#{indent('Error getting RPM info for #{query_source}:', 2)}
|
|
406
404
|
#{indent(version_results[:stderr].strip, 5)}
|
|
407
|
-
#{indent("Run '#{rpm_version_query.gsub("\n",'\\n')} #{query_source}' to recreate the issue.", 2)}
|
|
405
|
+
#{indent("Run '#{rpm_version_query.gsub("\n", '\\n')} #{query_source}' to recreate the issue.", 2)}
|
|
408
406
|
EOE
|
|
409
407
|
end
|
|
410
408
|
|
|
411
409
|
unless signature_results.nil?
|
|
412
|
-
if signature_results[:exit_status] != 0
|
|
413
|
-
raise <<~EOE
|
|
410
|
+
raise <<~EOE if signature_results[:exit_status] != 0
|
|
414
411
|
#{indent('Error getting RPM signature for #{query_source}:', 2)}
|
|
415
412
|
#{indent(signature_results[:stderr].strip, 5)}
|
|
416
|
-
#{indent("Run '#{rpm_signature_query.gsub("\n",'\\n')} #{query_source}' to recreate the issue.", 2)}
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
end
|
|
413
|
+
#{indent("Run '#{rpm_signature_query.gsub("\n", '\\n')} #{query_source}' to recreate the issue.", 2)}
|
|
414
|
+
EOE
|
|
415
|
+
|
|
416
|
+
signature = signature_results[:stdout].strip
|
|
421
417
|
end
|
|
422
418
|
|
|
423
419
|
version_results[:stdout].strip.lines.each do |line|
|
|
424
420
|
info = common_info.dup
|
|
425
|
-
parts = line.split
|
|
421
|
+
parts = line.split
|
|
426
422
|
|
|
427
423
|
info[:basename], info[:version], info[:release], info[:arch] = parts
|
|
428
|
-
info[:signature] = signature unless signature.nil?
|
|
424
|
+
info[:signature] = signature unless signature.nil? || signature.include?('none')
|
|
429
425
|
info[:full_version] = "#{info[:version]}-#{info[:release]}"
|
|
430
426
|
info[:name] = "#{info[:basename]}-#{info[:full_version]}"
|
|
431
427
|
info[:rpm_name] = "#{info[:name]}.#{info[:arch]}.rpm"
|
|
@@ -434,35 +430,35 @@ module Simp
|
|
|
434
430
|
end
|
|
435
431
|
|
|
436
432
|
if @verbose
|
|
437
|
-
puts
|
|
433
|
+
puts '== SIMP::RPM.get_info'
|
|
438
434
|
require 'pp'
|
|
439
435
|
pp info_array
|
|
440
436
|
end
|
|
441
437
|
|
|
442
438
|
if info_array.size == 1
|
|
443
|
-
|
|
439
|
+
info_array[0]
|
|
444
440
|
else
|
|
445
441
|
# will only happen when source is spec file and that spec file
|
|
446
442
|
# specifies sub-packages
|
|
447
|
-
|
|
443
|
+
info_array
|
|
448
444
|
end
|
|
449
445
|
end
|
|
450
446
|
|
|
451
447
|
def self.indent(message, indent_length)
|
|
452
|
-
|
|
448
|
+
message.split("\n").map { |line| (' ' * indent_length) + line }.join("\n")
|
|
453
449
|
end
|
|
454
450
|
|
|
455
|
-
def self.create_rpm_build_metadata(project_dir, srpms=nil, rpms=nil)
|
|
451
|
+
def self.create_rpm_build_metadata(project_dir, srpms = nil, rpms = nil)
|
|
456
452
|
require 'yaml'
|
|
457
453
|
|
|
458
454
|
last_build = {
|
|
459
|
-
'git_hash' =>
|
|
460
|
-
'srpms'
|
|
461
|
-
'rpms'
|
|
455
|
+
'git_hash' => `git rev-list --max-count=1 HEAD`.chomp,
|
|
456
|
+
'srpms' => {},
|
|
457
|
+
'rpms' => {}
|
|
462
458
|
}
|
|
463
459
|
|
|
464
460
|
Dir.chdir(File.join(project_dir, 'dist')) do
|
|
465
|
-
if srpms.nil?
|
|
461
|
+
if srpms.nil? || rpms.nil?
|
|
466
462
|
all_rpms = Dir.glob('*.rpm')
|
|
467
463
|
srpms = Dir.glob('src.rpm')
|
|
468
464
|
rpms = all_rpms - srpms
|
|
@@ -472,10 +468,10 @@ module Simp
|
|
|
472
468
|
file_stat = File.stat(srpm)
|
|
473
469
|
|
|
474
470
|
last_build['srpms'][File.basename(srpm)] = {
|
|
475
|
-
'metadata'
|
|
476
|
-
'size'
|
|
471
|
+
'metadata' => Simp::RPM.get_info(srpm),
|
|
472
|
+
'size' => file_stat.size,
|
|
477
473
|
'timestamp' => file_stat.ctime,
|
|
478
|
-
'path'
|
|
474
|
+
'path' => File.absolute_path(srpm)
|
|
479
475
|
}
|
|
480
476
|
end
|
|
481
477
|
|
|
@@ -484,14 +480,14 @@ module Simp
|
|
|
484
480
|
|
|
485
481
|
last_build['rpms'][File.basename(rpm)] = {
|
|
486
482
|
'metadata' => Simp::RPM.get_info(rpm),
|
|
487
|
-
'size'
|
|
483
|
+
'size' => file_stat.size,
|
|
488
484
|
'timestamp' => file_stat.ctime,
|
|
489
|
-
'path'
|
|
490
|
-
|
|
485
|
+
'path' => File.absolute_path(rpm)
|
|
486
|
+
}
|
|
491
487
|
end
|
|
492
488
|
|
|
493
489
|
FileUtils.mkdir_p(File.join(project_dir, 'dist', 'logs'))
|
|
494
|
-
File.open('logs/last_rpm_build_metadata.yaml','w') do |fh|
|
|
490
|
+
File.open('logs/last_rpm_build_metadata.yaml', 'w') do |fh|
|
|
495
491
|
fh.puts(last_build.to_yaml)
|
|
496
492
|
end
|
|
497
493
|
end
|
|
@@ -499,7 +495,7 @@ module Simp
|
|
|
499
495
|
|
|
500
496
|
# Returns the version of RPM installed on the system
|
|
501
497
|
def self.version
|
|
502
|
-
|
|
498
|
+
`rpm --version`.strip.split.last
|
|
503
499
|
end
|
|
504
500
|
end
|
|
505
501
|
end
|