omnibus 5.5.0 → 5.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (102) hide show
  1. checksums.yaml +4 -4
  2. data/.github/PULL_REQUEST_TEMPLATE.md +11 -0
  3. data/.travis.yml +2 -1
  4. data/CHANGELOG.md +37 -0
  5. data/Gemfile +5 -4
  6. data/MAINTAINERS.md +12 -17
  7. data/README.md +98 -107
  8. data/appveyor.yml +1 -1
  9. data/lib/omnibus.rb +4 -4
  10. data/lib/omnibus/builder.rb +42 -9
  11. data/lib/omnibus/cli.rb +5 -0
  12. data/lib/omnibus/cli/base.rb +1 -1
  13. data/lib/omnibus/cli/publish.rb +5 -3
  14. data/lib/omnibus/compressors/dmg.rb +2 -2
  15. data/lib/omnibus/config.rb +42 -5
  16. data/lib/omnibus/core_extensions/open_uri.rb +1 -0
  17. data/lib/omnibus/download_helpers.rb +4 -4
  18. data/lib/omnibus/fetchers/git_fetcher.rb +15 -5
  19. data/lib/omnibus/fetchers/net_fetcher.rb +1 -1
  20. data/lib/omnibus/fetchers/path_fetcher.rb +1 -1
  21. data/lib/omnibus/file_syncer.rb +2 -2
  22. data/lib/omnibus/generator_files/omnibus.rb.erb +1 -0
  23. data/lib/omnibus/git_cache.rb +31 -13
  24. data/lib/omnibus/health_check.rb +1 -173
  25. data/lib/omnibus/licensing.rb +48 -7
  26. data/lib/omnibus/manifest.rb +3 -5
  27. data/lib/omnibus/manifest_entry.rb +1 -1
  28. data/lib/omnibus/metadata.rb +2 -1
  29. data/lib/omnibus/packager.rb +3 -1
  30. data/lib/omnibus/packagers/appx.rb +3 -3
  31. data/lib/omnibus/packagers/base.rb +9 -0
  32. data/lib/omnibus/packagers/bff.rb +4 -6
  33. data/lib/omnibus/packagers/deb.rb +95 -1
  34. data/lib/omnibus/packagers/ips.rb +50 -4
  35. data/lib/omnibus/packagers/pkgsrc.rb +112 -0
  36. data/lib/omnibus/packagers/rpm.rb +72 -3
  37. data/lib/omnibus/packagers/solaris.rb +0 -4
  38. data/lib/omnibus/packagers/windows_base.rb +1 -1
  39. data/lib/omnibus/project.rb +13 -3
  40. data/lib/omnibus/publishers/artifactory_publisher.rb +4 -6
  41. data/lib/omnibus/publishers/s3_publisher.rb +8 -3
  42. data/lib/omnibus/reports.rb +1 -1
  43. data/lib/omnibus/s3_cache.rb +18 -5
  44. data/lib/omnibus/s3_helpers.rb +45 -8
  45. data/lib/omnibus/software.rb +55 -37
  46. data/lib/omnibus/sugarable.rb +4 -0
  47. data/lib/omnibus/templating.rb +29 -13
  48. data/lib/omnibus/util.rb +81 -2
  49. data/lib/omnibus/version.rb +1 -1
  50. data/lib/omnibus/whitelist.rb +228 -0
  51. data/omnibus.gemspec +9 -8
  52. data/resources/dmg/create_dmg.osascript.erb +33 -13
  53. data/resources/ips/doc-transform.erb +2 -0
  54. data/resources/rpm/spec.erb +1 -2
  55. data/spec/functional/builder_spec.rb +21 -21
  56. data/spec/functional/fetchers/git_fetcher_spec.rb +6 -6
  57. data/spec/functional/fetchers/net_fetcher_spec.rb +7 -7
  58. data/spec/functional/fetchers/path_fetcher_spec.rb +5 -5
  59. data/spec/functional/file_syncer_spec.rb +6 -6
  60. data/spec/functional/licensing_spec.rb +29 -16
  61. data/spec/functional/templating_spec.rb +23 -22
  62. data/spec/support/git_helpers.rb +30 -24
  63. data/spec/unit/build_version_spec.rb +1 -1
  64. data/spec/unit/builder_spec.rb +36 -24
  65. data/spec/unit/changelogprinter_spec.rb +10 -8
  66. data/spec/unit/cleanroom_spec.rb +6 -6
  67. data/spec/unit/compressors/dmg_spec.rb +23 -37
  68. data/spec/unit/compressors/null_spec.rb +2 -2
  69. data/spec/unit/compressors/tgz_spec.rb +2 -2
  70. data/spec/unit/config_spec.rb +2 -1
  71. data/spec/unit/digestable_spec.rb +2 -2
  72. data/spec/unit/fetchers/git_fetcher_spec.rb +5 -5
  73. data/spec/unit/fetchers/net_fetcher_spec.rb +46 -6
  74. data/spec/unit/fetchers/path_fetcher_spec.rb +5 -5
  75. data/spec/unit/file_syncer_spec.rb +19 -0
  76. data/spec/unit/git_cache_spec.rb +76 -22
  77. data/spec/unit/health_check_spec.rb +1 -1
  78. data/spec/unit/library_spec.rb +2 -2
  79. data/spec/unit/manifest_spec.rb +6 -6
  80. data/spec/unit/metadata_spec.rb +4 -4
  81. data/spec/unit/omnibus_spec.rb +4 -4
  82. data/spec/unit/package_spec.rb +6 -6
  83. data/spec/unit/packagers/appx_spec.rb +16 -12
  84. data/spec/unit/packagers/base_spec.rb +5 -5
  85. data/spec/unit/packagers/bff_spec.rb +45 -15
  86. data/spec/unit/packagers/deb_spec.rb +95 -17
  87. data/spec/unit/packagers/ips_spec.rb +61 -17
  88. data/spec/unit/packagers/makeself_spec.rb +5 -5
  89. data/spec/unit/packagers/msi_spec.rb +43 -43
  90. data/spec/unit/packagers/pkg_spec.rb +15 -15
  91. data/spec/unit/packagers/pkgsrc_spec.rb +77 -0
  92. data/spec/unit/packagers/rpm_spec.rb +94 -17
  93. data/spec/unit/packagers/solaris_spec.rb +11 -11
  94. data/spec/unit/project_spec.rb +53 -22
  95. data/spec/unit/publisher_spec.rb +2 -2
  96. data/spec/unit/publishers/artifactory_publisher_spec.rb +7 -3
  97. data/spec/unit/publishers/s3_publisher_spec.rb +1 -1
  98. data/spec/unit/s3_helpers_spec.rb +41 -3
  99. data/spec/unit/software_spec.rb +115 -37
  100. data/spec/unit/sugarable_spec.rb +23 -3
  101. data/spec/unit/util_spec.rb +42 -11
  102. metadata +49 -29
