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,31 @@
|
|
1
|
+
# -*- ruby -*-
|
2
|
+
require 'spec_helper'
|
3
|
+
|
4
|
+
describe 'Pkg::Util::Misc' do
|
5
|
+
context "#search_and_replace" do
|
6
|
+
let(:orig_string) { "#!/bin/bash\necho '__REPO_NAME__'" }
|
7
|
+
let(:updated_string) { "#!/bin/bash\necho 'abcdefg'" }
|
8
|
+
let(:good_replacements) do
|
9
|
+
{ __REPO_NAME__: Pkg::Paths.repo_name }
|
10
|
+
end
|
11
|
+
let(:warn_replacements) do
|
12
|
+
{ __REPO_NAME__: nil }
|
13
|
+
end
|
14
|
+
|
15
|
+
it 'replaces the token with the Pkg::Config variable' do
|
16
|
+
Pkg::Config.config_from_hash({:project => "foo", :repo_name => 'abcdefg'})
|
17
|
+
Pkg::Util::Misc.search_and_replace(orig_string, good_replacements).should eq(updated_string)
|
18
|
+
end
|
19
|
+
|
20
|
+
it 'does no replacement if the Pkg::Config variable is not set' do
|
21
|
+
Pkg::Config.config_from_hash({:project => 'foo',})
|
22
|
+
Pkg::Util::Misc.search_and_replace(orig_string, good_replacements).should eq(orig_string)
|
23
|
+
end
|
24
|
+
|
25
|
+
it 'warns and continues if the Pkg::Config variable is unknown to packaging' do
|
26
|
+
Pkg::Config.config_from_hash({:project => 'foo',})
|
27
|
+
Pkg::Util::Misc.should_receive(:warn).with("replacement value for '#{warn_replacements.keys.first}' probably shouldn't be nil")
|
28
|
+
Pkg::Util::Misc.search_and_replace(orig_string, warn_replacements).should eq(orig_string)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,239 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'socket'
|
3
|
+
require 'open3'
|
4
|
+
|
5
|
+
describe "Pkg::Util::Net" do
|
6
|
+
let(:target) { "/tmp/placething" }
|
7
|
+
let(:target_uri) { "http://google.com" }
|
8
|
+
let(:content) { "stuff" }
|
9
|
+
let(:rsync) { "/bin/rsync" }
|
10
|
+
let(:ssh) { "/usr/local/bin/ssh" }
|
11
|
+
let(:s3cmd) { "/usr/local/bin/s3cmd" }
|
12
|
+
|
13
|
+
describe "#fetch_uri" do
|
14
|
+
context "given a target directory" do
|
15
|
+
it "does nothing if the directory isn't writable" do
|
16
|
+
File.stub(:writable?).with(File.dirname(target)) { false }
|
17
|
+
File.should_receive(:open).never
|
18
|
+
Pkg::Util::Net.fetch_uri(target_uri, target)
|
19
|
+
end
|
20
|
+
|
21
|
+
it "writes the content of the uri to a file if directory is writable" do
|
22
|
+
File.should_receive(:writable?).once.with(File.dirname(target)) { true }
|
23
|
+
File.should_receive(:open).once.with(target, 'w')
|
24
|
+
Pkg::Util::Net.fetch_uri(target_uri, target)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
describe "hostname utils" do
|
30
|
+
|
31
|
+
describe "hostname" do
|
32
|
+
it "should return the hostname of the current host" do
|
33
|
+
Socket.stub(:gethostname) { "foo" }
|
34
|
+
Pkg::Util::Net.hostname.should eq("foo")
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
describe "check_host" do
|
39
|
+
context "with required :true" do
|
40
|
+
it "should raise an exception if the passed host does not match the current host" do
|
41
|
+
Socket.stub(:gethostname) { "foo" }
|
42
|
+
Pkg::Util::Net.should_receive(:check_host).and_raise(RuntimeError)
|
43
|
+
expect{ Pkg::Util::Net.check_host("bar", :required => true) }.to raise_error(RuntimeError)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
context "with required :false" do
|
48
|
+
it "should return nil if the passed host does not match the current host" do
|
49
|
+
Socket.stub(:gethostname) { "foo" }
|
50
|
+
Pkg::Util::Net.check_host("bar", :required => false).should be_nil
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
describe "remote_ssh_cmd" do
|
57
|
+
it "should fail if ssh is not present" do
|
58
|
+
Pkg::Util::Tool.stub(:find_tool).with("ssh") { fail }
|
59
|
+
Pkg::Util::Tool.should_receive(:check_tool).with("ssh").and_raise(RuntimeError)
|
60
|
+
expect{ Pkg::Util::Net.remote_ssh_cmd("foo", "bar") }.to raise_error(RuntimeError)
|
61
|
+
end
|
62
|
+
|
63
|
+
it "should be able to not fail fast" do
|
64
|
+
Pkg::Util::Tool.should_receive(:check_tool).with("ssh").and_return(ssh)
|
65
|
+
Kernel.should_receive(:system).with("#{ssh} -t foo 'bar'")
|
66
|
+
Pkg::Util::Execution.should_receive(:success?).and_return(true)
|
67
|
+
Pkg::Util::Net.remote_ssh_cmd("foo", "bar", false, '', false)
|
68
|
+
end
|
69
|
+
|
70
|
+
context "without output captured" do
|
71
|
+
it "should execute a command :foo on a host :bar using Kernel" do
|
72
|
+
Pkg::Util::Tool.should_receive(:check_tool).with("ssh").and_return(ssh)
|
73
|
+
Kernel.should_receive(:system).with("#{ssh} -t foo 'set -e; bar'")
|
74
|
+
Pkg::Util::Execution.should_receive(:success?).and_return(true)
|
75
|
+
Pkg::Util::Net.remote_ssh_cmd("foo", "bar")
|
76
|
+
end
|
77
|
+
|
78
|
+
it "should escape single quotes in the command" do
|
79
|
+
Pkg::Util::Tool.should_receive(:check_tool).with("ssh").and_return(ssh)
|
80
|
+
Kernel.should_receive(:system).with("#{ssh} -t foo 'set -e; b'\\''ar'")
|
81
|
+
Pkg::Util::Execution.should_receive(:success?).and_return(true)
|
82
|
+
Pkg::Util::Net.remote_ssh_cmd("foo", "b'ar")
|
83
|
+
end
|
84
|
+
|
85
|
+
it "should raise an error if ssh fails" do
|
86
|
+
Pkg::Util::Tool.should_receive(:check_tool).with("ssh").and_return(ssh)
|
87
|
+
Kernel.should_receive(:system).with("#{ssh} -t foo 'set -e; bar'")
|
88
|
+
Pkg::Util::Execution.should_receive(:success?).and_return(false)
|
89
|
+
expect{ Pkg::Util::Net.remote_ssh_cmd("foo", "bar") }.to raise_error(RuntimeError, /Remote ssh command failed./)
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
context "with output captured" do
|
94
|
+
it "should execute a command :foo on a host :bar using Pkg::Util::Execution.capture3" do
|
95
|
+
Pkg::Util::Tool.should_receive(:check_tool).with("ssh").and_return(ssh)
|
96
|
+
Pkg::Util::Execution.should_receive(:capture3).with("#{ssh} -t foo 'set -e; bar'")
|
97
|
+
Pkg::Util::Execution.should_receive(:success?).and_return(true)
|
98
|
+
Pkg::Util::Net.remote_ssh_cmd("foo", "bar", true)
|
99
|
+
end
|
100
|
+
|
101
|
+
it "should escape single quotes in the command" do
|
102
|
+
Pkg::Util::Tool.should_receive(:check_tool).with("ssh").and_return(ssh)
|
103
|
+
Pkg::Util::Execution.should_receive(:capture3).with("#{ssh} -t foo 'set -e; b'\\''ar'")
|
104
|
+
Pkg::Util::Execution.should_receive(:success?).and_return(true)
|
105
|
+
Pkg::Util::Net.remote_ssh_cmd("foo", "b'ar", true)
|
106
|
+
end
|
107
|
+
|
108
|
+
it "should raise an error if ssh fails" do
|
109
|
+
Pkg::Util::Tool.should_receive(:check_tool).with("ssh").and_return(ssh)
|
110
|
+
Pkg::Util::Execution.should_receive(:capture3).with("#{ssh} -t foo 'set -e; bar'")
|
111
|
+
Pkg::Util::Execution.should_receive(:success?).and_return(false)
|
112
|
+
expect{ Pkg::Util::Net.remote_ssh_cmd("foo", "bar", true) }.to raise_error(RuntimeError, /Remote ssh command failed./)
|
113
|
+
end
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
117
|
+
describe "#rsync_to" do
|
118
|
+
defaults = "--recursive --hard-links --links --verbose --omit-dir-times --no-perms --no-owner --no-group"
|
119
|
+
it "should fail if rsync is not present" do
|
120
|
+
Pkg::Util::Tool.stub(:find_tool).with("rsync") { fail }
|
121
|
+
Pkg::Util::Tool.should_receive(:check_tool).with("rsync").and_raise(RuntimeError)
|
122
|
+
expect{ Pkg::Util::Net.rsync_to("foo", "bar", "boo") }.to raise_error(RuntimeError)
|
123
|
+
end
|
124
|
+
|
125
|
+
it "should rsync 'thing' to 'foo@bar:/home/foo' with flags '#{defaults} --ignore-existing'" do
|
126
|
+
Pkg::Util::Tool.should_receive(:check_tool).with("rsync").and_return(rsync)
|
127
|
+
Pkg::Util::Execution.should_receive(:capture3).with("#{rsync} #{defaults} --ignore-existing thing foo@bar:/home/foo", true)
|
128
|
+
Pkg::Util::Net.rsync_to("thing", "foo@bar", "/home/foo")
|
129
|
+
end
|
130
|
+
|
131
|
+
it "rsyncs 'thing' to 'foo@bar:/home/foo' with flags that don't include --ignore-existing" do
|
132
|
+
Pkg::Util::Tool.should_receive(:check_tool).with("rsync").and_return(rsync)
|
133
|
+
Pkg::Util::Execution.should_receive(:capture3).with("#{rsync} #{defaults} thing foo@bar:/home/foo", true)
|
134
|
+
Pkg::Util::Net.rsync_to("thing", "foo@bar", "/home/foo", extra_flags: [])
|
135
|
+
end
|
136
|
+
|
137
|
+
it "rsyncs 'thing' to 'foo@bar:/home/foo' with flags that don't include arbitrary flags" do
|
138
|
+
Pkg::Util::Tool.should_receive(:check_tool).with("rsync").and_return(rsync)
|
139
|
+
Pkg::Util::Execution.should_receive(:capture3).with("#{rsync} #{defaults} --foo-bar --and-another-flag thing foo@bar:/home/foo", true)
|
140
|
+
Pkg::Util::Net.rsync_to("thing", "foo@bar", "/home/foo", extra_flags: ["--foo-bar", "--and-another-flag"])
|
141
|
+
end
|
142
|
+
end
|
143
|
+
|
144
|
+
describe "#s3sync_to" do
|
145
|
+
it "should fail if s3cmd is not present" do
|
146
|
+
Pkg::Util::Tool.should_receive(:find_tool).with('s3cmd', :required => true).and_raise(RuntimeError)
|
147
|
+
Pkg::Util::Execution.should_not_receive(:capture3).with("#{s3cmd} sync 'foo' s3://bar/boo/")
|
148
|
+
expect{ Pkg::Util::Net.s3sync_to("foo", "bar", "boo") }.to raise_error(RuntimeError)
|
149
|
+
end
|
150
|
+
|
151
|
+
it "should fail if ~/.s3cfg is not present" do
|
152
|
+
Pkg::Util::Tool.should_receive(:check_tool).with("s3cmd").and_return(s3cmd)
|
153
|
+
Pkg::Util::File.should_receive(:file_exists?).with(File.join(ENV['HOME'], '.s3cfg')).and_return(false)
|
154
|
+
expect{ Pkg::Util::Net.s3sync_to("foo", "bar", "boo") }.to raise_error(RuntimeError, /does not exist/)
|
155
|
+
end
|
156
|
+
|
157
|
+
it "should s3 sync 'thing' to 's3://foo@bar/home/foo/' with no flags" do
|
158
|
+
Pkg::Util::Tool.should_receive(:check_tool).with("s3cmd").and_return(s3cmd)
|
159
|
+
Pkg::Util::File.should_receive(:file_exists?).with(File.join(ENV['HOME'], '.s3cfg')).and_return(true)
|
160
|
+
Pkg::Util::Execution.should_receive(:capture3).with("#{s3cmd} sync 'thing' s3://foo@bar/home/foo/")
|
161
|
+
Pkg::Util::Net.s3sync_to("thing", "foo@bar", "home/foo")
|
162
|
+
end
|
163
|
+
|
164
|
+
it "should s3 sync 'thing' to 's3://foo@bar/home/foo/' with --delete-removed and --acl-public" do
|
165
|
+
Pkg::Util::Tool.should_receive(:check_tool).with("s3cmd").and_return(s3cmd)
|
166
|
+
Pkg::Util::File.should_receive(:file_exists?).with(File.join(ENV['HOME'], '.s3cfg')).and_return(true)
|
167
|
+
Pkg::Util::Execution.should_receive(:capture3).with("#{s3cmd} sync --delete-removed --acl-public 'thing' s3://foo@bar/home/foo/")
|
168
|
+
Pkg::Util::Net.s3sync_to("thing", "foo@bar", "home/foo", ["--delete-removed", "--acl-public"])
|
169
|
+
end
|
170
|
+
end
|
171
|
+
|
172
|
+
describe "#rsync_from" do
|
173
|
+
defaults = "--recursive --hard-links --links --verbose --omit-dir-times --no-perms --no-owner --no-group"
|
174
|
+
it "should fail if rsync is not present" do
|
175
|
+
Pkg::Util::Tool.stub(:find_tool).with("rsync") { fail }
|
176
|
+
Pkg::Util::Tool.should_receive(:check_tool).with("rsync").and_raise(RuntimeError)
|
177
|
+
expect{ Pkg::Util::Net.rsync_from("foo", "bar", "boo") }.to raise_error(RuntimeError)
|
178
|
+
end
|
179
|
+
|
180
|
+
it "should not include the flags '--ignore-existing' by default" do
|
181
|
+
Pkg::Util::Tool.should_receive(:check_tool).with("rsync").and_return(rsync)
|
182
|
+
Pkg::Util::Execution.should_receive(:capture3).with("#{rsync} #{defaults} foo@bar:thing /home/foo", true)
|
183
|
+
Pkg::Util::Net.rsync_from("thing", "foo@bar", "/home/foo")
|
184
|
+
end
|
185
|
+
|
186
|
+
it "should rsync 'thing' from 'foo@bar' to '/home/foo' with flags '#{defaults}'" do
|
187
|
+
Pkg::Util::Tool.should_receive(:check_tool).with("rsync").and_return(rsync)
|
188
|
+
Pkg::Util::Execution.should_receive(:capture3).with("#{rsync} #{defaults} foo@bar:thing /home/foo", true)
|
189
|
+
Pkg::Util::Net.rsync_from("thing", "foo@bar", "/home/foo")
|
190
|
+
end
|
191
|
+
|
192
|
+
it "rsyncs 'thing' from 'foo@bar:/home/foo' with flags that don't include arbitrary flags" do
|
193
|
+
Pkg::Util::Tool.should_receive(:check_tool).with("rsync").and_return(rsync)
|
194
|
+
Pkg::Util::Execution.should_receive(:capture3).with("#{rsync} #{defaults} --foo-bar --and-another-flag foo@bar:thing /home/foo", true)
|
195
|
+
Pkg::Util::Net.rsync_from("thing", "foo@bar", "/home/foo", extra_flags: ["--foo-bar", "--and-another-flag"])
|
196
|
+
end
|
197
|
+
end
|
198
|
+
|
199
|
+
describe "#curl_form_data" do
|
200
|
+
let(:curl) {"/bin/curl"}
|
201
|
+
let(:form_data) {["name=FOO"]}
|
202
|
+
let(:options) { {:quiet => true} }
|
203
|
+
|
204
|
+
it "should return false on failure" do
|
205
|
+
Pkg::Util::Tool.should_receive(:check_tool).with("curl").and_return(curl)
|
206
|
+
Pkg::Util::Execution.should_receive(:capture3).with("#{curl} -i '#{target_uri}'").and_return(['stdout', 'stderr', 1])
|
207
|
+
Pkg::Util::Net.curl_form_data(target_uri).should eq(['stdout', 1])
|
208
|
+
end
|
209
|
+
|
210
|
+
|
211
|
+
it "should curl with just the uri" do
|
212
|
+
Pkg::Util::Tool.should_receive(:check_tool).with("curl").and_return(curl)
|
213
|
+
Pkg::Util::Execution.should_receive(:capture3).with("#{curl} -i '#{target_uri}'")
|
214
|
+
Pkg::Util::Net.curl_form_data(target_uri)
|
215
|
+
end
|
216
|
+
|
217
|
+
it "should curl with the form data and uri" do
|
218
|
+
Pkg::Util::Tool.should_receive(:check_tool).with("curl").and_return(curl)
|
219
|
+
Pkg::Util::Execution.should_receive(:capture3).with("#{curl} -i #{form_data[0]} '#{target_uri}'")
|
220
|
+
Pkg::Util::Net.curl_form_data(target_uri, form_data)
|
221
|
+
end
|
222
|
+
|
223
|
+
it "should curl with form data, uri, and be quiet" do
|
224
|
+
Pkg::Util::Tool.should_receive(:check_tool).with("curl").and_return(curl)
|
225
|
+
Pkg::Util::Execution.should_receive(:capture3).with("#{curl} -i #{form_data[0]} '#{target_uri}'").and_return(['stdout', 'stderr', 0])
|
226
|
+
Pkg::Util::Net.curl_form_data(target_uri, form_data, options).should eq(['', 0])
|
227
|
+
end
|
228
|
+
|
229
|
+
end
|
230
|
+
|
231
|
+
describe "#print_url_info" do
|
232
|
+
it "should output correct formatting" do
|
233
|
+
Pkg::Util::Net.should_receive(:puts).with("\n////////////////////////////////////////////////////////////////////////////////\n\n
|
234
|
+
Build submitted. To view your build progress, go to\n#{target_uri}\n\n
|
235
|
+
////////////////////////////////////////////////////////////////////////////////\n\n")
|
236
|
+
Pkg::Util::Net.print_url_info(target_uri)
|
237
|
+
end
|
238
|
+
end
|
239
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Pkg::Util::OS do
|
4
|
+
def as_host_os(platform, &block)
|
5
|
+
old = RbConfig::CONFIG['host_os']
|
6
|
+
RbConfig::CONFIG['host_os'] = platform
|
7
|
+
begin
|
8
|
+
yield
|
9
|
+
ensure
|
10
|
+
RbConfig::CONFIG['host_os'] = old
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
it "detects windows when host_os contains mingw" do
|
15
|
+
as_host_os('mingw32') do
|
16
|
+
expect(Pkg::Util::OS).to be_windows
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
it "detects windows when host_os contains mswin60" do
|
21
|
+
as_host_os('mswin60') do
|
22
|
+
expect(Pkg::Util::OS).to be_windows
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
it "does not detect windows when host_os contains darwin" do
|
27
|
+
as_host_os('darwin12.5.0') do
|
28
|
+
expect(Pkg::Util::OS).to_not be_windows
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,70 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe "Pkg::Util::RakeUtils" do
|
4
|
+
let(:foo_defined?) { Rake::Task.task_defined?(:foo) }
|
5
|
+
let(:bar_defined?) { Rake::Task.task_defined?(:bar) }
|
6
|
+
let(:define_foo) { body = proc{}; Rake::Task.define_task(:foo, &body) }
|
7
|
+
let(:define_bar) { body = proc{}; Rake::Task.define_task(:bar, &body) }
|
8
|
+
|
9
|
+
before(:each) do
|
10
|
+
if foo_defined?
|
11
|
+
Rake::Task[:foo].clear_prerequisites
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
describe "#task_defined?" do
|
16
|
+
context "given a Rake::Task task name" do
|
17
|
+
it "should return true if the task exists" do
|
18
|
+
Rake::Task.stub(:task_defined?).with(:foo) {true}
|
19
|
+
expect(Pkg::Util::RakeUtils.task_defined?(:foo)).to be_true
|
20
|
+
end
|
21
|
+
it "should return false if the task does not exist" do
|
22
|
+
Rake::Task.stub(:task_defined?).with(:foo) {false}
|
23
|
+
expect(Pkg::Util::RakeUtils.task_defined?(:foo)).to be_false
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
describe "#get_task" do
|
29
|
+
it "should return a task object for a named task" do
|
30
|
+
foo = nil
|
31
|
+
if !foo_defined?
|
32
|
+
foo = define_foo
|
33
|
+
else
|
34
|
+
foo = Rake::Task[:foo]
|
35
|
+
end
|
36
|
+
task = Pkg::Util::RakeUtils.get_task(:foo)
|
37
|
+
expect(task).to be_a(Rake::Task)
|
38
|
+
expect(task).to be(foo)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
describe "#add_dependency" do
|
43
|
+
it "should add a dependency to a given rake task" do
|
44
|
+
foo = nil
|
45
|
+
bar = nil
|
46
|
+
if !foo_defined?
|
47
|
+
foo = define_foo
|
48
|
+
else
|
49
|
+
foo = Rake::Task[:foo]
|
50
|
+
end
|
51
|
+
if !bar_defined?
|
52
|
+
bar = define_bar
|
53
|
+
else
|
54
|
+
bar = Rake::Task[:bar]
|
55
|
+
end
|
56
|
+
Pkg::Util::RakeUtils.add_dependency(foo, bar)
|
57
|
+
expect(Rake::Task["foo"].prerequisites).to include(bar)
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
describe "#evaluate_pre_tasks" do
|
62
|
+
context "Given a data file with :pre_tasks defined" do
|
63
|
+
it "should, for each k=>v pair, add v as a dependency to k" do
|
64
|
+
Pkg::Config.config_from_yaml(File.join(FIXTURES, 'util', 'pre_tasks.yaml'))
|
65
|
+
expect(Pkg::Util::RakeUtils).to receive(:add_dependency)
|
66
|
+
Pkg::Util::RakeUtils.evaluate_pre_tasks
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
@@ -0,0 +1,117 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe '#Pkg::Util::Ship' do
|
4
|
+
describe '#collect_packages' do
|
5
|
+
msi_pkgs = [
|
6
|
+
'pkg/windows/puppet5/puppet-agent-1.4.1.2904.g8023dd1-x86.msi',
|
7
|
+
'pkg/windows/puppet5/puppet-agent-x86.msi'
|
8
|
+
]
|
9
|
+
swix_pkgs = [
|
10
|
+
'pkg/eos/puppet5/4/i386/puppet-agent-1.4.1.2904.g8023dd1-1.eos4.i386.swix',
|
11
|
+
'pkg/eos/puppet5/4/i386/puppet-agent-1.4.1.2904.g8023dd1-1.eos4.i386.swix.asc',
|
12
|
+
]
|
13
|
+
|
14
|
+
it 'returns an array of packages found on the filesystem' do
|
15
|
+
allow(Dir).to receive(:glob).with('pkg/**/*.swix*').and_return(swix_pkgs)
|
16
|
+
expect(Pkg::Util::Ship.collect_packages(['pkg/**/*.swix*'])).to eq(swix_pkgs)
|
17
|
+
end
|
18
|
+
|
19
|
+
describe 'define excludes' do
|
20
|
+
before :each do
|
21
|
+
allow(Dir).to receive(:glob).with('pkg/**/*.msi').and_return(msi_pkgs)
|
22
|
+
end
|
23
|
+
it 'correctly excludes any packages that match a passed excludes argument' do
|
24
|
+
expect(Pkg::Util::Ship.collect_packages(['pkg/**/*.msi'], ['puppet-agent-x(86|64).msi'])).not_to include('pkg/windows/puppet5/puppet-agent-x86.msi')
|
25
|
+
end
|
26
|
+
it 'correctly includes packages that do not match a passed excluded argument' do
|
27
|
+
expect(Pkg::Util::Ship.collect_packages(['pkg/**/*.msi'], ['puppet-agent-x(86|64).msi'])).to include('pkg/windows/puppet5/puppet-agent-1.4.1.2904.g8023dd1-x86.msi')
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
it 'fails when it cannot find any packages at all' do
|
32
|
+
allow(Dir).to receive(:glob).with('pkg/**/*.html').and_return([])
|
33
|
+
expect(Pkg::Util::Ship.collect_packages(['pkg/**/*.html'])).to be_empty
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
local_pkgs = [
|
38
|
+
'pkg/deb/cumulus/puppet5/puppet-agent_1.4.1.2904.g8023dd1-1cumulus_amd64.deb',
|
39
|
+
'pkg/deb/wheezy/puppet5/puppet-agent_1.4.1.2904.g8023dd1-1wheezy_i386.deb',
|
40
|
+
'pkg/el/5/puppet5/x86_64/puppet-agent-1.4.1.2904.g8023dd1-1.el5.x86_64.rpm',
|
41
|
+
'pkg/sles/11/puppet5/i386/puppet-agent-1.4.1.2904.g8023dd1-1.sles11.i386.rpm',
|
42
|
+
'pkg/mac/10.10/puppet5/x86_64/puppet-agent-1.4.1.2904.g8023dd1-1.osx10.10.dmg',
|
43
|
+
'pkg/eos/4/puppet5/i386/puppet-agent-1.4.1.2904.g8023dd1-1.eos4.i386.swix',
|
44
|
+
'pkg/eos/4/puppet5/i386/puppet-agent-1.4.1.2904.g8023dd1-1.eos4.i386.swix.asc',
|
45
|
+
'pkg/windows/puppet5/puppet-agent-1.4.1.2904.g8023dd1-x86.msi',
|
46
|
+
]
|
47
|
+
new_pkgs = [
|
48
|
+
'pkg/cumulus/puppet5/puppet-agent_1.4.1.2904.g8023dd1-1cumulus_amd64.deb',
|
49
|
+
'pkg/wheezy/puppet5/puppet-agent_1.4.1.2904.g8023dd1-1wheezy_i386.deb',
|
50
|
+
'pkg/puppet5/el/5/x86_64/puppet-agent-1.4.1.2904.g8023dd1-1.el5.x86_64.rpm',
|
51
|
+
'pkg/puppet5/sles/11/i386/puppet-agent-1.4.1.2904.g8023dd1-1.sles11.i386.rpm',
|
52
|
+
'pkg/mac/puppet5/10.10/x86_64/puppet-agent-1.4.1.2904.g8023dd1-1.osx10.10.dmg',
|
53
|
+
'pkg/eos/puppet5/4/i386/puppet-agent-1.4.1.2904.g8023dd1-1.eos4.i386.swix',
|
54
|
+
'pkg/eos/puppet5/4/i386/puppet-agent-1.4.1.2904.g8023dd1-1.eos4.i386.swix.asc',
|
55
|
+
'pkg/windows/puppet5/puppet-agent-1.4.1.2904.g8023dd1-x86.msi',
|
56
|
+
]
|
57
|
+
|
58
|
+
describe '#reorganize_packages' do
|
59
|
+
tmpdir = Dir.mktmpdir
|
60
|
+
|
61
|
+
before :each do
|
62
|
+
allow(Pkg::Paths).to receive(:repo_name).and_return('puppet5')
|
63
|
+
expect(FileUtils).to receive(:cp).at_least(:once)
|
64
|
+
end
|
65
|
+
|
66
|
+
it 'makes a temporary directory' do
|
67
|
+
expect(FileUtils).to receive(:mkdir_p).at_least(:once)
|
68
|
+
Pkg::Util::Ship.reorganize_packages(local_pkgs, tmpdir)
|
69
|
+
end
|
70
|
+
|
71
|
+
it 'leaves the old packages in place' do
|
72
|
+
orig = local_pkgs
|
73
|
+
Pkg::Util::Ship.reorganize_packages(local_pkgs, tmpdir)
|
74
|
+
expect(local_pkgs).to eq(orig)
|
75
|
+
end
|
76
|
+
|
77
|
+
it 'returns a list of packages that do not have the temp dir in the path' do
|
78
|
+
expect(Pkg::Util::Ship.reorganize_packages(local_pkgs, tmpdir)).to eq(new_pkgs)
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
describe '#ship_pkgs' do
|
83
|
+
test_staging_server = 'foo.delivery.puppetlabs.net'
|
84
|
+
test_remote_path = '/opt/repository/yum'
|
85
|
+
|
86
|
+
it 'ships the packages to the staging server' do
|
87
|
+
allow(Pkg::Util::Ship).to receive(:collect_packages).and_return(local_pkgs)
|
88
|
+
allow(Pkg::Util::Ship).to receive(:reorganize_packages).and_return(new_pkgs)
|
89
|
+
allow(Pkg::Util).to receive(:ask_yes_or_no).and_return(true)
|
90
|
+
# All of these expects must be called in the same block in order for the
|
91
|
+
# tests to work without actually shipping anything
|
92
|
+
expect(Pkg::Util::Net).to receive(:remote_ssh_cmd).with(test_staging_server, /#{test_remote_path}/).exactly(local_pkgs.count).times
|
93
|
+
expect(Pkg::Util::Net).to receive(:rsync_to).with(anything, test_staging_server, /#{test_remote_path}/, anything).exactly(local_pkgs.count).times
|
94
|
+
expect(Pkg::Util::Net).to receive(:remote_set_ownership).with(test_staging_server, 'root', 'release', anything).exactly(local_pkgs.count).times
|
95
|
+
expect(Pkg::Util::Net).to receive(:remote_set_permissions).with(test_staging_server, '775', anything).exactly(local_pkgs.count).times
|
96
|
+
expect(Pkg::Util::Net).to receive(:remote_set_permissions).with(test_staging_server, '0664', anything).exactly(local_pkgs.count).times
|
97
|
+
expect(Pkg::Util::Net).to receive(:remote_set_immutable).with(test_staging_server, anything).exactly(local_pkgs.count).times
|
98
|
+
Pkg::Util::Ship.ship_pkgs(['pkg/**/*.rpm'], test_staging_server, test_remote_path)
|
99
|
+
end
|
100
|
+
|
101
|
+
it 'ships packages containing the string `pkg` to the right place' do
|
102
|
+
allow(Pkg::Util::Ship).to receive(:collect_packages).and_return(['pkg/el/5/puppet5/x86_64/my-super-sweet-pkg-1.0.0-1.el5.x86_64.rpm' ])
|
103
|
+
allow(Pkg::Util::Ship).to receive(:reorganize_packages).and_return(['pkg/puppet5/el/5/x86_64/my-super-sweet-pkg-1.0.0-1.el5.x86_64.rpm'])
|
104
|
+
allow(Pkg::Util).to receive(:ask_yes_or_no).and_return(true)
|
105
|
+
allow(Dir).to receive(:mktmpdir).and_return('/tmp/test')
|
106
|
+
# All of these expects must be called in the same block in order for the
|
107
|
+
# tests to work without actually shipping anything
|
108
|
+
expect(Pkg::Util::Net).to receive(:remote_ssh_cmd).with(test_staging_server, /#{test_remote_path}/)
|
109
|
+
expect(Pkg::Util::Net).to receive(:rsync_to).with(anything, test_staging_server, /#{test_remote_path}/, anything)
|
110
|
+
expect(Pkg::Util::Net).to receive(:remote_set_ownership).with(test_staging_server, 'root', 'release', ['/opt/repository/yum/puppet5/el/5/x86_64', '/opt/repository/yum/puppet5/el/5/x86_64/my-super-sweet-pkg-1.0.0-1.el5.x86_64.rpm'])
|
111
|
+
expect(Pkg::Util::Net).to receive(:remote_set_permissions).with(test_staging_server, '775', anything)
|
112
|
+
expect(Pkg::Util::Net).to receive(:remote_set_permissions).with(test_staging_server, '0664', anything)
|
113
|
+
expect(Pkg::Util::Net).to receive(:remote_set_immutable).with(test_staging_server, anything)
|
114
|
+
Pkg::Util::Ship.ship_pkgs(['pkg/**/*.rpm'], test_staging_server, test_remote_path, excludes: ['puppet-agent'])
|
115
|
+
end
|
116
|
+
end
|
117
|
+
end
|