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,97 @@
|
|
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").and_yield
|
20
|
+
expect(Dir).to receive(:chdir).with("project/1.1.1").and_yield
|
21
|
+
Pkg::Repo.create_signed_repo_archive("/path", "project-debian-6-i386", "version")
|
22
|
+
end
|
23
|
+
|
24
|
+
it "should use a ref if ref is specified as versioning" do
|
25
|
+
allow(Pkg::Util::Tool).to receive(:check_tool).and_return("tarcommand")
|
26
|
+
allow(Dir).to receive(:chdir).with("pkg").and_yield
|
27
|
+
allow(Pkg::Util::File).to receive(:empty_dir?).and_return(false)
|
28
|
+
allow(Pkg::Util::Execution).to receive(:capture3)
|
29
|
+
|
30
|
+
expect(Pkg::Config).to receive(:project).and_return("project")
|
31
|
+
expect(Pkg::Config).to receive(:ref).and_return("AAAAAAAAAAAAAAA")
|
32
|
+
expect(Dir).to receive(:chdir).with("project/AAAAAAAAAAAAAAA").and_yield
|
33
|
+
Pkg::Repo.create_signed_repo_archive("/path", "project-debian-6-i386", "ref")
|
34
|
+
end
|
35
|
+
|
36
|
+
it "should use dot versions if version is specified as versioning" do
|
37
|
+
allow(Pkg::Util::Tool).to receive(:check_tool).and_return("tarcommand")
|
38
|
+
allow(Dir).to receive(:chdir).with("pkg").and_yield
|
39
|
+
allow(Pkg::Util::File).to receive(:empty_dir?).and_return(false)
|
40
|
+
allow(Pkg::Util::Execution).to receive(:capture3)
|
41
|
+
|
42
|
+
expect(Pkg::Config).to receive(:project).and_return("project")
|
43
|
+
expect(Pkg::Util::Version).to receive(:dot_version).and_return("1.1.1")
|
44
|
+
expect(Dir).to receive(:chdir).with("project/1.1.1").and_yield
|
45
|
+
Pkg::Repo.create_signed_repo_archive("/path", "project-debian-6-i386", "version")
|
46
|
+
end
|
47
|
+
|
48
|
+
it "should fail if ENV['FAIL_ON_MISSING_TARGET'] is true and empty_dir? is also true" do
|
49
|
+
allow(Pkg::Util::Tool).to receive(:check_tool).and_return("tarcommand")
|
50
|
+
allow(Pkg::Config).to receive(:project).and_return("project")
|
51
|
+
allow(Pkg::Util::Version).to receive(:dot_version).and_return("1.1.1")
|
52
|
+
allow(Pkg::Util::Execution).to receive(:capture3)
|
53
|
+
allow(Dir).to receive(:chdir).with("pkg").and_yield
|
54
|
+
allow(Dir).to receive(:chdir).with("project/1.1.1").and_yield
|
55
|
+
allow(Pkg::Util::File).to receive(:empty_dir?).and_return(true)
|
56
|
+
ENV['FAIL_ON_MISSING_TARGET'] = "true"
|
57
|
+
|
58
|
+
expect{Pkg::Repo.create_signed_repo_archive("/path", "project-debian-6-i386", "version")}.to raise_error(RuntimeError, "ERROR: missing packages under /path")
|
59
|
+
end
|
60
|
+
|
61
|
+
it "should only warn if ENV['FAIL_ON_MISSING_TARGET'] is false and empty_dir? is true" do
|
62
|
+
allow(Pkg::Util::Tool).to receive(:check_tool).and_return("tarcommand")
|
63
|
+
allow(Pkg::Config).to receive(:project).and_return("project")
|
64
|
+
allow(Pkg::Util::Version).to receive(:dot_version).and_return("1.1.1")
|
65
|
+
allow(Pkg::Util::Execution).to receive(:capture3)
|
66
|
+
allow(Dir).to receive(:chdir).with("pkg").and_yield
|
67
|
+
allow(Dir).to receive(:chdir).with("project/1.1.1").and_yield
|
68
|
+
allow(Pkg::Util::File).to receive(:empty_dir?).and_return(true)
|
69
|
+
ENV['FAIL_ON_MISSING_TARGET'] = "false"
|
70
|
+
|
71
|
+
expect{Pkg::Repo.create_signed_repo_archive("/path", "project-debian-6-i386", "version")}.not_to raise_error
|
72
|
+
end
|
73
|
+
|
74
|
+
it "should invoke tar correctly" do
|
75
|
+
allow(Pkg::Util::Tool).to receive(:check_tool).and_return("tarcommand")
|
76
|
+
allow(Pkg::Config).to receive(:project).and_return("project")
|
77
|
+
allow(Pkg::Util::Version).to receive(:dot_version).and_return("1.1.1")
|
78
|
+
allow(Dir).to receive(:chdir).with("pkg").and_yield
|
79
|
+
allow(Dir).to receive(:chdir).with("project/1.1.1").and_yield
|
80
|
+
allow(Pkg::Util::File).to receive(:empty_dir?).and_return(false)
|
81
|
+
|
82
|
+
expect(Pkg::Util::Execution).to receive(:capture3).with("tarcommand --owner=0 --group=0 --create --gzip --file repos/project-debian-6-i386.tar.gz /path")
|
83
|
+
Pkg::Repo.create_signed_repo_archive("/path", "project-debian-6-i386", "version")
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
describe "#create_signed_repo_archive" do
|
88
|
+
it "should invoke create_signed_repo_archive correctly for multiple entries in platform_repos" do
|
89
|
+
allow(Pkg::Config).to receive(:platform_repos).and_return(platform_repo_stub)
|
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
|
+
Pkg::Repo.create_all_repo_archives("project", "version")
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
@@ -0,0 +1,61 @@
|
|
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.11-x86_64', 'windows-2012-x64']
|
11
|
+
platform_data = {:platform_data => {
|
12
|
+
'aix-6.1-power' => {:artifact => './aix/6.1/PC1/ppc/puppet-agent-5.3.2.155.gb25e649-1.aix6.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.11-x86_64' => {:artifact => './apple/10.11/PC1/x86_64/puppet-agent-5.3.2.155.gb25e649-1.osx10.11.dmg'},
|
15
|
+
'sles-11-s390x' => {:artifact => './sles/11/PC1/s390x/puppet-agent-5.3.2.155.gb25e649-1.sles11.s390x.rpm'},
|
16
|
+
'solaris-10-sparc' => {:artifact => './solaris/10/PC1/puppet-agent-5.3.2.155.gb25e649-1.sparc.pkg.gz'},
|
17
|
+
'ubuntu-16.04-amd64' => {:artifact => './deb/xenial/PC1/puppet-agent_5.3.2.155.gb25e649-1xenial_amd64.deb'},
|
18
|
+
'windows-2012-x64' => {:artifact => './windows/puppet-agent-x64.msi'},
|
19
|
+
}}
|
20
|
+
build_url = "builds.delivery.puppetlabs.net/#{project}/#{ref}"
|
21
|
+
build_path = "/opt/jenkins-builds/#{project}/#{ref}"
|
22
|
+
|
23
|
+
before :each do
|
24
|
+
allow(Pkg::Config).to receive(:project).and_return(project)
|
25
|
+
allow(Pkg::Config).to receive(:ref).and_return(ref)
|
26
|
+
allow(Pkg::Config).to receive(:foss_platforms).and_return(foss_platforms)
|
27
|
+
allow(File).to receive(:readable?).with("#{local_target}/#{ref}.yaml").and_return(true)
|
28
|
+
allow(Pkg::Util::Serialization).to receive(:load_yaml).and_return(platform_data)
|
29
|
+
end
|
30
|
+
|
31
|
+
describe '#foss_only_retrieve' do
|
32
|
+
it 'should fail without foss_platforms' do
|
33
|
+
allow(Pkg::Config).to receive(:foss_platforms).and_return(nil)
|
34
|
+
expect { Pkg::Retrieve.foss_only_retrieve(build_url, local_target) }.to raise_error(/I don't know anything about FOSS_PLATFORMS/)
|
35
|
+
end
|
36
|
+
|
37
|
+
it 'should fail if cannot read <ref>.yaml' do
|
38
|
+
allow(File).to receive(:readable?).with("#{local_target}/#{ref}.yaml").and_return(false)
|
39
|
+
expect { Pkg::Retrieve.foss_only_retrieve(build_url, local_target) }.to raise_error(/Couldn't read #{ref}.yaml/)
|
40
|
+
end
|
41
|
+
|
42
|
+
it 'should retrieve foss_only packages' do
|
43
|
+
expect(Pkg::Retrieve).to receive(:default_wget).exactly(1 + foss_platforms.count).times
|
44
|
+
Pkg::Retrieve.foss_only_retrieve(build_url, local_target)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
describe '#retrieve_all' do
|
49
|
+
it 'should try to use wget first' do
|
50
|
+
expect(Pkg::Retrieve).to receive(:default_wget)
|
51
|
+
Pkg::Retrieve.retrieve_all(build_url, build_path, remote_target, local_target)
|
52
|
+
end
|
53
|
+
|
54
|
+
it 'should use rsync if wget is not found' do
|
55
|
+
allow(Pkg::Util::Tool).to receive(:find_tool).with('wget').and_return(nil)
|
56
|
+
expect(Pkg::Util::Net).to receive(:rsync_from)
|
57
|
+
Pkg::Retrieve.retrieve_all(build_url, build_path, remote_target, local_target)
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
@@ -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_ssh_cmd).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_ssh_cmd).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::Rpm::Repo.should_receive(:invoke_task).with("pl:fetch")
|
128
|
+
Pkg::Util::Net.should_receive(:remote_ssh_cmd).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
|
@@ -0,0 +1,122 @@
|
|
1
|
+
# -*- ruby -*-
|
2
|
+
require 'spec_helper'
|
3
|
+
|
4
|
+
describe "tar.rb" do
|
5
|
+
let(:project) { "packaging" }
|
6
|
+
let(:version) { "1.2.3" }
|
7
|
+
let(:files) { [ "a", "b", "c" ] }
|
8
|
+
let(:templates) do
|
9
|
+
[
|
10
|
+
"ext/redhat/spec.erb",
|
11
|
+
{ "source" => "ext/debian/control.erb", "target" => "ext/debian/not-a-control-file" },
|
12
|
+
"ext/debian/changelog.erb",
|
13
|
+
"ext/packaging/thing.erb"
|
14
|
+
]
|
15
|
+
end
|
16
|
+
let(:expanded_templates) do
|
17
|
+
[
|
18
|
+
"#{PROJECT_ROOT}/ext/redhat/spec.erb",
|
19
|
+
{ "source" => "ext/debian/control.erb", "target" => "ext/debian/not-a-control-file" },
|
20
|
+
"#{PROJECT_ROOT}/ext/debian/changelog.erb"
|
21
|
+
]
|
22
|
+
end
|
23
|
+
|
24
|
+
describe "#expand_templates" do
|
25
|
+
it "should be invoked when Pkg::Config.templates is set" do
|
26
|
+
Pkg::Config.config_from_hash(
|
27
|
+
{
|
28
|
+
:templates => templates,
|
29
|
+
:project => project,
|
30
|
+
:version => version,
|
31
|
+
:files => files,
|
32
|
+
:project_root => PROJECT_ROOT,
|
33
|
+
:packaging_root => "ext/packaging"
|
34
|
+
})
|
35
|
+
|
36
|
+
Pkg::Tar.any_instance.should_receive(:expand_templates)
|
37
|
+
Pkg::Tar.new
|
38
|
+
end
|
39
|
+
|
40
|
+
it "packaging templates should be filtered and paths should be expanded" do
|
41
|
+
Pkg::Config.config_from_hash(
|
42
|
+
{
|
43
|
+
:templates => templates,
|
44
|
+
:project => project,
|
45
|
+
:version => version,
|
46
|
+
:files => files,
|
47
|
+
:project_root => PROJECT_ROOT,
|
48
|
+
:packaging_root => "ext/packaging"
|
49
|
+
})
|
50
|
+
|
51
|
+
templates.each do |temp|
|
52
|
+
if temp.is_a?(String)
|
53
|
+
Dir.stub(:glob).with(File.join(PROJECT_ROOT, temp)).and_return(File.join(PROJECT_ROOT, temp))
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
tar = Pkg::Tar.new
|
58
|
+
tar.templates = templates
|
59
|
+
tar.expand_templates
|
60
|
+
tar.templates.should eq expanded_templates
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
describe "#template" do
|
65
|
+
it "should handle hashes and strings correctly" do
|
66
|
+
Pkg::Config.config_from_hash(
|
67
|
+
{
|
68
|
+
:templates => expanded_templates,
|
69
|
+
:project => project,
|
70
|
+
:version => version,
|
71
|
+
:files => files,
|
72
|
+
:project_root => PROJECT_ROOT,
|
73
|
+
:packaging_root => "ext/packaging"
|
74
|
+
})
|
75
|
+
|
76
|
+
# Set up correct stubs and expectations
|
77
|
+
expanded_templates.each do |temp|
|
78
|
+
if temp.is_a?(String)
|
79
|
+
full_path_temp = File.join(PROJECT_ROOT, temp)
|
80
|
+
target = full_path_temp.sub(File.extname(full_path_temp), "")
|
81
|
+
elsif temp.is_a?(Hash)
|
82
|
+
full_path_temp = File.join(PROJECT_ROOT, temp["source"])
|
83
|
+
target = File.join(PROJECT_ROOT, temp["target"])
|
84
|
+
end
|
85
|
+
|
86
|
+
Dir.stub(:glob).with(full_path_temp).and_return(full_path_temp)
|
87
|
+
File.stub(:exist?).with(full_path_temp).and_return(true)
|
88
|
+
Pkg::Util::File.should_receive(:erb_file).with(full_path_temp, target, true, :binding => an_instance_of(Binding))
|
89
|
+
end
|
90
|
+
|
91
|
+
Pkg::Tar.new.template
|
92
|
+
end
|
93
|
+
|
94
|
+
it "should raise an error if the template source can't be found" do
|
95
|
+
Pkg::Config.config_from_hash(
|
96
|
+
{
|
97
|
+
:templates => expanded_templates,
|
98
|
+
:project => project,
|
99
|
+
:version => version,
|
100
|
+
:files => files,
|
101
|
+
:project_root => PROJECT_ROOT,
|
102
|
+
:packaging_root => "ext/packaging"
|
103
|
+
})
|
104
|
+
|
105
|
+
# Set up correct stubs and expectations
|
106
|
+
expanded_templates.each do |temp|
|
107
|
+
if temp.is_a?(String)
|
108
|
+
full_path_temp = File.join(PROJECT_ROOT, temp)
|
109
|
+
target = full_path_temp.sub(File.extname(full_path_temp), "")
|
110
|
+
elsif temp.is_a?(Hash)
|
111
|
+
full_path_temp = File.join(PROJECT_ROOT, temp["source"])
|
112
|
+
target = File.join(PROJECT_ROOT, temp["target"])
|
113
|
+
end
|
114
|
+
|
115
|
+
Dir.stub(:glob).with(full_path_temp).and_return(full_path_temp)
|
116
|
+
File.stub(:exist?).with(full_path_temp).and_return(false)
|
117
|
+
end
|
118
|
+
|
119
|
+
expect { Pkg::Tar.new.template }.to raise_error RuntimeError
|
120
|
+
end
|
121
|
+
end
|
122
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe "Pkg::Util::Execution" do
|
4
|
+
let(:command) { "/usr/bin/do-something-important --arg1=thing2" }
|
5
|
+
let(:output) { "the command returns some really cool stuff that may be useful later" }
|
6
|
+
|
7
|
+
describe "#success?" do
|
8
|
+
it "should return false on failure" do
|
9
|
+
%x{false}
|
10
|
+
Pkg::Util::Execution.success?.should be_false
|
11
|
+
end
|
12
|
+
|
13
|
+
it "should return true on success" do
|
14
|
+
%x{true}
|
15
|
+
Pkg::Util::Execution.success?.should be_true
|
16
|
+
end
|
17
|
+
|
18
|
+
it "should return false when passed an exitstatus object from a failure" do
|
19
|
+
%x{false}
|
20
|
+
Pkg::Util::Execution.success?($?).should be_false
|
21
|
+
end
|
22
|
+
|
23
|
+
it "should return true when passed and exitstatus object from a success" do
|
24
|
+
%x{true}
|
25
|
+
Pkg::Util::Execution.success?($?).should be_true
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
describe "#ex" do
|
30
|
+
it "should raise an error if the command fails" do
|
31
|
+
Pkg::Util::Execution.should_receive(:`).with(command).and_return(true)
|
32
|
+
Pkg::Util::Execution.should_receive(:success?).and_return(false)
|
33
|
+
expect{ Pkg::Util::Execution.ex(command) }.to raise_error(RuntimeError)
|
34
|
+
end
|
35
|
+
|
36
|
+
it "should return the output of the command for success" do
|
37
|
+
Pkg::Util::Execution.should_receive(:`).with(command).and_return(output)
|
38
|
+
Pkg::Util::Execution.should_receive(:success?).and_return(true)
|
39
|
+
Pkg::Util::Execution.ex(command).should == output
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
describe "#capture3" do
|
44
|
+
it "should raise an error if the command fails" do
|
45
|
+
Open3.should_receive(:capture3).with(command).and_return([output, '', 1])
|
46
|
+
Pkg::Util::Execution.should_receive(:success?).with(1).and_return(false)
|
47
|
+
expect{ Pkg::Util::Execution.capture3(command) }.to raise_error(RuntimeError, /#{output}/)
|
48
|
+
end
|
49
|
+
|
50
|
+
it "should return the output of the command for success" do
|
51
|
+
Open3.should_receive(:capture3).with(command).and_return([output, '', 0])
|
52
|
+
Pkg::Util::Execution.should_receive(:success?).with(0).and_return(true)
|
53
|
+
Pkg::Util::Execution.capture3(command).should == [output, '', 0]
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|