omnibus 4.0.0 → 4.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (111) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +8 -0
  3. data/.travis.yml +3 -11
  4. data/CHANGELOG.md +50 -0
  5. data/MAINTAINERS.md +26 -0
  6. data/README.md +61 -4
  7. data/appveyor.yml +35 -0
  8. data/docs/Build Cache.md +28 -3
  9. data/docs/Building on RHEL.md +1 -1
  10. data/features/commands/publish.feature +4 -9
  11. data/features/step_definitions/generator_steps.rb +14 -1
  12. data/features/support/env.rb +5 -3
  13. data/lib/omnibus.rb +10 -0
  14. data/lib/omnibus/build_version.rb +34 -25
  15. data/lib/omnibus/build_version_dsl.rb +43 -4
  16. data/lib/omnibus/builder.rb +30 -11
  17. data/lib/omnibus/changelog.rb +52 -0
  18. data/lib/omnibus/changelog_printer.rb +77 -0
  19. data/lib/omnibus/cli.rb +37 -2
  20. data/lib/omnibus/cli/changelog.rb +149 -0
  21. data/lib/omnibus/cli/publish.rb +30 -10
  22. data/lib/omnibus/config.rb +41 -2
  23. data/lib/omnibus/digestable.rb +6 -1
  24. data/lib/omnibus/exceptions.rb +15 -1
  25. data/lib/omnibus/fetcher.rb +78 -34
  26. data/lib/omnibus/fetchers/git_fetcher.rb +84 -42
  27. data/lib/omnibus/fetchers/net_fetcher.rb +64 -13
  28. data/lib/omnibus/fetchers/null_fetcher.rb +8 -1
  29. data/lib/omnibus/fetchers/path_fetcher.rb +24 -1
  30. data/lib/omnibus/file_syncer.rb +52 -1
  31. data/lib/omnibus/generator.rb +22 -21
  32. data/lib/omnibus/generator_files/.kitchen.yml.erb +8 -12
  33. data/lib/omnibus/generator_files/Berksfile.erb +4 -4
  34. data/lib/omnibus/generator_files/Gemfile.erb +3 -3
  35. data/lib/omnibus/generator_files/README.md.erb +17 -0
  36. data/lib/omnibus/generator_files/omnibus.rb.erb +6 -0
  37. data/lib/omnibus/git_repository.rb +43 -0
  38. data/lib/omnibus/health_check.rb +5 -1
  39. data/lib/omnibus/manifest.rb +134 -0
  40. data/lib/omnibus/manifest_diff.rb +88 -0
  41. data/lib/omnibus/manifest_entry.rb +43 -0
  42. data/lib/omnibus/metadata.rb +19 -1
  43. data/lib/omnibus/package.rb +9 -0
  44. data/lib/omnibus/packagers/base.rb +1 -1
  45. data/lib/omnibus/packagers/bff.rb +5 -5
  46. data/lib/omnibus/packagers/deb.rb +11 -4
  47. data/lib/omnibus/packagers/msi.rb +243 -2
  48. data/lib/omnibus/packagers/rpm.rb +68 -14
  49. data/lib/omnibus/packagers/solaris.rb +17 -23
  50. data/lib/omnibus/project.rb +129 -16
  51. data/lib/omnibus/publisher.rb +62 -49
  52. data/lib/omnibus/publishers/artifactory_publisher.rb +96 -5
  53. data/lib/omnibus/publishers/s3_publisher.rb +20 -25
  54. data/lib/omnibus/s3_cache.rb +13 -34
  55. data/lib/omnibus/s3_helpers.rb +119 -0
  56. data/lib/omnibus/semantic_version.rb +57 -0
  57. data/lib/omnibus/software.rb +87 -28
  58. data/lib/omnibus/sugarable.rb +18 -0
  59. data/lib/omnibus/templating.rb +8 -1
  60. data/lib/omnibus/version.rb +1 -1
  61. data/omnibus.gemspec +10 -7
  62. data/resources/bff/gen.template.erb +1 -1
  63. data/resources/msi/bundle.wxs.erb +17 -0
  64. data/resources/msi/localization-en-us.wxl.erb +1 -1
  65. data/resources/rpm/spec.erb +1 -1
  66. data/spec/functional/builder_spec.rb +15 -7
  67. data/spec/functional/fetchers/git_fetcher_spec.rb +44 -12
  68. data/spec/functional/fetchers/net_fetcher_spec.rb +171 -20
  69. data/spec/functional/fetchers/path_fetcher_spec.rb +16 -1
  70. data/spec/functional/file_syncer_spec.rb +58 -5
  71. data/spec/functional/templating_spec.rb +17 -6
  72. data/spec/spec_helper.rb +17 -0
  73. data/spec/support/file_helpers.rb +12 -2
  74. data/spec/support/git_helpers.rb +23 -18
  75. data/spec/support/matchers.rb +22 -0
  76. data/spec/support/output_helpers.rb +29 -0
  77. data/spec/unit/build_version_dsl_spec.rb +31 -4
  78. data/spec/unit/build_version_spec.rb +11 -4
  79. data/spec/unit/builder_spec.rb +33 -0
  80. data/spec/unit/changelog_spec.rb +55 -0
  81. data/spec/unit/cleanroom_spec.rb +1 -1
  82. data/spec/unit/compressors/dmg_spec.rb +3 -3
  83. data/spec/unit/compressors/tgz_spec.rb +3 -3
  84. data/spec/unit/config_spec.rb +3 -1
  85. data/spec/unit/fetcher_spec.rb +35 -0
  86. data/spec/unit/fetchers/git_fetcher_spec.rb +28 -14
  87. data/spec/unit/fetchers/net_fetcher_spec.rb +178 -24
  88. data/spec/unit/fetchers/path_fetcher_spec.rb +8 -7
  89. data/spec/unit/generator_spec.rb +22 -21
  90. data/spec/unit/git_repository_spec.rb +60 -0
  91. data/spec/unit/manifest_diff_spec.rb +75 -0
  92. data/spec/unit/manifest_spec.rb +116 -0
  93. data/spec/unit/metadata_spec.rb +11 -0
  94. data/spec/unit/omnibus_spec.rb +9 -6
  95. data/spec/unit/package_spec.rb +1 -1
  96. data/spec/unit/packagers/base_spec.rb +8 -18
  97. data/spec/unit/packagers/bff_spec.rb +9 -5
  98. data/spec/unit/packagers/deb_spec.rb +44 -12
  99. data/spec/unit/packagers/makeself_spec.rb +4 -4
  100. data/spec/unit/packagers/msi_spec.rb +122 -6
  101. data/spec/unit/packagers/pkg_spec.rb +3 -3
  102. data/spec/unit/packagers/rpm_spec.rb +37 -12
  103. data/spec/unit/project_spec.rb +18 -1
  104. data/spec/unit/publisher_spec.rb +65 -0
  105. data/spec/unit/publishers/artifactory_publisher_spec.rb +26 -20
  106. data/spec/unit/publishers/s3_publisher_spec.rb +14 -30
  107. data/spec/unit/s3_cacher_spec.rb +1 -1
  108. data/spec/unit/s3_helpers_spec.rb +32 -0
  109. data/spec/unit/semantic_version_spec.rb +55 -0
  110. data/spec/unit/software_spec.rb +112 -4
  111. metadata +86 -16