@@ -87,7 +87,7 @@ module Omnibus
87
87
  end
88
88
  end
89
89
 
90
- describe '#install_dir' do
90
+ describe "#install_dir" do
91
91
  it "removes duplicate slashes" do
92
92
  subject.install_dir("///opt//chef")
93
93
  expect(subject.install_dir).to eq("/opt/chef")
@@ -108,7 +108,7 @@ module Omnibus
108
108
  end
109
109
  end
110
110
 
111
- describe '#default_root' do
111
+ describe "#default_root" do
112
112
  context "on Windows" do
113
113
  before { stub_ohai(platform: "windows", version: "2012") }
114
114
 
@@ -145,19 +145,19 @@ module Omnibus
145
145
  end
146
146
  end
147
147
 
148
- describe '#license' do
148
+ describe "#license" do
149
149
  it "sets the default to Unspecified" do
150
150
  expect(subject.license).to eq ("Unspecified")
151
151
  end
152
152
  end
153
153
 
154
- describe '#license_file_path' do
154
+ describe "#license_file_path" do
155
155
  it "sets the default to LICENSE" do
156
156
  expect(subject.license_file_path).to eq ("/sample/LICENSE")
157
157
  end
158
158
  end
159
159
 
160
- describe '#dirty!' do
160
+ describe "#dirty!" do
161
161
  let(:software) { double(Omnibus::Software) }
162
162
 
163
163
  it "dirties the cache" do
@@ -173,7 +173,7 @@ module Omnibus
173
173
  end
174
174
  end
175
175
 
176
- describe '#dirty?' do
176
+ describe "#dirty?" do
177
177
  it "returns true by default" do
178
178
  subject.instance_variable_set(:@culprit, nil)
179
179
  expect(subject).to_not be_dirty
@@ -190,7 +190,7 @@ module Omnibus
190
190
  end
191
191
  end
192
192
 
193
- describe '#<=>' do
193
+ describe "#<=>" do
194
194
  let(:chefdk) { described_class.new.tap { |p| p.name("chefdk") } }
195
195
  let(:chef) { described_class.new.tap { |p| p.name("chef") } }
196
196
  let(:ruby) { described_class.new.tap { |p| p.name("ruby") } }
@@ -201,7 +201,7 @@ module Omnibus
201
201
  end
202
202
  end
203
203
 
204
- describe '#build_iteration' do
204
+ describe "#build_iteration" do
205
205
  let(:fauxhai_options) { Hash.new }
206
206
 
207
207
  before { stub_ohai(fauxhai_options) }
@@ -243,20 +243,20 @@ module Omnibus
243
243
  end
244
244
  end
245
245
 
246
- describe '#overrides' do
246
+ describe "#overrides" do
247
247
  before { subject.overrides.clear }
248
248
 
249
- it 'sets all the things through #overrides' do
249
+ it "sets all the things through #overrides" do
250
250
  subject.override(:thing, version: "6.6.6")
251
251
  expect(subject.override(:zlib)).to be_nil
252
252
  end
253
253
 
254
- it 'retrieves the things set through #overrides' do
254
+ it "retrieves the things set through #overrides" do
255
255
  subject.override(:thing, version: "6.6.6")
