packaging 0.99.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 +7 -0
- data/LICENSE +17 -0
- data/README-Solaris.md +117 -0
- data/README.md +1031 -0
- data/lib/packaging.rb +32 -0
- data/lib/packaging/artifactory.rb +278 -0
- data/lib/packaging/config.rb +392 -0
- data/lib/packaging/config/params.rb +366 -0
- data/lib/packaging/deb.rb +28 -0
- data/lib/packaging/deb/repo.rb +263 -0
- data/lib/packaging/gem.rb +112 -0
- data/lib/packaging/ips.rb +57 -0
- data/lib/packaging/msi.rb +89 -0
- data/lib/packaging/nuget.rb +39 -0
- data/lib/packaging/osx.rb +36 -0
- data/lib/packaging/paths.rb +238 -0
- data/lib/packaging/platforms.rb +480 -0
- data/lib/packaging/repo.rb +55 -0
- data/lib/packaging/retrieve.rb +46 -0
- data/lib/packaging/rpm.rb +5 -0
- data/lib/packaging/rpm/repo.rb +257 -0
- data/lib/packaging/tar.rb +154 -0
- data/lib/packaging/util.rb +146 -0
- data/lib/packaging/util/date.rb +15 -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 +62 -0
- data/lib/packaging/util/jenkins.rb +95 -0
- data/lib/packaging/util/misc.rb +69 -0
- data/lib/packaging/util/net.rb +368 -0
- data/lib/packaging/util/os.rb +17 -0
- data/lib/packaging/util/platform.rb +40 -0
- data/lib/packaging/util/rake_utils.rb +111 -0
- data/lib/packaging/util/serialization.rb +19 -0
- data/lib/packaging/util/ship.rb +171 -0
- data/lib/packaging/util/tool.rb +41 -0
- data/lib/packaging/util/version.rb +326 -0
- data/spec/fixtures/config/ext/build_defaults.yaml +2 -0
- data/spec/fixtures/config/ext/project_data.yaml +2 -0
- data/spec/fixtures/config/params.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 +171 -0
- data/spec/lib/packaging/config_spec.rb +556 -0
- data/spec/lib/packaging/deb/repo_spec.rb +148 -0
- data/spec/lib/packaging/deb_spec.rb +52 -0
- data/spec/lib/packaging/paths_spec.rb +153 -0
- data/spec/lib/packaging/platforms_spec.rb +153 -0
- data/spec/lib/packaging/repo_spec.rb +97 -0
- data/spec/lib/packaging/retrieve_spec.rb +61 -0
- data/spec/lib/packaging/rpm/repo_spec.rb +133 -0
- data/spec/lib/packaging/tar_spec.rb +122 -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 +239 -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 +117 -0
- data/spec/lib/packaging/util/version_spec.rb +123 -0
- data/spec/lib/packaging_spec.rb +19 -0
- data/spec/spec_helper.rb +36 -0
- data/static_artifacts/PackageInfo.plist +3 -0
- data/tasks/00_utils.rake +216 -0
- data/tasks/30_metrics.rake +33 -0
- data/tasks/apple.rake +266 -0
- data/tasks/build.rake +12 -0
- data/tasks/clean.rake +5 -0
- data/tasks/config.rake +30 -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 +57 -0
- data/tasks/gem.rake +146 -0
- data/tasks/jenkins.rake +494 -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 +335 -0
- data/tasks/pe_deb.rake +12 -0
- data/tasks/pe_rpm.rake +13 -0
- data/tasks/pe_ship.rake +221 -0
- data/tasks/pe_sign.rake +13 -0
- data/tasks/pe_tar.rake +5 -0
- data/tasks/retrieve.rake +45 -0
- data/tasks/rpm.rake +66 -0
- data/tasks/rpm_repos.rake +29 -0
- data/tasks/ship.rake +752 -0
- data/tasks/sign.rake +226 -0
- data/tasks/tag.rake +8 -0
- data/tasks/tar.rake +34 -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 +344 -0
- data/templates/repo.xml.erb +114 -0
- metadata +234 -0
@@ -0,0 +1 @@
|
|
1
|
+
{"url": "git://github.com/puppetlabs/leatherman.git", "ref": "refs/tags/0.6.2"}
|
File without changes
|
@@ -0,0 +1 @@
|
|
1
|
+
{"url": "git://github.com/puppetlabs/leatherman.git", "ref": "4eef05389ebf418b62af17406c7f9f13fa51f975"}
|
File without changes
|
File without changes
|
@@ -0,0 +1,171 @@
|
|
1
|
+
# -*- ruby -*-
|
2
|
+
require 'spec_helper'
|
3
|
+
require 'packaging/artifactory'
|
4
|
+
|
5
|
+
describe 'artifactory.rb' do
|
6
|
+
|
7
|
+
project = 'puppet-agent'
|
8
|
+
project_version = 'ashawithlettersandnumbers'
|
9
|
+
default_repo_name = 'testing'
|
10
|
+
artifactory_uri = 'https://artifactory.url'
|
11
|
+
|
12
|
+
let(:platform_data) {
|
13
|
+
{
|
14
|
+
'el-6-x86_64' => {
|
15
|
+
:artifact => "./el/6/PC1/x86_64/puppet-agent-5.3.1.34.gf65f9ef-1.el6.x86_64.rpm",
|
16
|
+
:repo_config => "../repo_configs/rpm/pl-puppet-agent-f65f9efbb727c3d2d72d6799c0fc345a726f27b5-el-6-x86_64.repo",
|
17
|
+
},
|
18
|
+
'ubuntu-16.04-amd64' => {
|
19
|
+
:artifact => "./deb/xenial/PC1/puppet-agent_5.3.1.34.gf65f9ef-1xenial_amd64.deb",
|
20
|
+
:repo_config => "../repo_configs/deb/pl-puppet-agent-f65f9efbb727c3d2d72d6799c0fc345a726f27b5-xenial.list",
|
21
|
+
},
|
22
|
+
'windows-2012-x86' => {
|
23
|
+
:artifact => "./windows/puppet-agent-5.3.1.34-x86.msi",
|
24
|
+
:repo_config => '',
|
25
|
+
},
|
26
|
+
'eos-4-i386' => {
|
27
|
+
:artifact => "./eos/4/PC1/i386/puppet-agent-5.3.1.34.gf65f9ef-1.eos4.i386.swix",
|
28
|
+
:repo_config => '',
|
29
|
+
},
|
30
|
+
'osx-10.12-x86_64' => {
|
31
|
+
:artifact => "./apple/10.12/PC1/x86_64/puppet-agent-5.3.1.34.gf65f9ef-1.osx10.12.dmg",
|
32
|
+
:repo_config => '',
|
33
|
+
},
|
34
|
+
'solaris-10-sparc' => {
|
35
|
+
:artifact => "./solaris/10/PC1/puppet-agent-5.3.1.34.gf65f9ef-1.sparc.pkg.gz",
|
36
|
+
:repo_config => '',
|
37
|
+
},
|
38
|
+
}
|
39
|
+
}
|
40
|
+
|
41
|
+
platform_tags = {
|
42
|
+
'el-6-x86_64' => {
|
43
|
+
:toplevel_repo => 'rpm',
|
44
|
+
:repo_subdirectories => "#{default_repo_name}/#{project}/#{project_version}/el-6-x86_64",
|
45
|
+
:package_format => 'rpm',
|
46
|
+
:package_name => 'path/to/a/el/6/package/puppet-agent-5.3.1.34.gf65f9ef-1.el6.x86_64.rpm',
|
47
|
+
},
|
48
|
+
'ubuntu-16.04-amd64' => {
|
49
|
+
:toplevel_repo => 'debian__local',
|
50
|
+
:repo_subdirectories => "#{default_repo_name}/#{project}/#{project_version}/ubuntu-16.04",
|
51
|
+
:codename => 'xenial',
|
52
|
+
:arch => 'amd64',
|
53
|
+
:package_name => 'path/to/a/xenial/package/puppet-agent_5.3.1.34.gf65f9ef-1xenial_amd64.deb',
|
54
|
+
},
|
55
|
+
'windows-2012-x86' => {
|
56
|
+
:toplevel_repo => 'generic',
|
57
|
+
:repo_subdirectories => "#{default_repo_name}/#{project}/#{project_version}/windows-x86",
|
58
|
+
:package_name => 'path/to/a/windows/package/puppet-agent-5.3.1.34-x86.msi',
|
59
|
+
},
|
60
|
+
'eos-4-i386' => {
|
61
|
+
:toplevel_repo => 'generic',
|
62
|
+
:repo_subdirectories => "#{default_repo_name}/#{project}/#{project_version}/eos-4-i386",
|
63
|
+
:package_name => 'path/to/an/eos/4/package/puppet-agent-5.3.1.34.gf65f9ef-1.eos4.i386.swix',
|
64
|
+
},
|
65
|
+
'osx-10.12-x86_64' => {
|
66
|
+
:toplevel_repo => 'generic',
|
67
|
+
:repo_subdirectories => "#{default_repo_name}/#{project}/#{project_version}/osx-10.12-x86_64",
|
68
|
+
:package_name => 'path/to/an/osx/10.12/package/puppet-agent-5.3.1.34.gf65f9ef-1.osx10.12.dmg',
|
69
|
+
},
|
70
|
+
'solaris-10-sparc' => {
|
71
|
+
:toplevel_repo => 'generic',
|
72
|
+
:repo_subdirectories => "#{default_repo_name}/#{project}/#{project_version}/solaris-10-sparc",
|
73
|
+
:package_name => 'path/to/a/solaris/10/package/puppet-agent-5.3.1.34.gf65f9ef-1.sparc.pkg.gz',
|
74
|
+
},
|
75
|
+
}
|
76
|
+
|
77
|
+
let(:artifact) { Pkg::ManageArtifactory.new(project, project_version, {:repo_base => default_repo_name, :artifactory_uri => artifactory_uri})}
|
78
|
+
|
79
|
+
around(:each) do |example|
|
80
|
+
original_artifactory_api_key = ENV['ARTIFACTORY_API_KEY']
|
81
|
+
ENV['ARTIFACTORY_API_KEY'] = 'anapikeythatdefinitelyworks'
|
82
|
+
example.run
|
83
|
+
ENV['ARTIFACTORY_API_KEY'] = original_artifactory_api_key
|
84
|
+
end
|
85
|
+
|
86
|
+
platform_tags.each do |platform_tag, platform_tag_data|
|
87
|
+
describe '#location_for' do
|
88
|
+
if platform_tag_data[:codename]
|
89
|
+
it 'returns the expected repo name and paths by default, prepending `pool` for debian-ish platforms' do
|
90
|
+
expect(artifact.location_for(platform_tag)).to match_array([
|
91
|
+
platform_tag_data[:toplevel_repo],
|
92
|
+
platform_tag_data[:repo_subdirectories],
|
93
|
+
File.join('pool', platform_tag_data[:repo_subdirectories])
|
94
|
+
])
|
95
|
+
end
|
96
|
+
else
|
97
|
+
it 'returns the expected repo name and paths by default' do
|
98
|
+
expect(artifact.location_for(platform_tag)).to match_array([
|
99
|
+
platform_tag_data[:toplevel_repo],
|
100
|
+
platform_tag_data[:repo_subdirectories],
|
101
|
+
platform_tag_data[:repo_subdirectories]
|
102
|
+
])
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
it 'returns the correct paths for the passed in format' do
|
107
|
+
expect(artifact.location_for('generic')).to match_array([
|
108
|
+
'generic',
|
109
|
+
File.join(default_repo_name, project, project_version),
|
110
|
+
File.join(default_repo_name, project, project_version)
|
111
|
+
])
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
115
|
+
describe '#package_name' do
|
116
|
+
it 'parses the retrieved yaml file and returns the correct package name' do
|
117
|
+
expect(artifact.package_name(platform_data, platform_tag)).to eq(File.basename(platform_tag_data[:package_name]))
|
118
|
+
end
|
119
|
+
|
120
|
+
it 'fails if it cannot find a valid platform name' do
|
121
|
+
new_platform_data = platform_data
|
122
|
+
new_platform_data.delete_if { |k| k.match(platform_tag) }
|
123
|
+
expect{artifact.package_name(new_platform_data, platform_tag)}.to raise_error
|
124
|
+
end
|
125
|
+
end
|
126
|
+
|
127
|
+
describe '#deb_list_contents' do
|
128
|
+
it "returns the correct contents for the debian list file for #{platform_tag}" do
|
129
|
+
if platform_tag_data[:codename]
|
130
|
+
expect(artifact.deb_list_contents(platform_tag)).to eq("deb #{artifactory_uri}/#{platform_tag_data[:toplevel_repo].chomp('/pool')} #{platform_tag_data[:codename]} #{platform_tag_data[:repo_subdirectories]}")
|
131
|
+
else
|
132
|
+
expect{artifact.deb_list_contents(platform_tag)}.to raise_error
|
133
|
+
end
|
134
|
+
end
|
135
|
+
end
|
136
|
+
|
137
|
+
describe '#rpm_repo_contents' do
|
138
|
+
it "returns the correct contents for the rpm repo file for #{platform_tag}" do
|
139
|
+
if platform_tag_data[:package_format] == 'rpm'
|
140
|
+
expect(artifact.rpm_repo_contents(platform_tag)).to include("baseurl=#{artifactory_uri}\/#{platform_tag_data[:toplevel_repo]}\/#{platform_tag_data[:repo_subdirectories]}")
|
141
|
+
else
|
142
|
+
expect{artifact.rpm_repo_contents(platform_tag)}.to raise_error
|
143
|
+
end
|
144
|
+
end
|
145
|
+
end
|
146
|
+
|
147
|
+
describe '#deploy_properties' do
|
148
|
+
it "returns the correct contents for the deploy properties for #{platform_tag}" do
|
149
|
+
if platform_tag_data[:codename]
|
150
|
+
expect(artifact.deploy_properties(platform_tag)).to include({
|
151
|
+
'deb.distribution' => platform_tag_data[:codename],
|
152
|
+
'deb.component' => platform_tag_data[:repo_subdirectories]
|
153
|
+
})
|
154
|
+
else
|
155
|
+
expect(artifact.deploy_properties(platform_tag)).not_to include({
|
156
|
+
'deb.component' => platform_tag_data[:repo_subdirectories]
|
157
|
+
})
|
158
|
+
end
|
159
|
+
end
|
160
|
+
end
|
161
|
+
end
|
162
|
+
|
163
|
+
describe '#check_authorization' do
|
164
|
+
it 'fails gracefully if authorization is not set' do
|
165
|
+
original_artifactory_api_key = ENV['ARTIFACTORY_API_KEY']
|
166
|
+
ENV['ARTIFACTORY_API_KEY'] = nil
|
167
|
+
expect { artifact.deploy_package('path/to/el/7/x86_64/package.rpm') }.to raise_error
|
168
|
+
ENV['ARTIFACTORY_API_KEY'] = original_artifactory_api_key
|
169
|
+
end
|
170
|
+
end
|
171
|
+
end
|
@@ -0,0 +1,556 @@
|
|
1
|
+
# -*- ruby -*-
|
2
|
+
require 'spec_helper'
|
3
|
+
require 'yaml'
|
4
|
+
|
5
|
+
describe "Pkg::Config" do
|
6
|
+
|
7
|
+
Build_Params = [:apt_host,
|
8
|
+
:apt_releases,
|
9
|
+
:apt_repo_path,
|
10
|
+
:apt_repo_url,
|
11
|
+
:apt_repo_name,
|
12
|
+
:apt_repo_command,
|
13
|
+
:author,
|
14
|
+
:benchmark,
|
15
|
+
:build_date,
|
16
|
+
:build_defaults,
|
17
|
+
:build_dmg,
|
18
|
+
:build_doc,
|
19
|
+
:build_gem,
|
20
|
+
:build_ips,
|
21
|
+
:build_msi,
|
22
|
+
:build_pe,
|
23
|
+
:build_tar,
|
24
|
+
:builder_data_file,
|
25
|
+
:bundle_platforms,
|
26
|
+
:certificate_pem,
|
27
|
+
:cows,
|
28
|
+
:db_table,
|
29
|
+
:deb_build_host,
|
30
|
+
:deb_build_mirrors,
|
31
|
+
:debversion,
|
32
|
+
:debug,
|
33
|
+
:default_cow,
|
34
|
+
:default_mock,
|
35
|
+
:description,
|
36
|
+
:dmg_path,
|
37
|
+
:email,
|
38
|
+
:files,
|
39
|
+
:final_mocks,
|
40
|
+
:freight_conf,
|
41
|
+
:gem_default_executables,
|
42
|
+
:gem_dependencies,
|
43
|
+
:gem_description,
|
44
|
+
:gem_devel_dependencies,
|
45
|
+
:gem_development_dependencies,
|
46
|
+
:gem_excludes,
|
47
|
+
:gem_executables,
|
48
|
+
:gem_files,
|
49
|
+
:gem_forge_project,
|
50
|
+
:gem_host,
|
51
|
+
:gem_name,
|
52
|
+
:gem_path,
|
53
|
+
:gem_platform_dependencies,
|
54
|
+
:gem_rdoc_options,
|
55
|
+
:gem_require_path,
|
56
|
+
:gem_required_ruby_version,
|
57
|
+
:gem_required_rubygems_version,
|
58
|
+
:gem_runtime_dependencies,
|
59
|
+
:gem_summary,
|
60
|
+
:gem_test_files,
|
61
|
+
:gemversion,
|
62
|
+
:gpg_key,
|
63
|
+
:gpg_name,
|
64
|
+
:homepage,
|
65
|
+
:ips_build_host,
|
66
|
+
:ips_host,
|
67
|
+
:ips_inter_cert,
|
68
|
+
:ips_package_host,
|
69
|
+
:ips_path,
|
70
|
+
:ips_repo,
|
71
|
+
:ips_store,
|
72
|
+
:jenkins_build_host,
|
73
|
+
:jenkins_packaging_job,
|
74
|
+
:jenkins_repo_path,
|
75
|
+
:metrics,
|
76
|
+
:metrics_url,
|
77
|
+
:msi_name,
|
78
|
+
:name,
|
79
|
+
:nonfinal_apt_repo_command,
|
80
|
+
:nonfinal_apt_repo_path,
|
81
|
+
:nonfinal_apt_repo_staging_path,
|
82
|
+
:nonfinal_dmg_path,
|
83
|
+
:nonfinal_ips_path,
|
84
|
+
:nonfinal_msi_path,
|
85
|
+
:nonfinal_p5p_path,
|
86
|
+
:nonfinal_repo_name,
|
87
|
+
:nonfinal_repo_link_target,
|
88
|
+
:nonfinal_svr4_path,
|
89
|
+
:nonfinal_swix_path,
|
90
|
+
:nonfinal_yum_repo_path,
|
91
|
+
:notify,
|
92
|
+
:project,
|
93
|
+
:origversion,
|
94
|
+
:osx_build_host,
|
95
|
+
:packager,
|
96
|
+
:packaging_repo,
|
97
|
+
:packaging_root,
|
98
|
+
:packaging_url,
|
99
|
+
:pbuild_conf,
|
100
|
+
:pe_name,
|
101
|
+
:pe_version,
|
102
|
+
:pg_major_version,
|
103
|
+
:pre_tar_task,
|
104
|
+
:pre_tasks,
|
105
|
+
:privatekey_pem,
|
106
|
+
:random_mockroot,
|
107
|
+
:rc_mocks,
|
108
|
+
:release,
|
109
|
+
:rpm_build_host,
|
110
|
+
:rpmrelease,
|
111
|
+
:rpmversion,
|
112
|
+
:ref,
|
113
|
+
:repo_name,
|
114
|
+
:short_ref,
|
115
|
+
:sign_tar,
|
116
|
+
:signing_server,
|
117
|
+
:summary,
|
118
|
+
:svr4_host,
|
119
|
+
:svr4_path,
|
120
|
+
:swix_path,
|
121
|
+
:tar_excludes,
|
122
|
+
:tar_host,
|
123
|
+
:tarball_path,
|
124
|
+
:team,
|
125
|
+
:templates,
|
126
|
+
:update_version_file,
|
127
|
+
:version,
|
128
|
+
:version_file,
|
129
|
+
:version_strategy,
|
130
|
+
:yum_host,
|
131
|
+
:yum_repo_path,
|
132
|
+
:yum_repo_name,
|
133
|
+
:yum_repo_command,
|
134
|
+
]
|
135
|
+
|
136
|
+
describe "#new" do
|
137
|
+
Build_Params.each do |param|
|
138
|
+
it "should have r/w accessors for #{param}" do
|
139
|
+
Pkg::Config.should respond_to(param)
|
140
|
+
Pkg::Config.should respond_to("#{param.to_s}=")
|
141
|
+
end
|
142
|
+
end
|
143
|
+
end
|
144
|
+
|
145
|
+
describe "#config_from_hash" do
|
146
|
+
good_params = { :yum_host => 'foo', :pe_name => 'bar' }
|
147
|
+
context "given a valid params hash #{good_params}" do
|
148
|
+
it "should set instance variable values for each param" do
|
149
|
+
good_params.each do |param, value|
|
150
|
+
Pkg::Config.should_receive(:instance_variable_set).with("@#{param}", value)
|
151
|
+
end
|
152
|
+
Pkg::Config.config_from_hash(good_params)
|
153
|
+
end
|
154
|
+
end
|
155
|
+
|
156
|
+
bad_params = { :foo => 'bar' }
|
157
|
+
context "given an invalid params hash #{bad_params}" do
|
158
|
+
bad_params.each do |param, value|
|
159
|
+
it "should print a warning that param '#{param}' is not valid" do
|
160
|
+
Pkg::Config.should_receive(:warn).with(/No build data parameter found for '#{param}'/)
|
161
|
+
Pkg::Config.config_from_hash(bad_params)
|
162
|
+
end
|
163
|
+
|
164
|
+
it "should not try to set instance variable @:#{param}" do
|
165
|
+
Pkg::Config.should_not_receive(:instance_variable_set).with("@#{param}", value)
|
166
|
+
Pkg::Config.config_from_hash(bad_params)
|
167
|
+
end
|
168
|
+
end
|
169
|
+
end
|
170
|
+
|
171
|
+
mixed_params = { :sign_tar => TRUE, :baz => 'qux' }
|
172
|
+
context "given a hash with both valid and invalid params" do
|
173
|
+
it "should set the valid param" do
|
174
|
+
Pkg::Config.should_receive(:instance_variable_set).with("@sign_tar", TRUE)
|
175
|
+
Pkg::Config.config_from_hash(mixed_params)
|
176
|
+
end
|
177
|
+
|
178
|
+
it "should issue a warning that the invalid param is not valid" do
|
179
|
+
Pkg::Config.should_receive(:warn).with(/No build data parameter found for 'baz'/)
|
180
|
+
Pkg::Config.config_from_hash(mixed_params)
|
181
|
+
end
|
182
|
+
|
183
|
+
it "should not try to set instance variable @:baz" do
|
184
|
+
Pkg::Config.should_not_receive(:instance_variable_set).with("@baz", "qux")
|
185
|
+
Pkg::Config.config_from_hash(mixed_params)
|
186
|
+
end
|
187
|
+
end
|
188
|
+
end
|
189
|
+
|
190
|
+
describe "#params" do
|
191
|
+
it "should return a hash containing keys for all build parameters" do
|
192
|
+
params = Pkg::Config.config
|
193
|
+
Build_Params.each { |param| params.has_key?(param).should == TRUE }
|
194
|
+
end
|
195
|
+
end
|
196
|
+
|
197
|
+
describe "#platform_data" do
|
198
|
+
platform_tags = [
|
199
|
+
'eos-4-i386',
|
200
|
+
'osx-10.12-x86_64',
|
201
|
+
'cisco-wrlinux-7-x86_64',
|
202
|
+
'ubuntu-16.04-i386',
|
203
|
+
'cumulus-2.2-amd64',
|
204
|
+
'el-6-s390x',
|
205
|
+
'el-7-ppc64le',
|
206
|
+
'sles-12-x86_64',
|
207
|
+
]
|
208
|
+
|
209
|
+
artifacts = \
|
210
|
+
"./artifacts/eos/4/PC1/i386/puppet-agent-5.3.2-1.eos4.i386.swix\n" \
|
211
|
+
"./artifacts/apple/10.12/PC1/x86_64/puppet-agent-5.3.2.658.gc79ef9a-1.osx10.12.dmg\n" \
|
212
|
+
"./artifacts/cisco-wrlinux/7/PC1/x86_64/puppet-agent-5.3.2-1.cisco_wrlinux7.x86_64.rpm\n" \
|
213
|
+
"./artifacts/deb/xenial/PC1/puppet-agent_5.3.2-1xenial_i386.deb\n" \
|
214
|
+
"./artifacts/deb/cumulus/PC1/puppet-agent_5.3.2-1cumulus_amd64.deb\n" \
|
215
|
+
"./artifacts/el/6/PC1/s390x/puppet-agent-5.3.2.658.gc79ef9a-1.el6.s390x.rpm\n" \
|
216
|
+
"./artifacts/el/7/PC1/ppc64le/puppet-agent-5.3.2-1.el7.ppc64le.rpm\n" \
|
217
|
+
"./artifacts/sles/12/PC1/x86_64/puppet-agent-5.3.2-1.sles12.x86_64.rpm"
|
218
|
+
|
219
|
+
aix_artifacts = \
|
220
|
+
"./artifacts/aix/6.1/PC1/ppc/puppet-agent-5.3.2-1.aix6.1.ppc.rpm"
|
221
|
+
|
222
|
+
fedora_artifacts = \
|
223
|
+
"./artifacts/fedora/f25/PC1/x86_64/puppet-agent-5.3.2-1.fedoraf25.x86_64.rpm"
|
224
|
+
|
225
|
+
windows_artifacts = \
|
226
|
+
"./artifacts/windows/puppet-agent-x64.msi\n" \
|
227
|
+
"./artifacts/windows/puppet-agent-5.3.2-x86.wixpdb\n" \
|
228
|
+
"./artifacts/windows/puppet-agent-5.3.2-x86.msi\n" \
|
229
|
+
"./artifacts/windows/puppet-agent-5.3.2-x64.msi"
|
230
|
+
|
231
|
+
solaris_artifacts = \
|
232
|
+
"./artifacts/solaris/11/PC1/puppet-agent@5.3.2,5.11-1.sparc.p5p\n" \
|
233
|
+
"./artifacts/solaris/10/PC1/puppet-agent-5.3.2-1.i386.pkg.gz"
|
234
|
+
|
235
|
+
stretch_artifacts = \
|
236
|
+
"./artifacts/deb/stretch/PC1/puppet-agent-dbgsym_5.3.2-1stretch_i386.deb\n" \
|
237
|
+
"./artifacts/deb/stretch/PC1/puppet-agent_5.3.2-1stretch_i386.deb\n" \
|
238
|
+
"./artifacts/deb/stretch/PC1/puppet-agent_5.3.2.658.gc79ef9a-1stretch_amd64.deb\n" \
|
239
|
+
"./artifacts/deb/stretch/PC1/puppet-agent-dbgsym_5.3.2.658.gc79ef9a-1stretch_amd64.deb"
|
240
|
+
|
241
|
+
project = 'puppet-agent'
|
242
|
+
ref = '5.3.2'
|
243
|
+
|
244
|
+
before :each do
|
245
|
+
allow(Pkg::Config).to receive(:project).and_return(project)
|
246
|
+
allow(Pkg::Config).to receive(:ref).and_return(ref)
|
247
|
+
allow(Pkg::Util::Net).to receive(:check_host_ssh).and_return([])
|
248
|
+
end
|
249
|
+
|
250
|
+
it "should return a hash mapping platform tags to paths" do
|
251
|
+
allow(Pkg::Util::Net).to receive(:remote_ssh_cmd).and_return(artifacts, nil)
|
252
|
+
expect(Pkg::Config.platform_data.keys).to eql(platform_tags)
|
253
|
+
end
|
254
|
+
|
255
|
+
it "should return nil if project isn't set" do
|
256
|
+
allow(Pkg::Config).to receive(:project).and_return(nil)
|
257
|
+
expect(Pkg::Config.platform_data).to be_nil
|
258
|
+
end
|
259
|
+
|
260
|
+
it "should return nil if ref isn't set" do
|
261
|
+
allow(Pkg::Config).to receive(:ref).and_return(nil)
|
262
|
+
expect(Pkg::Config.platform_data).to be_nil
|
263
|
+
end
|
264
|
+
|
265
|
+
it "should return nil if can't connect to build server" do
|
266
|
+
allow(Pkg::Util::Net).to receive(:check_host_ssh).and_return(['something'])
|
267
|
+
expect(Pkg::Config.platform_data).to be_nil
|
268
|
+
end
|
269
|
+
|
270
|
+
it "should not use 'f' in fedora platform tags" do
|
271
|
+
allow(Pkg::Util::Net).to receive(:remote_ssh_cmd).and_return(fedora_artifacts, nil)
|
272
|
+
data = Pkg::Config.platform_data
|
273
|
+
expect(data).to include('fedora-25-x86_64')
|
274
|
+
expect(data).not_to include('fedora-f25-x86_64')
|
275
|
+
end
|
276
|
+
|
277
|
+
it "should collect packages whose extname differ from package_format" do
|
278
|
+
allow(Pkg::Util::Net).to receive(:remote_ssh_cmd).and_return(solaris_artifacts, nil)
|
279
|
+
data = Pkg::Config.platform_data
|
280
|
+
expect(data).to include('solaris-10-i386' => {:artifact => './solaris/10/PC1/puppet-agent-5.3.2-1.i386.pkg.gz', :repo_config => nil})
|
281
|
+
expect(data).to include('solaris-11-sparc' => {:artifact => './solaris/11/PC1/puppet-agent@5.3.2,5.11-1.sparc.p5p', :repo_config => nil})
|
282
|
+
end
|
283
|
+
|
284
|
+
it "should collect versioned msis" do
|
285
|
+
allow(Pkg::Util::Net).to receive(:remote_ssh_cmd).and_return(windows_artifacts, nil)
|
286
|
+
data = Pkg::Config.platform_data
|
287
|
+
expect(data['windows-2012-x86']).to include(:artifact => './windows/puppet-agent-5.3.2-x86.msi')
|
288
|
+
expect(data['windows-2012-x64']).to include(:artifact => './windows/puppet-agent-5.3.2-x64.msi')
|
289
|
+
end
|
290
|
+
|
291
|
+
it "should not collect debug packages" do
|
292
|
+
allow(Pkg::Util::Net).to receive(:remote_ssh_cmd).and_return(stretch_artifacts, nil)
|
293
|
+
data = Pkg::Config.platform_data
|
294
|
+
expect(data['debian-9-amd64']).to include(:artifact => './deb/stretch/PC1/puppet-agent_5.3.2.658.gc79ef9a-1stretch_amd64.deb')
|
295
|
+
end
|
296
|
+
|
297
|
+
it "should use 'ppc' instead of 'power' in aix paths" do
|
298
|
+
allow(Pkg::Util::Net).to receive(:remote_ssh_cmd).and_return(aix_artifacts, nil)
|
299
|
+
data = Pkg::Config.platform_data
|
300
|
+
expect(data['aix-6.1-power']).to include(:artifact => './aix/6.1/PC1/ppc/puppet-agent-5.3.2-1.aix6.1.ppc.rpm')
|
301
|
+
end
|
302
|
+
|
303
|
+
it "should not record an aix repo config" do
|
304
|
+
allow(Pkg::Util::Net).to receive(:remote_ssh_cmd).and_return(aix_artifacts, nil)
|
305
|
+
data = Pkg::Config.platform_data
|
306
|
+
expect(data['aix-6.1-power'][:repo_config]).to be_nil
|
307
|
+
end
|
308
|
+
end
|
309
|
+
|
310
|
+
describe "#config_to_yaml" do
|
311
|
+
it "should write a valid yaml file" do
|
312
|
+
file = double('file')
|
313
|
+
File.should_receive(:open).with(anything(), 'w').and_yield(file)
|
314
|
+
file.should_receive(:puts).with(instance_of(String))
|
315
|
+
YAML.should_receive(:load_file).with(file)
|
316
|
+
expect { YAML.load_file(file) }.to_not raise_error
|
317
|
+
Pkg::Config.config_to_yaml
|
318
|
+
end
|
319
|
+
end
|
320
|
+
|
321
|
+
describe "#get_binding" do
|
322
|
+
it "should return the binding of the Pkg::Config object" do
|
323
|
+
# test by eval'ing using the binding before and after setting a param
|
324
|
+
orig = Pkg::Config.apt_host
|
325
|
+
Pkg::Config.apt_host = "foo"
|
326
|
+
expect(eval("@apt_host", Pkg::Config.get_binding)).to eq("foo")
|
327
|
+
Pkg::Config.apt_host = "bar"
|
328
|
+
expect(eval("@apt_host", Pkg::Config.get_binding)).to eq("bar")
|
329
|
+
Pkg::Config.apt_host = orig
|
330
|
+
end
|
331
|
+
end
|
332
|
+
|
333
|
+
describe "#config_from_yaml" do
|
334
|
+
context "given a yaml file" do
|
335
|
+
it "should, use it to set params" do
|
336
|
+
# apt_host: is set to "foo" in the fixture
|
337
|
+
orig = Pkg::Config.apt_host
|
338
|
+
Pkg::Config.apt_host = "bar"
|
339
|
+
Pkg::Config.config_from_yaml(File.join(FIXTURES, 'config', 'params.yaml'))
|
340
|
+
expect(Pkg::Config.apt_host).to eq("foo")
|
341
|
+
Pkg::Config.apt_host = orig
|
342
|
+
end
|
343
|
+
end
|
344
|
+
end
|
345
|
+
|
346
|
+
describe "#string_to_array" do
|
347
|
+
ary = %W(FOO BAR ARR RAY)
|
348
|
+
context "given a string with spaces in it" do
|
349
|
+
it "should return an array containing the contents of that string" do
|
350
|
+
space_str = "FOO BAR ARR RAY"
|
351
|
+
expect(Pkg::Config.string_to_array(space_str)).to eq(ary)
|
352
|
+
end
|
353
|
+
end
|
354
|
+
|
355
|
+
context "given a string with commas in it" do
|
356
|
+
it "should return an array containing the contents of that string" do
|
357
|
+
comma_str = "FOO,BAR,ARR,RAY"
|
358
|
+
expect(Pkg::Config.string_to_array(comma_str)).to eq(ary)
|
359
|
+
end
|
360
|
+
end
|
361
|
+
|
362
|
+
context "given a string with semicolons in it" do
|
363
|
+
it "should return an array containing the contents of that string" do
|
364
|
+
semi_str = "FOO;BAR;ARR;RAY"
|
365
|
+
expect(Pkg::Config.string_to_array(semi_str)).to eq(ary)
|
366
|
+
end
|
367
|
+
end
|
368
|
+
|
369
|
+
context "given a string with multiple delimiters in it" do
|
370
|
+
delimiters = [',', ' ', ';']
|
371
|
+
mixed_str = "FOO, BAR, ARR, ; RAY"
|
372
|
+
mixed_arr = Pkg::Config.string_to_array(mixed_str)
|
373
|
+
|
374
|
+
it "should not return the delimiters as array items" do
|
375
|
+
expect(mixed_arr).to_not include(*delimiters)
|
376
|
+
end
|
377
|
+
|
378
|
+
it "should not contain empty strings" do
|
379
|
+
expect(mixed_arr).to_not include("\s")
|
380
|
+
end
|
381
|
+
|
382
|
+
it "should still return the expected array" do
|
383
|
+
expect(mixed_arr).to eq(ary)
|
384
|
+
end
|
385
|
+
end
|
386
|
+
end
|
387
|
+
|
388
|
+
describe "#cow_list" do
|
389
|
+
it "should return a list of the cows for a project" do
|
390
|
+
Pkg::Config.cows = "base-lucid-i386.cow base-lucid-amd64.cow base-precise-i386.cow base-precise-amd64.cow base-quantal-i386.cow base-quantal-amd64.cow base-saucy-i386.cow base-saucy-amd64.cow base-sid-i386.cow base-sid-amd64.cow base-squeeze-i386.cow base-squeeze-amd64.cow base-stable-i386.cow base-stable-amd64.cow base-testing-i386.cow base-testing-amd64.cow base-trusty-i386.cow base-trusty-amd64.cow base-unstable-i386.cow base-unstable-amd64.cow base-wheezy-i386.cow base-wheezy-amd64.cow"
|
391
|
+
Pkg::Config.cow_list.should eq "lucid precise quantal saucy sid squeeze stable testing trusty unstable wheezy"
|
392
|
+
end
|
393
|
+
end
|
394
|
+
|
395
|
+
describe "#config" do
|
396
|
+
context "given :format => :hash" do
|
397
|
+
it "should call Pkg::Config.config_to_hash" do
|
398
|
+
expect(Pkg::Config).to receive(:config_to_hash)
|
399
|
+
Pkg::Config.config(:target => nil, :format => :hash)
|
400
|
+
end
|
401
|
+
end
|
402
|
+
|
403
|
+
context "given :format => :yaml" do
|
404
|
+
it "should call Pkg::Config.config_to_yaml if given :format => :yaml" do
|
405
|
+
expect(Pkg::Config).to receive(:config_to_yaml)
|
406
|
+
Pkg::Config.config(:target => nil, :format => :yaml)
|
407
|
+
end
|
408
|
+
end
|
409
|
+
end
|
410
|
+
|
411
|
+
describe "#issue_reassignments" do
|
412
|
+
around do |example|
|
413
|
+
prev_tar_host = Pkg::Config.tar_host
|
414
|
+
Pkg::Config.tar_host = nil
|
415
|
+
example.run
|
416
|
+
Pkg::Config.tar_host = prev_tar_host
|
417
|
+
end
|
418
|
+
|
419
|
+
it "should set tar_host to staging_server" do
|
420
|
+
Pkg::Config.config_from_hash({ :staging_server => 'foo' })
|
421
|
+
Pkg::Config.issue_reassignments
|
422
|
+
Pkg::Config.tar_host.should eq("foo")
|
423
|
+
end
|
424
|
+
end
|
425
|
+
|
426
|
+
describe "#config_to_hash" do
|
427
|
+
it "should return a hash object" do
|
428
|
+
hash = Pkg::Config.config_to_hash
|
429
|
+
hash.should be_a(Hash)
|
430
|
+
end
|
431
|
+
|
432
|
+
it "should return a hash with the current parameters" do
|
433
|
+
Pkg::Config.apt_host = "foo"
|
434
|
+
Pkg::Config.config_to_hash[:apt_host].should eq("foo")
|
435
|
+
Pkg::Config.apt_host = "bar"
|
436
|
+
Pkg::Config.config_to_hash[:apt_host].should eq("bar")
|
437
|
+
end
|
438
|
+
end
|
439
|
+
|
440
|
+
describe "#load_default_configs" do
|
441
|
+
before(:each) do
|
442
|
+
@project_root = double('project_root')
|
443
|
+
Pkg::Config.project_root = @project_root
|
444
|
+
@test_project_data = File.join(Pkg::Config.project_root, 'ext', 'project_data.yaml')
|
445
|
+
@test_build_defaults = File.join(Pkg::Config.project_root, 'ext', 'build_defaults.yaml')
|
446
|
+
end
|
447
|
+
|
448
|
+
around do |example|
|
449
|
+
orig = Pkg::Config.project_root
|
450
|
+
example.run
|
451
|
+
Pkg::Config.project_root = orig
|
452
|
+
end
|
453
|
+
|
454
|
+
context "given ext/build_defaults.yaml and ext/project_data.yaml are readable" do
|
455
|
+
it "should try to load build_defaults.yaml and project_data.yaml" do
|
456
|
+
allow(File).to receive(:readable?).with(@test_project_data).and_return(true)
|
457
|
+
allow(File).to receive(:readable?).with(@test_build_defaults).and_return(true)
|
458
|
+
expect(Pkg::Config).to receive(:config_from_yaml).with(@test_project_data)
|
459
|
+
expect(Pkg::Config).to receive(:config_from_yaml).with(@test_build_defaults)
|
460
|
+
Pkg::Config.load_default_configs
|
461
|
+
end
|
462
|
+
end
|
463
|
+
|
464
|
+
context "given ext/build_defaults.yaml is readable but ext/project_data.yaml is not" do
|
465
|
+
it "should try to load build_defaults.yaml but not project_data.yaml" do
|
466
|
+
allow(File).to receive(:readable?).with(@test_project_data).and_return(false)
|
467
|
+
allow(File).to receive(:readable?).with(@test_build_defaults).and_return(true)
|
468
|
+
expect(Pkg::Config).to_not receive(:config_from_yaml).with(@test_project_data)
|
469
|
+
expect(Pkg::Config).to receive(:config_from_yaml).with(@test_build_defaults)
|
470
|
+
Pkg::Config.load_default_configs
|
471
|
+
end
|
472
|
+
end
|
473
|
+
|
474
|
+
context "given ext/build_defaults.yaml is not readable but ext/project_data.yaml is" do
|
475
|
+
it "should try to load build_defaults.yaml then unset project_root" do
|
476
|
+
allow(File).to receive(:readable?).with(@test_project_data).and_return(true)
|
477
|
+
allow(File).to receive(:readable?).with(@test_build_defaults).and_return(false)
|
478
|
+
expect(Pkg::Config).to_not receive(:config_from_yaml).with(@test_build_defaults)
|
479
|
+
Pkg::Config.load_default_configs
|
480
|
+
expect(Pkg::Config.project_root).to be_nil
|
481
|
+
end
|
482
|
+
end
|
483
|
+
|
484
|
+
context "given ext/build_defaults.yaml and ext/project_data.yaml are not readable" do
|
485
|
+
it "should not try to load build_defaults.yaml and project_data.yaml" do
|
486
|
+
Pkg::Config.project_root = 'foo'
|
487
|
+
expect(Pkg::Config).to_not receive(:config_from_yaml)
|
488
|
+
Pkg::Config.load_default_configs
|
489
|
+
end
|
490
|
+
|
491
|
+
it "should set the project root to nil" do
|
492
|
+
Pkg::Config.project_root = 'foo'
|
493
|
+
Pkg::Config.load_default_configs
|
494
|
+
expect(Pkg::Config.project_root).to be_nil
|
495
|
+
end
|
496
|
+
end
|
497
|
+
end
|
498
|
+
|
499
|
+
describe "#load_versioning" do
|
500
|
+
around do |example|
|
501
|
+
orig = Pkg::Config.project_root
|
502
|
+
example.run
|
503
|
+
Pkg::Config.project_root = orig
|
504
|
+
end
|
505
|
+
|
506
|
+
# We let the actual version determination testing happen in the version
|
507
|
+
# tests. Here we just test that we try when we should.
|
508
|
+
context "When project root is nil" do
|
509
|
+
it "should not try to load versioning" do
|
510
|
+
Pkg::Config.project_root = nil
|
511
|
+
expect(Pkg::Util::Version).to_not receive(:git_sha_or_tag)
|
512
|
+
Pkg::Config.load_versioning
|
513
|
+
end
|
514
|
+
end
|
515
|
+
end
|
516
|
+
|
517
|
+
describe "#load_envvars" do
|
518
|
+
# We're going to pollute the environment with this test, so afterwards we
|
519
|
+
# explicitly set everything to nil to prevent any hazardous effects on
|
520
|
+
# the rest of the tests.
|
521
|
+
after(:all) do
|
522
|
+
reset_env(Pkg::Params::ENV_VARS.map {|hash| hash[:envvar].to_s})
|
523
|
+
end
|
524
|
+
|
525
|
+
Pkg::Params::ENV_VARS.each do |v|
|
526
|
+
case v[:type]
|
527
|
+
when :bool
|
528
|
+
it "should set boolean value on #{v[:var]} for :type == :bool" do
|
529
|
+
ENV[v[:envvar].to_s] = "FOO"
|
530
|
+
Pkg::Util.stub(:boolean_value) {"FOO"}
|
531
|
+
allow(Pkg::Config).to receive(:instance_variable_set)
|
532
|
+
expect(Pkg::Util).to receive(:boolean_value).with("FOO")
|
533
|
+
expect(Pkg::Config).to receive(:instance_variable_set).with("@#{v[:var]}", "FOO")
|
534
|
+
Pkg::Config.load_envvars
|
535
|
+
end
|
536
|
+
when :array
|
537
|
+
it "should set Pkg::Config##{v[:var]} to an Array for :type == :array" do
|
538
|
+
ENV[v[:envvar].to_s] = "FOO BAR ARR RAY"
|
539
|
+
Pkg::Config.stub(:string_to_array) {%w(FOO BAR ARR RAY)}
|
540
|
+
allow(Pkg::Config).to receive(:instance_variable_set)
|
541
|
+
expect(Pkg::Config).to receive(:string_to_array).with("FOO BAR ARR RAY")
|
542
|
+
expect(Pkg::Config).to receive(:instance_variable_set).with("@#{v[:var]}", %w(FOO BAR ARR RAY))
|
543
|
+
Pkg::Config.load_envvars
|
544
|
+
end
|
545
|
+
else
|
546
|
+
it "should set Pkg::Config##{v[:var]} to ENV[#{v[:envvar].to_s}]" do
|
547
|
+
ENV[v[:envvar].to_s] = "FOO"
|
548
|
+
Pkg::Util.stub(:boolean_value) {"FOO"}
|
549
|
+
allow(Pkg::Config).to receive(:instance_variable_set)
|
550
|
+
expect(Pkg::Config).to receive(:instance_variable_set).with("@#{v[:var]}", "FOO")
|
551
|
+
Pkg::Config.load_envvars
|
552
|
+
end
|
553
|
+
end
|
554
|
+
end
|
555
|
+
end
|
556
|
+
end
|