@@ -41,7 +41,9 @@ module Omnibus
41
41
  it_behaves_like 'a cleanroom setter', :exclude, %|exclude 'hamlet'|
42
42
  it_behaves_like 'a cleanroom setter', :config_file, %|config_file '/path/to/config.rb'|
43
43
  it_behaves_like 'a cleanroom setter', :extra_package_file, %|extra_package_file '/path/to/asset'|
44
-
44
+ it_behaves_like 'a cleanroom setter', :text_manifest_path, %|text_manifest_path '/path/to/manifest.txt'|
45
+ it_behaves_like 'a cleanroom setter', :json_manifest_path, %|json_manifest_path '/path/to/manifest.txt'|
46
+ it_behaves_like 'a cleanroom setter', :build_git_revision, %|build_git_revision 'wombats'|
45
47
  it_behaves_like 'a cleanroom getter', :files_path
46
48
 
47
49
  describe 'basics' do
@@ -125,6 +127,21 @@ module Omnibus
125
127
  end
126
128
  end
127
129
 
130
+ describe "build_git_revision" do
131
+ let(:git_repo_subdir_path) do
132
+ path = local_git_repo("foobar", annotated_tags: ["1.0", "2.0", "3.0"])
133
+ subdir_path = File.join(path, "asubdir")
134
+ Dir.mkdir(subdir_path)
135
+ subdir_path
136
+ end
137
+
138
+ it "returns a revision even when running in a subdir" do
139
+ Dir.chdir(git_repo_subdir_path) do
140
+ expect(subject.build_git_revision).to eq("632501dde2c41f3bdd988b818b4c008e2ff398dc")
141
+ end
142
+ end
143
+ end
144
+
128
145
  describe '#dirty!' do