256
256
  expect(subject.override(:thing)[:version]).to eq("6.6.6")
257
257
  end
258
258
 
259
- it 'symbolizes #overrides' do
259
+ it "symbolizes #overrides" do
260
260
  subject.override("thing", version: "6.6.6")
261
261
  [:thing, "thing"].each do |thing|
262
262
  expect(subject.override(thing)).not_to be_nil
@@ -265,7 +265,7 @@ module Omnibus
265
265
  end
266
266
  end
267
267
 
268
- describe '#ohai' do
268
+ describe "#ohai" do
269
269
  before { stub_ohai(platform: "ubuntu", version: "12.04") }
270
270
 
271
271
  it "is a DSL method" do
@@ -277,21 +277,21 @@ module Omnibus
277
277
  end
278
278
  end
279
279
 
280
- describe '#packagers_for_system' do
280
+ describe "#packagers_for_system" do
281
281
  it "returns array of packager objects" do
282
282
  subject.packagers_for_system.each do |packager|
283
283
  expect(packager).to be_a(Packager::Base)
284
284
  end
285
285
  end
286
286
 
287
- it 'calls Packager#for_current_system' do
287
+ it "calls Packager#for_current_system" do
288
288
  expect(Packager).to receive(:for_current_system)
289
289
  .and_call_original
290
290
  subject.packagers_for_system
291
291
  end
292
292
  end
293
293
 
294
- describe '#package' do
294
+ describe "#package" do
295
295
  it "raises an exception when a block is not given" do
296
296
  expect { subject.package(:foo) }.to raise_error(InvalidValue)
297
297
  end
@@ -312,7 +312,7 @@ module Omnibus
312
312
  end
313
313
  end
314
314
 
315
- describe '#packagers' do
315
+ describe "#packagers" do
316
316
  it "returns a Hash" do
317
317
  expect(subject.packagers).to be_a(Hash)
318
318
  end
@@ -323,12 +323,12 @@ module Omnibus
323
323
  end
324
324
  end
325
325
 
326
- describe '#compressor' do
326
+ describe "#compressor" do
327
327
  it "returns a compressor object" do
328
328
  expect(subject.compressor).to be_a(Compressor::Base)
329
329
  end
330
330
 
331
- it 'calls Compressor#for_current_system' do
331
+ it "calls Compressor#for_current_system" do
332
332
  expect(Compressor).to receive(:for_current_system)
333
333
  .and_call_original
334
334
 
@@ -347,7 +347,7 @@ module Omnibus
347
347
  end
348
348
  end
349
349
 
350
- describe '#compress' do
350
+ describe "#compress" do
351
351
  it "does not raises an exception when a block is not given" do
352
352
  expect { subject.compress(:foo) }.to_not raise_error
353
353
  end
@@ -373,7 +373,7 @@ module Omnibus
373
373
  end
374
374
  end
375
375
 
376
- describe '#compressors' do
376
+ describe "#compressors" do
377
377
  it "returns a Hash" do
378
378
  expect(subject.compressors).to be_a(Hash)
379
379
  end
@@ -384,7 +384,7 @@ module Omnibus
384
384
  end
385
385
  end
386
386
 
387
- describe '#shasum' do
387
+ describe "#shasum" do
388
388
  context "when a filepath is given" do
389
389
  let(:path) { "/project.rb" }
390
390
  let(:file) { double(File) }
@@ -413,5 +413,36 @@ module Omnibus
413
413
  end
414
414
  end
415
415
  end
416
+
417
+ describe "#restore_complete_build" do
418
+ let(:cached_build) { double(GitCache) }
419
+ let(:first_software) { double(Omnibus::Software) }
420
+ let(:last_software) { double(Omnibus::Software) }
421
+
422
+ before do
423
+ allow(Config).to receive(:use_git_caching).and_return(git_caching)
424
+ end
425
+
426
+ context "when git caching is enabled" do
427
+ let(:git_caching) { true }
428
+
429
+ it "restores the last software built" do
430
+ expect(subject).to receive(:softwares).and_return([first_software, last_software])
431
+ expect(GitCache).to receive(:new).with(last_software).and_return(cached_build)
432
+ expect(cached_build).to receive(:restore_from_cache)
433
+ subject.restore_complete_build
434
+ end
435
+ end
436
+
437
+ context "when git caching is disabled" do
438
+ let(:git_caching) { false }
439
+
440
+ it "does nothing" do
441
+ expect(subject).not_to receive(:softwares)
442
+ expect(GitCache).not_to receive(:new)
443
+ subject.restore_complete_build
444
+ end
445
+ end
446
+ end
416
447
  end
417
448
  end
@@ -24,7 +24,7 @@ module Omnibus
24
24
 
25
25
  subject { described_class.new(pattern, options) }
26
26
 
27
- describe '#packages' do
27
+ describe "#packages" do
28
28
  let(:a) { "/path/to/files/a.deb" }
29
29
  let(:b) { "/path/to/files/b.deb" }
30
30
  let(:glob) { [a, b] }
@@ -185,7 +185,7 @@ module Omnibus
185
185
 
186
186
  end
