omnibus 3.1.1 → 3.2.0.rc.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (105) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +71 -0
  3. data/Gemfile +0 -7
  4. data/README.md +108 -36
  5. data/Rakefile +1 -5
  6. data/docs/omnibus-build-cache.md +5 -5
  7. data/features/commands/_deprecated.feature +21 -3
  8. data/features/step_definitions/generator_steps.rb +7 -7
  9. data/lib/omnibus.rb +232 -171
  10. data/lib/omnibus/build_version.rb +2 -2
  11. data/lib/omnibus/builder.rb +38 -19
  12. data/lib/omnibus/cleaner.rb +5 -5
  13. data/lib/omnibus/cleanroom.rb +141 -0
  14. data/lib/omnibus/cli.rb +6 -9
  15. data/lib/omnibus/cli/base.rb +2 -1
  16. data/lib/omnibus/cli/cache.rb +15 -21
  17. data/lib/omnibus/cli/deprecated.rb +40 -4
  18. data/lib/omnibus/cli/publish.rb +61 -0
  19. data/lib/omnibus/config.rb +350 -189
  20. data/lib/omnibus/digestable.rb +131 -0
  21. data/lib/omnibus/exceptions.rb +163 -83
  22. data/lib/omnibus/fetcher.rb +1 -1
  23. data/lib/omnibus/fetchers/net_fetcher.rb +19 -13
  24. data/lib/omnibus/fetchers/path_fetcher.rb +8 -1
  25. data/lib/omnibus/fetchers/s3_cache_fetcher.rb +16 -7
  26. data/lib/omnibus/generator.rb +2 -2
  27. data/lib/omnibus/generator_files/Gemfile.erb +4 -1
  28. data/lib/omnibus/generator_files/README.md.erb +10 -0
  29. data/lib/omnibus/generator_files/{omnibus.rb.example.erb → omnibus.rb.erb} +20 -11
  30. data/lib/omnibus/generator_files/package_scripts/makeselfinst.erb +1 -1
  31. data/lib/omnibus/generator_files/project.rb.erb +2 -2
  32. data/lib/omnibus/generator_files/windows_msi/localization-en-us.wxl.erb +3 -3
  33. data/lib/omnibus/git_cache.rb +192 -0
  34. data/lib/omnibus/health_check.rb +171 -116
  35. data/lib/omnibus/library.rb +4 -2
  36. data/lib/omnibus/logger.rb +60 -1
  37. data/lib/omnibus/null_argumentable.rb +51 -0
  38. data/lib/omnibus/ohai.rb +29 -8
  39. data/lib/omnibus/package.rb +240 -0
  40. data/lib/omnibus/packagers/base.rb +21 -42
  41. data/lib/omnibus/packagers/mac_dmg.rb +5 -5
  42. data/lib/omnibus/packagers/mac_pkg.rb +20 -19
  43. data/lib/omnibus/packagers/windows_msi.rb +7 -7
  44. data/lib/omnibus/project.rb +969 -486
  45. data/lib/omnibus/publisher.rb +76 -0
  46. data/lib/omnibus/publishers/artifactory_publisher.rb +168 -0
  47. data/lib/omnibus/publishers/null_publisher.rb +23 -0
  48. data/lib/omnibus/publishers/s3_publisher.rb +99 -0
  49. data/lib/omnibus/s3_cache.rb +150 -63
  50. data/lib/omnibus/software.rb +749 -321
  51. data/lib/omnibus/{sugar.rb → sugarable.rb} +11 -6
  52. data/lib/omnibus/version.rb +1 -1
  53. data/omnibus.gemspec +8 -8
  54. data/spec/data/complicated/config/projects/angrychef.rb +1 -1
  55. data/spec/data/complicated/config/projects/chef-windows.rb +1 -1
  56. data/spec/data/complicated/config/projects/chef.rb +1 -1
  57. data/spec/data/complicated/config/projects/chefdk-windows.rb +1 -1
  58. data/spec/data/complicated/config/projects/chefdk.rb +1 -1
  59. data/spec/data/complicated/config/software/cacerts.rb +1 -1
  60. data/spec/data/complicated/config/software/chef-client-msi.rb +1 -1
  61. data/spec/data/complicated/config/software/libgcc.rb +1 -1
  62. data/spec/data/complicated/config/software/libiconv.rb +0 -11
  63. data/spec/data/complicated/config/software/libpng.rb +2 -2
  64. data/spec/data/complicated/config/software/openssl.rb +1 -1
  65. data/spec/data/complicated/config/software/ruby.rb +1 -1
  66. data/spec/data/complicated/config/software/runit.rb +4 -4
  67. data/spec/data/projects/chefdk.rb +1 -1
  68. data/spec/data/projects/sample.rb +1 -1
  69. data/spec/data/software/erchef.rb +3 -1
  70. data/spec/functional/packagers/mac_spec.rb +25 -24
  71. data/spec/functional/packagers/windows_spec.rb +21 -20
  72. data/spec/spec_helper.rb +43 -4
  73. data/spec/unit/build_version_spec.rb +14 -16
  74. data/spec/unit/cleanroom_spec.rb +63 -0
  75. data/spec/unit/config_spec.rb +36 -30
  76. data/spec/unit/digestable_spec.rb +38 -0
  77. data/spec/unit/fetchers/net_fetcher_spec.rb +98 -87
  78. data/spec/unit/{install_path_cache_spec.rb → git_cache_spec.rb} +67 -56
  79. data/spec/unit/health_check_spec.rb +73 -0
  80. data/spec/unit/library_spec.rb +166 -159
  81. data/spec/unit/ohai_spec.rb +19 -0
  82. data/spec/unit/omnibus_spec.rb +43 -41
  83. data/spec/unit/package_spec.rb +178 -0
  84. data/spec/unit/packagers/base_spec.rb +17 -47
  85. data/spec/unit/packagers/mac_pkg_spec.rb +104 -126
  86. data/spec/unit/project_spec.rb +176 -25
  87. data/spec/unit/publisher_spec.rb +49 -0
  88. data/spec/unit/publishers/artifactory_publisher_spec.rb +80 -0
  89. data/spec/unit/publishers/s3_publisher_spec.rb +120 -0
  90. data/spec/unit/s3_cacher_spec.rb +84 -19
  91. data/spec/unit/software_spec.rb +397 -170
  92. data/spec/unit/sugarable_spec.rb +43 -0
  93. metadata +62 -50
  94. data/Guardfile +0 -10
  95. data/lib/omnibus/artifact.rb +0 -165
  96. data/lib/omnibus/cli/release.rb +0 -40
  97. data/lib/omnibus/generator_files/Vagrantfile.erb +0 -75
  98. data/lib/omnibus/install_path_cache.rb +0 -105
  99. data/lib/omnibus/overrides.rb +0 -88
  100. data/lib/omnibus/package_release.rb +0 -154
  101. data/lib/omnibus/software_s3_urls.rb +0 -50
  102. data/spec/unit/artifact_spec.rb +0 -91
  103. data/spec/unit/overrides_spec.rb +0 -102
  104. data/spec/unit/package_release_spec.rb +0 -180
  105. data/spec/unit/sugar_spec.rb +0 -17