129
146
  let(:software) { double(Omnibus::Software) }
130
147
 
@@ -42,6 +42,71 @@ module Omnibus
42
42
  it 'returns an array of Package objects' do
43
43
  expect(subject.packages.first).to be_a(Package)
44
44
  end
45
+
46
+ context 'a platform mappings matrix is provided' do
47
+ let(:options) do
48
+ {
49
+ platform_mappings: {
50
+ 'ubuntu-12.04' => [
51
+ 'ubuntu-12.04',
52
+ 'ubuntu-14.04',
53
+ ],
54
+ },
55
+ }
56
+ end
57
+
58
+ let(:package) do
59
+ Package.new('/path/to/files/chef.deb')
60
+ end
61
+
62
+ let(:metadata) do
63
+ Metadata.new(package,
64
+ name: 'chef',
65
+ friendly_name: 'Chef',
66
+ homepage: 'https://www.getchef.com',
67
+ version: '11.0.6',
68
+ iteration: 1,
69
+ basename: 'chef.deb',
70
+ platform: 'ubuntu',
71
+ platform_version: '12.04',
72
+ arch: 'x86_64',
73
+ sha1: 'SHA1',
74
+ md5: 'ABCDEF123456',
75
+ )
76
+ end
77
+
78
+ before do
79
+ allow(package).to receive(:metadata).and_return(metadata)
80
+ allow(FileSyncer).to receive_message_chain(:glob, :map).and_return([package])
81
+ end
82
+
83
+ it 'creates a package for each publish platform' do
84
+ expect(subject.packages.size).to eq(2)
85
+ expect(
86
+ subject.packages.map do |p|
87
+ p.metadata[:platform_version]
88
+ end
89
+ ).to include('12.04', '14.04')
90
+ end
91
+
92
+ context 'the build platform does not exist' do
93
+ let(:options) do
94
+ {
95
+ platform_mappings: {
96
+ 'ubuntu-10.04' => [
97
+ 'ubuntu-12.04',
98
+ 'ubuntu-14.04',
99
+ ],
100
+ },
101
+ }
102
+ end
103
+
104
+ it 'prints a warning' do
105
+ output = capture_logging { subject.packages }
106
+ expect(output).to include('Could not locate a package for build platform ubuntu-10.04. Publishing will be skipped for: ubuntu-12.04, ubuntu-14.04')
107
+ end
108
+ end
109
+ end
45
110
  end
46
111
 
47
112
  describe '#publish' do
@@ -34,11 +34,14 @@ module Omnibus
34
34
  let(:packages) { [package] }
35
35
  let(:client) { double('Artifactory::Client') }
36
36
  let(:artifact) { double('Artifactory::Resource::Artifact', upload: nil) }
37
+ let(:build) { double('Artifactory::Resource::Build') }
37
38
 
38
39
  before do
39
40
  allow(subject).to receive(:client).and_return(client)
40
41
  allow(subject).to receive(:artifact_for).and_return(artifact)
42
+ allow(subject).to receive(:build_for).and_return(build)
41
43
  allow(package).to receive(:metadata).and_return(metadata)
44
+ allow(build).to receive(:save)
42
45
  end
43
46
 
44
47
  subject { described_class.new(path, repository: repository) }
@@ -65,6 +68,20 @@ module Omnibus
65
68
  subject.publish
66
69
  end
67
70
 