187
187
 
188
- describe '#publish' do
188
+ describe "#publish" do
189
189
  it "is an abstract method" do
190
190
  expect { subject.publish }.to raise_error(NotImplementedError)
191
191
  end
@@ -112,6 +112,10 @@ module Omnibus
112
112
  "omnibus.sha512" => "SHA512",
113
113
  "omnibus.version" => "11.0.6",
114
114
  "omnibus.license" => "Apache-2.0",
115
+ "md5" => "ABCDEF123456",
116
+ "sha1" => "SHA1",
117
+ "sha256" => "SHA256",
118
+ "sha512" => "SHA512",
115
119
  }
116
120
  end
117
121
  let(:metadata_json_properites) do
@@ -137,7 +141,7 @@ module Omnibus
137
141
 
138
142
  subject { described_class.new(path, options) }
139
143
 
140
- describe '#publish' do
144
+ describe "#publish" do
141
145
  before do
142
146
  allow(subject).to receive(:packages).and_return(packages)
143
147
  Config.artifactory_base_path("com/getchef")
@@ -191,7 +195,7 @@ module Omnibus
191
195
  # raise an exception a set number of times.
192
196
  @times = 0
193
197
  allow(artifact).to receive(:upload) do
194
- @times += 1;
198
+ @times += 1
195
199
  raise Artifactory::Error::HTTPError.new("status" => "409", "message" => "CONFLICT") unless @times > 1
196
200
  end
197
201
  end
@@ -246,7 +250,7 @@ module Omnibus
246
250
  end
247
251
  end
248
252
 
249
- describe '#metadata_properties_for' do
253
+ describe "#metadata_properties_for" do
250
254
  it "returns the transformed package metadata values" do
251
255
  expect(subject.send(:metadata_properties_for, package)).to include(package_properties.merge(build_values))
252
256
  end
@@ -40,7 +40,7 @@ module Omnibus
40
40
 
41
41
  subject { described_class.new(path) }
42
42
 
43
- describe '#publish' do
43
+ describe "#publish" do
44
44
  before { allow(subject).to receive(:packages).and_return(packages) }
45
45
 
46
46
  it "validates the package" do
@@ -5,8 +5,8 @@ module Omnibus
5
5
  describe S3Helpers do
6
6
  include Omnibus::S3Helpers
7
7
 
8
- context 'when #s3_configuration is not defined' do
9
- describe '#client' do
8
+ context "when #s3_configuration is not defined" do
9
+ describe "#client" do
10
10
  it "raises an error if it is not overridden" do
11
11
  expect { s3_configuration }.to raise_error(RuntimeError,
12
12
  "You must override s3_configuration")
@@ -19,7 +19,7 @@ module Omnibus
19
19
  end
20
20
  end
21
21
 
22
- describe '#to_base64_digest' do
22
+ describe "#to_base64_digest" do
23
23
  it 'turns "c3b5247592ce694f7097873aa07d66fe" into "w7UkdZLOaU9wl4c6oH1m/g=="' do
24
24
  expect(to_base64_digest("c3b5247592ce694f7097873aa07d66fe")).to eql("w7UkdZLOaU9wl4c6oH1m/g==")
25
25
  end
@@ -29,4 +29,42 @@ module Omnibus
29
29
  end
30
30
  end
31
31
  end
32
+
33
+ context "when #s3_configuration is defined" do
34
+ describe "#get_credentials" do
35
+ let(:klass) do
36
+ Class.new do
37
+ include Omnibus::S3Helpers
38
+ end
39
+ end
40
+ let(:instance) { klass.new }
41
+ let(:key_pair) { { access_key_id: "key_id", secret_access_key: "access_key" } }
42
+ let(:profile) { "my-profile" }
43
+ let(:config) { { bucket_name: "foo", region: "us-east-1" } }
44
+
45
+ it "uses configured key pairs" do
46
+ allow_any_instance_of(klass).to receive(:s3_configuration).and_return(config.merge!(key_pair))
47
+ expect(Aws::Credentials).to receive(:new).with(
48
+ config[:access_key_id],
49
+ config[:secret_access_key]
50
+ )
51
+ expect(Aws::SharedCredentials).to_not receive(:new)
52
+ instance.send(:get_credentials)
53
+ end
54
+
55
+ it "preferrs shared credentials profiles over key pairs" do
56
+ allow_any_instance_of(klass).to receive(:s3_configuration).and_return(
57
+ {
58
+ **config,
59
+ **key_pair,
60
+ profile: profile,
61
+ }
62
+ )
63
+ expect(Aws::Credentials).to_not receive(:new)
64
+ allow(Aws::SharedCredentials).to receive(:new).with(profile_name: profile)
65
+ instance.send(:get_credentials)
66
+ end
67
+
68
+ end
69
+ end
32
70
  end
@@ -42,6 +42,7 @@ module Omnibus
42
42
  it_behaves_like "a cleanroom setter", :license, %{license 'Apache 2.0'}
43
43
  it_behaves_like "a cleanroom setter", :license_file, %{license_file 'LICENSES/artistic.txt'}
