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/rake/build/pkg.rb
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/rake -T
|
|
2
|
+
# frozen_string_literal: true
|
|
2
3
|
|
|
4
|
+
require 'English'
|
|
3
5
|
require 'simp/yum'
|
|
4
6
|
require 'simp/rake/pkg'
|
|
5
7
|
require 'simp/rake/build/constants'
|
|
@@ -7,118 +9,120 @@ require 'simp/rake/build/rpmdeps'
|
|
|
7
9
|
|
|
8
10
|
module Simp; end
|
|
9
11
|
module Simp::Rake; end
|
|
10
|
-
module Simp::Rake::Build
|
|
11
12
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
class Simp::Rake::Build::Pkg < Rake::TaskLib
|
|
14
|
+
include Simp::Rake
|
|
15
|
+
include Simp::Rake::Build::Constants
|
|
15
16
|
|
|
16
|
-
|
|
17
|
-
|
|
17
|
+
def initialize(base_dir)
|
|
18
|
+
init_member_vars(base_dir)
|
|
18
19
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
20
|
+
@cpu_limit = get_cpu_limit
|
|
21
|
+
@verbose = ENV.fetch('SIMP_PKG_verbose', 'no') == 'yes'
|
|
22
|
+
@rpm_build_metadata = 'last_rpm_build_metadata.yaml'
|
|
23
|
+
@rpm_dependency_file = File.join(@base_dir, 'build', 'rpm', 'dependencies.yaml')
|
|
24
|
+
@build_keys_dir = ENV.fetch('SIMP_PKG_build_keys_dir', File.join(@base_dir, '.dev_gpgkeys'))
|
|
25
|
+
@long_gpg_socket_err_msg = <<~MSG
|
|
25
26
|
If the problem is 'socket name <xxx> is too long', use SIMP_PKG_build_keys_dir
|
|
26
27
|
to override
|
|
27
28
|
#{@build_keys_dir}
|
|
28
29
|
with a shorter path. The socket name must be < 108 characters.
|
|
29
30
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
# Main tasks
|
|
43
|
-
##############################################################################
|
|
31
|
+
MSG
|
|
32
|
+
# nil = default not set; use local preference
|
|
33
|
+
@fetch_published_rpm_default = if ENV['SIMP_PKG_fetch_published_rpm']
|
|
34
|
+
(
|
|
35
|
+
(ENV.fetch('SIMP_PKG_fetch_published_rpm', nil) =~ %r{\A(yes|true)\Z}i) ? true : false
|
|
36
|
+
)
|
|
37
|
+
else
|
|
38
|
+
nil
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
define_tasks
|
|
42
|
+
end
|
|
44
43
|
|
|
45
|
-
|
|
46
|
-
|
|
44
|
+
def define_tasks
|
|
45
|
+
namespace :pkg do
|
|
46
|
+
##############################################################################
|
|
47
|
+
# Main tasks
|
|
48
|
+
##############################################################################
|
|
49
|
+
|
|
50
|
+
# Have to get things set up inside the proper namespace
|
|
51
|
+
task :prep, [:method] do |_t, args|
|
|
52
|
+
# This doesn't get caught for things like 'rake clean'
|
|
53
|
+
if $simp6 && $simp6_build_dir
|
|
54
|
+
@build_dir = $simp6_build_dir || @distro_build_dir
|
|
55
|
+
@dvd_src = File.join(@build_dir, File.basename(@dvd_src))
|
|
56
|
+
end
|
|
47
57
|
|
|
48
|
-
|
|
49
|
-
if $simp6 && $simp6_build_dir
|
|
50
|
-
@build_dir = $simp6_build_dir || @distro_build_dir
|
|
51
|
-
@dvd_src = File.join(@build_dir, File.basename(@dvd_src))
|
|
52
|
-
end
|
|
58
|
+
args.with_defaults(:method => 'tracking')
|
|
53
59
|
|
|
54
|
-
|
|
60
|
+
@build_dirs = {
|
|
61
|
+
:modules => get_module_dirs(args[:method]),
|
|
62
|
+
:aux => [
|
|
63
|
+
# Anything in here gets built!
|
|
64
|
+
"#{@src_dir}/assets/*",
|
|
65
|
+
],
|
|
66
|
+
:doc => "#{@src_dir}/doc"
|
|
67
|
+
}
|
|
55
68
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
# Anything in here gets built!
|
|
60
|
-
"#{@src_dir}/assets/*"
|
|
61
|
-
],
|
|
62
|
-
:doc => "#{@src_dir}/doc"
|
|
63
|
-
}
|
|
69
|
+
@build_dirs[:aux].map! { |dir| Dir.glob(dir) }
|
|
70
|
+
@build_dirs[:aux].flatten!
|
|
71
|
+
@build_dirs[:aux].delete_if { |f| !File.directory?(f) }
|
|
64
72
|
|
|
65
|
-
|
|
66
|
-
@
|
|
67
|
-
|
|
73
|
+
@pkg_dirs = {
|
|
74
|
+
:simp => "#{@build_dir}/SIMP"
|
|
75
|
+
}
|
|
76
|
+
end
|
|
68
77
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
}
|
|
72
|
-
end
|
|
78
|
+
clean_failures = []
|
|
79
|
+
clean_failures_lock = Mutex.new
|
|
73
80
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
rescue Exception => e
|
|
92
|
-
clean_failures_lock.synchronize do
|
|
93
|
-
clean_failures << dir
|
|
94
|
-
end
|
|
95
|
-
raise Parallel::Kill
|
|
81
|
+
task :clean => [:prep] do |t, _args|
|
|
82
|
+
@build_dirs.each_pair do |_k, dirs|
|
|
83
|
+
Parallel.map(
|
|
84
|
+
Array(dirs),
|
|
85
|
+
:in_processes => @cpu_limit,
|
|
86
|
+
:progress => t.name,
|
|
87
|
+
) do |dir|
|
|
88
|
+
Dir.chdir(dir) do
|
|
89
|
+
begin
|
|
90
|
+
rake_flags = Rake.application.options.trace ? '--trace' : ''
|
|
91
|
+
`rake clean #{rake_flags}`
|
|
92
|
+
clean_failures_lock.synchronize do
|
|
93
|
+
clean_failures << dir unless $CHILD_STATUS.success?
|
|
94
|
+
end
|
|
95
|
+
rescue Exception
|
|
96
|
+
clean_failures_lock.synchronize do
|
|
97
|
+
clean_failures << dir
|
|
96
98
|
end
|
|
99
|
+
raise Parallel::Kill
|
|
97
100
|
end
|
|
98
101
|
end
|
|
99
102
|
end
|
|
103
|
+
end
|
|
100
104
|
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
end
|
|
105
|
+
unless clean_failures.empty?
|
|
106
|
+
raise(%(Error: The following directories had failures in #{task.name}:\n * #{clean_failures.join("\n * ")}))
|
|
104
107
|
end
|
|
108
|
+
end
|
|
105
109
|
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
end
|
|
110
|
+
task :clobber => [:prep] do |t, _args|
|
|
111
|
+
@build_dirs.each_pair do |_k, dirs|
|
|
112
|
+
Parallel.map(
|
|
113
|
+
Array(dirs),
|
|
114
|
+
:in_processes => @cpu_limit,
|
|
115
|
+
:progress => t.name,
|
|
116
|
+
) do |dir|
|
|
117
|
+
Dir.chdir(dir) do
|
|
118
|
+
rake_flags = Rake.application.options.trace ? '--trace' : ''
|
|
119
|
+
sh %(rake clobber #{rake_flags})
|
|
117
120
|
end
|
|
118
121
|
end
|
|
119
122
|
end
|
|
123
|
+
end
|
|
120
124
|
|
|
121
|
-
|
|
125
|
+
desc <<~DESC
|
|
122
126
|
Prepare a GPG signing key to sign build packages
|
|
123
127
|
|
|
124
128
|
* :key - the name of the build keys subdirectory to prepare
|
|
@@ -146,147 +150,144 @@ module Simp::Rake::Build
|
|
|
146
150
|
ENV vars:
|
|
147
151
|
- Set `SIMP_PKG_verbose=yes` to report file operations as they happen.
|
|
148
152
|
- Set `SIMP_PKG_build_keys_dir` to override the default build keys path.
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
153
|
+
DESC
|
|
154
|
+
task :key_prep, [:key] => [:prep] do |_t, args|
|
|
155
|
+
args.with_defaults(:key => 'dev')
|
|
156
|
+
key = args.key
|
|
157
|
+
key_dir = File.join(@build_keys_dir, key)
|
|
158
|
+
dvd_dir = @dvd_src
|
|
155
159
|
|
|
156
|
-
|
|
160
|
+
FileUtils.mkdir_p @build_keys_dir
|
|
157
161
|
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
162
|
+
Dir.chdir(@build_keys_dir) do
|
|
163
|
+
if key == 'dev'
|
|
164
|
+
require 'simp/local_gpg_signing_key'
|
|
161
165
|
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
end
|
|
166
|
+
begin
|
|
167
|
+
Simp::LocalGpgSigningKey.new(key_dir, { verbose: @verbose }).ensure_key
|
|
168
|
+
rescue Exception => e
|
|
169
|
+
raise("#{e.message}\n\n#{@long_gpg_socket_err_msg}")
|
|
170
|
+
end
|
|
171
|
+
else
|
|
172
|
+
unless File.directory?(key_dir)
|
|
173
|
+
raise("Could not find GPG keydir '#{key_dir}' in '#{Dir.pwd}'")
|
|
171
174
|
end
|
|
175
|
+
end
|
|
172
176
|
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
177
|
+
Dir.chdir(key_dir) do
|
|
178
|
+
rpm_build_keys = Dir.glob('RPM-GPG-KEY-*')
|
|
179
|
+
if rpm_build_keys.empty?
|
|
180
|
+
raise("Could not find any RPM-GPG-KEY-* files in '#{key_dir}'")
|
|
181
|
+
end
|
|
178
182
|
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
183
|
+
# Copy development keys into the root of the ISO for convenience
|
|
184
|
+
if key == 'dev'
|
|
185
|
+
unless File.directory?(dvd_dir)
|
|
186
|
+
raise("Could not find DVD ISO root directory '#{dvd_dir}'")
|
|
187
|
+
end
|
|
184
188
|
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
end
|
|
189
|
+
rpm_build_keys.each do |gpgkey|
|
|
190
|
+
FileUtils.cp(gpgkey, dvd_dir, :verbose => @verbose)
|
|
191
|
+
end
|
|
192
|
+
# Otherwise, make sure it isn't present for the build
|
|
193
|
+
else
|
|
194
|
+
Dir[File.join(dvd_dir, 'RPM-GPG-KEY-SIMP*')].each do |to_del|
|
|
195
|
+
FileUtils.rm(to_del)
|
|
193
196
|
end
|
|
194
197
|
end
|
|
195
198
|
end
|
|
196
199
|
end
|
|
200
|
+
end
|
|
197
201
|
|
|
198
|
-
|
|
199
|
-
|
|
202
|
+
def populate_rpm_dir(rpm_dir)
|
|
203
|
+
srpm_dir = File.join(File.dirname(rpm_dir), 'SRPMS')
|
|
200
204
|
|
|
201
|
-
|
|
202
|
-
|
|
205
|
+
FileUtils.mkdir_p(rpm_dir)
|
|
206
|
+
FileUtils.mkdir_p(srpm_dir)
|
|
203
207
|
|
|
204
|
-
|
|
208
|
+
rpm_metadata = `find -P #{@src_dir} -xdev -type f -name #{@rpm_build_metadata}`.lines.map(&:strip).sort
|
|
205
209
|
|
|
206
|
-
|
|
210
|
+
raise("No #{@rpm_build_metadata} files found under #{@src_dir}") if rpm_metadata.empty?
|
|
207
211
|
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
+
rpm_metadata.each do |mf|
|
|
213
|
+
metadata = YAML.load_file(mf)
|
|
214
|
+
rpms = metadata['rpms']
|
|
215
|
+
srpms = metadata['srpms']
|
|
212
216
|
|
|
213
|
-
|
|
217
|
+
raise("No RPMs found at #{rpm_dir}") if rpms.nil? || rpms.empty?
|
|
214
218
|
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
219
|
+
have_signed_rpm = false
|
|
220
|
+
Dir.chdir(rpm_dir) do
|
|
221
|
+
rpms.each_key do |rpm|
|
|
222
|
+
if @verbose
|
|
223
|
+
puts "Copying #{rpm} to #{rpm_dir}"
|
|
224
|
+
end
|
|
221
225
|
|
|
222
|
-
|
|
223
|
-
|
|
226
|
+
arch = rpms[rpm]['metadata'][:arch]
|
|
227
|
+
FileUtils.mkdir_p(arch)
|
|
224
228
|
|
|
225
|
-
|
|
229
|
+
FileUtils.cp(rpms[rpm]['path'], arch)
|
|
226
230
|
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
end
|
|
231
|
+
if rpms[rpm][:signature]
|
|
232
|
+
have_signed_rpm = true
|
|
230
233
|
end
|
|
231
234
|
end
|
|
235
|
+
end
|
|
232
236
|
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
if @verbose
|
|
237
|
-
puts "Found signed RPM - skipping copy of '#{srpm}'"
|
|
238
|
-
end
|
|
239
|
-
|
|
240
|
-
next
|
|
241
|
-
end
|
|
242
|
-
|
|
237
|
+
Dir.chdir(srpm_dir) do
|
|
238
|
+
srpms.each_key do |srpm|
|
|
239
|
+
if have_signed_rpm && !srpms[srpm][:signature]
|
|
243
240
|
if @verbose
|
|
244
|
-
puts "
|
|
241
|
+
puts "Found signed RPM - skipping copy of '#{srpm}'"
|
|
245
242
|
end
|
|
246
243
|
|
|
247
|
-
|
|
248
|
-
|
|
244
|
+
next
|
|
245
|
+
end
|
|
249
246
|
|
|
250
|
-
|
|
247
|
+
if @verbose
|
|
248
|
+
puts "Copying '#{srpm}' to '#{srpm_dir}'"
|
|
251
249
|
end
|
|
250
|
+
|
|
251
|
+
arch = srpms[srpm]['metadata'][:arch]
|
|
252
|
+
FileUtils.mkdir_p(arch)
|
|
253
|
+
|
|
254
|
+
FileUtils.cp(srpms[srpm]['path'], arch)
|
|
252
255
|
end
|
|
253
256
|
end
|
|
254
257
|
end
|
|
258
|
+
end
|
|
255
259
|
|
|
260
|
+
# desc <<~DESC
|
|
261
|
+
# Build the entire SIMP release.
|
|
262
|
+
#
|
|
263
|
+
# * :docs - Build the docs. Set this to false if you wish to skip building the docs.
|
|
264
|
+
# * :key - The GPG key to sign the RPMs with. Defaults to 'dev'.
|
|
265
|
+
#
|
|
266
|
+
# ENV vars:
|
|
267
|
+
# - Set `SIMP_PKG_verbose=yes` to report file operations as they happen.
|
|
268
|
+
# - Set `SIMP_YUM_makecache=no` if you do NOT want to rebuild the
|
|
269
|
+
# build-specific YUM cache
|
|
270
|
+
# DESC
|
|
271
|
+
task :build, [:docs, :key] => [:prep, :key_prep] do |_t, args|
|
|
272
|
+
args.with_defaults(:key => 'dev')
|
|
273
|
+
args.with_defaults(:docs => 'true')
|
|
274
|
+
|
|
275
|
+
check_dvd_env
|
|
276
|
+
|
|
277
|
+
get_yum_helper
|
|
278
|
+
|
|
279
|
+
Rake::Task['pkg:aux'].invoke
|
|
280
|
+
if args.docs.to_s == 'true'
|
|
281
|
+
Rake::Task['pkg:doc'].invoke
|
|
282
|
+
end
|
|
283
|
+
Rake::Task['pkg:modules'].invoke
|
|
256
284
|
|
|
257
|
-
|
|
258
|
-
desc <<~DESC
|
|
259
|
-
Build the entire SIMP release.
|
|
260
|
-
|
|
261
|
-
* :docs - Build the docs. Set this to false if you wish to skip building the docs.
|
|
262
|
-
* :key - The GPG key to sign the RPMs with. Defaults to 'dev'.
|
|
263
|
-
|
|
264
|
-
ENV vars:
|
|
265
|
-
- Set `SIMP_PKG_verbose=yes` to report file operations as they happen.
|
|
266
|
-
- Set `SIMP_YUM_makecache=no` if you do NOT want to rebuild the
|
|
267
|
-
build-specific YUM cache
|
|
268
|
-
DESC
|
|
269
|
-
=end
|
|
270
|
-
task :build,[:docs,:key] => [:prep,:key_prep] do |t,args|
|
|
271
|
-
args.with_defaults(:key => 'dev')
|
|
272
|
-
args.with_defaults(:docs => 'true')
|
|
273
|
-
|
|
274
|
-
check_dvd_env
|
|
275
|
-
|
|
276
|
-
get_yum_helper
|
|
277
|
-
|
|
278
|
-
Rake::Task['pkg:aux'].invoke
|
|
279
|
-
if "#{args.docs}" == 'true'
|
|
280
|
-
Rake::Task['pkg:doc'].invoke
|
|
281
|
-
end
|
|
282
|
-
Rake::Task['pkg:modules'].invoke
|
|
283
|
-
|
|
284
|
-
populate_rpm_dir(@rpm_dir)
|
|
285
|
+
populate_rpm_dir(@rpm_dir)
|
|
285
286
|
|
|
286
|
-
|
|
287
|
-
|
|
287
|
+
Rake::Task['pkg:signrpms'].invoke(args[:key])
|
|
288
|
+
end
|
|
288
289
|
|
|
289
|
-
|
|
290
|
+
desc <<~DESC
|
|
290
291
|
Build the Puppet module RPMs.
|
|
291
292
|
|
|
292
293
|
* :method - The Puppetfile from which the repository information
|
|
@@ -294,12 +295,12 @@ module Simp::Rake::Build
|
|
|
294
295
|
|
|
295
296
|
ENV vars:
|
|
296
297
|
- Set `SIMP_PKG_verbose=yes` to report file operations as they happen.
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
298
|
+
DESC
|
|
299
|
+
task :modules, [:method] => [:prep] do |t, _args|
|
|
300
|
+
build(@build_dirs[:modules], t)
|
|
301
|
+
end
|
|
301
302
|
|
|
302
|
-
|
|
303
|
+
desc <<~DESC
|
|
303
304
|
Build a single Puppet Module RPM.
|
|
304
305
|
|
|
305
306
|
* :name - The path, or name, of the module to build. If a name is
|
|
@@ -313,59 +314,59 @@ module Simp::Rake::Build
|
|
|
313
314
|
- Set `SIMP_PKG_verbose=yes` to report file operations as they happen.
|
|
314
315
|
- Set `SIMP_YUM_makecache=no` if you do NOT want to rebuild the
|
|
315
316
|
build-specific YUM cache
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
317
|
+
DESC
|
|
318
|
+
task :single, [:name, :method] => [:prep] do |t, args|
|
|
319
|
+
raise("You must pass :name to '#{t.name}'") unless args[:name]
|
|
319
320
|
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
if args[:name].include?('/')
|
|
324
|
-
fail("'#{args[:name]}' does not exist!") unless File.directory?(mod_path)
|
|
325
|
-
else
|
|
326
|
-
load_puppetfile(args[:method])
|
|
327
|
-
local_module = puppetfile.modules.select{|m| m[:name] == args[:name]}.first
|
|
321
|
+
mod_path = File.absolute_path(args[:name])
|
|
322
|
+
get_yum_helper
|
|
328
323
|
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
324
|
+
if args[:name].include?('/')
|
|
325
|
+
raise("'#{args[:name]}' does not exist!") unless File.directory?(mod_path)
|
|
326
|
+
else
|
|
327
|
+
load_puppetfile(args[:method])
|
|
328
|
+
local_module = puppetfile.modules.find { |m| m[:name] == args[:name] }
|
|
332
329
|
|
|
333
|
-
|
|
330
|
+
unless local_module
|
|
331
|
+
raise("'#{args[:name]}' was not found in the Puppetfile")
|
|
334
332
|
end
|
|
335
333
|
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
puts("Your packages can be found in '#{mod_path}/dist'")
|
|
334
|
+
mod_path = local_module[:path]
|
|
339
335
|
end
|
|
340
336
|
|
|
341
|
-
|
|
337
|
+
build(Array(mod_path), t)
|
|
338
|
+
|
|
339
|
+
puts("Your packages can be found in '#{mod_path}/dist'")
|
|
340
|
+
end
|
|
341
|
+
|
|
342
|
+
desc <<~DESC
|
|
342
343
|
Build the SIMP non-module RPMs.
|
|
343
344
|
|
|
344
345
|
ENV vars:
|
|
345
346
|
- Set `SIMP_PKG_verbose=yes` to report file operations as they happen.
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
347
|
+
DESC
|
|
348
|
+
task :aux => [:prep] do |t, _args|
|
|
349
|
+
build(@build_dirs[:aux], t)
|
|
350
|
+
end
|
|
350
351
|
|
|
351
|
-
|
|
352
|
+
desc <<~DESC
|
|
352
353
|
Build the SIMP documentation.
|
|
353
354
|
|
|
354
355
|
ENV vars:
|
|
355
356
|
- Set `SIMP_PKG_verbose=yes` to report file operations as they happen.
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
Dir.chdir(@build_dirs[:doc]) do
|
|
362
|
-
sh %{rake munge:prep}
|
|
363
|
-
end
|
|
357
|
+
DESC
|
|
358
|
+
task :doc => [:prep] do |t, _args|
|
|
359
|
+
# Need to make sure that the docs have the version updated
|
|
360
|
+
# appropriately prior to building
|
|
364
361
|
|
|
365
|
-
|
|
362
|
+
Dir.chdir(@build_dirs[:doc]) do
|
|
363
|
+
sh %(rake munge:prep)
|
|
366
364
|
end
|
|
367
365
|
|
|
368
|
-
|
|
366
|
+
build(@build_dirs[:doc], t)
|
|
367
|
+
end
|
|
368
|
+
|
|
369
|
+
desc <<~DESC
|
|
369
370
|
Sign a set of RPMs.
|
|
370
371
|
|
|
371
372
|
Signs any unsigned RPMs in the specified directory
|
|
@@ -386,160 +387,157 @@ module Simp::Rake::Build
|
|
|
386
387
|
* Set `SIMP_PKG_rpmsign_timeout` to override the maximum time in seconds
|
|
387
388
|
to wait for an individual RPM signing operation to complete.
|
|
388
389
|
- Defaults to 60 seconds.
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
390
|
+
DESC
|
|
391
|
+
task :signrpms, [:key, :rpm_dir, :force, :digest_algo] => [:prep, :key_prep] do |t, args|
|
|
392
|
+
require 'simp/rpm_signer'
|
|
393
|
+
|
|
394
|
+
args.with_defaults(:key => 'dev')
|
|
395
|
+
args.with_defaults(:rpm_dir => File.join(File.dirname(@rpm_dir), '*RPMS'))
|
|
396
|
+
args.with_defaults(:force => 'false')
|
|
397
|
+
args.with_defaults(:digest_algo => 'sha256')
|
|
398
|
+
|
|
399
|
+
force = (args[:force].to_s != 'false')
|
|
400
|
+
timeout = ENV['SIMP_PKG_rpmsign_timeout'] ? ENV['SIMP_PKG_rpmsign_timeout'].to_i : 60
|
|
401
|
+
|
|
402
|
+
opts = {
|
|
403
|
+
:digest_algo => args[:digest_algo],
|
|
404
|
+
:force => force,
|
|
405
|
+
:max_concurrent => @cpu_limit,
|
|
406
|
+
:progress_bar_title => t.name,
|
|
407
|
+
:timeout_seconds => timeout,
|
|
408
|
+
:verbose => @verbose
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
results = nil
|
|
412
|
+
begin
|
|
413
|
+
results = Simp::RpmSigner.sign_rpms(
|
|
414
|
+
args[:rpm_dir],
|
|
415
|
+
File.join(@build_keys_dir, args[:key]),
|
|
416
|
+
opts,
|
|
417
|
+
)
|
|
418
|
+
rescue Exception => e
|
|
419
|
+
raise("#{e.message}\n\n#{@long_gpg_socket_err_msg}")
|
|
420
|
+
end
|
|
409
421
|
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
422
|
+
if results
|
|
423
|
+
successes = results.select { |_rpm, status| status == :signed }
|
|
424
|
+
failures = results.select { |_rpm, status| status == :unsigned }
|
|
425
|
+
already_signed = results.select { |_rpm, status| status == :skipped_already_signed }
|
|
426
|
+
|
|
427
|
+
if opts[:verbose]
|
|
428
|
+
puts
|
|
429
|
+
puts 'Summary'
|
|
430
|
+
puts '======='
|
|
431
|
+
puts "# RPMs already signed: #{already_signed.size}"
|
|
432
|
+
puts "# RPMs successfully signed: #{successes.size}"
|
|
433
|
+
puts "# RPM signing failures: #{failures.size}"
|
|
434
|
+
puts
|
|
419
435
|
end
|
|
420
436
|
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
puts '======='
|
|
430
|
-
puts "# RPMs already signed: #{already_signed.size}"
|
|
431
|
-
puts "# RPMs successfully signed: #{successes.size}"
|
|
432
|
-
puts "# RPM signing failures: #{failures.size}"
|
|
433
|
-
puts
|
|
434
|
-
end
|
|
435
|
-
|
|
436
|
-
if !failures.empty?
|
|
437
|
-
if ((results.size - already_signed.size) == (failures.size))
|
|
438
|
-
detail = already_signed.empty? ? '' : 'unsigned '
|
|
439
|
-
raise("ERROR: Failed to sign all #{detail}RPMs in #{args[:rpm_dir]}")
|
|
440
|
-
else
|
|
441
|
-
err_msg = "ERROR: Failed to sign some RPMs in #{args[:rpm_dir]}:\n"
|
|
442
|
-
err_msg += " #{failures.keys.join("\n ")}"
|
|
443
|
-
raise(err_msg)
|
|
444
|
-
end
|
|
437
|
+
unless failures.empty?
|
|
438
|
+
if (results.size - already_signed.size) == failures.size
|
|
439
|
+
detail = already_signed.empty? ? '' : 'unsigned '
|
|
440
|
+
raise("ERROR: Failed to sign all #{detail}RPMs in #{args[:rpm_dir]}")
|
|
441
|
+
else
|
|
442
|
+
err_msg = "ERROR: Failed to sign some RPMs in #{args[:rpm_dir]}:\n"
|
|
443
|
+
err_msg += " #{failures.keys.join("\n ")}"
|
|
444
|
+
raise(err_msg)
|
|
445
445
|
end
|
|
446
446
|
end
|
|
447
447
|
end
|
|
448
|
+
end
|
|
448
449
|
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
450
|
+
# desc <<~DESC
|
|
451
|
+
# Check that RPMs are signed.
|
|
452
|
+
#
|
|
453
|
+
# Checks all RPM files in a directory to see if they are trusted.
|
|
454
|
+
# * :rpm_dir - A directory containing RPM files to check. Default #{@build_dir}/SIMP
|
|
455
|
+
# * :key_dir - The path to the GPG keys you want to check the packages against. Default #{@src_dir}/assets/gpgkeys/
|
|
456
|
+
# DESC
|
|
457
|
+
task :checksig, [:rpm_dir, :key_dir] => [:prep] do |_t, args|
|
|
458
|
+
begin
|
|
459
|
+
default_key_dir = File.join(@src_dir, 'assets', 'gpgkeys', 'GPGKEYS')
|
|
460
|
+
args.with_defaults(:rpm_dir => @pkg_dirs[:simp])
|
|
461
|
+
args.with_defaults(:key_dir => default_key_dir)
|
|
452
462
|
|
|
453
|
-
|
|
454
|
-
* :rpm_dir - A directory containing RPM files to check. Default #{@build_dir}/SIMP
|
|
455
|
-
* :key_dir - The path to the GPG keys you want to check the packages against. Default #{@src_dir}/assets/gpgkeys/
|
|
456
|
-
DESC
|
|
457
|
-
=end
|
|
458
|
-
task :checksig,[:rpm_dir,:key_dir] => [:prep] do |t,args|
|
|
459
|
-
begin
|
|
463
|
+
rpm_dirs = Dir.glob(args[:rpm_dir])
|
|
460
464
|
|
|
461
|
-
|
|
462
|
-
args.with_defaults(:rpm_dir => @pkg_dirs[:simp])
|
|
463
|
-
args.with_defaults(:key_dir => default_key_dir)
|
|
465
|
+
raise("Could not find files at #{args[:rpm_dir]}!") if rpm_dirs.empty?
|
|
464
466
|
|
|
465
|
-
|
|
467
|
+
temp_gpg_dir = Dir.mktmpdir
|
|
468
|
+
at_exit { FileUtils.rm_rf(temp_gpg_dir) }
|
|
466
469
|
|
|
467
|
-
|
|
470
|
+
rpm_cmd = %(rpm --dbpath #{temp_gpg_dir})
|
|
468
471
|
|
|
469
|
-
|
|
470
|
-
at_exit { FileUtils.remove_entry(temp_gpg_dir) if File.exist?(temp_gpg_dir) }
|
|
472
|
+
`#{rpm_cmd} --initdb`
|
|
471
473
|
|
|
472
|
-
|
|
474
|
+
public_keys = Dir.glob(File.join(args[:key_dir], '*'))
|
|
473
475
|
|
|
474
|
-
|
|
476
|
+
if public_keys.empty?
|
|
477
|
+
key_dirs_tried = [args[:key_dir]]
|
|
475
478
|
|
|
476
|
-
|
|
479
|
+
# try path to GPG keys for SIMP 6.1+
|
|
480
|
+
if (args[:key_dir] != default_key_dir) && File.exist?(default_key_dir)
|
|
481
|
+
key_dirs_tried << default_key_dir
|
|
482
|
+
public_keys = Dir.glob(File.join(default_key_dir, '*'))
|
|
483
|
+
end
|
|
477
484
|
|
|
478
485
|
if public_keys.empty?
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
public_keys = Dir.glob(File.join(default_key_dir, '*'))
|
|
485
|
-
end
|
|
486
|
-
|
|
487
|
-
if public_keys.empty?
|
|
488
|
-
# try path to GPG keys for SIMP 6.0
|
|
489
|
-
old_key_dir = File.join(@src_dir, 'assets', 'simp-gpgkeys', 'GPGKEYS')
|
|
490
|
-
if File.exist?(old_key_dir)
|
|
491
|
-
key_dirs_tried << old_key_dir
|
|
492
|
-
public_keys = Dir.glob(File.join(old_key_dir, '*'))
|
|
493
|
-
end
|
|
486
|
+
# try path to GPG keys for SIMP 6.0
|
|
487
|
+
old_key_dir = File.join(@src_dir, 'assets', 'simp-gpgkeys', 'GPGKEYS')
|
|
488
|
+
if File.exist?(old_key_dir)
|
|
489
|
+
key_dirs_tried << old_key_dir
|
|
490
|
+
public_keys = Dir.glob(File.join(old_key_dir, '*'))
|
|
494
491
|
end
|
|
492
|
+
end
|
|
495
493
|
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
end
|
|
494
|
+
if public_keys.empty?
|
|
495
|
+
warn "pkg:checksig: Warning no GPG keys found in #{key_dirs_tried}"
|
|
499
496
|
end
|
|
497
|
+
end
|
|
500
498
|
|
|
501
|
-
|
|
502
|
-
|
|
499
|
+
# be sure to include any development keys packaged with the DVD
|
|
500
|
+
public_keys += Dir.glob(File.join(@dvd_src, 'RPM-GPG-KEY*'))
|
|
503
501
|
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
502
|
+
# Only import thngs that look like GPG keys...
|
|
503
|
+
public_keys.each do |key|
|
|
504
|
+
next if File.directory?(key) || !File.readable?(key)
|
|
507
505
|
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
end
|
|
506
|
+
File.read(key).each_line do |line|
|
|
507
|
+
if line.include?('-----BEGIN PGP PUBLIC KEY BLOCK-----')
|
|
508
|
+
`#{rpm_cmd} --import #{key}`
|
|
509
|
+
break
|
|
513
510
|
end
|
|
514
511
|
end
|
|
512
|
+
end
|
|
515
513
|
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
end
|
|
514
|
+
bad_rpms = []
|
|
515
|
+
rpm_dirs.each do |rpm_dir|
|
|
516
|
+
Find.find(rpm_dir) do |path|
|
|
517
|
+
next unless %r{.*\.rpm$}.match?(path)
|
|
518
|
+
|
|
519
|
+
`#{rpm_cmd} --checksig #{path}`.strip
|
|
520
|
+
result = $CHILD_STATUS
|
|
521
|
+
unless result&.exitstatus&.zero?
|
|
522
|
+
bad_rpms << path.split(%r{\s}).first
|
|
526
523
|
end
|
|
527
524
|
end
|
|
525
|
+
end
|
|
528
526
|
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
527
|
+
if bad_rpms.empty?
|
|
528
|
+
puts 'Checksig succeeded'
|
|
529
|
+
else
|
|
530
|
+
bad_rpms.map! { |x| " * #{x}" }
|
|
531
|
+
bad_rpms.unshift('ERROR: Untrusted RPMs found in the repository:')
|
|
532
532
|
|
|
533
|
-
|
|
534
|
-
else
|
|
535
|
-
puts "Checksig succeeded"
|
|
536
|
-
end
|
|
537
|
-
ensure
|
|
538
|
-
remove_entry_secure temp_gpg_dir if (temp_gpg_dir && File.exist?(temp_gpg_dir))
|
|
533
|
+
raise(bad_rpms.join("\n"))
|
|
539
534
|
end
|
|
535
|
+
ensure
|
|
536
|
+
remove_entry_secure temp_gpg_dir if temp_gpg_dir && File.exist?(temp_gpg_dir)
|
|
540
537
|
end
|
|
538
|
+
end
|
|
541
539
|
|
|
542
|
-
|
|
540
|
+
desc <<~DESC
|
|
543
541
|
Run repoclosure on RPM files.
|
|
544
542
|
|
|
545
543
|
Finds all rpm files in the target dir and all of its subdirectories, then
|
|
@@ -553,18 +551,18 @@ module Simp::Rake::Build
|
|
|
553
551
|
- Set `SIMP_PKG_verbose=yes` to report file operations as they happen.
|
|
554
552
|
- Set `SIMP_PKG_repoclose_pe=yes` to enable repoclosure on PE-related RPMs.
|
|
555
553
|
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
554
|
+
DESC
|
|
555
|
+
task :repoclosure, [:target_dir, :aux_dir] => [:prep] do |t, args|
|
|
556
|
+
default_target = @pkg_dirs[:simp]
|
|
557
|
+
args.with_defaults(:target_dir => File.expand_path(default_target))
|
|
560
558
|
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
559
|
+
if args[:aux_dir]
|
|
560
|
+
args[:aux_dir] = File.expand_path(args[:aux_dir])
|
|
561
|
+
end
|
|
564
562
|
|
|
565
|
-
|
|
563
|
+
_repoclose_pe = ENV.fetch('SIMP_PKG_repoclose_pe', 'no') == 'yes'
|
|
566
564
|
|
|
567
|
-
|
|
565
|
+
yum_conf_template = <<~YUM_CONF
|
|
568
566
|
[main]
|
|
569
567
|
keepcache=0
|
|
570
568
|
exactarch=1
|
|
@@ -579,499 +577,494 @@ module Simp::Rake::Build
|
|
|
579
577
|
<% repo_files.each do |repo| -%>
|
|
580
578
|
include=file://<%= repo %>
|
|
581
579
|
<% end -%>
|
|
582
|
-
|
|
580
|
+
YUM_CONF
|
|
583
581
|
|
|
584
|
-
|
|
582
|
+
yum_repo_template = <<~YUM_REPO
|
|
585
583
|
[<%= repo_name %>]
|
|
586
584
|
name=<%= repo_name %>
|
|
587
585
|
baseurl=file://<%= repo_path %>
|
|
588
586
|
enabled=1
|
|
589
587
|
gpgcheck=0
|
|
590
588
|
protect=1
|
|
591
|
-
|
|
589
|
+
YUM_REPO
|
|
592
590
|
|
|
593
|
-
|
|
591
|
+
raise("#{args[:target_dir]} does not exist!") unless File.directory?(args[:target_dir])
|
|
594
592
|
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
593
|
+
Dir.mktmpdir do |temp_pkg_dir|
|
|
594
|
+
Dir.chdir(temp_pkg_dir) do
|
|
595
|
+
mkdir_p('repos/basetest')
|
|
596
|
+
mkdir_p('repos/lookaside')
|
|
597
|
+
mkdir_p('repodata')
|
|
600
598
|
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
599
|
+
Dir.glob(File.join(args[:target_dir], '**', '*.rpm'))
|
|
600
|
+
.delete_if { |x| x =~ %r{\.src\.rpm$} }
|
|
601
|
+
.each do |path|
|
|
602
|
+
sym_path = "repos/basetest/#{File.basename(path)}"
|
|
603
|
+
ln_sf(path, sym_path, :verbose => @verbose) unless File.exist?(sym_path)
|
|
604
|
+
end
|
|
607
605
|
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
end
|
|
606
|
+
if args[:aux_dir]
|
|
607
|
+
Dir.glob(File.join(args[:aux_dir], '**', '*.rpm'))
|
|
608
|
+
.delete_if { |x| x =~ %r{\.src\.rpm$} }
|
|
609
|
+
.each do |path|
|
|
610
|
+
sym_path = "repos/lookaside/#{File.basename(path)}"
|
|
611
|
+
ln_sf(path, sym_path, :verbose => @verbose) unless File.exist?(sym_path)
|
|
615
612
|
end
|
|
613
|
+
end
|
|
616
614
|
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
Dir.chdir(repo) { sh %{createrepo .} }
|
|
615
|
+
repo_files = []
|
|
616
|
+
Dir.glob('repos/*').each do |repo|
|
|
617
|
+
next unless File.directory?(repo)
|
|
621
618
|
|
|
622
|
-
|
|
623
|
-
repo_path = File.expand_path(repo)
|
|
624
|
-
conf_file = "#{temp_pkg_dir}/#{repo_name}.conf"
|
|
619
|
+
Dir.chdir(repo) { sh %(createrepo .) }
|
|
625
620
|
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
621
|
+
repo_name = File.basename(repo)
|
|
622
|
+
repo_path = File.expand_path(repo)
|
|
623
|
+
conf_file = "#{temp_pkg_dir}/#{repo_name}.conf"
|
|
629
624
|
|
|
630
|
-
|
|
631
|
-
end
|
|
632
|
-
end
|
|
625
|
+
File.write(conf_file, ERB.new(yum_repo_template, trim_mode: '-').result(binding))
|
|
633
626
|
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
end
|
|
627
|
+
repo_files << conf_file
|
|
628
|
+
end
|
|
637
629
|
|
|
638
|
-
|
|
639
|
-
if dnf_system
|
|
640
|
-
cmd = 'repoclosure -c basetest.conf --disablerepo=* --enablerepo=basetest'
|
|
641
|
-
else
|
|
642
|
-
cmd = 'repoclosure -c repodata -n -t -r basetest -l lookaside -c yum.conf'
|
|
643
|
-
end
|
|
630
|
+
File.write('yum.conf', ERB.new(yum_conf_template, trim_mode: '-').result(binding))
|
|
644
631
|
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
end
|
|
652
|
-
repoclosure_output = %x(#{cmd})
|
|
632
|
+
dnf_system = which('dnf')
|
|
633
|
+
cmd = if dnf_system
|
|
634
|
+
'repoclosure -c basetest.conf --disablerepo=* --enablerepo=basetest'
|
|
635
|
+
else
|
|
636
|
+
'repoclosure -c repodata -n -t -r basetest -l lookaside -c yum.conf'
|
|
637
|
+
end
|
|
653
638
|
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
639
|
+
if ENV['SIMP_BUILD_verbose'] == 'yes'
|
|
640
|
+
puts
|
|
641
|
+
puts '-' * 80
|
|
642
|
+
puts "#### RUNNING: `#{cmd}`"
|
|
643
|
+
puts " in path '#{Dir.pwd}'"
|
|
644
|
+
puts '-' * 80
|
|
645
|
+
end
|
|
646
|
+
repoclosure_output = `#{cmd}`
|
|
658
647
|
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
648
|
+
if !$CHILD_STATUS.success? || repoclosure_output.include?('nresolved')
|
|
649
|
+
errmsg = ['Error: REPOCLOSURE FAILED:']
|
|
650
|
+
errmsg << [repoclosure_output]
|
|
651
|
+
puts(errmsg.join("\n"))
|
|
652
|
+
|
|
653
|
+
raise('Repoclosure Failed') unless dnf_system
|
|
654
|
+
|
|
655
|
+
if ENV.fetch('SIMP_BUILD_prompt', 'yes') != 'no'
|
|
656
|
+
puts('- Press any key to continue or ^C to abort -')
|
|
657
|
+
$stdin.gets
|
|
667
658
|
end
|
|
659
|
+
|
|
668
660
|
end
|
|
669
661
|
end
|
|
670
662
|
end
|
|
663
|
+
end
|
|
671
664
|
|
|
672
|
-
|
|
665
|
+
desc <<~DESC
|
|
673
666
|
Print published status of all project RPMs
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
667
|
+
DESC
|
|
668
|
+
task :check_published => [:prep] do |_t, _args|
|
|
669
|
+
begin
|
|
670
|
+
yum_helper = Simp::YUM.new(
|
|
671
|
+
Simp::YUM.generate_yum_conf(File.join(@distro_build_dir, 'yum_data')),
|
|
672
|
+
ENV.fetch('SIMP_YUM_makecache', 'yes') == 'yes',
|
|
673
|
+
)
|
|
674
|
+
rescue Simp::YUM::Error
|
|
675
|
+
end
|
|
682
676
|
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
677
|
+
errmsg = Parallel.map(
|
|
678
|
+
# Allow for shell globs
|
|
679
|
+
Array(@build_dirs.values).flatten.sort,
|
|
680
|
+
:in_processes => 1,
|
|
681
|
+
) { |dir|
|
|
682
|
+
_errmsg = nil
|
|
689
683
|
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
end
|
|
701
|
-
else
|
|
702
|
-
_errmsg = "Error: Cound not find specified build directory '#{dir}'"
|
|
684
|
+
if Dir.exist?(dir)
|
|
685
|
+
begin
|
|
686
|
+
require_rebuild?(dir, yum_helper, {
|
|
687
|
+
fetch: false,
|
|
688
|
+
verbose: true,
|
|
689
|
+
check_git: true,
|
|
690
|
+
prefix: ''
|
|
691
|
+
})
|
|
692
|
+
rescue StandardError => e
|
|
693
|
+
_errmsg = "Error: require_rebuild?(): Status check failed on '#{dir}' => #{e}"
|
|
703
694
|
end
|
|
695
|
+
else
|
|
696
|
+
_errmsg = "Error: Cound not find specified build directory '#{dir}'"
|
|
697
|
+
end
|
|
704
698
|
|
|
705
|
-
|
|
706
|
-
|
|
699
|
+
_errmsg
|
|
700
|
+
}.compact
|
|
707
701
|
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
end
|
|
702
|
+
unless errmsg.empty?
|
|
703
|
+
raise(errmsg.join("\n"))
|
|
711
704
|
end
|
|
705
|
+
end
|
|
712
706
|
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
707
|
+
##############################################################################
|
|
708
|
+
# Helper methods
|
|
709
|
+
##############################################################################
|
|
716
710
|
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
711
|
+
# Generate a random string suitable for a rake task namespace
|
|
712
|
+
#
|
|
713
|
+
# This is used as a workaround for Parallelization
|
|
714
|
+
def generate_namespace
|
|
715
|
+
(0...24).map { rand(65..90).chr }.join.downcase
|
|
716
|
+
end
|
|
717
|
+
|
|
718
|
+
# Return a SIMP::YUM object configured for the local build dir or nil
|
|
719
|
+
#
|
|
720
|
+
# ENV vars:
|
|
721
|
+
# - Set `SIMP_PKG_verbose=yes` to report file operations as they happen.
|
|
722
|
+
# - Set `SIMP_YUM_makecache=no` if you do NOT want to rebuild the
|
|
723
|
+
# build-specific YUM cache
|
|
724
|
+
def get_yum_helper(makecache = (ENV.fetch('SIMP_YUM_makecache', 'yes') == 'yes'))
|
|
725
|
+
begin
|
|
726
|
+
build_yum_data = File.join(@distro_build_dir, 'yum_data')
|
|
727
|
+
Simp::YUM.new(Simp::YUM.generate_yum_conf(build_yum_data), makecache)
|
|
728
|
+
rescue Simp::YUM::Error => e
|
|
729
|
+
warn "Simp::YUM::Error: #{e}" if @verbose
|
|
722
730
|
end
|
|
731
|
+
end
|
|
723
732
|
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
733
|
+
# Check and see if 'dir' requires a rebuild based on published packages
|
|
734
|
+
#
|
|
735
|
+
# If 'fetch' is true => Download the published RPM
|
|
736
|
+
# If 'verbose' is true => Print helpful information to stderr
|
|
737
|
+
# If 'check_git' is true => Print the git tag status if 'verbose' is true
|
|
738
|
+
# 'prefix' is used to prepend verbose messages
|
|
739
|
+
#
|
|
740
|
+
# FIXME
|
|
741
|
+
# - Method is too long
|
|
742
|
+
# - Method needs to be passed in class variables (@xxx) so that it
|
|
743
|
+
# can be pulled out into a library that is easily unit-testable
|
|
744
|
+
def require_rebuild?(dir, yum_helper, opts = {
|
|
745
|
+
unique_namespace: generate_namespace,
|
|
746
|
+
fetch: false,
|
|
747
|
+
verbose: @verbose,
|
|
748
|
+
check_git: false,
|
|
749
|
+
prefix: ''
|
|
750
|
+
})
|
|
751
|
+
always_require_rebuild = ENV.select { |x| x =~ %r{SIMP_BUILD_PKG_require_rebuild}i }
|
|
752
|
+
if !always_require_rebuild.empty? && (always_require_rebuild =~ %r{\A(yes|always)\Z}i)
|
|
753
|
+
return true
|
|
737
754
|
end
|
|
738
755
|
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
#
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
756
|
+
result = false
|
|
757
|
+
rpm_metadata = File.exist?(@rpm_dependency_file) ? YAML.load_file(@rpm_dependency_file) : {}
|
|
758
|
+
dir_relpath = Pathname.new(dir).relative_path_from(Pathname.new(Dir.pwd)).to_path
|
|
759
|
+
warn "\n require_rebuild? (#{dir_relpath}):" if @verbose
|
|
760
|
+
|
|
761
|
+
Dir.chdir(dir) do
|
|
762
|
+
if File.exist?('metadata.json')
|
|
763
|
+
# Generate RPM metadata files
|
|
764
|
+
# - 'build/rpm_metadata/requires' file containing RPM
|
|
765
|
+
# dependency/obsoletes information from the
|
|
766
|
+
# 'dependencies.yaml' and the module's
|
|
767
|
+
# 'metadata.json'; always created
|
|
768
|
+
# - 'build/rpm_metadata/release' file containing RPM
|
|
769
|
+
# release qualifier from the 'dependencies.yaml';
|
|
770
|
+
# only created if release qualifier if specified in
|
|
771
|
+
# the 'dependencies.yaml'
|
|
772
|
+
Simp::Rake::Build::RpmDeps.generate_rpm_meta_files(dir, rpm_metadata)
|
|
773
|
+
|
|
774
|
+
new_rpm = Simp::Rake::Pkg.new(Dir.pwd, opts[:unique_namespace], @simp_version)
|
|
775
|
+
new_rpm_info = Simp::RPM.new(new_rpm.spec_file)
|
|
776
|
+
else
|
|
777
|
+
spec_file = Dir.glob(File.join('build', '*.spec'))
|
|
778
|
+
raise("No spec file found in #{dir}/build") if spec_file.empty?
|
|
779
|
+
|
|
780
|
+
warn " Found spec file: #{File.expand_path(spec_file.first)}" if @verbose
|
|
781
|
+
new_rpm_info = Simp::RPM.new(spec_file.first)
|
|
760
782
|
end
|
|
761
|
-
result = false
|
|
762
|
-
rpm_metadata = File.exist?(@rpm_dependency_file) ? YAML.load(File.read(@rpm_dependency_file)) : {}
|
|
763
|
-
dir_relpath = Pathname.new(dir).relative_path_from(Pathname.new(Dir.pwd)).to_path
|
|
764
|
-
$stderr.puts "\n require_rebuild? (#{dir_relpath}):" if @verbose
|
|
765
783
|
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
# 'metadata.json'; always created
|
|
773
|
-
# - 'build/rpm_metadata/release' file containing RPM
|
|
774
|
-
# release qualifier from the 'dependencies.yaml';
|
|
775
|
-
# only created if release qualifier if specified in
|
|
776
|
-
# the 'dependencies.yaml'
|
|
777
|
-
Simp::Rake::Build::RpmDeps::generate_rpm_meta_files(dir, rpm_metadata)
|
|
778
|
-
|
|
779
|
-
new_rpm = Simp::Rake::Pkg.new(Dir.pwd, opts[:unique_namespace], @simp_version)
|
|
780
|
-
new_rpm_info = Simp::RPM.new(new_rpm.spec_file)
|
|
781
|
-
else
|
|
782
|
-
spec_file = Dir.glob(File.join('build', '*.spec'))
|
|
783
|
-
fail("No spec file found in #{dir}/build") if spec_file.empty?
|
|
784
|
-
$stderr.puts " Found spec file: #{File.expand_path(spec_file.first)}" if @verbose
|
|
785
|
-
new_rpm_info = Simp::RPM.new(spec_file.first)
|
|
786
|
-
end
|
|
784
|
+
if @verbose
|
|
785
|
+
warn ' Details:'
|
|
786
|
+
warn " Puppetfile name: #{File.basename(dir)}"
|
|
787
|
+
warn " RPM name: #{new_rpm_info.name}"
|
|
788
|
+
warn " Local directory: #{dir}"
|
|
789
|
+
end
|
|
787
790
|
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
$stderr.puts " Local directory: #{dir}"
|
|
791
|
+
if opts[:check_git]
|
|
792
|
+
git_origin_url = nil
|
|
793
|
+
['origin', 'upstream'].each do |r|
|
|
794
|
+
git_origin_url = `git config --get remote.#{r}.url`.strip if git_origin_url.to_s.empty?
|
|
793
795
|
end
|
|
796
|
+
warn " Git origin URL: #{git_origin_url}" if @verbose
|
|
797
|
+
require_tag = false
|
|
798
|
+
|
|
799
|
+
# FIXME: The check below is insufficient. See logic in compare_latest_tag,
|
|
800
|
+
# which does a git diff between files checked out and latest tag to see
|
|
801
|
+
# if any changes to mission-relevant files have been made and if the
|
|
802
|
+
# version has been bumped, when such changes have been made.
|
|
803
|
+
#
|
|
804
|
+
# We remove any leading 'v' chars since some external projects use them
|
|
805
|
+
latest_tag = `git describe --abbrev=0 --tags 2>/dev/null`.strip.gsub(%r{^v}, '')
|
|
806
|
+
|
|
807
|
+
# Legacy munge
|
|
808
|
+
# We remove any leading 'simp-', leading 'simp6.0.0-', or trailing
|
|
809
|
+
# '-post1' strings used previously for some projects. This munge
|
|
810
|
+
# logic can be remove in SIMP 7.
|
|
811
|
+
latest_tag.gsub!(%r{^simp-|^simp6.0.0-|-post1$}, '')
|
|
794
812
|
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
[
|
|
798
|
-
|
|
813
|
+
begin
|
|
814
|
+
rpm_version = Gem::Version.new(new_rpm_info.version)
|
|
815
|
+
rpm_release = (new_rpm_info.release =~ %r{^(\d+)[.-_]?}) ? new_rpm_info.release.match(%r{^(\d+)[.-_]?})[1] : nil
|
|
816
|
+
if @verbose
|
|
817
|
+
warn ' ' + [
|
|
818
|
+
"RPM version-rel: #{"#{rpm_version}-#{rpm_release}".ljust(10)} ",
|
|
819
|
+
"(semver: #{rpm_version}, relver: #{rpm_release})",
|
|
820
|
+
].join
|
|
799
821
|
end
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
#FIXME The check below is insufficient. See logic in compare_latest_tag,
|
|
804
|
-
# which does a git diff between files checked out and latest tag to see
|
|
805
|
-
# if any changes to mission-relevant files have been made and if the
|
|
806
|
-
# version has been bumped, when such changes have been made.
|
|
807
|
-
#
|
|
808
|
-
# We remove any leading 'v' chars since some external projects use them
|
|
809
|
-
latest_tag = %x(git describe --abbrev=0 --tags 2>/dev/null).strip.gsub(/^v/,'')
|
|
810
|
-
|
|
811
|
-
# Legacy munge
|
|
812
|
-
# We remove any leading 'simp-', leading 'simp6.0.0-', or trailing
|
|
813
|
-
# '-post1' strings used previously for some projects. This munge
|
|
814
|
-
# logic can be remove in SIMP 7.
|
|
815
|
-
latest_tag.gsub!(/^simp-|^simp6.0.0-|-post1$/,'')
|
|
822
|
+
rescue ArgumentError
|
|
823
|
+
warn ">>#{new_rpm_info.basename}: Could not determine RPM version from '#{new_rpm_info.version}'"
|
|
824
|
+
end
|
|
816
825
|
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
826
|
+
begin
|
|
827
|
+
if latest_tag.empty?
|
|
828
|
+
require_tag = true
|
|
829
|
+
warn ' Latest Git tag semver: (none)' if @verbose
|
|
830
|
+
else
|
|
831
|
+
# Gem::Version interprets an RPM-style release suffix like
|
|
832
|
+
# `1.2.3-4` as `1.2.3.pre.4`, which is *less* than `1.2.3`.
|
|
833
|
+
# So we compare SemVer first, then relver numbers if needed
|
|
834
|
+
latest_tag_version = Gem::Version.new(latest_tag.sub(%r{-\d+$}, ''))
|
|
835
|
+
latest_tag_release = (latest_tag =~ %r{-(\d+)$}) ? latest_tag.match(%r{-(\d+)$})[1].to_i : nil
|
|
820
836
|
if @verbose
|
|
821
|
-
|
|
822
|
-
"
|
|
823
|
-
"(semver: #{
|
|
837
|
+
warn ' ' + [
|
|
838
|
+
"Latest Git tag: #{latest_tag.ljust(10)} ",
|
|
839
|
+
"(semver: #{latest_tag_version}#{", relver: #{latest_tag_release}" if latest_tag_release})",
|
|
824
840
|
].join
|
|
825
841
|
end
|
|
826
|
-
rescue ArgumentError
|
|
827
|
-
$stderr.puts ">>#{new_rpm_info.basename}: Could not determine RPM version from '#{new_rpm_info.version}'"
|
|
828
|
-
end
|
|
829
|
-
|
|
830
|
-
begin
|
|
831
|
-
if latest_tag.empty?
|
|
832
|
-
require_tag = true
|
|
833
|
-
$stderr.puts " Latest Git tag semver: (none)" if @verbose
|
|
834
|
-
else
|
|
835
|
-
# Gem::Version interprets an RPM-style release suffix like
|
|
836
|
-
# `1.2.3-4` as `1.2.3.pre.4`, which is *less* than `1.2.3`.
|
|
837
|
-
# So we compare SemVer first, then relver numbers if needed
|
|
838
|
-
latest_tag_version = Gem::Version.new(latest_tag.sub(/-\d+$/,''))
|
|
839
|
-
latest_tag_release = latest_tag.match(/-(\d+)$/) ? latest_tag.match(/-(\d+)$/)[1].to_i : nil
|
|
840
|
-
if @verbose
|
|
841
|
-
$stderr.puts ' ' + [
|
|
842
|
-
"Latest Git tag: #{latest_tag.ljust(10)} ",
|
|
843
|
-
"(semver: #{latest_tag_version}#{latest_tag_release ? ", relver: #{latest_tag_release}" : nil})",
|
|
844
|
-
].join
|
|
845
|
-
end
|
|
846
|
-
end
|
|
847
|
-
rescue ArgumentError
|
|
848
|
-
$stderr.puts ">>#{git_origin_url}: Invalid git tag version '#{latest_tag}' "
|
|
849
842
|
end
|
|
843
|
+
rescue ArgumentError
|
|
844
|
+
warn ">>#{git_origin_url}: Invalid git tag version '#{latest_tag}' "
|
|
845
|
+
end
|
|
850
846
|
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
end
|
|
847
|
+
if rpm_version && latest_tag_version
|
|
848
|
+
# undefined behavior, so far (this current logic skips it):
|
|
849
|
+
# what to do if rpm_release is set and latest_tag_release is nil?
|
|
850
|
+
if latest_tag_release &&
|
|
851
|
+
rpm_release &&
|
|
852
|
+
(rpm_version == latest_tag_version) &&
|
|
853
|
+
(rpm_release > latest_tag_release)
|
|
854
|
+
require_tag = true
|
|
855
|
+
elsif rpm_version > latest_tag_version
|
|
856
|
+
require_tag = true
|
|
862
857
|
end
|
|
858
|
+
end
|
|
863
859
|
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
end
|
|
860
|
+
if opts[:verbose] && require_tag
|
|
861
|
+
warn [
|
|
862
|
+
"#{opts[:prefix]}Git Release Tag Required: ",
|
|
863
|
+
"[#{git_origin_url || dir_relpath}] ",
|
|
864
|
+
"tag: #{latest_tag} => ",
|
|
865
|
+
"rpm: #{new_rpm_info.version}#{"-#{rpm_release}" if latest_tag_release} ",
|
|
866
|
+
"[#{new_rpm_info.basename}]",
|
|
867
|
+
].join
|
|
873
868
|
end
|
|
869
|
+
end
|
|
874
870
|
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
end
|
|
871
|
+
# Pull down any newer versions of the target RPM if we've been
|
|
872
|
+
# given a yum_helper
|
|
873
|
+
#
|
|
874
|
+
# Just build from scratch if something goes wrong
|
|
875
|
+
if yum_helper
|
|
876
|
+
# Most RPM spec files generate a single package, but we have
|
|
877
|
+
# a handful that generate multiple (sub-)packages
|
|
878
|
+
new_rpm_info.packages.each do |package|
|
|
879
|
+
begin
|
|
880
|
+
published_rpm = yum_helper.available_package(package)
|
|
881
|
+
|
|
882
|
+
if published_rpm
|
|
883
|
+
if new_rpm_info.package_newer?(package, published_rpm)
|
|
884
|
+
if opts[:verbose]
|
|
885
|
+
warn "#{opts[:prefix]}RPM Publish Required: #{published_rpm} => #{new_rpm_info.rpm_name(package)}"
|
|
886
|
+
end
|
|
887
|
+
result = true
|
|
888
|
+
else
|
|
889
|
+
warn "#{opts[:prefix]}Found Existing Remote RPM: #{published_rpm}" if opts[:verbose]
|
|
890
|
+
if opts[:fetch]
|
|
891
|
+
# Download published RPM, unless it's already been downloaded.
|
|
892
|
+
# TODO Unhandled edge case: Validate that downloaded RPM is valid
|
|
893
|
+
if File.exist?(File.join('dist', published_rpm))
|
|
894
|
+
warn "#{opts[:prefix]}#{published_rpm} previously downloaded" if opts[:verbose]
|
|
895
|
+
else
|
|
896
|
+
# We know the package exists. So in a brute-force fashion,
|
|
897
|
+
# we're going to retry a couple of times.
|
|
898
|
+
# (Real fix is for user to update retry and timeout parameters
|
|
899
|
+
# in their yum config).
|
|
900
|
+
tries = ENV.fetch('SIMP_YUM_retries', '3').to_i
|
|
901
|
+
begin
|
|
902
|
+
yum_helper.download(package.to_s, :target_dir => 'dist')
|
|
903
|
+
warn "#{opts[:prefix]}Downloaded #{published_rpm}" if opts[:verbose]
|
|
904
|
+
rescue Simp::YUM::Error
|
|
905
|
+
tries -= 1
|
|
906
|
+
if tries.positive?
|
|
907
|
+
retry
|
|
908
|
+
else
|
|
909
|
+
warn ">>Failed to download existing remote RPM: #{published_rpm}. RPM will be locally rebuilt"
|
|
910
|
+
result = true
|
|
916
911
|
end
|
|
917
912
|
end
|
|
918
913
|
end
|
|
919
914
|
end
|
|
920
|
-
else
|
|
921
|
-
if opts[:verbose]
|
|
922
|
-
$stderr.puts "#{opts[:prefix]}RPM Publish Required (new RPM): #{new_rpm_info.rpm_name(package)}"
|
|
923
|
-
end
|
|
924
|
-
result = true
|
|
925
915
|
end
|
|
926
|
-
|
|
927
|
-
|
|
916
|
+
else
|
|
917
|
+
if opts[:verbose]
|
|
918
|
+
warn "#{opts[:prefix]}RPM Publish Required (new RPM): #{new_rpm_info.rpm_name(package)}"
|
|
919
|
+
end
|
|
920
|
+
result = true
|
|
928
921
|
end
|
|
922
|
+
rescue Simp::YUM::Error => e
|
|
923
|
+
warn e if opts[:verbose]
|
|
929
924
|
end
|
|
930
|
-
else
|
|
931
|
-
$stderr.puts '>>Issue creating YUM configuration. Packages will be locally generated.' if opts[:verbose]
|
|
932
|
-
|
|
933
|
-
result = true
|
|
934
925
|
end
|
|
935
|
-
end
|
|
936
|
-
|
|
937
|
-
return result
|
|
938
|
-
end
|
|
939
|
-
|
|
940
|
-
def build_pupmod_rpm(dir, yum_helper, dbg_prefix = ' ')
|
|
941
|
-
unique_namespace = generate_namespace
|
|
942
|
-
if require_rebuild?(dir, yum_helper, {
|
|
943
|
-
unique_namespace: unique_namespace,
|
|
944
|
-
fetch: @fetch_published_rpm.nil? ? true : @fetch_published_rpm,
|
|
945
|
-
verbose: @verbose,
|
|
946
|
-
prefix: dbg_prefix,
|
|
947
|
-
})
|
|
948
|
-
$stderr.puts("#{dbg_prefix}Running 'rake pkg:rpm' on #{File.basename(dir)}") if @verbose
|
|
949
|
-
Rake::Task["#{unique_namespace}:pkg:rpm"].invoke
|
|
950
926
|
else
|
|
951
|
-
|
|
952
|
-
|
|
927
|
+
warn '>>Issue creating YUM configuration. Packages will be locally generated.' if opts[:verbose]
|
|
928
|
+
|
|
929
|
+
result = true
|
|
953
930
|
end
|
|
954
|
-
true
|
|
955
931
|
end
|
|
956
932
|
|
|
933
|
+
result
|
|
934
|
+
end
|
|
957
935
|
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
936
|
+
def build_pupmod_rpm(dir, yum_helper, dbg_prefix = ' ')
|
|
937
|
+
unique_namespace = generate_namespace
|
|
938
|
+
if require_rebuild?(dir, yum_helper, {
|
|
939
|
+
unique_namespace: unique_namespace,
|
|
940
|
+
fetch: @fetch_published_rpm.nil? || @fetch_published_rpm,
|
|
941
|
+
verbose: @verbose,
|
|
942
|
+
prefix: dbg_prefix
|
|
943
|
+
})
|
|
944
|
+
warn("#{dbg_prefix}Running 'rake pkg:rpm' on #{File.basename(dir)}") if @verbose
|
|
945
|
+
Rake::Task["#{unique_namespace}:pkg:rpm"].invoke
|
|
946
|
+
else
|
|
947
|
+
# Record metadata for the downloaded RPM
|
|
948
|
+
Simp::RPM.create_rpm_build_metadata(File.expand_path(dir))
|
|
949
|
+
end
|
|
950
|
+
true
|
|
951
|
+
end
|
|
967
952
|
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
953
|
+
def build_rakefile_rpm(dir, yum_helper, dbg_prefix = ' ')
|
|
954
|
+
if require_rebuild?(dir, yum_helper, {
|
|
955
|
+
fetch: @fetch_published_rpm.nil? || @fetch_published_rpm,
|
|
956
|
+
verbose: @verbose,
|
|
957
|
+
prefix: dbg_prefix
|
|
958
|
+
})
|
|
959
|
+
warn("#{dbg_prefix}Running 'rake pkg:rpm' in #{File.basename(dir)}") if @verbose
|
|
960
|
+
rake_flags = Rake.application.options.trace ? '--trace' : ''
|
|
961
|
+
cmd = %(SIMP_BUILD_version=#{@simp_version} rake pkg:rpm #{rake_flags} 2>&1)
|
|
962
|
+
|
|
963
|
+
build_success = true
|
|
964
|
+
begin
|
|
965
|
+
`#{cmd}`
|
|
966
|
+
build_success = $CHILD_STATUS.success?
|
|
972
967
|
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
968
|
+
true
|
|
969
|
+
rescue StandardError
|
|
970
|
+
build_success = false
|
|
971
|
+
end
|
|
977
972
|
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
973
|
+
unless build_success
|
|
974
|
+
if @verbose
|
|
975
|
+
warn("First 'rake pkg:rpm' attempt for #{dir} failed, running bundle and trying again.")
|
|
976
|
+
end
|
|
982
977
|
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
978
|
+
if Bundler.respond_to?(:with_unbundled_env)
|
|
979
|
+
# Bundler 2.1+
|
|
980
|
+
clean_env_method = :with_unbundled_env
|
|
981
|
+
bundle_install_cmd = %(bundle config set with 'development' && bundle install)
|
|
982
|
+
else
|
|
983
|
+
# Old Bundler
|
|
984
|
+
clean_env_method = :with_clean_env
|
|
985
|
+
bundle_install_cmd = %(bundle install --with development)
|
|
986
|
+
end
|
|
992
987
|
|
|
993
|
-
|
|
994
|
-
|
|
988
|
+
::Bundler.send(clean_env_method) do
|
|
989
|
+
`#{bundle_install_cmd}`
|
|
995
990
|
|
|
996
|
-
|
|
991
|
+
output = `#{cmd} 2>&1`
|
|
997
992
|
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
end
|
|
993
|
+
unless $CHILD_STATUS.success?
|
|
994
|
+
raise("Error in #{dir} running #{cmd}\n#{output}")
|
|
1001
995
|
end
|
|
1002
996
|
end
|
|
1003
|
-
else
|
|
1004
|
-
# Record metadata for the downloaded RPM
|
|
1005
|
-
Simp::RPM::create_rpm_build_metadata(File.expand_path(dir))
|
|
1006
|
-
built_rpm = true
|
|
1007
997
|
end
|
|
998
|
+
else
|
|
999
|
+
# Record metadata for the downloaded RPM
|
|
1000
|
+
Simp::RPM.create_rpm_build_metadata(File.expand_path(dir))
|
|
1001
|
+
true
|
|
1008
1002
|
end
|
|
1003
|
+
end
|
|
1009
1004
|
|
|
1005
|
+
# Takes a list of directories to hop into and perform builds within
|
|
1006
|
+
#
|
|
1007
|
+
# The task must be passed so that we can output the calling name in the
|
|
1008
|
+
# status bar.
|
|
1009
|
+
def build(dirs, task, _rebuild_for_arch = false, remake_yum_cache = false)
|
|
1010
|
+
raise("Could not find RPM dependency file '#{@rpm_dependency_file}'") unless File.exist?(@rpm_dependency_file)
|
|
1010
1011
|
|
|
1011
|
-
|
|
1012
|
-
#
|
|
1013
|
-
# The task must be passed so that we can output the calling name in the
|
|
1014
|
-
# status bar.
|
|
1015
|
-
def build(dirs, task, rebuild_for_arch=false, remake_yum_cache = false)
|
|
1016
|
-
fail("Could not find RPM dependency file '#{@rpm_dependency_file}'") unless File.exist?(@rpm_dependency_file)
|
|
1017
|
-
yum_helper = get_yum_helper( remake_yum_cache )
|
|
1012
|
+
yum_helper = get_yum_helper(remake_yum_cache)
|
|
1018
1013
|
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1014
|
+
Parallel.map(
|
|
1015
|
+
# Allow for shell globs
|
|
1016
|
+
Array(dirs), {
|
|
1017
|
+
in_processes: @cpu_limit,
|
|
1018
|
+
progress: (ENV.fetch('SIMP_PKG_progress_bar', 'yes') == 'yes') ? task.name : nil
|
|
1019
|
+
}
|
|
1020
|
+
) do |dir|
|
|
1021
|
+
raise("Could not find directory #{dir}") unless Dir.exist?(dir)
|
|
1027
1022
|
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
if File.exist?('metadata.json')
|
|
1033
|
-
# We're building a module, override anything down there
|
|
1034
|
-
built_rpm = build_pupmod_rpm(dir, yum_helper)
|
|
1035
|
-
elsif File.exist?('Rakefile')
|
|
1036
|
-
# We're building one of the extra assets and should honor its Rakefile
|
|
1037
|
-
# and RPM spec file.
|
|
1038
|
-
built_rpm = build_rakefile_rpm(dir, yum_helper)
|
|
1039
|
-
else
|
|
1040
|
-
puts "Warning: '#{dir}' could not be built (not a pupmod & no Rakefile!)"
|
|
1041
|
-
end
|
|
1023
|
+
Dir.chdir(dir) do
|
|
1024
|
+
built_rpm = false
|
|
1025
|
+
warn("\nPackaging #{File.basename(dir)}") if @verbose
|
|
1042
1026
|
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1027
|
+
if File.exist?('metadata.json')
|
|
1028
|
+
# We're building a module, override anything down there
|
|
1029
|
+
built_rpm = build_pupmod_rpm(dir, yum_helper)
|
|
1030
|
+
elsif File.exist?('Rakefile')
|
|
1031
|
+
# We're building one of the extra assets and should honor its Rakefile
|
|
1032
|
+
# and RPM spec file.
|
|
1033
|
+
built_rpm = build_rakefile_rpm(dir, yum_helper)
|
|
1034
|
+
else
|
|
1035
|
+
puts "Warning: '#{dir}' could not be built (not a pupmod & no Rakefile!)"
|
|
1036
|
+
end
|
|
1046
1037
|
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
raise("Empty Tarball '#{pkg}' generated for #{dir}")
|
|
1051
|
-
end
|
|
1052
|
-
end
|
|
1038
|
+
if built_rpm
|
|
1039
|
+
tarballs = Dir.glob('dist/*.tar.gz')
|
|
1040
|
+
rpms = Dir.glob('dist/*.rpm').delete_if { |x| x =~ %r{\.src\.rpm$} }
|
|
1053
1041
|
|
|
1054
|
-
|
|
1042
|
+
# Not all items generate tarballs
|
|
1043
|
+
tarballs.each do |pkg|
|
|
1044
|
+
if File.stat(pkg).size.zero?
|
|
1045
|
+
raise("Empty Tarball '#{pkg}' generated for #{dir}")
|
|
1046
|
+
end
|
|
1055
1047
|
end
|
|
1056
|
-
|
|
1048
|
+
|
|
1049
|
+
raise("No RPMs generated for #{dir}") if rpms.empty?
|
|
1057
1050
|
end
|
|
1051
|
+
warn("Finished #{File.basename(dir)}") if @verbose
|
|
1058
1052
|
end
|
|
1059
1053
|
end
|
|
1054
|
+
end
|
|
1060
1055
|
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
end
|
|
1056
|
+
# desc "Checks the environment for building the DVD tarball
|
|
1057
|
+
def check_dvd_env
|
|
1058
|
+
["#{@dvd_src}/isolinux", "#{@dvd_src}/ks"].each do |dir|
|
|
1059
|
+
File.directory?(dir) or raise "Environment not suitable: Unable to find directory '#{dir}'"
|
|
1066
1060
|
end
|
|
1061
|
+
end
|
|
1067
1062
|
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
end
|
|
1063
|
+
# Return an Array of all puppet module directories
|
|
1064
|
+
def get_module_dirs(method = 'tracking')
|
|
1065
|
+
load_puppetfile(method)
|
|
1066
|
+
module_paths.select { |x| File.basename(File.dirname(x)) == 'modules' }.sort
|
|
1073
1067
|
end
|
|
1074
1068
|
end
|
|
1075
1069
|
end
|
|
1076
|
-
|
|
1077
1070
|
end
|