71
+ it 'it creates a build record for all packages' do
72
+ expect(build).to receive(:save).once
73
+ subject.publish
74
+ end
75
+
76
+ context 'when no packages exist' do
77
+ let(:packages) { [] }
78
+
79
+ it 'does nothing' do
80
+ expect(artifact).to_not receive(:upload)
81
+ expect(build).to_not receive(:save)
82
+ end
83
+ end
84
+
68
85
  context 'when upload fails' do
69
86
  before do
70
87
  Config.publish_retries(3)
@@ -85,26 +102,6 @@ module Omnibus
85
102
 
86
103
  end
87
104
 
88
- context 'when an alternate platform and platform version are provided' do
89
- subject do
90
- described_class.new(path,
91
- repository: repository,
92
- platform: 'debian',
93
- platform_version: '7',
94
- )
95
- end
96
-
97
- it 'overrides the platform and platform version used for publishing' do
98
- expect(artifact).to receive(:upload).with(
99
- repository,
100
- 'com/getchef/chef/11.0.6/debian/7/chef.deb',
101
- an_instance_of(Hash),
102
- ).once
103
-
104
- subject.publish
105
- end
106
- end
107
-
108
105
  context 'when a block is given' do
109
106
  it 'yields the package to the block' do
110
107
  block = ->(package) { package.do_something! }
@@ -112,6 +109,15 @@ module Omnibus
112
109
  subject.publish(&block)
113
110
  end
114
111
  end
112
+
113
+ context 'when the :build_record option is false' do
114
+ subject { described_class.new(path, repository: repository, build_record: false) }
115
+
116
+ it 'does not create a build record at the end of publishing' do
117
+ expect(build).to_not receive(:save)
118
+ subject.publish
119
+ end
120
+ end
115
121
  end
116
122
  end
117
123
  end
@@ -30,11 +30,12 @@ module Omnibus
30
30
 
31
31
  let(:packages) { [package] }
32
32
 
33
- let(:client) { double('UberS3', store: nil) }
33
+ let(:client) { double('Aws::S3::Resource') }
34
34
 
35
35
  before do
36
36
  allow(package).to receive(:metadata).and_return(metadata)
37
37
  allow(subject).to receive(:client).and_return(client)
38
+ allow(subject).to receive(:store_object)
38
39
  end
39
40
 
40
41
  subject { described_class.new(path) }
@@ -48,21 +49,22 @@ module Omnibus
48
49
  end
49
50
 
50
51
  it 'uploads the metadata' do