44
44
  it_behaves_like "a cleanroom setter", :skip_transitive_dependency_licensing, %{skip_transitive_dependency_licensing true}
45
+ it_behaves_like "a cleanroom setter", :dependency_licenses, %{dependency_licenses [{license: "MIT"}]}
45
46
  it_behaves_like "a cleanroom setter", :whitelist_file, %{whitelist_file '/opt/whatever'}
46
47
  it_behaves_like "a cleanroom setter", :relative_path, %{relative_path '/path/to/extracted'}
47
48
  it_behaves_like "a cleanroom setter", :build, %|build {}|
@@ -76,7 +77,8 @@ module Omnibus
76
77
  "CXXFLAGS" => "-I/opt/project/embedded/include -O2",
77
78
  "CPPFLAGS" => "-I/opt/project/embedded/include -O2",
78
79
  "LD_RUN_PATH" => "/opt/project/embedded/lib",
79
- "PKG_CONFIG_PATH" => "/opt/project/embedded/lib/pkgconfig"
80
+ "PKG_CONFIG_PATH" => "/opt/project/embedded/lib/pkgconfig",
81
+ "OMNIBUS_INSTALL_DIR" => "/opt/project"
80
82
  )
81
83
  end
82
84
  it "overrides LDFLAGS" do
@@ -86,7 +88,8 @@ module Omnibus
86
88
  "CXXFLAGS" => "-I/opt/project/embedded/include -O2",
87
89
  "CPPFLAGS" => "-I/opt/project/embedded/include -O2",
88
90
  "LD_RUN_PATH" => "/opt/project/embedded/lib",
89
- "PKG_CONFIG_PATH" => "/opt/project/embedded/lib/pkgconfig"
91
+ "PKG_CONFIG_PATH" => "/opt/project/embedded/lib/pkgconfig",
92
+ "OMNIBUS_INSTALL_DIR" => "/opt/project"
90
93
  )
91
94
  end
92
95
  it "overrides CFLAGS" do
@@ -96,7 +99,8 @@ module Omnibus
96
99
  "CXXFLAGS" => "-I/opt/project/embedded/include -O2",
97
100
  "CPPFLAGS" => "-I/opt/project/embedded/include -O2",
98
101
  "LD_RUN_PATH" => "/opt/project/embedded/lib",
99
- "PKG_CONFIG_PATH" => "/opt/project/embedded/lib/pkgconfig"
102
+ "PKG_CONFIG_PATH" => "/opt/project/embedded/lib/pkgconfig",
103
+ "OMNIBUS_INSTALL_DIR" => "/opt/project"
100
104
  )
101
105
  end
102
106
  it "overrides CXXFLAGS" do
@@ -106,7 +110,8 @@ module Omnibus
106
110
  "CXXFLAGS" => "-I/opt/project/embedded/include -O2",
107
111
  "CPPFLAGS" => "-I/opt/project/embedded/include -O2",
108
112
  "LD_RUN_PATH" => "/opt/project/embedded/lib",
109
- "PKG_CONFIG_PATH" => "/opt/project/embedded/lib/pkgconfig"
113
+ "PKG_CONFIG_PATH" => "/opt/project/embedded/lib/pkgconfig",
114
+ "OMNIBUS_INSTALL_DIR" => "/opt/project"
110
115
  )
111
116
  end
112
117
  it "overrides CPPFLAGS" do
@@ -116,7 +121,8 @@ module Omnibus
116
121
  "CXXFLAGS" => "-I/opt/project/embedded/include -O2",
117
122
  "CPPFLAGS" => "-I/opt/project/embedded/include -O2",
118
123
  "LD_RUN_PATH" => "/opt/project/embedded/lib",
119
- "PKG_CONFIG_PATH" => "/opt/project/embedded/lib/pkgconfig"
124
+ "PKG_CONFIG_PATH" => "/opt/project/embedded/lib/pkgconfig",
125
+ "OMNIBUS_INSTALL_DIR" => "/opt/project"
120
126
  )
121
127
  end
122
128
  it "preserves anything else" do
@@ -127,7 +133,8 @@ module Omnibus
127
133
  "CXXFLAGS" => "-I/opt/project/embedded/include -O2",
128
134
  "CPPFLAGS" => "-I/opt/project/embedded/include -O2",
129
135
  "LD_RUN_PATH" => "/opt/project/embedded/lib",
130
- "PKG_CONFIG_PATH" => "/opt/project/embedded/lib/pkgconfig"
136
+ "PKG_CONFIG_PATH" => "/opt/project/embedded/lib/pkgconfig",
137
+ "OMNIBUS_INSTALL_DIR" => "/opt/project"
131
138
  )
132
139
  end
133
140
  end
@@ -149,7 +156,8 @@ module Omnibus
149
156
  "LDFLAGS" => "-Wl,-rpath,/opt/project/embedded/lib -L/opt/project/embedded/lib -static-libgcc",
150
157
  "LD_OPTIONS" => "-R/opt/project/embedded/lib",
151
158
  "LD_RUN_PATH" => "/opt/project/embedded/lib",
