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
|
@@ -1,132 +1,123 @@
|
|
|
1
1
|
#!/usr/bin/rake -T
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
2
4
|
require 'open3'
|
|
3
5
|
require 'simp/rpm'
|
|
4
6
|
require 'simp/rake/build/constants'
|
|
5
7
|
|
|
6
8
|
module Simp; end
|
|
7
9
|
module Simp::Rake; end
|
|
8
|
-
module Simp::Rake::Build
|
|
9
|
-
|
|
10
|
-
class Upload < ::Rake::TaskLib
|
|
11
|
-
include Simp::Rake::Build::Constants
|
|
12
10
|
|
|
13
|
-
|
|
14
|
-
|
|
11
|
+
class Simp::Rake::Build::Upload < Rake::TaskLib
|
|
12
|
+
include Simp::Rake::Build::Constants
|
|
15
13
|
|
|
16
|
-
|
|
17
|
-
|
|
14
|
+
def initialize(base_dir)
|
|
15
|
+
init_member_vars(base_dir)
|
|
18
16
|
|
|
19
|
-
|
|
17
|
+
define_tasks
|
|
18
|
+
end
|
|
20
19
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
20
|
+
def define_tasks
|
|
21
|
+
namespace :upload do
|
|
22
|
+
task :prep do
|
|
23
|
+
if $simp6
|
|
24
|
+
@build_dir = $simp6_build_dir || @distro_build_dir
|
|
26
25
|
end
|
|
26
|
+
end
|
|
27
27
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
# Get a list of all packages that have been updated since the passed
|
|
33
|
-
# date or git identifier (tag, branch, or commit).
|
|
28
|
+
##############################################################################
|
|
29
|
+
# Helper methods
|
|
30
|
+
##############################################################################
|
|
34
31
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
printed_info = false
|
|
32
|
+
# Get a list of all packages that have been updated since the passed
|
|
33
|
+
# date or git identifier (tag, branch, or commit).
|
|
38
34
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
Find.find(@build_dir) do |file|
|
|
43
|
-
next if file == @build_dir
|
|
44
|
-
Find.prune if file !~ /^#{@build_dir}\/(Ext.*(\.rpm)?|GPGKEYS)/
|
|
45
|
-
to_check << file if File.file?(file)
|
|
46
|
-
end
|
|
35
|
+
def get_updated_packages(start, script_format)
|
|
36
|
+
pkg_info = {}
|
|
37
|
+
printed_info = false
|
|
47
38
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
is_commit = false
|
|
55
|
-
oldstart = start
|
|
56
|
-
humanstart = ''
|
|
57
|
-
# Before changing the directory, see if we've got a commit or a
|
|
58
|
-
# date. If we've got a tag or branch from the top level, then we
|
|
59
|
-
# need to get the date from there and use it later.
|
|
60
|
-
Dir.chdir(@spec_dir) do
|
|
61
|
-
stdin,stdout,stderr = Open3.popen3('git','rev-list',start)
|
|
62
|
-
stderr.read !~ /^fatal:/ and is_commit = true
|
|
63
|
-
|
|
64
|
-
if is_commit
|
|
65
|
-
# Snag the date.
|
|
66
|
-
start, humanstart = `git log #{start} --pretty=format:"%ct##%cd" --max-count=1`.chomp.split('##')
|
|
67
|
-
else
|
|
68
|
-
printed_info = true
|
|
69
|
-
end
|
|
70
|
-
end
|
|
39
|
+
to_check = []
|
|
40
|
+
# Find all static RPMs and GPGKEYS that we may need to update so
|
|
41
|
+
# that we can see if we have newer versions to upload!
|
|
42
|
+
Find.find(@build_dir) do |file|
|
|
43
|
+
next if file == @build_dir
|
|
71
44
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
# Get the file HEAD commit
|
|
76
|
-
# If we're not in a git repo, this will explode, but that's just
|
|
77
|
-
# fine.
|
|
78
|
-
current_head = `git rev-list HEAD --max-count=1`.chomp
|
|
79
|
-
|
|
80
|
-
begin
|
|
81
|
-
# Convert the spec files to something more human readable...
|
|
82
|
-
pkg_info[file] = {
|
|
83
|
-
:is_new => false
|
|
84
|
-
}
|
|
85
|
-
pkg_info[file][:alias] = file
|
|
86
|
-
if file =~ /.spec$/
|
|
87
|
-
if script_format
|
|
88
|
-
pkg_info[file][:alias] = "#{@build_dir}/RPMS/#{Simp::RPM.new(file).name}*.rpm"
|
|
89
|
-
else
|
|
90
|
-
pkg_info[file][:alias] = Simp::RPM.new(file).name
|
|
91
|
-
end
|
|
92
|
-
end
|
|
93
|
-
rescue
|
|
94
|
-
raise "Error: There was an issue getting information from #{file}"
|
|
95
|
-
end
|
|
45
|
+
Find.prune unless %r{^#{@build_dir}/(Ext.*(\.rpm)?|GPGKEYS)}.match?(file)
|
|
46
|
+
to_check << file if File.file?(file)
|
|
47
|
+
end
|
|
96
48
|
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
49
|
+
# Smash in all of the file files!
|
|
50
|
+
to_check += Dir.glob("#{@spec_dir}/*.spec")
|
|
51
|
+
to_check += Dir.glob("#{@src_dir}/puppet/modules/*/pkg/*.spec")
|
|
52
|
+
|
|
53
|
+
to_check.each do |file|
|
|
54
|
+
is_commit = false
|
|
55
|
+
oldstart = start
|
|
56
|
+
humanstart = ''
|
|
57
|
+
# Before changing the directory, see if we've got a commit or a
|
|
58
|
+
# date. If we've got a tag or branch from the top level, then we
|
|
59
|
+
# need to get the date from there and use it later.
|
|
60
|
+
Dir.chdir(@spec_dir) do
|
|
61
|
+
_, _, stderr = Open3.popen3('git', 'rev-list', start)
|
|
62
|
+
stderr.read !~ %r{^fatal:} and is_commit = true
|
|
63
|
+
|
|
64
|
+
if is_commit
|
|
65
|
+
# Snag the date.
|
|
66
|
+
start, humanstart = `git log #{start} --pretty=format:"%ct##%cd" --max-count=1`.chomp.split('##')
|
|
67
|
+
else
|
|
68
|
+
printed_info = true
|
|
69
|
+
end
|
|
70
|
+
end
|
|
101
71
|
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
72
|
+
!printed_info and puts "Info: Comparing to '#{humanstart}' based on input of '#{oldstart}'"
|
|
73
|
+
|
|
74
|
+
Dir.chdir(File.dirname(file)) do
|
|
75
|
+
# Get the file HEAD commit
|
|
76
|
+
# If we're not in a git repo, this will explode, but that's just
|
|
77
|
+
# fine.
|
|
78
|
+
`git rev-list HEAD --max-count=1`.chomp
|
|
79
|
+
|
|
80
|
+
begin
|
|
81
|
+
# Convert the spec files to something more human readable...
|
|
82
|
+
pkg_info[file] = {
|
|
83
|
+
:is_new => false
|
|
84
|
+
}
|
|
85
|
+
pkg_info[file][:alias] = file
|
|
86
|
+
if %r{.spec$}.match?(file)
|
|
87
|
+
pkg_info[file][:alias] = if script_format
|
|
88
|
+
"#{@build_dir}/RPMS/#{Simp::RPM.new(file).name}*.rpm"
|
|
89
|
+
else
|
|
90
|
+
Simp::RPM.new(file).name
|
|
91
|
+
end
|
|
107
92
|
end
|
|
93
|
+
rescue StandardError
|
|
94
|
+
raise "Error: There was an issue getting information from #{file}"
|
|
108
95
|
end
|
|
109
|
-
|
|
96
|
+
# It turns out that an invalid date will just return
|
|
97
|
+
# everything
|
|
98
|
+
commit_head = `git log --before="#{start}" --pretty=format:%H --max-count=1 #{File.basename(file)}`.chomp
|
|
110
99
|
|
|
111
|
-
|
|
100
|
+
# Did we find something different?
|
|
101
|
+
pkg_info[file][:is_new] = (commit_head.empty? || !system('git', 'diff', '--quiet', commit_head, File.basename(file)))
|
|
102
|
+
end
|
|
112
103
|
end
|
|
113
104
|
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
Get a list of modified packages.
|
|
105
|
+
pkg_info
|
|
106
|
+
end
|
|
117
107
|
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
108
|
+
# desc <<-EOM
|
|
109
|
+
# Get a list of modified packages.
|
|
110
|
+
#
|
|
111
|
+
# The package list is created from the given date or git identifier (tag, branch, or hash)
|
|
112
|
+
# EOM
|
|
113
|
+
task :get_modified, [:start, :script_format] => [:prep] do |_t, args|
|
|
114
|
+
args.with_defaults(:script_format => false)
|
|
123
115
|
|
|
124
|
-
|
|
116
|
+
args.start or raise "Error: You must specify a 'start'"
|
|
125
117
|
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
end
|
|
118
|
+
updated_pkgs = get_updated_packages(args.start, args.script_format)
|
|
119
|
+
updated_pkgs.keys.sort.each do |k|
|
|
120
|
+
updated_pkgs[k][:is_new] and puts "Updated: #{updated_pkgs[k][:alias]}"
|
|
130
121
|
end
|
|
131
122
|
end
|
|
132
123
|
end
|
data/lib/simp/rake/fixtures.rb
CHANGED
|
@@ -1,87 +1,90 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
require 'rake/tasklib'
|
|
2
4
|
|
|
3
5
|
module Simp; end
|
|
4
|
-
module Simp::Rake
|
|
5
|
-
class Fixtures < ::Rake::TaskLib
|
|
6
|
-
def initialize( dir )
|
|
7
|
-
@base_dir = dir
|
|
8
|
-
###::CLEAN.include( '.fixtures.yml.local' )
|
|
9
|
-
define
|
|
10
|
-
end
|
|
11
6
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
.reduce({}){|h,pairs|
|
|
19
|
-
pairs.each{|k,v|
|
|
20
|
-
(h[k] ||= []) << v
|
|
21
|
-
}; h
|
|
22
|
-
}
|
|
23
|
-
.keys
|
|
24
|
-
.uniq
|
|
25
|
-
.sort
|
|
26
|
-
end
|
|
7
|
+
class Simp::Rake::Fixtures < Rake::TaskLib
|
|
8
|
+
def initialize(dir)
|
|
9
|
+
@base_dir = dir
|
|
10
|
+
# ##::CLEAN.include( '.fixtures.yml.local' )
|
|
11
|
+
define
|
|
12
|
+
end
|
|
27
13
|
|
|
28
|
-
|
|
29
|
-
|
|
14
|
+
def define
|
|
15
|
+
namespace :fixtures do
|
|
16
|
+
def flatten_fixtures_hash(_f)
|
|
17
|
+
_f
|
|
18
|
+
.map { |_k, v| v.values }
|
|
19
|
+
.flatten
|
|
20
|
+
.each_with_object({}) { |pairs, h|
|
|
21
|
+
pairs.each do |k, v|
|
|
22
|
+
(h[k] ||= []) << v
|
|
23
|
+
end
|
|
24
|
+
}
|
|
25
|
+
.keys
|
|
26
|
+
.uniq
|
|
27
|
+
.sort
|
|
28
|
+
end
|
|
30
29
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
[k, v ]}
|
|
34
|
-
]
|
|
30
|
+
def fixtures_yml_local(_f)
|
|
31
|
+
_f_m = flatten_fixtures_hash(_f)
|
|
35
32
|
|
|
36
|
-
|
|
33
|
+
_s = _f_m.to_h do |k|
|
|
34
|
+
v = _f['fixtures']['repositories'].key?(k) ? "#\{source_dir}/../#{k}" : _f['fixtures']['symlinks'].fetch(k)
|
|
35
|
+
[k, v]
|
|
37
36
|
end
|
|
38
37
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
pwd = File.expand_path(@base_dir)
|
|
42
|
-
_f = YAML.load_file(File.join(pwd,'.fixtures.yml'))
|
|
43
|
-
_l = clean_yaml(fixtures_yml_local( _f ).to_yaml)
|
|
44
|
-
_o = File.join(pwd,'.fixtures.yml.local')
|
|
45
|
-
File.open( _o,'w'){|f| puts _l; f.puts _l}
|
|
46
|
-
puts
|
|
47
|
-
puts "# written to '#{_o}'"
|
|
48
|
-
end
|
|
38
|
+
{ 'fixtures' => { 'symlinks' => _s } }
|
|
39
|
+
end
|
|
49
40
|
|
|
41
|
+
desc 'generate .fixtures.yml.local formm the entries in .fixtures.yml'
|
|
42
|
+
task :generate do
|
|
43
|
+
pwd = File.expand_path(@base_dir)
|
|
44
|
+
_f = YAML.load_file(File.join(pwd, '.fixtures.yml'))
|
|
45
|
+
_l = clean_yaml(fixtures_yml_local(_f).to_yaml)
|
|
46
|
+
_o = File.join(pwd, '.fixtures.yml.local')
|
|
47
|
+
File.open(_o, 'w') do |f|
|
|
48
|
+
puts _l
|
|
49
|
+
f.puts _l
|
|
50
|
+
end
|
|
51
|
+
puts
|
|
52
|
+
puts "# written to '#{_o}'"
|
|
53
|
+
end
|
|
50
54
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
55
|
+
desc 'check for missing .fixture modules'
|
|
56
|
+
task :diff do
|
|
57
|
+
require 'yaml'
|
|
58
|
+
pwd = File.expand_path(@base_dir)
|
|
59
|
+
_f = YAML.load_file(File.join(pwd, '.fixtures.yml'))
|
|
56
60
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
61
|
+
unless File.file?(File.join(pwd, '.fixtures.yml.local'))
|
|
62
|
+
raise "ERROR: Can't diff fixtures without a `.fixtures.yml.local` file"
|
|
63
|
+
end
|
|
60
64
|
|
|
61
|
-
|
|
65
|
+
_fl = YAML.load_file(File.join(pwd, '.fixtures.yml.local'))
|
|
62
66
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
67
|
+
# reduce modules
|
|
68
|
+
_f_m = flatten_fixtures_hash(_f)
|
|
69
|
+
_fl_m = flatten_fixtures_hash(_fl)
|
|
70
|
+
_f_u = (_f_m - _fl_m)
|
|
71
|
+
_fl_u = (_fl_m - _f_m)
|
|
68
72
|
|
|
69
|
-
|
|
73
|
+
if (_f_u.size + _fl_u.size).positive?
|
|
74
|
+
warn ''
|
|
75
|
+
warn 'WARNING: .fixtures.yml & .fixtures.yml.local have different files!'
|
|
76
|
+
warn ''
|
|
77
|
+
if _f_u.size.positive?
|
|
78
|
+
warn 'Unique modules to .fixtures.yml:'
|
|
79
|
+
_f_u.each { |x| warn " - #{x}" }
|
|
70
80
|
warn ''
|
|
71
|
-
|
|
81
|
+
end
|
|
82
|
+
if _fl_u.size.positive?
|
|
83
|
+
warn 'Unique modules to .fixtures.yml.local:'
|
|
84
|
+
_fl_u.each { |x| warn " - #{x}" }
|
|
72
85
|
warn ''
|
|
73
|
-
if _f_u.size > 0
|
|
74
|
-
warn 'Unique modules to .fixtures.yml:'
|
|
75
|
-
_f_u.each{|x| warn " - #{x}"}
|
|
76
|
-
warn ''
|
|
77
|
-
end
|
|
78
|
-
if _fl_u.size > 0
|
|
79
|
-
warn 'Unique modules to .fixtures.yml.local:'
|
|
80
|
-
_fl_u.each{|x| warn " - #{x}"}
|
|
81
|
-
warn ''
|
|
82
|
-
end
|
|
83
|
-
exit 1
|
|
84
86
|
end
|
|
87
|
+
exit 1
|
|
85
88
|
end
|
|
86
89
|
end
|
|
87
90
|
end
|
|
@@ -1,25 +1,28 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
module Simp; end
|
|
2
4
|
module Simp::Rake; end
|
|
5
|
+
|
|
3
6
|
class Simp::Rake::Helpers
|
|
4
7
|
module Simp::Rake::Helpers::RPMSpec
|
|
5
8
|
require 'simp/rake/build/constants'
|
|
6
9
|
|
|
7
10
|
include Simp::Rake::Build::Constants
|
|
8
11
|
|
|
9
|
-
def rpm_template(simp_version=nil)
|
|
12
|
+
def rpm_template(simp_version = nil)
|
|
10
13
|
simp_version = ENV.fetch('SIMP_BUILD_version', simp_version)
|
|
11
14
|
|
|
12
|
-
if simp_version
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
simp_main_version = if simp_version
|
|
16
|
+
simp_version.split('.').first
|
|
17
|
+
else
|
|
18
|
+
'default'
|
|
19
|
+
end
|
|
17
20
|
|
|
18
21
|
template_file = File.join(File.dirname(__FILE__), 'assets', 'rpm_spec', "simp#{simp_main_version}.spec")
|
|
19
22
|
|
|
20
23
|
raise "Error: Could not find template for SIMP version #{simp_version}" unless File.exist?(template_file)
|
|
21
24
|
|
|
22
|
-
|
|
25
|
+
File.read(template_file)
|
|
23
26
|
end
|
|
24
27
|
end
|
|
25
28
|
end
|
data/lib/simp/rake/helpers.rb
CHANGED
|
@@ -1,23 +1,25 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
require File.expand_path('pkg', File.dirname(__FILE__))
|
|
2
4
|
require File.expand_path('fixtures', File.dirname(__FILE__))
|
|
3
5
|
|
|
4
6
|
module Simp; end
|
|
5
7
|
module Simp::Rake; end
|
|
6
|
-
class Simp::Rake::Helpers
|
|
7
8
|
|
|
9
|
+
class Simp::Rake::Helpers
|
|
8
10
|
# dir = top-level of project,
|
|
9
|
-
def initialize(
|
|
10
|
-
Simp::Rake::Pkg.new(
|
|
11
|
+
def initialize(dir = Dir.pwd)
|
|
12
|
+
Simp::Rake::Pkg.new(dir) do |t|
|
|
11
13
|
t.clean_list << "#{t.base_dir}/spec/fixtures/hieradata/hiera.yaml"
|
|
12
14
|
end
|
|
13
15
|
|
|
14
|
-
Simp::Rake::Fixtures.new(
|
|
16
|
+
Simp::Rake::Fixtures.new(dir)
|
|
15
17
|
end
|
|
16
18
|
|
|
17
19
|
def self.check_required_commands(required_commands)
|
|
18
20
|
require 'facter'
|
|
19
21
|
|
|
20
|
-
invalid_commands =
|
|
22
|
+
invalid_commands = []
|
|
21
23
|
|
|
22
24
|
Array(required_commands).each do |command|
|
|
23
25
|
unless Array(command).find { |x| Facter::Core::Execution.which(x) }
|
|
@@ -25,16 +27,16 @@ class Simp::Rake::Helpers
|
|
|
25
27
|
end
|
|
26
28
|
end
|
|
27
29
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
+
return if invalid_commands.empty?
|
|
31
|
+
|
|
32
|
+
errmsg = <<-EOM
|
|
30
33
|
Error: The following required commands were not found on your system:
|
|
31
34
|
|
|
32
35
|
* #{invalid_commands.join("\n * ")}
|
|
33
36
|
|
|
34
37
|
Please update your system and try again.
|
|
35
|
-
|
|
38
|
+
EOM
|
|
36
39
|
|
|
37
|
-
|
|
38
|
-
end
|
|
40
|
+
raise(errmsg)
|
|
39
41
|
end
|
|
40
42
|
end
|