51
- expect(client).to receive(:store).with(
52
+ expect(subject).to receive(:store_object).with(
52
53
  'ubuntu/14.04/x86_64/chef.deb/chef.deb.metadata.json',
53
54
  package.metadata.to_json,
54
- access: :private,
55
+ nil,
56
+ 'private',
55
57
  ).once
56
58
 
57
59
  subject.publish
58
60
  end
59
61
 
60
62
  it 'uploads the package' do
61
- expect(client).to receive(:store).with(
63
+ expect(subject).to receive(:store_object).with(
62
64
  'ubuntu/14.04/x86_64/chef.deb/chef.deb',
63
65
  package.content,
64
- access: :private,
65
- content_md5: package.metadata[:md5],
66
+ package.metadata[:md5],
67
+ 'private'
66
68
  ).once
67
69
 
68
70
  subject.publish
@@ -72,10 +74,11 @@ module Omnibus
72
74
  subject { described_class.new(path, acl: 'public') }
73
75
 
74
76
  it 'sets the access control to public_read' do
75
- expect(client).to receive(:store).with(
77
+ expect(subject).to receive(:store_object).with(
76
78
  'ubuntu/14.04/x86_64/chef.deb/chef.deb.metadata.json',
77
79
  package.metadata.to_json,
78
- access: :public_read,
80
+ nil,
81
+ 'public-read',
79
82
  ).once
80
83
 
81
84
  subject.publish
@@ -86,30 +89,11 @@ module Omnibus
86
89
  subject { described_class.new(path, acl: 'baconbits') }
87
90
 
88
91
  it 'sets the access control to private' do
89
- expect(client).to receive(:store).with(
92
+ expect(subject).to receive(:store_object).with(
90
93
  'ubuntu/14.04/x86_64/chef.deb/chef.deb.metadata.json',
91
94
  package.metadata.to_json,
92
- access: :private,
93
- ).once
94
-
95
- subject.publish
96
- end
97
- end
98
-
99
- context 'when an alternate platform and platform version are provided' do
100
- subject do
101
- described_class.new(path,
102
- platform: 'debian',
103
- platform_version: '7',
104
- )
105
- end
106
-
107
- it 'overrides the platform and platform version used for publishing' do
108
- expect(client).to receive(:store).with(
109
- 'debian/7/x86_64/chef.deb/chef.deb',
110
- package.content,
111
- access: :private,
112
- content_md5: package.metadata[:md5],
95
+ nil,
96
+ 'private',
113
97
  ).once
114
98
 
115
99
  subject.publish
@@ -43,7 +43,7 @@ module Omnibus
43
43
  before { allow(S3Cache).to receive(:bucket).and_return(bucket) }
44
44
 
45
45
  it 'lists the keys on the S3 bucket' do
46
- expect(bucket).to receive(:objects).with('/').once
46
+ expect(bucket).to receive(:objects).once
47
47
  S3Cache.keys
48
48
  end
49
49
  end
@@ -0,0 +1,32 @@
1
+ require 'spec_helper'
2
+ require 'omnibus/s3_helpers'
3
+
4
+ module Omnibus
5
+ describe S3Helpers do
6
+ include Omnibus::S3Helpers
7
+
8
+ context 'when #s3_configuration is not defined' do
9
+ describe '#client' do
10
+ it 'raises an error if it is not overridden' do
11
+ expect { s3_configuration }.to raise_error(RuntimeError,
12
+ "You must override s3_configuration")
13
+ end
14
+
15
+ it 'raises an error stating that s3_configuration must be overriden' do
16
+ expect { client }.to raise_error(RuntimeError,
17
+ "You must override s3_configuration")
18
+ end
19
+ end
20
+ end
21
+
22
+ describe '#to_base64_digest' do
23
+ it 'turns "c3b5247592ce694f7097873aa07d66fe" into "w7UkdZLOaU9wl4c6oH1m/g=="' do
24
+ expect(to_base64_digest("c3b5247592ce694f7097873aa07d66fe")).to eql('w7UkdZLOaU9wl4c6oH1m/g==')
25
+ end
26
+
27
+ it 'allows a nil input without error' do
28
+ expect(to_base64_digest(nil)).to be_nil
29
+ end
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,55 @@
1
+ #
2
+ # Copyright 2015 Chef Software, Inc.
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+ #
16
+ require 'spec_helper'
17
+
18
+ module Omnibus
19
+ describe SemanticVersion do
20
+
21
+ it "raises an InvalidVersion error if it doesn't understand the format" do
22
+ expect {Omnibus::SemanticVersion.new("wut")}.to raise_error(Omnibus::InvalidVersion)
23
+ end
24
+
25
+ it "preserves leading the leading v when printing the string" do
26
+ v = Omnibus::SemanticVersion.new("v1.0.0")
27
+ expect(v.to_s).to eq("v1.0.0")
28
+ end
29
+
30
+ it "can bump the patch version" do
31
+ v = Omnibus::SemanticVersion.new("1.0.0")
32
+ expect(v.next_patch.to_s).to eq("1.0.1")
33
+ end
34
+
35
+ it "can bump the minor version" do
36
+ v = Omnibus::SemanticVersion.new("1.1.0")
37
+ expect(v.next_minor.to_s).to eq("1.2.0")
38
+ end
39
+
40
+ it "can bump the major version" do
41
+ v = Omnibus::SemanticVersion.new("1.0.0")
42
+ expect(v.next_major.to_s).to eq("2.0.0")
43
+ end
44
+
45
+ it "resets the patch version when bumping minor versions" do
46
+ v = Omnibus::SemanticVersion.new("1.1.1")
47
+ expect(v.next_minor.to_s).to eq("1.2.0")
48
+ end
49
+
50
+ it "resets the patch and minor version when bumping major versions" do
51
+ v = Omnibus::SemanticVersion.new("1.1.1")
52
+ expect(v.next_major.to_s).to eq("2.0.0")
53
+ end
54
+ end
55
+ end
@@ -52,43 +52,58 @@ module Omnibus
52
52
  'LDFLAGS' => '-Wl,-rpath,/opt/project/embedded/lib -L/opt/project/embedded/lib',
53
53
  'CFLAGS' => '-I/opt/project/embedded/include',
54
54
  'CXXFLAGS' => '-I/opt/project/embedded/include',
55
+ 'CPPFLAGS' => '-I/opt/project/embedded/include',
55
56
  'LD_RUN_PATH' => '/opt/project/embedded/lib',
56
57
  'PKG_CONFIG_PATH' => '/opt/project/embedded/lib/pkgconfig'
57
58
  )
58
59
  end
59
- it 'ovesrride LDFLAGS' do
60
+ it 'overrides LDFLAGS' do
60
61
  expect(subject.with_standard_compiler_flags('LDFLAGS' => 'foo')).to eq(
61
62
  'LDFLAGS' => '-Wl,-rpath,/opt/project/embedded/lib -L/opt/project/embedded/lib',
62
63
  'CFLAGS' => '-I/opt/project/embedded/include',
63
64
  'CXXFLAGS' => '-I/opt/project/embedded/include',
65
+ 'CPPFLAGS' => '-I/opt/project/embedded/include',
64
66
  'LD_RUN_PATH' => '/opt/project/embedded/lib',
65
67
  'PKG_CONFIG_PATH' => '/opt/project/embedded/lib/pkgconfig'
66
68
  )
67
69
  end
68
- it 'ovesrride CFLAGS' do
70
+ it 'overrides CFLAGS' do
69
71
  expect(subject.with_standard_compiler_flags('CFLAGS'=>'foo')).to eq(
70
72
  'LDFLAGS' => '-Wl,-rpath,/opt/project/embedded/lib -L/opt/project/embedded/lib',
71
73
  'CFLAGS' => '-I/opt/project/embedded/include',
72
74
  'CXXFLAGS' => '-I/opt/project/embedded/include',
75
+ 'CPPFLAGS' => '-I/opt/project/embedded/include',
73
76
  'LD_RUN_PATH' => '/opt/project/embedded/lib',
74
77
  'PKG_CONFIG_PATH' => '/opt/project/embedded/lib/pkgconfig'
75
78
  )
76
79
  end
77
- it 'ovesrride CXXFLAGS' do
80
+ it 'overrides CXXFLAGS' do
78
81
  expect(subject.with_standard_compiler_flags('CXXFLAGS'=>'foo')).to eq(
79
82
  'LDFLAGS' => '-Wl,-rpath,/opt/project/embedded/lib -L/opt/project/embedded/lib',
80
83
  'CFLAGS' => '-I/opt/project/embedded/include',
81
84
  'CXXFLAGS' => '-I/opt/project/embedded/include',
85
+ 'CPPFLAGS' => '-I/opt/project/embedded/include',
82
86
  'LD_RUN_PATH' => '/opt/project/embedded/lib',
83
87
  'PKG_CONFIG_PATH' => '/opt/project/embedded/lib/pkgconfig'
84
88
  )
85
89
  end
86
- it 'presserve anything else' do
90
+ it 'overrides CPPFLAGS' do
91
+ expect(subject.with_standard_compiler_flags('CPPFLAGS'=>'foo')).to eq(
92
+ 'LDFLAGS' => '-Wl,-rpath,/opt/project/embedded/lib -L/opt/project/embedded/lib',
93
+ 'CFLAGS' => '-I/opt/project/embedded/include',
94
+ 'CXXFLAGS' => '-I/opt/project/embedded/include',
95
+ 'CPPFLAGS' => '-I/opt/project/embedded/include',
96
+ 'LD_RUN_PATH' => '/opt/project/embedded/lib',
97
+ 'PKG_CONFIG_PATH' => '/opt/project/embedded/lib/pkgconfig'
98
+ )
99
+ end
100
+ it 'preserves anything else' do
87
101
  expect(subject.with_standard_compiler_flags('numberwang'=>4)).to eq(
88
102
  'numberwang' => 4,
89
103
  'LDFLAGS' => '-Wl,-rpath,/opt/project/embedded/lib -L/opt/project/embedded/lib',
90
104
  'CFLAGS' => '-I/opt/project/embedded/include',
91
105
  'CXXFLAGS' => '-I/opt/project/embedded/include',
106
+ 'CPPFLAGS' => '-I/opt/project/embedded/include',
92
107
  'LD_RUN_PATH' => '/opt/project/embedded/lib',
93
108
  'PKG_CONFIG_PATH' => '/opt/project/embedded/lib/pkgconfig'
94
109
  )
@@ -109,11 +124,39 @@ module Omnibus
109
124
  'LDFLAGS' => '-R/opt/project/embedded/lib -L/opt/project/embedded/lib -static-libgcc',
110
125
  'CFLAGS' => '-I/opt/project/embedded/include',
111
126
  "CXXFLAGS" => "-I/opt/project/embedded/include",
127
+ "CPPFLAGS" => "-I/opt/project/embedded/include",
112
128
  'LD_RUN_PATH' => '/opt/project/embedded/lib',
113
129
  'LD_OPTIONS' => '-R/opt/project/embedded/lib',
114
130
  'PKG_CONFIG_PATH' => '/opt/project/embedded/lib/pkgconfig'
115
131
  )
116
132
  end
133
+
134
+ context 'when loader mapping file is specified' do
135
+ # Let the unit tests run on windows where auto-path translation occurs.
136
+ let(:project_root) { File.join(tmp_path, '/root/project') }
137
+ before do
138
+ stub_ohai(platform: 'solaris2', version: '5.11') do |data|
139
+ # For some reason, this isn't set in Fauxhai
140
+ data['platform'] = 'solaris2'
141
+ end
142
+ Config.project_root(project_root)
143
+ Config.solaris_linker_mapfile('files/mapfile/solaris')
144
+ allow(File).to receive(:exist?).and_return(true)
145
+ end
146
+
147
+ it 'sets LD_OPTIONS correctly' do
148
+ expect(subject.with_standard_compiler_flags).to eq(
149
+ 'CC' => 'gcc -static-libgcc',
150
+ 'LDFLAGS' => '-R/opt/project/embedded/lib -L/opt/project/embedded/lib -static-libgcc',
151
+ 'CFLAGS' => '-I/opt/project/embedded/include',
152
+ "CXXFLAGS" => "-I/opt/project/embedded/include",
153
+ "CPPFLAGS" => "-I/opt/project/embedded/include",
154
+ 'LD_RUN_PATH' => '/opt/project/embedded/lib',
155
+ 'LD_OPTIONS' => "-R/opt/project/embedded/lib -M #{project_root}/files/mapfile/solaris",
156
+ 'PKG_CONFIG_PATH' => '/opt/project/embedded/lib/pkgconfig'
157
+ )
158
+ end
159
+ end
117
160
  end
118
161
 
119
162
  context 'on mac_os_x' do
@@ -124,6 +167,7 @@ module Omnibus
124
167
  'LDFLAGS' => '-L/opt/project/embedded/lib',
125
168
  'CFLAGS' => '-I/opt/project/embedded/include',
126
169
  "CXXFLAGS" => "-I/opt/project/embedded/include",
170
+ "CPPFLAGS" => "-I/opt/project/embedded/include",
127
171
  'LD_RUN_PATH' => '/opt/project/embedded/lib',
128
172
  'PKG_CONFIG_PATH' => '/opt/project/embedded/lib/pkgconfig'
129
173
  )
@@ -144,6 +188,7 @@ module Omnibus
144
188
  'CXX' => 'xlC_r -q64',
145
189
  'CFLAGS' => '-q64 -I/opt/project/embedded/include -D_LARGE_FILES -O',
146
190
  "CXXFLAGS" => "-q64 -I/opt/project/embedded/include -D_LARGE_FILES -O",
191
+ "CPPFLAGS" => "-q64 -I/opt/project/embedded/include -D_LARGE_FILES -O",
147
192
  'LDFLAGS' => '-q64 -L/opt/project/embedded/lib -Wl,-blibpath:/opt/project/embedded/lib:/usr/lib:/lib',
148
193
  'LD' => 'ld -b64',
149
194
  'OBJECT_MODE' => '64',
@@ -163,6 +208,7 @@ module Omnibus
163
208
  expect(subject.with_standard_compiler_flags).to eq(
164
209
  'CFLAGS' => '-I/opt/project/embedded/include',
165
210
  'CXXFLAGS' => '-I/opt/project/embedded/include',
211
+ 'CPPFLAGS' => '-I/opt/project/embedded/include',
166
212
  'LDFLAGS' => '-L/opt/project/embedded/lib',
167
213
  'LD_RUN_PATH' => '/opt/project/embedded/lib',
168
214
  'PKG_CONFIG_PATH' => '/opt/project/embedded/lib/pkgconfig',
@@ -180,6 +226,7 @@ module Omnibus
180
226
  'CXX' => 'clang++',
181
227
  'CFLAGS' => '-I/opt/project/embedded/include',
182
228
  'CXXFLAGS' => '-I/opt/project/embedded/include',
229
+ 'CPPFLAGS' => '-I/opt/project/embedded/include',
183
230
  'LDFLAGS' => '-L/opt/project/embedded/lib',
184
231
  'LD_RUN_PATH' => '/opt/project/embedded/lib',
185
232
  'PKG_CONFIG_PATH' => '/opt/project/embedded/lib/pkgconfig',
@@ -256,6 +303,9 @@ module Omnibus
256
303
  end
257
304
 
258
305
  context '`Path` does not exist in the environment' do
306
+ before do
307
+ allow(ENV).to receive(:keys).and_return(['PATH'])
308
+ end
259
309
  it 'returns a path key of `PATH`' do
260
310
  expect(subject.with_embedded_path).to eq(
261
311
  'PATH' => prepended_path
@@ -277,6 +327,64 @@ module Omnibus
277
327
  end
278
328
  end
279
329
 
330
+ describe "#manifest_entry" do
331
+ let(:a_source) do
332
+ { url: 'http://example.com/',
333
+ md5: 'abcd1234' }
334
+ end
335
+
336
+ let(:manifest_entry) {Omnibus::ManifestEntry.new("software", {locked_version: "1.2.8", locked_source: a_source})}
337
+ let(:manifest) do
338
+ m = Omnibus::Manifest.new
339
+ m.add("software", manifest_entry)
340
+ end
341
+
342
+ let(:project_with_manifest) do
343
+ described_class.new(project, nil, manifest).evaluate do
344
+ name 'software'
345
+ default_version '1.2.3'
346
+ source url: 'http://example.com/',
347
+ md5: 'abcd1234'
348
+ end
349
+ end
350
+
351
+ let(:project_without_manifest) do
352
+ described_class.new(project, nil, nil).evaluate do
353
+ name 'software'
354
+ default_version '1.2.3'
355
+ source url: 'http://example.com/',
356
+ md5: 'abcd1234'
357
+ end
358
+ end
359
+
360
+ let(:another_project) do
361
+ described_class.new(project, nil, manifest).evaluate do
362
+ name 'ruroh'
363
+ end
364
+ end
365
+
366
+ it "constructs a manifest entry if no manifest was provided" do
367
+ expect(project_without_manifest.manifest_entry).to be_a Omnibus::ManifestEntry
368
+ expect(project_without_manifest.manifest_entry.locked_version).to eq("1.2.3")
369
+ expect(project_without_manifest.manifest_entry.locked_source).to eq(a_source)
370
+ end
371
+
372
+ it "constructs a manifest entry with a fully resolved version" do
373
+ expect(Omnibus::Fetcher).to receive(:resolve_version).with("1.2.3", a_source).and_return("1.2.8")
374
+ expect(project_without_manifest.manifest_entry.locked_version).to eq("1.2.8")
375
+ end
376
+
377
+ it "returns the entry from the user-provided manifest if it was given one" do
378
+ expect(project_with_manifest.manifest_entry).to eq(manifest_entry)
379
+ expect(project_with_manifest.manifest_entry.locked_version).to eq("1.2.8")
380
+ expect(project_with_manifest.manifest_entry.locked_source).to eq(a_source)
381
+ end
382
+
383
+ it "raises an error if it was given a manifest but can't find it's entry" do
384
+ expect{another_project.manifest_entry}.to raise_error(Manifest::MissingManifestEntry)
385
+ end
386
+ end
387
+
280
388
  describe '#<=>' do
281
389
  let(:zlib) { described_class.new(project).tap { |s| s.name('zlib') } }
282
390
  let(:erchef) { described_class.new(project).tap { |s| s.name('erchef') } }