152
- "PKG_CONFIG_PATH" => "/opt/project/embedded/lib/pkgconfig"
159
+ "PKG_CONFIG_PATH" => "/opt/project/embedded/lib/pkgconfig",
160
+ "OMNIBUS_INSTALL_DIR" => "/opt/project"
153
161
  )
154
162
  end
155
163
 
@@ -175,7 +183,8 @@ module Omnibus
175
183
  "LDFLAGS" => "-Wl,-rpath,/opt/project/embedded/lib -L/opt/project/embedded/lib -static-libgcc",
176
184
  "LD_OPTIONS" => "-R/opt/project/embedded/lib",
177
185
  "LD_RUN_PATH" => "/opt/project/embedded/lib",
178
- "PKG_CONFIG_PATH" => "/opt/project/embedded/lib/pkgconfig"
186
+ "PKG_CONFIG_PATH" => "/opt/project/embedded/lib/pkgconfig",
187
+ "OMNIBUS_INSTALL_DIR" => "/opt/project"
179
188
  )
180
189
  end
181
190
  end
@@ -193,12 +202,13 @@ module Omnibus
193
202
  expect(subject.with_standard_compiler_flags).to eq(
194
203
  "CC" => "gcc -static-libgcc",
195
204
  "LDFLAGS" => "-R/opt/project/embedded/lib -L/opt/project/embedded/lib -static-libgcc",
196
- "CFLAGS" => "-I/opt/project/embedded/include",
197
- "CXXFLAGS" => "-I/opt/project/embedded/include",
198
- "CPPFLAGS" => "-I/opt/project/embedded/include",
205
+ "CFLAGS" => "-I/opt/project/embedded/include -O2",
206
+ "CXXFLAGS" => "-I/opt/project/embedded/include -O2",
207
+ "CPPFLAGS" => "-I/opt/project/embedded/include -O2",
199
208
  "LD_RUN_PATH" => "/opt/project/embedded/lib",
200
209
  "LD_OPTIONS" => "-R/opt/project/embedded/lib",
201
- "PKG_CONFIG_PATH" => "/opt/project/embedded/lib/pkgconfig"
210
+ "PKG_CONFIG_PATH" => "/opt/project/embedded/lib/pkgconfig",
211
+ "OMNIBUS_INSTALL_DIR" => "/opt/project"
202
212
  )
203
213
  end
204
214
 
@@ -219,12 +229,13 @@ module Omnibus
219
229
  expect(subject.with_standard_compiler_flags).to eq(
220
230
  "CC" => "gcc -static-libgcc",
221
231
  "LDFLAGS" => "-R/opt/project/embedded/lib -L/opt/project/embedded/lib -static-libgcc",
222
- "CFLAGS" => "-I/opt/project/embedded/include",
223
- "CXXFLAGS" => "-I/opt/project/embedded/include",
224
- "CPPFLAGS" => "-I/opt/project/embedded/include",
232
+ "CFLAGS" => "-I/opt/project/embedded/include -O2",
233
+ "CXXFLAGS" => "-I/opt/project/embedded/include -O2",
234
+ "CPPFLAGS" => "-I/opt/project/embedded/include -O2",
225
235
  "LD_RUN_PATH" => "/opt/project/embedded/lib",
226
236
  "LD_OPTIONS" => "-R/opt/project/embedded/lib -M #{project_root}/files/mapfile/solaris",
227
- "PKG_CONFIG_PATH" => "/opt/project/embedded/lib/pkgconfig"
237
+ "PKG_CONFIG_PATH" => "/opt/project/embedded/lib/pkgconfig",
238
+ "OMNIBUS_INSTALL_DIR" => "/opt/project"
228
239
  )
229
240
  end
230
241
  end
@@ -240,7 +251,8 @@ module Omnibus
240
251
  "CXXFLAGS" => "-I/opt/project/embedded/include -O2",
241
252
  "CPPFLAGS" => "-I/opt/project/embedded/include -O2",
242
253
  "LD_RUN_PATH" => "/opt/project/embedded/lib",
243
- "PKG_CONFIG_PATH" => "/opt/project/embedded/lib/pkgconfig"
254
+ "PKG_CONFIG_PATH" => "/opt/project/embedded/lib/pkgconfig",
255
+ "OMNIBUS_INSTALL_DIR" => "/opt/project"
244
256
  )
245
257
  end
246
258
  end
@@ -265,7 +277,8 @@ module Omnibus
265
277
  "OBJECT_MODE" => "64",
266
278
  "ARFLAGS" => "-X64 cru",
267
279
  "LD_RUN_PATH" => "/opt/project/embedded/lib",
268
- "PKG_CONFIG_PATH" => "/opt/project/embedded/lib/pkgconfig"
280
+ "PKG_CONFIG_PATH" => "/opt/project/embedded/lib/pkgconfig",
281
+ "OMNIBUS_INSTALL_DIR" => "/opt/project"
269
282
  )
270
283
  end
271
284
  end
@@ -282,7 +295,8 @@ module Omnibus
282
295
  "CPPFLAGS" => "-I/opt/project/embedded/include -O2",
