packaging 0.88.77
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 +7 -0
- data/LICENSE +17 -0
- data/README-Solaris.md +117 -0
- data/README.md +977 -0
- data/lib/packaging.rb +32 -0
- data/lib/packaging/archive.rb +126 -0
- data/lib/packaging/artifactory.rb +651 -0
- data/lib/packaging/artifactory/extensions.rb +94 -0
- data/lib/packaging/config.rb +492 -0
- data/lib/packaging/config/params.rb +387 -0
- data/lib/packaging/config/validations.rb +13 -0
- data/lib/packaging/deb.rb +28 -0
- data/lib/packaging/deb/repo.rb +264 -0
- data/lib/packaging/gem.rb +70 -0
- data/lib/packaging/metrics.rb +15 -0
- data/lib/packaging/nuget.rb +39 -0
- data/lib/packaging/paths.rb +376 -0
- data/lib/packaging/platforms.rb +507 -0
- data/lib/packaging/repo.rb +155 -0
- data/lib/packaging/retrieve.rb +75 -0
- data/lib/packaging/rpm.rb +5 -0
- data/lib/packaging/rpm/repo.rb +254 -0
- data/lib/packaging/sign.rb +8 -0
- data/lib/packaging/sign/deb.rb +9 -0
- data/lib/packaging/sign/dmg.rb +41 -0
- data/lib/packaging/sign/ips.rb +57 -0
- data/lib/packaging/sign/msi.rb +124 -0
- data/lib/packaging/sign/rpm.rb +115 -0
- data/lib/packaging/tar.rb +163 -0
- data/lib/packaging/util.rb +146 -0
- data/lib/packaging/util/date.rb +20 -0
- data/lib/packaging/util/execution.rb +85 -0
- data/lib/packaging/util/file.rb +125 -0
- data/lib/packaging/util/git.rb +174 -0
- data/lib/packaging/util/git_tags.rb +73 -0
- data/lib/packaging/util/gpg.rb +66 -0
- data/lib/packaging/util/jenkins.rb +95 -0
- data/lib/packaging/util/misc.rb +69 -0
- data/lib/packaging/util/net.rb +410 -0
- data/lib/packaging/util/os.rb +17 -0
- data/lib/packaging/util/platform.rb +40 -0
- data/lib/packaging/util/rake_utils.rb +112 -0
- data/lib/packaging/util/serialization.rb +19 -0
- data/lib/packaging/util/ship.rb +300 -0
- data/lib/packaging/util/tool.rb +41 -0
- data/lib/packaging/util/version.rb +334 -0
- data/spec/fixtures/config/ext/build_defaults.yaml +2 -0
- data/spec/fixtures/config/ext/project_data.yaml +2 -0
- data/spec/fixtures/configs/components/test_file.json +1 -0
- data/spec/fixtures/configs/components/test_file_2.json +0 -0
- data/spec/fixtures/configs/components/test_file_not_tagged.json +1 -0
- data/spec/fixtures/configs/components/test_file_wrong_ext.txt +0 -0
- data/spec/fixtures/configs/components/test_file_wrong_ext.wrong +0 -0
- data/spec/fixtures/util/pre_tasks.yaml +4 -0
- data/spec/lib/packaging/artifactory_spec.rb +221 -0
- data/spec/lib/packaging/config_spec.rb +576 -0
- data/spec/lib/packaging/deb/repo_spec.rb +157 -0
- data/spec/lib/packaging/deb_spec.rb +52 -0
- data/spec/lib/packaging/gem_spec.rb +86 -0
- data/spec/lib/packaging/paths_spec.rb +418 -0
- data/spec/lib/packaging/platforms_spec.rb +178 -0
- data/spec/lib/packaging/repo_spec.rb +135 -0
- data/spec/lib/packaging/retrieve_spec.rb +100 -0
- data/spec/lib/packaging/rpm/repo_spec.rb +133 -0
- data/spec/lib/packaging/sign_spec.rb +133 -0
- data/spec/lib/packaging/tar_spec.rb +116 -0
- data/spec/lib/packaging/util/execution_spec.rb +56 -0
- data/spec/lib/packaging/util/file_spec.rb +139 -0
- data/spec/lib/packaging/util/git_spec.rb +160 -0
- data/spec/lib/packaging/util/git_tag_spec.rb +36 -0
- data/spec/lib/packaging/util/gpg_spec.rb +64 -0
- data/spec/lib/packaging/util/jenkins_spec.rb +112 -0
- data/spec/lib/packaging/util/misc_spec.rb +31 -0
- data/spec/lib/packaging/util/net_spec.rb +259 -0
- data/spec/lib/packaging/util/os_spec.rb +31 -0
- data/spec/lib/packaging/util/rake_utils_spec.rb +70 -0
- data/spec/lib/packaging/util/ship_spec.rb +199 -0
- data/spec/lib/packaging/util/version_spec.rb +123 -0
- data/spec/lib/packaging_spec.rb +19 -0
- data/spec/spec_helper.rb +22 -0
- data/static_artifacts/PackageInfo.plist +3 -0
- data/tasks/00_utils.rake +214 -0
- data/tasks/30_metrics.rake +33 -0
- data/tasks/apple.rake +268 -0
- data/tasks/archive.rake +69 -0
- data/tasks/build.rake +12 -0
- data/tasks/clean.rake +5 -0
- data/tasks/config.rake +35 -0
- data/tasks/deb.rake +129 -0
- data/tasks/deb_repos.rake +28 -0
- data/tasks/deprecated.rake +130 -0
- data/tasks/doc.rake +20 -0
- data/tasks/education.rake +57 -0
- data/tasks/fetch.rake +60 -0
- data/tasks/gem.rake +159 -0
- data/tasks/jenkins.rake +538 -0
- data/tasks/jenkins_dynamic.rake +202 -0
- data/tasks/load_extras.rake +21 -0
- data/tasks/mock.rake +348 -0
- data/tasks/nightly_repos.rake +286 -0
- data/tasks/pe_deb.rake +12 -0
- data/tasks/pe_rpm.rake +13 -0
- data/tasks/pe_ship.rake +226 -0
- data/tasks/pe_sign.rake +13 -0
- data/tasks/pe_tar.rake +5 -0
- data/tasks/retrieve.rake +52 -0
- data/tasks/rpm.rake +66 -0
- data/tasks/rpm_repos.rake +29 -0
- data/tasks/ship.rake +692 -0
- data/tasks/sign.rake +154 -0
- data/tasks/tag.rake +8 -0
- data/tasks/tar.rake +28 -0
- data/tasks/update.rake +16 -0
- data/tasks/vanagon.rake +35 -0
- data/tasks/vendor_gems.rake +117 -0
- data/tasks/version.rake +33 -0
- data/tasks/z_data_dump.rake +65 -0
- data/templates/README +1 -0
- data/templates/downstream.xml.erb +47 -0
- data/templates/msi.xml.erb +197 -0
- data/templates/packaging.xml.erb +346 -0
- data/templates/repo.xml.erb +117 -0
- metadata +287 -0
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe 'Pkg::Platforms' do
|
|
4
|
+
describe '#by_package_format' do
|
|
5
|
+
it 'should return an array of platforms that use a given format' do
|
|
6
|
+
deb_platforms = ['debian', 'ubuntu']
|
|
7
|
+
rpm_platforms = ['aix', 'el', 'fedora', 'redhatfips', 'sles']
|
|
8
|
+
expect(Pkg::Platforms.by_package_format('deb')).to match_array(deb_platforms)
|
|
9
|
+
expect(Pkg::Platforms.by_package_format('rpm')).to match_array(rpm_platforms)
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
describe '#formats' do
|
|
14
|
+
it 'should return all package formats' do
|
|
15
|
+
fmts = ['rpm', 'deb', 'dmg', 'svr4', 'ips', 'msi']
|
|
16
|
+
expect(Pkg::Platforms.formats).to match_array(fmts)
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
describe '#supported_platforms' do
|
|
21
|
+
it 'should return all supported platforms' do
|
|
22
|
+
platforms = ['aix', 'debian', 'el', 'fedora', 'osx', 'redhatfips', 'sles', 'solaris', 'ubuntu', 'windows', 'windowsfips']
|
|
23
|
+
expect(Pkg::Platforms.supported_platforms).to match_array(platforms)
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
describe '#versions_for_platform' do
|
|
28
|
+
it 'should return all supported versions for a given platform' do
|
|
29
|
+
expect(Pkg::Platforms.versions_for_platform('el')).to match_array(['5', '6', '7', '8'])
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
it 'should raise an error if given a nonexistent platform' do
|
|
33
|
+
expect{Pkg::Platforms.versions_for_platform('notaplatform') }.to raise_error
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
describe '#codenames' do
|
|
38
|
+
it 'should return all codenames for a given platform' do
|
|
39
|
+
codenames = ['focal', 'bionic', 'buster', 'cosmic', 'jessie', 'stretch', 'trusty', 'xenial']
|
|
40
|
+
expect(Pkg::Platforms.codenames).to match_array(codenames)
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
describe '#codename_to_platform_version' do
|
|
45
|
+
it 'should return the platform and version corresponding to a given codename' do
|
|
46
|
+
expect(Pkg::Platforms.codename_to_platform_version('xenial')).to eq(['ubuntu', '16.04'])
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
it 'should fail if given nil as a codename' do
|
|
50
|
+
expect{Pkg::Platforms.codename_to_platform_version(nil)}.to raise_error
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
describe '#codename_for_platform_version' do
|
|
55
|
+
it 'should return the codename corresponding to a given platform and version' do
|
|
56
|
+
expect(Pkg::Platforms.codename_for_platform_version('ubuntu', '16.04')).to eq('xenial')
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
describe '#arches_for_codename' do
|
|
61
|
+
it 'should return an array of arches corresponding to a given codename' do
|
|
62
|
+
expect(Pkg::Platforms.arches_for_codename('xenial')).to match_array(['amd64', 'i386', 'ppc64el'])
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
it 'should be able to include source archietectures' do
|
|
66
|
+
expect(Pkg::Platforms.arches_for_codename('xenial', true)).to match_array(["amd64", "i386", "ppc64el", "source"])
|
|
67
|
+
end
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
describe '#codename_to_tags' do
|
|
71
|
+
it 'should return an array of platform tags corresponding to a given codename' do
|
|
72
|
+
expect(Pkg::Platforms.codename_to_tags('xenial')).to match_array(['ubuntu-16.04-i386', 'ubuntu-16.04-amd64', "ubuntu-16.04-ppc64el"])
|
|
73
|
+
end
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
describe '#arches_for_platform_version' do
|
|
77
|
+
it 'should return an array of arches for a given platform and version' do
|
|
78
|
+
expect(Pkg::Platforms.arches_for_platform_version('sles', '12')).to match_array(['x86_64', 'ppc64le'])
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
it 'should be able to include source architectures' do
|
|
82
|
+
expect(Pkg::Platforms.arches_for_platform_version('sles', '12', true)).to match_array(["SRPMS", "ppc64le", "x86_64"])
|
|
83
|
+
end
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
describe '#platform_tags' do
|
|
87
|
+
it 'should return an array of platform tags' do
|
|
88
|
+
tags = Pkg::Platforms.platform_tags
|
|
89
|
+
expect(tags).to be_instance_of(Array)
|
|
90
|
+
expect(tags.count).to be > 0
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
it 'should include a basic platform' do
|
|
94
|
+
tags = Pkg::Platforms.platform_tags
|
|
95
|
+
expect(tags).to include('el-7-x86_64')
|
|
96
|
+
end
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
describe '#platform_lookup' do
|
|
100
|
+
['osx-10.15-x86_64', 'osx-11-x86_64'].each do |platform|
|
|
101
|
+
it 'should return a hash of platform info' do
|
|
102
|
+
expect(Pkg::Platforms.platform_lookup(platform)).to be_instance_of(Hash)
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
it 'should include at least arch and package format keys' do
|
|
106
|
+
expect(Pkg::Platforms.platform_lookup(platform).keys).to include(:architectures)
|
|
107
|
+
expect(Pkg::Platforms.platform_lookup(platform).keys).to include(:package_format)
|
|
108
|
+
end
|
|
109
|
+
end
|
|
110
|
+
end
|
|
111
|
+
|
|
112
|
+
describe '#get_attribute' do
|
|
113
|
+
it 'returns info about a given platform' do
|
|
114
|
+
expect(Pkg::Platforms.get_attribute('el-6-x86_64', :signature_format)).to eq('v4')
|
|
115
|
+
end
|
|
116
|
+
|
|
117
|
+
it 'fails with a reasonable error when specified attribute is not defined' do
|
|
118
|
+
expect { Pkg::Platforms.get_attribute('osx-10.15-x86_64', :signature_format) }.to raise_error(/doesn't have information/)
|
|
119
|
+
end
|
|
120
|
+
end
|
|
121
|
+
|
|
122
|
+
describe '#package_format_for_tag' do
|
|
123
|
+
it 'should return the package format for a given platform tag' do
|
|
124
|
+
expect(Pkg::Platforms.package_format_for_tag('windows-2012-x86')).to eq('msi')
|
|
125
|
+
end
|
|
126
|
+
end
|
|
127
|
+
|
|
128
|
+
describe '#parse_platform_tag' do
|
|
129
|
+
test_cases = {
|
|
130
|
+
'debian-9-amd64' => ['debian', '9', 'amd64'],
|
|
131
|
+
'windows-2012-x86' => ['windows', '2012', 'x86'],
|
|
132
|
+
'windowsfips-2012-x64' => ['windowsfips', '2012', 'x64'],
|
|
133
|
+
'el-7-x86_64' => ['el', '7', 'x86_64'],
|
|
134
|
+
'el-6' => ['el', '6', ''],
|
|
135
|
+
'xenial-amd64' => ['ubuntu', '16.04', 'amd64'],
|
|
136
|
+
'xenial' => ['ubuntu', '16.04', ''],
|
|
137
|
+
'windows-2012' => ['windows', '2012', ''],
|
|
138
|
+
'redhatfips-7-x86_64' => ['redhatfips', '7', 'x86_64'],
|
|
139
|
+
'el-7-SRPMS' => ['el', '7', 'SRPMS'],
|
|
140
|
+
'ubuntu-16.04-source' => ['ubuntu', '16.04', 'source'],
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
fail_cases = [
|
|
144
|
+
'debian-4-amd64',
|
|
145
|
+
'el-x86_64',
|
|
146
|
+
'nothing',
|
|
147
|
+
'windows-x86',
|
|
148
|
+
'el-7-notarch',
|
|
149
|
+
'debian-7-x86_64',
|
|
150
|
+
'el-7-source',
|
|
151
|
+
'debian-7-SRPMS',
|
|
152
|
+
]
|
|
153
|
+
|
|
154
|
+
test_cases.each do |platform_tag, results|
|
|
155
|
+
it "returns an array for #{platform_tag}" do
|
|
156
|
+
expect(Pkg::Platforms.parse_platform_tag(platform_tag)).to match_array(results)
|
|
157
|
+
end
|
|
158
|
+
end
|
|
159
|
+
|
|
160
|
+
fail_cases.each do |platform_tag|
|
|
161
|
+
it "fails out for #{platform_tag}" do
|
|
162
|
+
expect { Pkg::Platforms.parse_platform_tag(platform_tag)}.to raise_error
|
|
163
|
+
end
|
|
164
|
+
end
|
|
165
|
+
end
|
|
166
|
+
|
|
167
|
+
describe '#generic_platform_tag' do
|
|
168
|
+
it 'fails for unsupported platforms' do
|
|
169
|
+
expect { Pkg::Platforms.generic_platform_tag('butts') }.to raise_error
|
|
170
|
+
end
|
|
171
|
+
|
|
172
|
+
it 'returns a supported platform tag containing the supplied platform' do
|
|
173
|
+
Pkg::Platforms.supported_platforms.each do |platform|
|
|
174
|
+
expect(Pkg::Platforms.platform_tags).to include(Pkg::Platforms.generic_platform_tag(platform))
|
|
175
|
+
end
|
|
176
|
+
end
|
|
177
|
+
end
|
|
178
|
+
end
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
# -*- ruby -*-
|
|
2
|
+
require 'spec_helper'
|
|
3
|
+
describe "#Pkg::Repo" do
|
|
4
|
+
let(:platform_repo_stub) do
|
|
5
|
+
[
|
|
6
|
+
{"name"=>"el-4-i386", "repo_location"=>"repos/el/4/**/i386"},
|
|
7
|
+
{"name"=>"el-5-i386", "repo_location"=>"repos/el/5/**/i386"},
|
|
8
|
+
{"name"=>"el-6-i386", "repo_location"=>"repos/el/6/**/i386"}
|
|
9
|
+
]
|
|
10
|
+
end
|
|
11
|
+
describe "#create_signed_repo_archive" do
|
|
12
|
+
it "should change to the correct dir" do
|
|
13
|
+
allow(Pkg::Util::Tool).to receive(:check_tool).and_return("tarcommand")
|
|
14
|
+
allow(Pkg::Config).to receive(:project).and_return("project")
|
|
15
|
+
allow(Pkg::Util::Version).to receive(:dot_version).and_return("1.1.1")
|
|
16
|
+
allow(Pkg::Util::File).to receive(:empty_dir?).and_return(false)
|
|
17
|
+
allow(Pkg::Util::Execution).to receive(:capture3)
|
|
18
|
+
|
|
19
|
+
expect(Dir).to receive(:chdir).with('pkg/project/1.1.1').and_yield
|
|
20
|
+
Pkg::Repo.create_signed_repo_archive("/path", "project-debian-6-i386", "version")
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
it 'should use a ref if ref is specified as versioning' do
|
|
24
|
+
allow(Pkg::Util::Tool).to receive(:check_tool).and_return('tarcommand')
|
|
25
|
+
allow(Dir).to receive(:chdir).with('pkg').and_yield
|
|
26
|
+
allow(Pkg::Util::File).to receive(:empty_dir?).and_return(false)
|
|
27
|
+
allow(Pkg::Util::Execution).to receive(:capture3)
|
|
28
|
+
|
|
29
|
+
expect(Pkg::Config).to receive(:project).and_return('project')
|
|
30
|
+
expect(Pkg::Config).to receive(:ref).and_return('AAAAAAAAAAAAAAA')
|
|
31
|
+
expect(Dir).to receive(:chdir).with('pkg/project/AAAAAAAAAAAAAAA').and_yield
|
|
32
|
+
Pkg::Repo.create_signed_repo_archive('/path', 'project-debian-6-i386', 'ref')
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
it 'should use dot versions if version is specified as versioning' do
|
|
36
|
+
allow(Pkg::Util::Tool).to receive(:check_tool).and_return('tarcommand')
|
|
37
|
+
allow(Dir).to receive(:chdir).with('pkg').and_yield
|
|
38
|
+
allow(Pkg::Util::File).to receive(:empty_dir?).and_return(false)
|
|
39
|
+
allow(Pkg::Util::Execution).to receive(:capture3)
|
|
40
|
+
|
|
41
|
+
expect(Pkg::Config).to receive(:project).and_return('project')
|
|
42
|
+
expect(Pkg::Util::Version).to receive(:dot_version).and_return('1.1.1')
|
|
43
|
+
expect(Dir).to receive(:chdir).with('pkg/project/1.1.1').and_yield
|
|
44
|
+
Pkg::Repo.create_signed_repo_archive('/path', 'project-debian-6-i386', 'version')
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
it 'should fail if ENV["FAIL_ON_MISSING_TARGET"] is true and empty_dir? is also true' do
|
|
48
|
+
allow(Pkg::Util::Tool).to receive(:check_tool).and_return('tarcommand')
|
|
49
|
+
allow(Pkg::Config).to receive(:project).and_return('project')
|
|
50
|
+
allow(Pkg::Util::Version).to receive(:dot_version).and_return('1.1.1')
|
|
51
|
+
allow(Pkg::Util::Execution).to receive(:capture3)
|
|
52
|
+
allow(Dir).to receive(:chdir).with('pkg').and_yield
|
|
53
|
+
allow(Dir).to receive(:chdir).with('project/1.1.1').and_yield
|
|
54
|
+
allow(Pkg::Util::File).to receive(:empty_dir?).and_return(true)
|
|
55
|
+
ENV['FAIL_ON_MISSING_TARGET'] = 'true'
|
|
56
|
+
|
|
57
|
+
expect{Pkg::Repo.create_signed_repo_archive('/path', 'project-debian-6-i386', 'version')}.to raise_error(RuntimeError, 'Error: missing packages under /path')
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
it "should only warn if ENV['FAIL_ON_MISSING_TARGET'] is false and empty_dir? is true" do
|
|
61
|
+
allow(Pkg::Util::Tool).to receive(:check_tool).and_return("tarcommand")
|
|
62
|
+
allow(Pkg::Config).to receive(:project).and_return("project")
|
|
63
|
+
allow(Pkg::Util::Version).to receive(:dot_version).and_return("1.1.1")
|
|
64
|
+
allow(Pkg::Util::Execution).to receive(:capture3)
|
|
65
|
+
allow(Dir).to receive(:chdir).with("pkg/project/1.1.1").and_yield
|
|
66
|
+
allow(Pkg::Util::File).to receive(:empty_dir?).and_return(true)
|
|
67
|
+
ENV['FAIL_ON_MISSING_TARGET'] = "false"
|
|
68
|
+
|
|
69
|
+
expect{Pkg::Repo.create_signed_repo_archive("/path", "project-debian-6-i386", "version")}.not_to raise_error
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
it 'should invoke tar correctly' do
|
|
73
|
+
allow(Pkg::Util::Tool).to receive(:check_tool).and_return('tarcommand')
|
|
74
|
+
allow(Pkg::Config).to receive(:project).and_return('project')
|
|
75
|
+
allow(Pkg::Util::Version).to receive(:dot_version).and_return('1.1.1')
|
|
76
|
+
allow(Dir).to receive(:chdir).with('pkg/project/1.1.1').and_yield
|
|
77
|
+
allow(Pkg::Util::File).to receive(:empty_dir?).and_return(false)
|
|
78
|
+
|
|
79
|
+
expect(Pkg::Util::Execution).to receive(:capture3).with('tarcommand --owner=0 --group=0 --create --gzip --file repos/project-debian-6-i386.tar.gz /path')
|
|
80
|
+
Pkg::Repo.create_signed_repo_archive('/path', 'project-debian-6-i386', 'version')
|
|
81
|
+
end
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
describe '#create_signed_repo_archive' do
|
|
85
|
+
it 'should invoke create_signed_repo_archive correctly for multiple entries in platform_repos' do
|
|
86
|
+
allow(Pkg::Config).to receive(:platform_repos).and_return(platform_repo_stub)
|
|
87
|
+
allow(Pkg::Config).to receive(:project).and_return('project')
|
|
88
|
+
allow(Pkg::Util::Version).to receive(:dot_version).and_return('1.1.1')
|
|
89
|
+
allow(Dir).to receive(:chdir).with('pkg/project/1.1.1').and_yield
|
|
90
|
+
|
|
91
|
+
expect(Pkg::Repo).to receive(:create_signed_repo_archive).with('repos/el/4/**/i386', 'project-el-4-i386', 'version')
|
|
92
|
+
expect(Pkg::Repo).to receive(:create_signed_repo_archive).with('repos/el/5/**/i386', 'project-el-5-i386', 'version')
|
|
93
|
+
expect(Pkg::Repo).to receive(:create_signed_repo_archive).with('repos/el/6/**/i386', 'project-el-6-i386', 'version')
|
|
94
|
+
|
|
95
|
+
allow(Pkg::Util::Execution).to receive(:capture3)
|
|
96
|
+
Pkg::Repo.create_all_repo_archives('project', 'version')
|
|
97
|
+
end
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
describe "#argument_required?" do
|
|
101
|
+
let(:repo_command) { "some command with __REPO_PATH__ but not repo name or anything" }
|
|
102
|
+
let(:required_arg) { 'repo_path' }
|
|
103
|
+
let(:optional_arg) { 'repo_name' }
|
|
104
|
+
|
|
105
|
+
it 'should return true if command requires arg' do
|
|
106
|
+
expect(Pkg::Repo.argument_required?(required_arg, repo_command)).to be_true
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
it 'should return false if command does not need arg' do
|
|
110
|
+
expect(Pkg::Repo.argument_required?(optional_arg, repo_command)).to be_false
|
|
111
|
+
end
|
|
112
|
+
end
|
|
113
|
+
|
|
114
|
+
describe "#update_repo" do
|
|
115
|
+
let(:remote_host) { 'weth.delivery.puppetlabs.net' }
|
|
116
|
+
let(:repo_command) { "some command with __REPO_NAME__ and __REPO_PATH__ and stuff" }
|
|
117
|
+
let(:repo_name) { 'puppet5' }
|
|
118
|
+
let(:repo_path) { '/opt/repository/apt' }
|
|
119
|
+
let(:apt_releases) { ['stretch', 'trusty', 'xenial'] }
|
|
120
|
+
|
|
121
|
+
before(:each) do
|
|
122
|
+
allow(Pkg::Util::Gpg).to receive(:key)
|
|
123
|
+
allow(Pkg::Config).to receive(:apt_releases).and_return(apt_releases)
|
|
124
|
+
end
|
|
125
|
+
|
|
126
|
+
it 'should fail if required params are nil' do
|
|
127
|
+
expect{ Pkg::Repo.update_repo(remote_host, repo_command, { :repo_path => repo_path }) }.to raise_error(RuntimeError, /Missing required argument 'repo_name'/)
|
|
128
|
+
end
|
|
129
|
+
|
|
130
|
+
it 'should execute command if optional params are nil' do
|
|
131
|
+
expect(Pkg::Util::Net).to receive(:remote_execute).with(remote_host, "some command with #{repo_name} and #{repo_path} and stuff")
|
|
132
|
+
Pkg::Repo.update_repo(remote_host, repo_command, { :repo_name => repo_name, :repo_path => repo_path })
|
|
133
|
+
end
|
|
134
|
+
end
|
|
135
|
+
end
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
require 'packaging/retrieve'
|
|
3
|
+
require 'packaging/paths'
|
|
4
|
+
|
|
5
|
+
describe 'Pkg::Retrieve' do
|
|
6
|
+
local_target = 'pkg'
|
|
7
|
+
remote_target = 'repos'
|
|
8
|
+
project = 'puppet-agent'
|
|
9
|
+
ref = 'b25e64984dd505391f248fe5501ad81e2645b6d2'
|
|
10
|
+
foss_platforms = ['el-7-x86_64', 'ubuntu-16.04-amd64', 'osx-10.15-x86_64', 'osx-11-x86_64', 'windows-2012-x64']
|
|
11
|
+
platform_data = {:platform_data => {
|
|
12
|
+
'aix-7.1-power' => {:artifact => './aix/7.1/PC1/ppc/puppet-agent-5.3.2.155.gb25e649-1.aix7.1.ppc.rpm'},
|
|
13
|
+
'el-7-x86_64' => {:artifact => './el/7/PC1/x86_64/puppet-agent-5.3.2.155.gb25e649-1.el7.x86_64.rpm'},
|
|
14
|
+
'osx-10.15-x86_64' => {:artifact => './apple/10.15/PC1/x86_64/puppet-agent-5.3.2.155.gb25e649-1.osx10.15.dmg'},
|
|
15
|
+
'osx-11-x86_64' => {:artifact => './apple/11/PC1/x86_64/puppet-agent-5.3.2.155.gb25e649-1.osx11.dmg'},
|
|
16
|
+
'sles-11-i386' => {:artifact => './sles/11/PC1/i386/puppet-agent-5.3.2.155.gb25e649-1.sles11.i386.rpm'},
|
|
17
|
+
'solaris-10-sparc' => {:artifact => './solaris/10/PC1/puppet-agent-5.3.2.155.gb25e649-1.sparc.pkg.gz'},
|
|
18
|
+
'ubuntu-16.04-amd64' => {:artifact => './deb/xenial/PC1/puppet-agent_5.3.2.155.gb25e649-1xenial_amd64.deb'},
|
|
19
|
+
'windows-2012-x64' => {:artifact => './windows/puppet-agent-x64.msi'},
|
|
20
|
+
}}
|
|
21
|
+
build_url = "builds.delivery.puppetlabs.net/#{project}/#{ref}/#{remote_target}"
|
|
22
|
+
build_path = "/opt/jenkins-builds/#{project}/#{ref}/#{remote_target}"
|
|
23
|
+
|
|
24
|
+
before :each do
|
|
25
|
+
allow(Pkg::Config).to receive(:project).and_return(project)
|
|
26
|
+
allow(Pkg::Config).to receive(:ref).and_return(ref)
|
|
27
|
+
allow(Pkg::Config).to receive(:foss_platforms).and_return(foss_platforms)
|
|
28
|
+
allow(File).to receive(:readable?).with("#{local_target}/#{ref}.yaml").and_return(true)
|
|
29
|
+
allow(Pkg::Util::Serialization).to receive(:load_yaml).and_return(platform_data)
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
describe '#default_wget_command' do
|
|
33
|
+
let(:options) { [
|
|
34
|
+
"--quiet",
|
|
35
|
+
"--recursive",
|
|
36
|
+
"--no-parent",
|
|
37
|
+
"--no-host-directories",
|
|
38
|
+
"--level=0",
|
|
39
|
+
"--cut-dirs=3",
|
|
40
|
+
"--directory-prefix=#{local_target}",
|
|
41
|
+
"--reject='index*",
|
|
42
|
+
] }
|
|
43
|
+
before :each do
|
|
44
|
+
allow(Pkg::Util::Tool).to receive(:check_tool).with('wget').and_return('wget')
|
|
45
|
+
end
|
|
46
|
+
context 'when no options passed' do
|
|
47
|
+
it 'should include default options' do
|
|
48
|
+
options.each do |option|
|
|
49
|
+
expect(Pkg::Retrieve.default_wget_command(local_target, build_url)).to include(option)
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
context 'when options are passed' do
|
|
54
|
+
it 'should add to existing options' do
|
|
55
|
+
options.push('--convert-links')
|
|
56
|
+
options.each do |option|
|
|
57
|
+
expect(Pkg::Retrieve.default_wget_command(local_target, build_url, {'convert-links' => true})).to include(option)
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
it 'should replace default values' do
|
|
61
|
+
options.push('--level=1').delete('--level=0')
|
|
62
|
+
expect(Pkg::Retrieve.default_wget_command(local_target, build_url, {'level' => 1})).to_not include('--level=0')
|
|
63
|
+
options.each do |option|
|
|
64
|
+
expect(Pkg::Retrieve.default_wget_command(local_target, build_url, {'level' => 1})).to include(option)
|
|
65
|
+
end
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
describe '#foss_only_retrieve' do
|
|
71
|
+
it 'should fail without foss_platforms' do
|
|
72
|
+
allow(Pkg::Config).to receive(:foss_platforms).and_return(nil)
|
|
73
|
+
expect { Pkg::Retrieve.foss_only_retrieve(build_url, local_target) }.to raise_error(/I don't know anything about FOSS_PLATFORMS/)
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
it 'should fail if cannot read <ref>.yaml' do
|
|
77
|
+
allow(File).to receive(:readable?).with("#{local_target}/#{ref}.yaml").and_return(false)
|
|
78
|
+
expect { Pkg::Retrieve.foss_only_retrieve(build_url, local_target) }.to raise_error(/Couldn't read #{ref}.yaml/)
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
it 'should retrieve foss_only packages' do
|
|
82
|
+
expect(Pkg::Retrieve).to receive(:default_wget).exactly(1 + foss_platforms.count).times
|
|
83
|
+
Pkg::Retrieve.foss_only_retrieve(build_url, local_target)
|
|
84
|
+
end
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
describe '#retrieve_all' do
|
|
88
|
+
it 'should try to use wget first' do
|
|
89
|
+
expect(Pkg::Retrieve).to receive(:default_wget)
|
|
90
|
+
Pkg::Retrieve.retrieve_all(build_url, build_path, local_target)
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
it 'should use rsync if wget is not found' do
|
|
94
|
+
allow(Pkg::Util::Tool).to receive(:find_tool).with('wget').and_return(nil)
|
|
95
|
+
expect(Pkg::Util::Net).to receive(:rsync_from)
|
|
96
|
+
Pkg::Retrieve.retrieve_all(build_url, build_path, local_target)
|
|
97
|
+
end
|
|
98
|
+
end
|
|
99
|
+
end
|
|
100
|
+
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe "Pkg::Rpm::Repo" do
|
|
4
|
+
let(:wget) { "/opt/tools/bin/wget" }
|
|
5
|
+
let(:builds_server) { "saturn.puppetlabs.net" }
|
|
6
|
+
let(:project) { "rpm_repos" }
|
|
7
|
+
let(:ref) { "1234abcd" }
|
|
8
|
+
let(:base_url) { "http://#{builds_server}/#{project}/#{ref}" }
|
|
9
|
+
let(:mocks) { ["el-5-i386", "el-5-x86_64", "el-5-SRPMS"] }
|
|
10
|
+
let(:wget_results) {
|
|
11
|
+
mocks.map do |mock|
|
|
12
|
+
dist, version, arch = mock.split('-')
|
|
13
|
+
"http://#{builds_server}/#{project}/#{ref}/repos/#{dist}/#{version}/products/#{arch}/repodata/"
|
|
14
|
+
end.join("\n")
|
|
15
|
+
}
|
|
16
|
+
let(:wget_garbage) { "\nother things\n and an index\nhttp://somethingelse.com" }
|
|
17
|
+
let(:repo_configs) { mocks.map { |mock| "pkg/repo_configs/rpm/pl-#{project}-#{ref}-#{mock}.repo" } }
|
|
18
|
+
|
|
19
|
+
# Setup and tear down for the tests
|
|
20
|
+
around do |example|
|
|
21
|
+
orig_server = Pkg::Config.builds_server
|
|
22
|
+
orig_host = Pkg::Config.distribution_server
|
|
23
|
+
orig_project = Pkg::Config.project
|
|
24
|
+
orig_ref = Pkg::Config.ref
|
|
25
|
+
orig_repo_path = Pkg::Config.jenkins_repo_path
|
|
26
|
+
Pkg::Config.builds_server = builds_server
|
|
27
|
+
Pkg::Config.project = project
|
|
28
|
+
Pkg::Config.ref = ref
|
|
29
|
+
example.run
|
|
30
|
+
Pkg::Config.builds_server = orig_server
|
|
31
|
+
Pkg::Config.distribution_server = orig_host
|
|
32
|
+
Pkg::Config.project = orig_project
|
|
33
|
+
Pkg::Config.ref = orig_ref
|
|
34
|
+
Pkg::Config.jenkins_repo_path = orig_repo_path
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
describe "#generate_repo_configs" do
|
|
38
|
+
it "fails if wget isn't available" do
|
|
39
|
+
Pkg::Util::Tool.stub(:find_tool).with("wget", {:required => true}) {false}
|
|
40
|
+
expect {Pkg::Rpm::Repo.generate_repo_configs}.to raise_error(RuntimeError)
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
it "warns if there are no rpm repos available for the build" do
|
|
44
|
+
Pkg::Util::Tool.should_receive(:find_tool).with("wget", {:required => true}).and_return(wget)
|
|
45
|
+
Pkg::Util::Execution.should_receive(:capture3).with("#{wget} --spider -r -l 5 --no-parent #{base_url}/repos/ 2>&1").and_return("")
|
|
46
|
+
Pkg::Rpm::Repo.should_receive(:warn).with("No rpm repos were found to generate configs from!")
|
|
47
|
+
Pkg::Rpm::Repo.generate_repo_configs
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
it "writes the expected repo configs to disk" do
|
|
51
|
+
Pkg::Util::Tool.should_receive(:find_tool).with("wget", {:required => true}).and_return(wget)
|
|
52
|
+
Pkg::Util::Execution.should_receive(:capture3).with("#{wget} --spider -r -l 5 --no-parent #{base_url}/repos/ 2>&1").and_return(wget_results + wget_garbage)
|
|
53
|
+
wget_results.split.each do |result|
|
|
54
|
+
cur_result = result.chomp('repodata/')
|
|
55
|
+
Pkg::Util::Execution.should_receive(:capture3).with("#{wget} --spider -r -l 1 --no-parent #{cur_result} 2>&1").and_return("#{cur_result}/thing.rpm")
|
|
56
|
+
end
|
|
57
|
+
FileUtils.should_receive(:mkdir_p).with("pkg/repo_configs/rpm")
|
|
58
|
+
config = []
|
|
59
|
+
repo_configs.each_with_index do |repo_config, i|
|
|
60
|
+
Pkg::Paths.should_receive(:tag_from_artifact_path).and_return(mocks[i])
|
|
61
|
+
Pkg::Platforms.should_receive(:parse_platform_tag).and_return(mocks[i].split('-'))
|
|
62
|
+
config[i] = double(File)
|
|
63
|
+
File.should_receive(:open).with(repo_config, 'w').and_yield(config[i])
|
|
64
|
+
config[i].should_receive(:puts)
|
|
65
|
+
end
|
|
66
|
+
Pkg::Rpm::Repo.generate_repo_configs
|
|
67
|
+
end
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
describe "#retrieve_repo_configs" do
|
|
71
|
+
it "fails if wget isn't available" do
|
|
72
|
+
Pkg::Util::Tool.stub(:find_tool).with("wget", {:required => true}) {false}
|
|
73
|
+
expect {Pkg::Rpm::Repo.generate_repo_configs}.to raise_error(RuntimeError)
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
it "fails if there are no deb repos available for the build" do
|
|
77
|
+
Pkg::Util::Tool.should_receive(:find_tool).with("wget", {:required => true}).and_return(wget)
|
|
78
|
+
FileUtils.should_receive(:mkdir_p).with("pkg/repo_configs").and_return(true)
|
|
79
|
+
Pkg::Util::Execution.should_receive(:capture3).with("#{wget} -r -np -nH --cut-dirs 3 -P pkg/repo_configs --reject 'index*' #{base_url}/repo_configs/rpm/").and_raise(RuntimeError)
|
|
80
|
+
expect {Pkg::Rpm::Repo.retrieve_repo_configs}.to raise_error(RuntimeError, /Couldn't retrieve rpm yum repo configs/)
|
|
81
|
+
end
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
describe "#create_local_repos" do
|
|
85
|
+
let(:command) { "/usr/bin/make some repos" }
|
|
86
|
+
let(:target_directory) { "/tmp/dir/thing" }
|
|
87
|
+
|
|
88
|
+
it "makes a repo in the target directory" do
|
|
89
|
+
Pkg::Rpm::Repo.should_receive(:repo_creation_command).with(target_directory).and_return("run this thing")
|
|
90
|
+
Pkg::Util::Execution.should_receive(:capture3).with("bash -c 'run this thing'")
|
|
91
|
+
Pkg::Rpm::Repo.create_local_repos(target_directory)
|
|
92
|
+
end
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
describe "#create_remote_repos" do
|
|
96
|
+
let(:command) { "/usr/bin/make some repos" }
|
|
97
|
+
let(:artifact_directory) { "/tmp/dir/thing" }
|
|
98
|
+
let(:pkg_directories) { ['el-6-i386', 'el/7/x86_64'] }
|
|
99
|
+
|
|
100
|
+
it "makes a repo in the target directory" do
|
|
101
|
+
File.stub(:join) {artifact_directory}
|
|
102
|
+
Pkg::Repo.should_receive(:directories_that_contain_packages).and_return(pkg_directories)
|
|
103
|
+
Pkg::Repo.should_receive(:populate_repo_directory)
|
|
104
|
+
Pkg::Rpm::Repo.should_receive(:repo_creation_command).and_return(command)
|
|
105
|
+
Pkg::Util::Net.should_receive(:remote_execute).with(Pkg::Config.distribution_server, command)
|
|
106
|
+
Pkg::Rpm::Repo.should_receive(:generate_repo_configs)
|
|
107
|
+
Pkg::Rpm::Repo.should_receive(:ship_repo_configs)
|
|
108
|
+
Pkg::Util::Net.should_receive(:remote_execute).with(Pkg::Config.distribution_server, "rm -f #{artifact_directory}/repos/.lock" )
|
|
109
|
+
Pkg::Rpm::Repo.create_remote_repos
|
|
110
|
+
end
|
|
111
|
+
end
|
|
112
|
+
|
|
113
|
+
describe "#ship_repo_configs" do
|
|
114
|
+
it "warn if there are no repo configs to ship" do
|
|
115
|
+
Pkg::Util::File.should_receive(:empty_dir?).with("pkg/repo_configs/rpm").and_return(true)
|
|
116
|
+
Pkg::Rpm::Repo.should_receive(:warn).with("No repo configs have been generated! Try pl:rpm_repo_configs.")
|
|
117
|
+
Pkg::Rpm::Repo.ship_repo_configs
|
|
118
|
+
end
|
|
119
|
+
|
|
120
|
+
it "ships repo configs to the build server" do
|
|
121
|
+
Pkg::Config.jenkins_repo_path = "/a/b/c/d"
|
|
122
|
+
Pkg::Config.project = "thing2"
|
|
123
|
+
Pkg::Config.ref = "abcd1234"
|
|
124
|
+
Pkg::Config.distribution_server = "a.host.that.wont.exist"
|
|
125
|
+
repo_dir = "#{Pkg::Config.jenkins_repo_path}/#{Pkg::Config.project}/#{Pkg::Config.ref}/repo_configs/rpm"
|
|
126
|
+
Pkg::Util::File.should_receive(:empty_dir?).with("pkg/repo_configs/rpm").and_return(false)
|
|
127
|
+
Pkg::Util::RakeUtils.should_receive(:invoke_task).with("pl:fetch")
|
|
128
|
+
Pkg::Util::Net.should_receive(:remote_execute).with(Pkg::Config.distribution_server, "mkdir -p #{repo_dir}")
|
|
129
|
+
Pkg::Util::Execution.should_receive(:retry_on_fail).with(:times => 3)
|
|
130
|
+
Pkg::Rpm::Repo.ship_repo_configs
|
|
131
|
+
end
|
|
132
|
+
end
|
|
133
|
+
end
|