@@ -1,50 +0,0 @@
1
- #
2
- # Copyright 2013-2014 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
-
17
- module Omnibus
18
- module SoftwareS3URLs
19
- class InsufficientSpecification < ArgumentError
20
- def initialize(key, package)
21
- @key, @package = key, package
22
- end
23
-
24
- def to_s
25
- "Software must specify a #{@key} to cache it in S3 (#{@package})!"
26
- end
27
- end
28
-
29
- def config
30
- Omnibus.config
31
- end
32
-
33
- def url_for(software)
34
- "http://#{config.s3_bucket}.s3.amazonaws.com/#{key_for_package(software)}"
35
- end
36
-
37
- private
38
-
39
- def key_for_package(package)
40
- return @key_for_package if @key_for_package
41
-
42
- package.name || raise(InsufficientSpecification.new(:name, package))
43
- package.version || raise(InsufficientSpecification.new(:version, package))
44
- package.checksum || raise(InsufficientSpecification.new(:checksum, package))
45
-
46
- @key_for_package = "#{package.name}-#{package.version}-#{package.checksum}"
47
- @key_for_package
48
- end
49
- end
50
- end
@@ -1,91 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Omnibus::Artifact do
4
-
5
- let(:path) { 'build_os=centos-5,machine_architecture=x86,role=oss-builder/pkg/demoproject-11.4.0-1.el5.x86_64.rpm' }
6
-
7
- let(:content) { StringIO.new("this is the package content\n") }
8
-
9
- let(:md5) { 'd41d8cd98f00b204e9800998ecf8427e' }
10
-
11
- let(:sha256) { 'e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855' }
12
-
13
- let(:platforms) { [%w(el 5 x86_64), ['sles', '11.2', 'x86_64']] }
14
-
15
- let(:artifact) { Omnibus::Artifact.new(path, platforms, version: '11.4.0-1') }
16
-
17
- it 'has the path to the package' do
18
- expect(artifact.path).to eq(path)
19
- end
20
-
21
- it 'has a list of platforms the package supports' do
22
- expect(artifact.platforms).to eq(platforms)
23
- end
24
-
25
- it 'generates a MD5 of an artifact' do
26
- expect(File).to receive(:open).with(path).and_return(content)
27
- expect(artifact.md5).to eq(md5)
28
- end
29
-
30
- it 'generates a SHA256 of an artifact' do
31
- expect(File).to receive(:open).with(path).and_return(content)
32
- expect(artifact.sha256).to eq(sha256)
33
- end
34
-
35
- it "generates 'flat' metadata" do
36
- expect(File).to receive(:open).twice.with(path).and_return(content)
37
- flat_metadata = artifact.flat_metadata
38
- expect(flat_metadata['platform']).to eq('el')
39
- expect(flat_metadata['platform_version']).to eq('5')
40
- expect(flat_metadata['arch']).to eq('x86_64')
41
- expect(flat_metadata['version']).to eq('11.4.0-1')
42
- expect(flat_metadata['basename']).to eq('demoproject-11.4.0-1.el5.x86_64.rpm')
43
- expect(flat_metadata['md5']).to eq(md5)
44
- expect(flat_metadata['sha256']).to eq(sha256)
45
- end
46
-
47
- it 'adds the package to a release manifest' do
48
- expected = {
49
- 'el' => {
50
- '5' => { 'x86_64' => { '11.4.0-1' => '/el/5/x86_64/demoproject-11.4.0-1.el5.x86_64.rpm' } },
51
- },
52
- 'sles' => {
53
- '11.2' => { 'x86_64' => { '11.4.0-1' => '/el/5/x86_64/demoproject-11.4.0-1.el5.x86_64.rpm' } },
54
- },
55
- }
56
-
57
- manifest = artifact.add_to_release_manifest!({})
58
- expect(manifest).to eq(expected)
59
- end
60
-
61
- it 'adds the package to a v2 release manifest' do
62
- expect(File).to receive(:open).with(path).twice.and_return(content)
63
- expected = {
64
- 'el' => {
65
- '5' => {
66
- 'x86_64' => {
67
- '11.4.0-1' => {
68
- 'relpath' => '/el/5/x86_64/demoproject-11.4.0-1.el5.x86_64.rpm',
69
- 'md5' => md5,
70
- 'sha256' => sha256,
71
- },
72
- },
73
- },
74
- },
75
- 'sles' => {
76
- '11.2' => {
77
- 'x86_64' => {
78
- '11.4.0-1' => {
79
- 'relpath' => '/el/5/x86_64/demoproject-11.4.0-1.el5.x86_64.rpm',
80
- 'md5' => md5,
81
- 'sha256' => sha256,
82
- },
83
- },
84
- },
85
- },
86
- }
87
- v2_manifest = artifact.add_to_v2_release_manifest!({})
88
- expect(v2_manifest).to eq(expected)
89
- end
90
-
91
- end
@@ -1,102 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Omnibus::Overrides do
4
- describe '#parse_file' do
5
-
6
- let(:overrides) { Omnibus::Overrides.parse_file(file) }
7
- subject { overrides }
8
-
9
- context 'with a valid overrides file' do
10
- let(:file) { overrides_path('good') }
11
-
12
- its(:size) { should eq(5) }
13
- its(['foo']) { should eq('1.2.3') }
14
- its(['bar']) { should eq('0.0.1') }
15
- its(['baz']) { should eq('deadbeefdeadbeefdeadbeefdeadbeef') }
16
- its(['spunky']) { should eq('master') }
17
- its(['monkey']) { should eq('release') }
18
- end
19
-
20
- context 'with an overrides file that contains a bad line' do
21
- let(:file) { overrides_path('bad_line') }
22
-
23
- it 'fails' do
24
- expect { overrides }.to raise_error(ArgumentError, "Invalid overrides line: 'THIS IS A BAD LINE'")
25
- end
26
- end
27
-
28
- context 'with an overrides file that contains duplicates' do
29
- let(:file) { overrides_path('with_dupes') }
30
- let(:duplicated_package) { 'erchef' }
31
- it 'fails' do
32
- expect { overrides }.to raise_error(ArgumentError, "Multiple overrides present for '#{duplicated_package}' in overrides file #{file}!")
33
- end
34
- end
35
-
36
- context "when passed 'nil'" do
37
- let(:file) { nil }
38
- it { should be_nil }
39
- end
40
- end # parse_file
41
-
42
- describe '#resolve_override_file' do
43
- subject { Omnibus::Overrides.resolve_override_file }
44
-
45
- context 'with no environment variable set' do
46
- before :each do
47
- stub_const('Omnibus::Overrides::DEFAULT_OVERRIDE_FILE_NAME', new_default_file)
48
- end
49
-
50
- context 'and a non-existent overrides file' do
51
- let(:new_default_file) { '/this/file/totally/does/not/exist.txt' }
52
- it { should be_nil }
53
- end
54
-
55
- context 'with an existing overrides file' do
56
- let(:path) { overrides_path('good') }
57
- let(:new_default_file) { path }
58
- it { should eq(path) }
59
- end
60
- end # no environment variable
61
-
62
- context 'with OMNIBUS_OVERRIDE_FILE environment variable set' do
63
- before { stub_env('OMNIBUS_OVERRIDE_FILE', env_override_file) }
64
-
65
- context 'to an existing file' do
66
- let(:path) { overrides_path('good') }
67
- let(:env_override_file) { path }
68
- it { should eq(path) }
69
- end
70
-
71
- context 'to a non-existent file' do
72
- let(:env_override_file) { '/this/file/totally/does/not/exist.txt' }
73
- it { should be_nil }
74
- end
75
-
76
- context 'to a non-existent file, but with an existing DEFAULT_OVERRIDE_FILE_NAME file' do
77
- let(:env_override_file) { '/this/file/totally/does/not/exist.txt' }
78
- let(:new_default_file) { overrides_path('good') }
79
-
80
- it "should still return 'nil', because environment variable has priority" do
81
- stub_const('Omnibus::Overrides::DEFAULT_OVERRIDE_FILE_NAME', new_default_file)
82
-
83
- expect(File.exist?(Omnibus::Overrides::DEFAULT_OVERRIDE_FILE_NAME)).to be_true
84
- expect(subject).to be_nil
85
- end
86
- end
87
- end
88
- end
89
-
90
- describe '#overrides' do
91
- context 'when an overrides file cannot be found' do
92
- before :each do
93
- Omnibus::Overrides.stub(:resolve_override_file).and_return(nil)
94
- end
95
-
96
- it 'returns an empty hash' do
97
- expect(Omnibus::Overrides.overrides).to eq({})
98
- end
99
- end
100
- end
101
-
102
- end
@@ -1,180 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Omnibus::PackageRelease do
4
- let(:s3_key) { 's3key' }
5
- let(:s3_secret) { 'hey-bezos-store-my-stuff' }
6
- let(:s3_bucket) { 'myorg-omnibus-packages' }
7
- let(:pkg_path) { 'pkg/chef_11.4.0-183-g2c0040c-0.el6.x86_64.rpm' }
8
- let(:pkg_metadata_path) { "#{pkg_path}.metadata.json" }
9
-
10
- let(:config) do
11
- {
12
- release_s3_access_key: s3_key,
13
- release_s3_secret_key: s3_secret,
14
- release_s3_bucket: s3_bucket,
15
- }
16
- end
17
- subject(:package_release) do
18
- Omnibus::PackageRelease.new(pkg_path)
19
- end
20
-
21
- it 'has a package path' do
22
- expect(package_release.package_path).to eq(pkg_path)
23
- end
24
-
25
- it "defaults to `:private' access policy" do
26
- expect(package_release.access_policy).to eq(:private)
27
- end
28
-
29
- describe 'validating configuration' do
30
-
31
- before do
32
- Omnibus.stub(:config).and_return(config)
33
- end
34
-
35
- it 'validates that the s3 key is set' do
36
- config.delete(:release_s3_access_key)
37
- expect { package_release.validate_config! }.to raise_error(Omnibus::InvalidS3ReleaseConfiguration)
38
- end
39
-
40
- it 'validates that the s3 secret key is set' do
41
- config.delete(:release_s3_secret_key)
42
- expect { package_release.validate_config! }.to raise_error(Omnibus::InvalidS3ReleaseConfiguration)
43
- end
44
-
45
- it 'validates that the s3 bucket is set' do
46
- config.delete(:release_s3_bucket)
47
- expect { package_release.validate_config! }.to raise_error(Omnibus::InvalidS3ReleaseConfiguration)
48
- end
49
-
50
- it 'does not error on a valid configuration' do
51
- expect { package_release.validate_config! }.to_not raise_error
52
- end
53
- end
54
-
55
- describe 'validating package for upload' do
56
- it 'ensures that the package file exists' do
57
- expect { package_release.validate_package! }.to raise_error(Omnibus::NoPackageFile)
58
- end
59
-
60
- it 'ensures that there is a metadata file for the package' do
61
- expect(File).to receive(:exist?).with(pkg_path).and_return(true)
62
- expect(File).to receive(:exist?).with(pkg_metadata_path).and_return(false)
63
- expect { package_release.validate_package! }.to raise_error(Omnibus::NoPackageMetadataFile)
64
- end
65
- end
66
-
67
- context 'with a valid config and package' do
68
-
69
- let(:basename) { 'chef_11.4.0-183-g2c0040c-0.el6.x86_64.rpm' }
70
- let(:md5) { '016f2e0854c69901b3f0ad8f99ffdb75' }
71
- let(:platform_path) { 'el/6/x86_64' }
72
- let(:pkg_content) { 'expected package content' }
73
-
74
- let(:metadata_json) do
75
- <<-E
76
- {
77
- "platform": "el",
78
- "platform_version": "6",
79
- "arch": "x86_64",
80
- "version": "11.4.0-183-g2c0040c",
81
- "basename": "#{basename}",
82
- "md5": "#{md5}",
83
- "sha256": "21191ab698d1663a5e738e470fad16a2c6efee05ed597002f2e846ec80ade38c"
84
- }
85
- E
86
- end
87
-
88
- before do
89
- package_release.stub(:config).and_return(config)
90
- File.stub(:exist?).with(pkg_metadata_path).and_return(true)
91
- File.stub(:exist?).with(pkg_path).and_return(true)
92
- IO.stub(:read).with(pkg_metadata_path).and_return(metadata_json)
93
- IO.stub(:read).with(pkg_path).and_return(pkg_content)
94
- end
95
-
96
- it 'configures s3 with the given credentials' do
97
- expected_s3_config = {
98
- access_key: s3_key,
99
- secret_access_key: s3_secret,
100
- bucket: s3_bucket,
101
- adaper: :net_http,
102
- }
103
- expect(UberS3).to receive(:new).with(expected_s3_config)
104
- package_release.s3_client
105
- end
106
-
107
- it 'generates the relative path for the package s3 key' do
108
- expect(package_release.platform_path).to eq(platform_path)
109
- end
110
-
111
- it 'uploads the package and metadata' do
112
- expect(package_release.s3_client).to receive(:store).with(
113
- "#{platform_path}/#{basename}.metadata.json",
114
- metadata_json,
115
- access: :private,
116
- )
117
- expect(package_release.s3_client).to receive(:store).with(
118
- "#{platform_path}/#{basename}",
119
- pkg_content,
120
- access: :private,
121
- content_md5: md5,
122
- )
123
- package_release.release
124
- end
125
-
126
- context 'and a callback is given for after upload' do
127
- let(:upload_records) { [] }
128
-
129
- subject(:package_release) do
130
- Omnibus::PackageRelease.new(pkg_path) do |uploaded|
131
- upload_records << uploaded
132
- end
133
- end
134
-
135
- it 'fires the after_upload callback for each item uploaded' do
136
- expect(package_release.s3_client).to receive(:store).with(
137
- "#{platform_path}/#{basename}.metadata.json",
138
- metadata_json,
139
- access: :private,
140
- )
141
- expect(package_release.s3_client).to receive(:store).with(
142
- "#{platform_path}/#{basename}",
143
- pkg_content,
144
- access: :private,
145
- content_md5: md5,
146
- )
147
- package_release.release
148
-
149
- expect(upload_records).to eq [
150
- "#{platform_path}/#{basename}.metadata.json",
151
- "#{platform_path}/#{basename}",
152
- ]
153
- end
154
- end
155
-
156
- context 'and the package is public' do
157
-
158
- subject(:package_release) do
159
- Omnibus::PackageRelease.new(pkg_path, access: :public_read)
160
- end
161
-
162
- it 'uploads the package and metadata' do
163
- expect(package_release.s3_client).to receive(:store).with(
164
- "#{platform_path}/#{basename}.metadata.json",
165
- metadata_json,
166
- access: :public_read,
167
- )
168
- expect(package_release.s3_client).to receive(:store).with(
169
- "#{platform_path}/#{basename}",
170
- pkg_content,
171
- access: :public_read,
172
- content_md5: md5,
173
- )
174
- package_release.release
175
- end
176
- end
177
-
178
- end
179
-
180
- end
@@ -1,17 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Omnibus::Software do
4
- it 'includes the Chef Sugar DSL methods' do
5
- expect(described_class).to be_method_defined(:windows?)
6
- expect(described_class).to be_method_defined(:vagrant?)
7
- expect(described_class).to be_method_defined(:_64_bit?)
8
- end
9
- end
10
-
11
- describe Omnibus::Project do
12
- it 'includes the Chef Sugar DSL methods' do
13
- expect(described_class).to be_method_defined(:windows?)
14
- expect(described_class).to be_method_defined(:vagrant?)
15
- expect(described_class).to be_method_defined(:_64_bit?)
16
- end
17
- end