283
296
  "LDFLAGS" => "-L/opt/project/embedded/lib",
284
297
  "LD_RUN_PATH" => "/opt/project/embedded/lib",
285
- "PKG_CONFIG_PATH" => "/opt/project/embedded/lib/pkgconfig"
298
+ "PKG_CONFIG_PATH" => "/opt/project/embedded/lib/pkgconfig",
299
+ "OMNIBUS_INSTALL_DIR" => "/opt/project"
286
300
  )
287
301
  end
288
302
 
@@ -300,7 +314,9 @@ module Omnibus
300
314
  "CPPFLAGS" => "-I/opt/project/embedded/include -O2",
301
315
  "LDFLAGS" => "-L/opt/project/embedded/lib",
302
316
  "LD_RUN_PATH" => "/opt/project/embedded/lib",
303
- "PKG_CONFIG_PATH" => "/opt/project/embedded/lib/pkgconfig" )
317
+ "PKG_CONFIG_PATH" => "/opt/project/embedded/lib/pkgconfig",
318
+ "OMNIBUS_INSTALL_DIR" => "/opt/project"
319
+ )
304
320
  end
305
321
  end
306
322
  end
@@ -319,7 +335,66 @@ module Omnibus
319
335
  "CPPFLAGS" => "-I/opt/project/embedded/include -O2",
320
336
  "LDFLAGS" => "-L/opt/project/embedded/lib",
321
337
  "LD_RUN_PATH" => "/opt/project/embedded/lib",
322
- "PKG_CONFIG_PATH" => "/opt/project/embedded/lib/pkgconfig"
338
+ "PKG_CONFIG_PATH" => "/opt/project/embedded/lib/pkgconfig",
339
+ "OMNIBUS_INSTALL_DIR" => "/opt/project"
340
+ )
341
+ end
342
+ end
343
+
344
+ context "on sles 11" do
345
+ before do
346
+ # sles identifies as suse
347
+ stub_ohai(platform: "suse", version: "11.4")
348
+ end
349
+ it "sets the defaults" do
350
+ expect(subject.with_standard_compiler_flags).to eq(
351
+ "LDFLAGS" => "-Wl,-rpath,/opt/project/embedded/lib -L/opt/project/embedded/lib",
352
+ "CFLAGS" => "-I/opt/project/embedded/include -O2",
353
+ "CXXFLAGS" => "-I/opt/project/embedded/include -O2",
354
+ "CPPFLAGS" => "-I/opt/project/embedded/include -O2",
355
+ "LD_RUN_PATH" => "/opt/project/embedded/lib",
356
+ "PKG_CONFIG_PATH" => "/opt/project/embedded/lib/pkgconfig",
357
+ "OMNIBUS_INSTALL_DIR" => "/opt/project"
358
+ )
359
+ end
360
+
361
+ context "with gcc 4.8 installed" do
362
+
363
+ before do
364
+ allow(subject).to receive(:which).and_return("/usr/bin/gcc-4.8")
365
+ end
366
+
367
+ it "sets the compiler args" do
368
+ expect(subject.with_standard_compiler_flags).to eq(
369
+ "CC" => "gcc-4.8",
370
+ "CXX" => "g++-4.8",
371
+ "LDFLAGS" => "-Wl,-rpath,/opt/project/embedded/lib -L/opt/project/embedded/lib",
372
+ "CFLAGS" => "-I/opt/project/embedded/include -O2",
373
+ "CXXFLAGS" => "-I/opt/project/embedded/include -O2",
374
+ "CPPFLAGS" => "-I/opt/project/embedded/include -O2",
375
+ "LD_RUN_PATH" => "/opt/project/embedded/lib",
376
+ "PKG_CONFIG_PATH" => "/opt/project/embedded/lib/pkgconfig",
377
+ "OMNIBUS_INSTALL_DIR" => "/opt/project"
378
+ )
379
+ end
380
+ end
381
+ end
382
+
383
+ context "on sles 12" do
384
+ before do
385
+ # sles identifies as suse
386
+ stub_ohai(platform: "suse", version: "12.1")
387
+ end
388
+
389
+ it "sets the defaults" do
390
+ expect(subject.with_standard_compiler_flags).to eq(
391
+ "LDFLAGS" => "-Wl,-rpath,/opt/project/embedded/lib -L/opt/project/embedded/lib",
392
+ "CFLAGS" => "-I/opt/project/embedded/include -O2",
393
+ "CXXFLAGS" => "-I/opt/project/embedded/include -O2",
394
+ "CPPFLAGS" => "-I/opt/project/embedded/include -O2",
395
+ "LD_RUN_PATH" => "/opt/project/embedded/lib",
396
+ "PKG_CONFIG_PATH" => "/opt/project/embedded/lib/pkgconfig",
397
+ "OMNIBUS_INSTALL_DIR" => "/opt/project"
323
398
  )
324
399
  end
325
400
  end
@@ -335,12 +410,13 @@ module Omnibus
335
410
  context "in 32-bit mode" do
336
411
  it "sets the default" do
