omnibus 5.0.0 → 5.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.rspec +2 -0
- data/.travis.yml +1 -0
- data/CHANGELOG.md +26 -0
- data/Gemfile +3 -0
- data/MAINTAINERS.md +1 -0
- data/appveyor.yml +1 -1
- data/bin/omnibus +5 -0
- data/lib/omnibus/builder.rb +165 -26
- data/lib/omnibus/digestable.rb +4 -2
- data/lib/omnibus/fetcher.rb +18 -5
- data/lib/omnibus/fetchers/git_fetcher.rb +38 -22
- data/lib/omnibus/fetchers/net_fetcher.rb +106 -37
- data/lib/omnibus/fetchers/path_fetcher.rb +13 -12
- data/lib/omnibus/file_syncer.rb +33 -14
- data/lib/omnibus/generator_files/README.md.erb +1 -1
- data/lib/omnibus/generator_files/package_scripts/postinst.erb +3 -3
- data/lib/omnibus/generator_files/package_scripts/postrm.erb +1 -1
- data/lib/omnibus/generator_files/package_scripts/preinst.erb +1 -1
- data/lib/omnibus/generator_files/package_scripts/prerm.erb +3 -3
- data/lib/omnibus/git_cache.rb +20 -7
- data/lib/omnibus/health_check.rb +144 -12
- data/lib/omnibus/packagers/bff.rb +57 -5
- data/lib/omnibus/packagers/deb.rb +2 -2
- data/lib/omnibus/packagers/pkg.rb +2 -2
- data/lib/omnibus/packagers/solaris.rb +18 -6
- data/lib/omnibus/project.rb +1 -1
- data/lib/omnibus/s3_cache.rb +8 -2
- data/lib/omnibus/software.rb +152 -18
- data/lib/omnibus/sugarable.rb +1 -5
- data/lib/omnibus/util.rb +1 -1
- data/lib/omnibus/version.rb +1 -1
- data/omnibus.gemspec +4 -1
- data/resources/bff/config.erb +7 -0
- data/resources/deb/md5sums.erb +1 -1
- data/spec/functional/builder_spec.rb +89 -2
- data/spec/functional/fetchers/git_fetcher_spec.rb +44 -37
- data/spec/functional/fetchers/net_fetcher_spec.rb +36 -5
- data/spec/functional/fetchers/path_fetcher_spec.rb +28 -28
- data/spec/unit/builder_spec.rb +143 -11
- data/spec/unit/fetchers/git_fetcher_spec.rb +23 -59
- data/spec/unit/fetchers/net_fetcher_spec.rb +151 -63
- data/spec/unit/fetchers/path_fetcher_spec.rb +4 -35
- data/spec/unit/git_cache_spec.rb +13 -14
- data/spec/unit/health_check_spec.rb +90 -0
- data/spec/unit/library_spec.rb +1 -1
- data/spec/unit/packagers/bff_spec.rb +126 -3
- data/spec/unit/packagers/deb_spec.rb +8 -3
- data/spec/unit/packagers/pkg_spec.rb +19 -19
- data/spec/unit/packagers/solaris_spec.rb +13 -1
- data/spec/unit/software_spec.rb +242 -38
- metadata +7 -6
- data/lib/omnibus/generator_files/package_scripts/makeselfinst.erb +0 -0
@@ -29,16 +29,16 @@ module Omnibus
|
|
29
29
|
context 'when the repository is cloned' do
|
30
30
|
before { allow(subject).to receive(:cloned?).and_return(true) }
|
31
31
|
before { allow(subject).to receive(:resolved_version).and_return('12341235')}
|
32
|
-
context 'when the revision is
|
33
|
-
before { allow(subject).to receive(:
|
32
|
+
context 'when the revision is not in the repo' do
|
33
|
+
before { allow(subject).to receive(:contains_revision?).and_return(false) }
|
34
34
|
|
35
35
|
it 'returns true' do
|
36
36
|
expect(subject.fetch_required?).to be_truthy
|
37
37
|
end
|
38
38
|
end
|
39
39
|
|
40
|
-
context 'when the
|
41
|
-
before { allow(subject).to receive(:
|
40
|
+
context 'when the revision is present in the repo' do
|
41
|
+
before { allow(subject).to receive(:contains_revision?).and_return(true) }
|
42
42
|
|
43
43
|
it 'returns false' do
|
44
44
|
expect(subject.fetch_required?).to be(false)
|
@@ -60,36 +60,23 @@ module Omnibus
|
|
60
60
|
end
|
61
61
|
|
62
62
|
describe '#clean' do
|
63
|
-
before
|
64
|
-
|
65
|
-
|
66
|
-
before do
|
67
|
-
allow(subject).to receive(:cloned?).and_return(true)
|
68
|
-
end
|
69
|
-
|
70
|
-
it 'cleans the directory' do
|
71
|
-
expect(subject).to receive(:git).with('clean -fdx')
|
72
|
-
subject.clean
|
73
|
-
end
|
74
|
-
|
75
|
-
it 'returns true' do
|
76
|
-
expect(subject.clean).to be_truthy
|
77
|
-
end
|
63
|
+
before do
|
64
|
+
allow(subject).to receive(:git)
|
65
|
+
allow(subject).to receive(:resolved_version).and_return('12341235')
|
78
66
|
end
|
79
67
|
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
68
|
+
it 'checks out the working directory at the correct revision' do
|
69
|
+
expect(subject).to receive(:git_checkout)
|
70
|
+
subject.clean
|
71
|
+
end
|
84
72
|
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
73
|
+
it 'cleans the directory' do
|
74
|
+
expect(subject).to receive(:git).with('clean -fdx')
|
75
|
+
subject.clean
|
76
|
+
end
|
89
77
|
|
90
|
-
|
91
|
-
|
92
|
-
end
|
78
|
+
it 'returns true' do
|
79
|
+
expect(subject.clean).to be_truthy
|
93
80
|
end
|
94
81
|
end
|
95
82
|
|
@@ -101,22 +88,9 @@ module Omnibus
|
|
101
88
|
context 'when the repository is cloned' do
|
102
89
|
before { allow(subject).to receive(:cloned?).and_return(true) }
|
103
90
|
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
it 'fetches and resets to the resolved_version' do
|
108
|
-
expect(subject).to receive(:git_fetch)
|
109
|
-
subject.fetch
|
110
|
-
end
|
111
|
-
end
|
112
|
-
|
113
|
-
context 'when the revision is the same' do
|
114
|
-
before { allow(subject).to receive(:same_revision?).and_return(true) }
|
115
|
-
|
116
|
-
it 'does not fetch or reset' do
|
117
|
-
expect(subject).to_not receive(:git_fetch)
|
118
|
-
subject.fetch
|
119
|
-
end
|
91
|
+
it 'fetches the resolved_version' do
|
92
|
+
expect(subject).to receive(:git_fetch)
|
93
|
+
subject.fetch
|
120
94
|
end
|
121
95
|
end
|
122
96
|
|
@@ -125,13 +99,12 @@ module Omnibus
|
|
125
99
|
allow(subject).to receive(:cloned?).and_return(false)
|
126
100
|
allow(subject).to receive(:dir_empty?).and_return(true)
|
127
101
|
allow(subject).to receive(:git_clone)
|
128
|
-
allow(subject).to receive(:git_checkout)
|
129
102
|
end
|
130
103
|
|
131
104
|
context 'but a directory does exist' do
|
132
105
|
before { expect(subject).to receive(:dir_empty?).with(project_dir).and_return(false)}
|
133
106
|
|
134
|
-
it 'forcefully removes and
|
107
|
+
it 'forcefully removes and recreates the directory' do
|
135
108
|
expect(FileUtils).to receive(:rm_rf).with(project_dir).and_return(project_dir)
|
136
109
|
expect(Dir).to receive(:mkdir).with(project_dir).and_return(0)
|
137
110
|
subject.fetch
|
@@ -142,21 +115,12 @@ module Omnibus
|
|
142
115
|
expect(subject).to receive(:git_clone).once
|
143
116
|
subject.fetch
|
144
117
|
end
|
145
|
-
|
146
|
-
it 'checks out the correct revision' do
|
147
|
-
expect(subject).to receive(:git_checkout).once
|
148
|
-
subject.fetch
|
149
|
-
end
|
150
118
|
end
|
151
119
|
end
|
152
120
|
|
153
121
|
describe '#version_for_cache' do
|
154
|
-
|
155
|
-
|
156
|
-
before { allow(subject).to receive(:current_revision).and_return(revision) }
|
157
|
-
|
158
|
-
it 'returns the shasum of the project_dir' do
|
159
|
-
expect(subject.version_for_cache).to eq("revision:#{revision}")
|
122
|
+
it 'returns the shasum of the commit that we expect to be at' do
|
123
|
+
expect(subject.version_for_cache).to eq('revision:123abcd1234')
|
160
124
|
end
|
161
125
|
end
|
162
126
|
end
|
@@ -2,8 +2,9 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
module Omnibus
|
4
4
|
describe NetFetcher do
|
5
|
-
let(:
|
6
|
-
let(:
|
5
|
+
let(:root_prefix) { '' }
|
6
|
+
let(:project_dir) { "#{root_prefix}/tmp/project" }
|
7
|
+
let(:build_dir) { "#{root_prefix}/tmp/build" }
|
7
8
|
let(:source) do
|
8
9
|
{ url: 'https://get.example.com/file.tar.gz', md5: 'abcd1234' }
|
9
10
|
end
|
@@ -101,14 +102,15 @@ module Omnibus
|
|
101
102
|
describe '#clean' do
|
102
103
|
before do
|
103
104
|
allow(FileUtils).to receive(:rm_rf)
|
104
|
-
allow(subject).to receive(:
|
105
|
+
allow(subject).to receive(:deploy)
|
106
|
+
allow(subject).to receive(:create_required_directories)
|
105
107
|
end
|
106
108
|
|
107
109
|
context 'when the project directory exists' do
|
108
110
|
before { allow(File).to receive(:exist?).and_return(true) }
|
109
111
|
|
110
|
-
it '
|
111
|
-
expect(subject).to receive(:
|
112
|
+
it 'deploys the archive' do
|
113
|
+
expect(subject).to receive(:deploy)
|
112
114
|
subject.clean
|
113
115
|
end
|
114
116
|
|
@@ -125,8 +127,8 @@ module Omnibus
|
|
125
127
|
context 'when the project directory does not exist' do
|
126
128
|
before { allow(File).to receive(:exist?).and_return(false) }
|
127
129
|
|
128
|
-
it '
|
129
|
-
expect(subject).to receive(:
|
130
|
+
it 'deploys the archive' do
|
131
|
+
expect(subject).to receive(:deploy)
|
130
132
|
subject.clean
|
131
133
|
end
|
132
134
|
|
@@ -187,7 +189,7 @@ module Omnibus
|
|
187
189
|
|
188
190
|
let(:tempfile_path) { "/tmp/intermediate_path/tempfile_path.random_garbage.tmp" }
|
189
191
|
|
190
|
-
let(:fetched_file) { instance_double("
|
192
|
+
let(:fetched_file) { instance_double("TempFile", path: tempfile_path) }
|
191
193
|
|
192
194
|
let(:destination_path) { "/cache/file.tar.gz" }
|
193
195
|
|
@@ -212,8 +214,9 @@ module Omnibus
|
|
212
214
|
|
213
215
|
fetched_file
|
214
216
|
end
|
215
|
-
expect(FileUtils).to receive(:cp).with(tempfile_path, destination_path)
|
216
217
|
expect(fetched_file).to receive(:close)
|
218
|
+
expect(FileUtils).to receive(:cp).with(tempfile_path, destination_path)
|
219
|
+
expect(fetched_file).to receive(:unlink)
|
217
220
|
end
|
218
221
|
|
219
222
|
it "downloads the thing" do
|
@@ -246,27 +249,35 @@ module Omnibus
|
|
246
249
|
|
247
250
|
end
|
248
251
|
|
249
|
-
shared_examples 'an extractor' do |extension,
|
252
|
+
shared_examples 'an extractor' do |extension, source_options, commands|
|
250
253
|
context "when the file is a .#{extension}" do
|
251
254
|
let(:manifest_entry) do
|
252
255
|
double(Omnibus::ManifestEntry,
|
253
256
|
name: 'file',
|
254
257
|
locked_version: "1.2.3",
|
255
258
|
described_version: '1.2.3',
|
256
|
-
locked_source: { url: "https://get.example.com/file.#{extension}", md5: 'abcd1234' })
|
259
|
+
locked_source: { url: "https://get.example.com/file.#{extension}", md5: 'abcd1234' }.merge(source_options)
|
260
|
+
)
|
257
261
|
end
|
258
262
|
|
259
263
|
subject { described_class.new(manifest_entry, project_dir, build_dir) }
|
260
264
|
|
261
|
-
it '
|
262
|
-
|
265
|
+
it 'shells out with the right commands' do
|
266
|
+
commands.each do |command|
|
267
|
+
if command.is_a?(String)
|
268
|
+
expect(subject).to receive(:shellout!).with(command)
|
269
|
+
else
|
270
|
+
expect(subject).to receive(:shellout!).with(*command)
|
271
|
+
end
|
272
|
+
end
|
273
|
+
subject.send(:extract)
|
263
274
|
end
|
264
275
|
end
|
265
276
|
end
|
266
277
|
|
267
|
-
describe '#
|
278
|
+
describe '#deploy' do
|
268
279
|
before do
|
269
|
-
described_class.send(:public, :
|
280
|
+
described_class.send(:public, :deploy)
|
270
281
|
end
|
271
282
|
|
272
283
|
context 'when the downloaded file is a folder' do
|
@@ -281,14 +292,12 @@ module Omnibus
|
|
281
292
|
subject { described_class.new(manifest_entry, project_dir, build_dir) }
|
282
293
|
|
283
294
|
before do
|
284
|
-
allow(FileUtils).to receive(:cp_r)
|
285
295
|
allow(File).to receive(:directory?).and_return(true)
|
286
296
|
end
|
287
297
|
|
288
298
|
it 'copies the entire directory to project_dir' do
|
289
|
-
|
290
|
-
|
291
|
-
subject.extract
|
299
|
+
expect(FileUtils).to receive(:cp_r).with("#{cache_dir}/folder/.", project_dir)
|
300
|
+
subject.deploy
|
292
301
|
end
|
293
302
|
end
|
294
303
|
|
@@ -304,37 +313,95 @@ module Omnibus
|
|
304
313
|
subject { described_class.new(manifest_entry, project_dir, build_dir) }
|
305
314
|
|
306
315
|
before do
|
307
|
-
allow(FileUtils).to receive(:mkdir_p)
|
308
|
-
allow(FileUtils).to receive(:cp)
|
309
316
|
allow(File).to receive(:directory?).and_return(false)
|
310
317
|
end
|
311
318
|
|
312
319
|
it 'copies the file into the project_dir' do
|
313
|
-
|
314
|
-
|
315
|
-
subject.extract
|
320
|
+
expect(FileUtils).to receive(:cp).with("#{cache_dir}/file", "#{project_dir}")
|
321
|
+
subject.deploy
|
316
322
|
end
|
317
323
|
end
|
318
324
|
end
|
319
325
|
|
320
|
-
describe '#
|
321
|
-
before { Config.source_dir('/tmp/out') }
|
326
|
+
describe '#extract' do
|
322
327
|
|
323
328
|
context 'on Windows' do
|
329
|
+
let(:root_prefix) { 'C:' }
|
330
|
+
|
324
331
|
before do
|
325
|
-
Config.cache_dir('C
|
332
|
+
Config.cache_dir('C:/')
|
326
333
|
stub_ohai(platform: 'windows', version: '2012')
|
334
|
+
allow(Dir).to receive(:mktmpdir).and_yield('C:/tmp_dir')
|
335
|
+
end
|
336
|
+
|
337
|
+
context 'when no extract overrides are present' do
|
338
|
+
it_behaves_like 'an extractor', '7z', {},
|
339
|
+
['7z.exe x C:\\file.7z -oC:\\tmp\\project -r -y']
|
340
|
+
it_behaves_like 'an extractor', 'zip', {},
|
341
|
+
['7z.exe x C:\\file.zip -oC:\\tmp\\project -r -y']
|
342
|
+
it_behaves_like 'an extractor', 'tar', {},
|
343
|
+
[['tar.exe xf C:\\file.tar -CC:\\tmp\\project', {returns: [0]}]]
|
344
|
+
it_behaves_like 'an extractor', 'tgz', {},
|
345
|
+
[['tar.exe zxf C:\\file.tgz -CC:\\tmp\\project', {returns: [0]}]]
|
346
|
+
it_behaves_like 'an extractor', 'tar.gz', {},
|
347
|
+
[['tar.exe zxf C:\\file.tar.gz -CC:\\tmp\\project', {returns: [0]}]]
|
348
|
+
it_behaves_like 'an extractor', 'tar.bz2', {},
|
349
|
+
[['tar.exe jxf C:\\file.tar.bz2 -CC:\\tmp\\project', {returns: [0]}]]
|
350
|
+
it_behaves_like 'an extractor', 'txz', {},
|
351
|
+
[['tar.exe Jxf C:\\file.txz -CC:\\tmp\\project', {returns: [0]}]]
|
352
|
+
it_behaves_like 'an extractor', 'tar.xz', {},
|
353
|
+
[['tar.exe Jxf C:\\file.tar.xz -CC:\\tmp\\project', {returns: [0]}]]
|
354
|
+
it_behaves_like 'an extractor', 'tar.lzma', {},
|
355
|
+
[['tar.exe --lzma -xf C:\\file.tar.lzma -CC:\\tmp\\project', {returns: [0]}]]
|
356
|
+
end
|
357
|
+
|
358
|
+
context 'when seven_zip extract strategy is chosen' do
|
359
|
+
it_behaves_like 'an extractor', '7z', { extract: :seven_zip },
|
360
|
+
['7z.exe x C:\\file.7z -oC:\\tmp\\project -r -y']
|
361
|
+
it_behaves_like 'an extractor', 'zip', { extract: :seven_zip },
|
362
|
+
['7z.exe x C:\\file.zip -oC:\\tmp\\project -r -y']
|
363
|
+
it_behaves_like 'an extractor', 'tar', { extract: :seven_zip },
|
364
|
+
['7z.exe x C:\\file.tar -oC:\\tmp\\project -r -y']
|
365
|
+
it_behaves_like 'an extractor', 'tgz', { extract: :seven_zip },
|
366
|
+
['7z.exe x C:\\file.tgz -oC:\\tmp_dir -r -y',
|
367
|
+
'7z.exe x C:\\tmp_dir\\file.tar -oC:\\tmp\\project -r -y']
|
368
|
+
it_behaves_like 'an extractor', 'tar.gz', { extract: :seven_zip },
|
369
|
+
['7z.exe x C:\\file.tar.gz -oC:\\tmp_dir -r -y',
|
370
|
+
'7z.exe x C:\\tmp_dir\\file.tar -oC:\\tmp\\project -r -y']
|
371
|
+
it_behaves_like 'an extractor', 'tar.bz2', { extract: :seven_zip },
|
372
|
+
['7z.exe x C:\\file.tar.bz2 -oC:\\tmp_dir -r -y',
|
373
|
+
'7z.exe x C:\\tmp_dir\\file.tar -oC:\\tmp\\project -r -y']
|
374
|
+
it_behaves_like 'an extractor', 'txz', { extract: :seven_zip },
|
375
|
+
['7z.exe x C:\\file.txz -oC:\\tmp_dir -r -y',
|
376
|
+
'7z.exe x C:\\tmp_dir\\file.tar -oC:\\tmp\\project -r -y']
|
377
|
+
it_behaves_like 'an extractor', 'tar.xz', { extract: :seven_zip },
|
378
|
+
['7z.exe x C:\\file.tar.xz -oC:\\tmp_dir -r -y',
|
379
|
+
'7z.exe x C:\\tmp_dir\\file.tar -oC:\\tmp\\project -r -y']
|
380
|
+
it_behaves_like 'an extractor', 'tar.lzma', { extract: :seven_zip },
|
381
|
+
['7z.exe x C:\\file.tar.lzma -oC:\\tmp_dir -r -y',
|
382
|
+
'7z.exe x C:\\tmp_dir\\file.tar -oC:\\tmp\\project -r -y']
|
383
|
+
end
|
384
|
+
|
385
|
+
context 'when lax_tar extract strategy is chosen' do
|
386
|
+
it_behaves_like 'an extractor', '7z', { extract: :lax_tar },
|
387
|
+
['7z.exe x C:\\file.7z -oC:\\tmp\\project -r -y']
|
388
|
+
it_behaves_like 'an extractor', 'zip', { extract: :lax_tar },
|
389
|
+
['7z.exe x C:\\file.zip -oC:\\tmp\\project -r -y']
|
390
|
+
it_behaves_like 'an extractor', 'tar', { extract: :lax_tar },
|
391
|
+
[['tar.exe xf C:\\file.tar -CC:\\tmp\\project', {returns: [0, 1]}]]
|
392
|
+
it_behaves_like 'an extractor', 'tgz', { extract: :lax_tar },
|
393
|
+
[['tar.exe zxf C:\\file.tgz -CC:\\tmp\\project', {returns: [0, 1]}]]
|
394
|
+
it_behaves_like 'an extractor', 'tar.gz', { extract: :lax_tar },
|
395
|
+
[['tar.exe zxf C:\\file.tar.gz -CC:\\tmp\\project', {returns: [0, 1]}]]
|
396
|
+
it_behaves_like 'an extractor', 'tar.bz2', { extract: :lax_tar },
|
397
|
+
[['tar.exe jxf C:\\file.tar.bz2 -CC:\\tmp\\project', {returns: [0, 1]}]]
|
398
|
+
it_behaves_like 'an extractor', 'txz', { extract: :lax_tar },
|
399
|
+
[['tar.exe Jxf C:\\file.txz -CC:\\tmp\\project', {returns: [0, 1]}]]
|
400
|
+
it_behaves_like 'an extractor', 'tar.xz', { extract: :lax_tar },
|
401
|
+
[['tar.exe Jxf C:\\file.tar.xz -CC:\\tmp\\project', {returns: [0, 1]}]]
|
402
|
+
it_behaves_like 'an extractor', 'tar.lzma', { extract: :lax_tar },
|
403
|
+
[['tar.exe --lzma -xf C:\\file.tar.lzma -CC:\\tmp\\project', {returns: [0, 1]}]]
|
327
404
|
end
|
328
|
-
|
329
|
-
it_behaves_like 'an extractor', '7z', '7z.exe x C:\\file.7z -o/tmp/out -r -y'
|
330
|
-
it_behaves_like 'an extractor', 'zip', '7z.exe x C:\\file.zip -o/tmp/out -r -y'
|
331
|
-
it_behaves_like 'an extractor', 'tar', 'tar xf C:\\file.tar -C/tmp/out'
|
332
|
-
it_behaves_like 'an extractor', 'tgz', 'tar zxf C:\\file.tgz -C/tmp/out'
|
333
|
-
it_behaves_like 'an extractor', 'tar.gz', 'tar zxf C:\\file.tar.gz -C/tmp/out'
|
334
|
-
it_behaves_like 'an extractor', 'bz2', 'tar jxf C:\\file.bz2 -C/tmp/out'
|
335
|
-
it_behaves_like 'an extractor', 'tar.bz2', 'tar jxf C:\\file.tar.bz2 -C/tmp/out'
|
336
|
-
it_behaves_like 'an extractor', 'txz', 'tar Jxf C:\\file.txz -C/tmp/out'
|
337
|
-
it_behaves_like 'an extractor', 'tar.xz', 'tar Jxf C:\\file.tar.xz -C/tmp/out'
|
338
405
|
end
|
339
406
|
|
340
407
|
context 'on Linux' do
|
@@ -344,38 +411,59 @@ module Omnibus
|
|
344
411
|
stub_const('File::ALT_SEPARATOR', nil)
|
345
412
|
end
|
346
413
|
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
|
414
|
+
context 'when gtar is not present' do
|
415
|
+
it_behaves_like 'an extractor', '7z', {},
|
416
|
+
['7z x /file.7z -o/tmp/project -r -y']
|
417
|
+
it_behaves_like 'an extractor', 'zip', {},
|
418
|
+
['unzip /file.zip -d /tmp/project']
|
419
|
+
it_behaves_like 'an extractor', 'tar', {},
|
420
|
+
['tar xf /file.tar -C/tmp/project']
|
421
|
+
it_behaves_like 'an extractor', 'tgz', {},
|
422
|
+
['tar zxf /file.tgz -C/tmp/project']
|
423
|
+
it_behaves_like 'an extractor', 'tar.gz', {},
|
424
|
+
['tar zxf /file.tar.gz -C/tmp/project']
|
425
|
+
it_behaves_like 'an extractor', 'tar.bz2', {},
|
426
|
+
['tar jxf /file.tar.bz2 -C/tmp/project']
|
427
|
+
it_behaves_like 'an extractor', 'txz', {},
|
428
|
+
['tar Jxf /file.txz -C/tmp/project']
|
429
|
+
it_behaves_like 'an extractor', 'tar.xz', {},
|
430
|
+
['tar Jxf /file.tar.xz -C/tmp/project']
|
431
|
+
it_behaves_like 'an extractor', 'tar.lzma', {},
|
432
|
+
['tar --lzma -xf /file.tar.lzma -C/tmp/project']
|
433
|
+
end
|
434
|
+
|
435
|
+
context 'when gtar is present' do
|
436
|
+
before do
|
437
|
+
Config.cache_dir('/')
|
361
438
|
|
362
|
-
|
363
|
-
|
439
|
+
stub_ohai(platform: 'ubuntu', version: '12.04')
|
440
|
+
stub_const('File::ALT_SEPARATOR', nil)
|
364
441
|
|
365
|
-
|
442
|
+
allow(Omnibus).to receive(:which)
|
366
443
|
.with('gtar')
|
367
444
|
.and_return('/path/to/gtar')
|
445
|
+
end
|
446
|
+
|
447
|
+
it_behaves_like 'an extractor', '7z', {},
|
448
|
+
['7z x /file.7z -o/tmp/project -r -y']
|
449
|
+
it_behaves_like 'an extractor', 'zip', {},
|
450
|
+
['unzip /file.zip -d /tmp/project']
|
451
|
+
it_behaves_like 'an extractor', 'tar', {},
|
452
|
+
['gtar xf /file.tar -C/tmp/project']
|
453
|
+
it_behaves_like 'an extractor', 'tgz', {},
|
454
|
+
['gtar zxf /file.tgz -C/tmp/project']
|
455
|
+
it_behaves_like 'an extractor', 'tar.gz', {},
|
456
|
+
['gtar zxf /file.tar.gz -C/tmp/project']
|
457
|
+
it_behaves_like 'an extractor', 'tar.bz2', {},
|
458
|
+
['gtar jxf /file.tar.bz2 -C/tmp/project']
|
459
|
+
it_behaves_like 'an extractor', 'txz', {},
|
460
|
+
['gtar Jxf /file.txz -C/tmp/project']
|
461
|
+
it_behaves_like 'an extractor', 'tar.xz', {},
|
462
|
+
['gtar Jxf /file.tar.xz -C/tmp/project']
|
463
|
+
it_behaves_like 'an extractor', 'tar.lzma', {},
|
464
|
+
['gtar --lzma -xf /file.tar.lzma -C/tmp/project']
|
368
465
|
end
|
369
466
|
|
370
|
-
it_behaves_like 'an extractor', '7z', '7z x /file.7z -o/tmp/out -r -y'
|
371
|
-
it_behaves_like 'an extractor', 'zip', 'unzip /file.zip -d /tmp/out'
|
372
|
-
it_behaves_like 'an extractor', 'tar', 'gtar xf /file.tar -C/tmp/out'
|
373
|
-
it_behaves_like 'an extractor', 'tgz', 'gtar zxf /file.tgz -C/tmp/out'
|
374
|
-
it_behaves_like 'an extractor', 'tar.gz', 'gtar zxf /file.tar.gz -C/tmp/out'
|
375
|
-
it_behaves_like 'an extractor', 'bz2', 'gtar jxf /file.bz2 -C/tmp/out'
|
376
|
-
it_behaves_like 'an extractor', 'tar.bz2', 'gtar jxf /file.tar.bz2 -C/tmp/out'
|
377
|
-
it_behaves_like 'an extractor', 'txz', 'gtar Jxf /file.txz -C/tmp/out'
|
378
|
-
it_behaves_like 'an extractor', 'tar.xz', 'gtar Jxf /file.tar.xz -C/tmp/out'
|
379
467
|
end
|
380
468
|
end
|
381
469
|
end
|
@@ -47,39 +47,8 @@ module Omnibus
|
|
47
47
|
end
|
48
48
|
|
49
49
|
describe '#clean' do
|
50
|
-
|
51
|
-
|
52
|
-
allow(subject).to receive(:fetch)
|
53
|
-
end
|
54
|
-
|
55
|
-
context 'when the directory exists' do
|
56
|
-
before do
|
57
|
-
allow(File).to receive(:exist?).with(project_dir).and_return(true)
|
58
|
-
end
|
59
|
-
|
60
|
-
it 'removes the directory' do
|
61
|
-
expect(FileUtils).to receive(:rm_rf).with(project_dir).once
|
62
|
-
subject.clean
|
63
|
-
end
|
64
|
-
|
65
|
-
it 'returns true' do
|
66
|
-
expect(subject.clean).to be_truthy
|
67
|
-
end
|
68
|
-
end
|
69
|
-
|
70
|
-
context 'when the directory does not exist' do
|
71
|
-
before do
|
72
|
-
allow(File).to receive(:exist?).with(project_dir).and_return(false)
|
73
|
-
end
|
74
|
-
|
75
|
-
it 'does not remove the directory' do
|
76
|
-
expect(FileUtils).to_not receive(:rm_rf)
|
77
|
-
subject.clean
|
78
|
-
end
|
79
|
-
|
80
|
-
it 'returns false' do
|
81
|
-
expect(subject.clean).to be(false)
|
82
|
-
end
|
50
|
+
it 'returns true' do
|
51
|
+
expect(subject.clean).to be_truthy
|
83
52
|
end
|
84
53
|
end
|
85
54
|
|
@@ -100,11 +69,11 @@ module Omnibus
|
|
100
69
|
|
101
70
|
before do
|
102
71
|
allow(subject).to receive(:digest_directory)
|
103
|
-
.with(
|
72
|
+
.with(source_path, :sha256, {})
|
104
73
|
.and_return(shasum)
|
105
74
|
end
|
106
75
|
|
107
|
-
it 'returns the shasum of the
|
76
|
+
it 'returns the shasum of the source directory' do
|
108
77
|
expect(subject.version_for_cache).to eq("path:#{source_path}|shasum:#{shasum}")
|
109
78
|
end
|
110
79
|
end
|