337
412
  expect(subject.with_standard_compiler_flags).to eq(
338
- "CFLAGS" => "-I/opt/project/embedded/include -m32 -O2 -fno-lto -march=i686",
339
- "CXXFLAGS" => "-I/opt/project/embedded/include -m32 -O2 -fno-lto -march=i686",
340
- "CPPFLAGS" => "-I/opt/project/embedded/include -m32 -O2 -fno-lto -march=i686",
413
+ "CFLAGS" => "-I/opt/project/embedded/include -m32 -O3 -march=i686",
414
+ "CXXFLAGS" => "-I/opt/project/embedded/include -m32 -O3 -march=i686",
415
+ "CPPFLAGS" => "-I/opt/project/embedded/include -m32 -O3 -march=i686",
341
416
  "LDFLAGS" => "-L/opt/project/embedded/lib -m32 -fno-lto",
342
417
  "LD_RUN_PATH" => "/opt/project/embedded/lib",
343
- "PKG_CONFIG_PATH" => "/opt/project/embedded/lib/pkgconfig"
418
+ "PKG_CONFIG_PATH" => "/opt/project/embedded/lib/pkgconfig",
419
+ "OMNIBUS_INSTALL_DIR" => "/opt/project"
344
420
  )
345
421
  end
346
422
  end
@@ -350,12 +426,13 @@ module Omnibus
350
426
 
351
427
  it "sets the default" do
352
428
  expect(subject.with_standard_compiler_flags).to eq(
353
- "CFLAGS" => "-I/opt/project/embedded/include -m64 -O2 -fno-lto -march=x86-64",
354
- "CXXFLAGS" => "-I/opt/project/embedded/include -m64 -O2 -fno-lto -march=x86-64",
355
- "CPPFLAGS" => "-I/opt/project/embedded/include -m64 -O2 -fno-lto -march=x86-64",
429
+ "CFLAGS" => "-I/opt/project/embedded/include -m64 -O3 -march=x86-64",
430
+ "CXXFLAGS" => "-I/opt/project/embedded/include -m64 -O3 -march=x86-64",
431
+ "CPPFLAGS" => "-I/opt/project/embedded/include -m64 -O3 -march=x86-64",
356
432
  "LDFLAGS" => "-L/opt/project/embedded/lib -m64 -fno-lto",
357
433
  "LD_RUN_PATH" => "/opt/project/embedded/lib",
358
- "PKG_CONFIG_PATH" => "/opt/project/embedded/lib/pkgconfig"
434
+ "PKG_CONFIG_PATH" => "/opt/project/embedded/lib/pkgconfig",
435
+ "OMNIBUS_INSTALL_DIR" => "/opt/project"
359
436
  )
360
437
  end
361
438
  end
@@ -425,9 +502,10 @@ module Omnibus
425
502
  allow(ENV).to receive(:keys).and_return(%w{ Path PATH })
426
503
  end
427
504
 
428
- it "returns a path key of `Path`" do
429
- expect(subject.with_embedded_path).to eq(
430
- "Path" => prepended_path
505
+ it "and raises an error when PATH is also set" do
506
+ expect { subject.with_embedded_path }.to raise_error(
507
+ RuntimeError,
508
+ "The current omnibus environment has multiple PATH/Path variables."
431
509
  )
432
510
  end
433
511
  end
@@ -446,7 +524,7 @@ module Omnibus
446
524
  end
447
525
  end
448
526
 
449
- describe '#ohai' do
527
+ describe "#ohai" do
450
528
  before { stub_ohai(platform: "ubuntu", version: "12.04") }
451
529
 
452
530
  it "is a DSL method" do
@@ -516,7 +594,7 @@ module Omnibus
516
594
  end
517
595
  end
518
596
 
519
- describe '#<=>' do
597
+ describe "#<=>" do
520
598
  let(:zlib) { described_class.new(project).tap { |s| s.name("zlib") } }
521
599
  let(:erchef) { described_class.new(project).tap { |s| s.name("erchef") } }
522
600
  let(:bacon) { described_class.new(project).tap { |s| s.name("bacon") } }
@@ -527,7 +605,7 @@ module Omnibus
527
605
  end
528
606
  end
529
607
 
530
- describe '#whitelist_file' do
608
+ describe "#whitelist_file" do
531
609
  it "appends to the whitelist_files array" do
532
610
  expect(subject.whitelist_files.size).to eq(0)
533
611
  subject.whitelist_file(/foo\/bar/)
@@ -636,7 +714,7 @@ module Omnibus
636
714
  end
637
715
  end
638
716
 
639
- describe '#fetcher' do
717
+ describe "#fetcher" do
640
718
  before do
641
719
  expect(Omnibus::Fetcher).to receive(:resolve_version).with("1.2.3", source).and_return("1.2.8")
642
720
  end
@@ -760,7 +838,7 @@ module Omnibus
760
838
  end
761
839
  end
762
840
 
763
- describe '#shasum' do
841
+ describe "#shasum" do
764
842
  context "when a filepath is given" do
765
843
  let(:path) { "/software.rb" }
766
844
  let(:file) { double(File) }