omnibus-sonian 1.2.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (70) hide show
  1. checksums.yaml +15 -0
  2. data/.gitignore +9 -0
  3. data/.rspec +1 -0
  4. data/.travis.yml +5 -0
  5. data/.yardopts +6 -0
  6. data/CHANGELOG.md +96 -0
  7. data/Gemfile +9 -0
  8. data/LICENSE +201 -0
  9. data/NOTICE +9 -0
  10. data/README.md +195 -0
  11. data/Rakefile +7 -0
  12. data/bin/makeself-header.sh +401 -0
  13. data/bin/makeself.sh +407 -0
  14. data/bin/omnibus +11 -0
  15. data/lib/omnibus.rb +304 -0
  16. data/lib/omnibus/artifact.rb +151 -0
  17. data/lib/omnibus/build_version.rb +285 -0
  18. data/lib/omnibus/builder.rb +328 -0
  19. data/lib/omnibus/clean_tasks.rb +30 -0
  20. data/lib/omnibus/cli.rb +35 -0
  21. data/lib/omnibus/cli/application.rb +140 -0
  22. data/lib/omnibus/cli/base.rb +118 -0
  23. data/lib/omnibus/cli/build.rb +62 -0
  24. data/lib/omnibus/cli/cache.rb +60 -0
  25. data/lib/omnibus/cli/release.rb +49 -0
  26. data/lib/omnibus/config.rb +224 -0
  27. data/lib/omnibus/exceptions.rb +143 -0
  28. data/lib/omnibus/fetcher.rb +184 -0
  29. data/lib/omnibus/fetchers.rb +22 -0
  30. data/lib/omnibus/fetchers/git_fetcher.rb +212 -0
  31. data/lib/omnibus/fetchers/net_fetcher.rb +193 -0
  32. data/lib/omnibus/fetchers/path_fetcher.rb +65 -0
  33. data/lib/omnibus/fetchers/s3_cache_fetcher.rb +42 -0
  34. data/lib/omnibus/health_check.rb +356 -0
  35. data/lib/omnibus/library.rb +62 -0
  36. data/lib/omnibus/overrides.rb +69 -0
  37. data/lib/omnibus/package_release.rb +163 -0
  38. data/lib/omnibus/project.rb +715 -0
  39. data/lib/omnibus/reports.rb +99 -0
  40. data/lib/omnibus/s3_cacher.rb +138 -0
  41. data/lib/omnibus/software.rb +441 -0
  42. data/lib/omnibus/templates/Berksfile.erb +3 -0
  43. data/lib/omnibus/templates/Gemfile.erb +4 -0
  44. data/lib/omnibus/templates/README.md.erb +102 -0
  45. data/lib/omnibus/templates/Vagrantfile.erb +95 -0
  46. data/lib/omnibus/templates/gitignore.erb +8 -0
  47. data/lib/omnibus/templates/omnibus.rb.example.erb +5 -0
  48. data/lib/omnibus/templates/package_scripts/makeselfinst.erb +27 -0
  49. data/lib/omnibus/templates/package_scripts/postinst.erb +17 -0
  50. data/lib/omnibus/templates/package_scripts/postrm.erb +9 -0
  51. data/lib/omnibus/templates/project.rb.erb +21 -0
  52. data/lib/omnibus/templates/software/c-example.rb.erb +42 -0
  53. data/lib/omnibus/templates/software/erlang-example.rb.erb +38 -0
  54. data/lib/omnibus/templates/software/ruby-example.rb.erb +24 -0
  55. data/lib/omnibus/util.rb +61 -0
  56. data/lib/omnibus/version.rb +20 -0
  57. data/omnibus.gemspec +34 -0
  58. data/spec/artifact_spec.rb +106 -0
  59. data/spec/build_version_spec.rb +266 -0
  60. data/spec/data/overrides/bad_line.overrides +3 -0
  61. data/spec/data/overrides/good.overrides +5 -0
  62. data/spec/data/overrides/with_dupes.overrides +4 -0
  63. data/spec/data/software/erchef.rb +40 -0
  64. data/spec/fetchers/net_fetcher_spec.rb +16 -0
  65. data/spec/overrides_spec.rb +114 -0
  66. data/spec/package_release_spec.rb +197 -0
  67. data/spec/s3_cacher_spec.rb +47 -0
  68. data/spec/software_spec.rb +85 -0
  69. data/spec/spec_helper.rb +28 -0
  70. metadata +252 -0
@@ -0,0 +1,40 @@
1
+ #
2
+ # Copyright:: Copyright (c) 2012 Opscode, Inc.
3
+ # License:: Apache License, Version 2.0
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+ #
17
+
18
+ name "erchef"
19
+ version "4b19a96d57bff9bbf4764d7323b92a0944009b9e"
20
+
21
+ dependencies ["erlang", "rsync", "curl"]
22
+
23
+ source :git => "git://github.com/opscode/erchef"
24
+
25
+ relative_path "erchef"
26
+
27
+ env = {
28
+ "PATH" => "#{install_dir}/embedded/bin:#{ENV["PATH"]}",
29
+ "LDFLAGS" => "-L#{install_dir}/embedded/lib -I#{install_dir}/embedded/include",
30
+ "CFLAGS" => "-L#{install_dir}/embedded/lib -I#{install_dir}/embedded/include",
31
+ "LD_RUN_PATH" => "#{install_dir}/embedded/lib"
32
+ }
33
+
34
+ build do
35
+ command "make distclean", :env => env
36
+ command "make rel", :env => env
37
+ command "mkdir -p #{install_dir}/embedded/service/erchef"
38
+ command "#{install_dir}/embedded/bin/rsync -a --delete --exclude=.git/*** --exclude=.gitignore ./rel/erchef/ #{install_dir}/embedded/service/erchef/"
39
+ command "rm -rf #{install_dir}/embedded/service/erchef/log"
40
+ end
@@ -0,0 +1,16 @@
1
+ require 'spec_helper'
2
+
3
+ describe Omnibus::NetFetcher do
4
+ it "should download and uncompress zip files" do
5
+ software_mock = stub 'software'
6
+ software_mock.stub :project_file => 'file.zip',
7
+ :name => 'file',
8
+ :source => '/tmp/out',
9
+ :checksum => 'abc123',
10
+ :source_uri => 'http://example.com/file.zip',
11
+ :source_dir => '/tmp/out',
12
+ :project_dir => '/tmp/project'
13
+ net_fetcher = Omnibus::NetFetcher.new software_mock
14
+ net_fetcher.extract_cmd.should == 'unzip file.zip -d /tmp/out'
15
+ end
16
+ end
@@ -0,0 +1,114 @@
1
+ require 'omnibus/overrides'
2
+ require 'spec_helper'
3
+
4
+ describe Omnibus::Overrides do
5
+ describe "#parse_file" do
6
+
7
+ let(:overrides){Omnibus::Overrides.parse_file(file)}
8
+ subject{overrides}
9
+
10
+ context "with a valid overrides file" do
11
+ let(:file){ overrides_path("good") }
12
+
13
+ its(:size){should eq(5)}
14
+ its(["foo"]){should eq("1.2.3")}
15
+ its(["bar"]){should eq("0.0.1")}
16
+ its(["baz"]){should eq("deadbeefdeadbeefdeadbeefdeadbeef")}
17
+ its(["spunky"]){should eq("master")}
18
+ its(["monkey"]){should eq("release")}
19
+ end
20
+
21
+ context "with an overrides file that contains a bad line" do
22
+ let(:file){ overrides_path("bad_line")}
23
+
24
+ it "fails" do
25
+ expect{ overrides }.to raise_error(ArgumentError, "Invalid overrides line: 'THIS IS A BAD LINE'")
26
+ end
27
+ end
28
+
29
+ context "with an overrides file that contains duplicates" do
30
+ let(:file){ overrides_path("with_dupes") }
31
+ let(:duplicated_package){"erchef"}
32
+ it "fails" do
33
+ expect{ overrides }.to raise_error(ArgumentError, "Multiple overrides present for '#{duplicated_package}' in overrides file #{file}!")
34
+ end
35
+ end
36
+
37
+ context "when passed 'nil'" do
38
+ let(:file){nil}
39
+ it{should be_nil}
40
+ end
41
+ end #parse_file
42
+
43
+ describe "#resolve_override_file" do
44
+ before :each do
45
+ @original = ENV['OMNIBUS_OVERRIDE_FILE']
46
+ ENV['OMNIBUS_OVERRIDE_FILE'] = env_override_file
47
+ end
48
+
49
+ after :each do
50
+ ENV['OMNIBUS_OVERRIDE_FILE'] = @original
51
+ end
52
+
53
+ subject{ Omnibus::Overrides.resolve_override_file }
54
+
55
+ context "with no environment variable set" do
56
+ let(:env_override_file){nil}
57
+
58
+ before :each do
59
+ stub_const("Omnibus::Overrides::DEFAULT_OVERRIDE_FILE_NAME", new_default_file)
60
+ end
61
+
62
+ context "and a non-existent overrides file" do
63
+ let(:new_default_file){ "/this/file/totally/does/not/exist.txt" }
64
+ it{should be_nil}
65
+ end
66
+
67
+ context "with an existing overrides file" do
68
+ let(:path){overrides_path("good")}
69
+ let(:new_default_file){ path }
70
+ it{should eq(path)}
71
+ end
72
+ end # no environment variable
73
+
74
+ context "with OMNIBUS_OVERRIDE_FILE environment variable set" do
75
+ context "to an existing file" do
76
+ let(:path){ overrides_path("good") }
77
+ let(:env_override_file){ path }
78
+ it{should eq(path)}
79
+ end
80
+
81
+ context "to a non-existent file" do
82
+ let(:env_override_file){ "/this/file/totally/does/not/exist.txt"}
83
+ it{should be_nil}
84
+ end
85
+
86
+ context "to a non-existent file, but with an existing DEFAULT_OVERRIDE_FILE_NAME file" do
87
+ let(:env_override_file){ "/this/file/totally/does/not/exist.txt"}
88
+ let(:new_default_file){overrides_path("good")}
89
+
90
+ it "should still return 'nil', because environment variable has priority" do
91
+ stub_const("Omnibus::Overrides::DEFAULT_OVERRIDE_FILE_NAME", new_default_file)
92
+
93
+ File.exist?(Omnibus::Overrides::DEFAULT_OVERRIDE_FILE_NAME).should be_true
94
+ ENV['OMNIBUS_OVERRIDE_FILE'].should_not be_nil
95
+
96
+ subject.should be_nil
97
+ end
98
+ end
99
+ end
100
+ end
101
+
102
+ describe "#overrides" do
103
+ context "when an overrides file cannot be found" do
104
+ before :each do
105
+ Omnibus::Overrides.stub(:resolve_override_file).and_return(nil)
106
+ end
107
+
108
+ it "returns an empty hash" do
109
+ Omnibus::Overrides.overrides.should eq({})
110
+ end
111
+ end
112
+ end
113
+
114
+ end
@@ -0,0 +1,197 @@
1
+ #
2
+ # Copyright:: Copyright (c) 2012 Opscode, Inc.
3
+ # License:: Apache License, Version 2.0
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+ #
17
+
18
+ require 'omnibus/package_release'
19
+ require 'spec_helper'
20
+
21
+ describe Omnibus::PackageRelease do
22
+ let(:s3_key) { "s3key" }
23
+ let(:s3_secret) { "hey-bezos-store-my-stuff" }
24
+ let(:s3_bucket) { "myorg-omnibus-packages" }
25
+ let(:pkg_path) { "pkg/chef_11.4.0-183-g2c0040c-0.el6.x86_64.rpm" }
26
+ let(:pkg_metadata_path) { "#{pkg_path}.metadata.json" }
27
+
28
+ let(:config) do
29
+ {
30
+ :release_s3_access_key => s3_key,
31
+ :release_s3_secret_key => s3_secret,
32
+ :release_s3_bucket => s3_bucket
33
+ }
34
+ end
35
+ subject(:package_release) do
36
+ Omnibus::PackageRelease.new(pkg_path)
37
+ end
38
+
39
+ it "has a package path" do
40
+ package_release.package_path.should == pkg_path
41
+ end
42
+
43
+ it "defaults to `:private' access policy" do
44
+ package_release.access_policy.should == :private
45
+ end
46
+
47
+ describe "validating configuration" do
48
+
49
+ before do
50
+ Omnibus.stub!(:config).and_return(config)
51
+ end
52
+
53
+ it "validates that the s3 key is set" do
54
+ config.delete(:release_s3_access_key)
55
+ lambda { package_release.validate_config! }.should raise_error(Omnibus::InvalidS3ReleaseConfiguration)
56
+ end
57
+
58
+ it "validates that the s3 secret key is set" do
59
+ config.delete(:release_s3_secret_key)
60
+ lambda { package_release.validate_config! }.should raise_error(Omnibus::InvalidS3ReleaseConfiguration)
61
+ end
62
+
63
+ it "validates that the s3 bucket is set" do
64
+ config.delete(:release_s3_bucket)
65
+ lambda { package_release.validate_config! }.should raise_error(Omnibus::InvalidS3ReleaseConfiguration)
66
+ end
67
+
68
+ it "does not error on a valid configuration" do
69
+ lambda { package_release.validate_config! }.should_not raise_error
70
+ end
71
+ end
72
+
73
+ describe "validating package for upload" do
74
+ it "ensures that the package file exists" do
75
+ lambda { package_release.validate_package! }.should raise_error(Omnibus::NoPackageFile)
76
+ end
77
+
78
+ it "ensures that there is a metadata file for the package" do
79
+ File.should_receive(:exist?).with(pkg_path).and_return(true)
80
+ File.should_receive(:exist?).with(pkg_metadata_path).and_return(false)
81
+ lambda { package_release.validate_package! }.should raise_error(Omnibus::NoPackageMetadataFile)
82
+ end
83
+ end
84
+
85
+ context "with a valid config and package" do
86
+
87
+ let(:basename) { "chef_11.4.0-183-g2c0040c-0.el6.x86_64.rpm" }
88
+ let(:md5) { "016f2e0854c69901b3f0ad8f99ffdb75" }
89
+ let(:platform_path) { "el/6/x86_64" }
90
+ let(:pkg_content) { "expected package content" }
91
+
92
+ let(:metadata_json) do
93
+ <<-E
94
+ {
95
+ "platform": "el",
96
+ "platform_version": "6",
97
+ "arch": "x86_64",
98
+ "version": "11.4.0-183-g2c0040c",
99
+ "basename": "#{basename}",
100
+ "md5": "#{md5}",
101
+ "sha256": "21191ab698d1663a5e738e470fad16a2c6efee05ed597002f2e846ec80ade38c"
102
+ }
103
+ E
104
+ end
105
+
106
+ before do
107
+ package_release.stub!(:config).and_return(config)
108
+ File.stub(:exist?).with(pkg_metadata_path).and_return(true)
109
+ File.stub(:exist?).with(pkg_path).and_return(true)
110
+ IO.stub(:read).with(pkg_metadata_path).and_return(metadata_json)
111
+ IO.stub(:read).with(pkg_path).and_return(pkg_content)
112
+ end
113
+
114
+ it "configures s3 with the given credentials" do
115
+ expected_s3_config = {
116
+ :access_key => s3_key,
117
+ :secret_access_key => s3_secret,
118
+ :bucket => s3_bucket,
119
+ :adaper => :net_http
120
+ }
121
+ UberS3.should_receive(:new).with(expected_s3_config)
122
+ package_release.s3_client
123
+ end
124
+
125
+ it "generates the relative path for the package s3 key" do
126
+ package_release.platform_path.should == platform_path
127
+ end
128
+
129
+
130
+ it "uploads the package and metadata" do
131
+ package_release.s3_client.should_receive(:store).with(
132
+ "#{platform_path}/#{basename}.metadata.json",
133
+ metadata_json,
134
+ :access => :private
135
+ )
136
+ package_release.s3_client.should_receive(:store).with(
137
+ "#{platform_path}/#{basename}",
138
+ pkg_content,
139
+ :access => :private,
140
+ :content_md5 => md5
141
+ )
142
+ package_release.release
143
+ end
144
+
145
+ context "and a callback is given for after upload" do
146
+ let(:upload_records) { [] }
147
+
148
+ subject(:package_release) do
149
+ Omnibus::PackageRelease.new(pkg_path) do |uploaded|
150
+ upload_records << uploaded
151
+ end
152
+ end
153
+
154
+ it "fires the after_upload callback for each item uploaded" do
155
+ package_release.s3_client.should_receive(:store).with(
156
+ "#{platform_path}/#{basename}.metadata.json",
157
+ metadata_json,
158
+ :access => :private
159
+ )
160
+ package_release.s3_client.should_receive(:store).with(
161
+ "#{platform_path}/#{basename}",
162
+ pkg_content,
163
+ :access => :private,
164
+ :content_md5 => md5
165
+ )
166
+ package_release.release
167
+
168
+ upload_records.should == [ "#{platform_path}/#{basename}.metadata.json",
169
+ "#{platform_path}/#{basename}" ]
170
+ end
171
+ end
172
+
173
+ context "and the package is public" do
174
+
175
+ subject(:package_release) do
176
+ Omnibus::PackageRelease.new(pkg_path, :access => :public_read)
177
+ end
178
+
179
+ it "uploads the package and metadata" do
180
+ package_release.s3_client.should_receive(:store).with(
181
+ "#{platform_path}/#{basename}.metadata.json",
182
+ metadata_json,
183
+ :access => :public_read
184
+ )
185
+ package_release.s3_client.should_receive(:store).with(
186
+ "#{platform_path}/#{basename}",
187
+ pkg_content,
188
+ :access => :public_read,
189
+ :content_md5 => md5
190
+ )
191
+ package_release.release
192
+ end
193
+ end
194
+
195
+ end
196
+
197
+ end
@@ -0,0 +1,47 @@
1
+ #
2
+ # Copyright:: Copyright (c) 2013 Opscode, Inc.
3
+ # License:: Apache License, Version 2.0
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+ #
17
+
18
+ require 'spec_helper'
19
+ require 'omnibus/s3_cacher'
20
+
21
+ describe Omnibus::S3Cache do
22
+
23
+ describe '#tarball_software' do
24
+ subject(:tarball_software) { described_class.new.tarball_software }
25
+
26
+ let(:source_a) { stub(source: { url: 'a' }) }
27
+ let(:source_b) { stub(source: { url: 'b' }) }
28
+ let(:source_c) { stub(source: {}) }
29
+ let(:projects) { [
30
+ stub({ library: [source_a, source_c] }),
31
+ stub({ library: [source_c, source_b] })
32
+ ] }
33
+ let(:software_with_urls) { [source_a, source_b] }
34
+
35
+ before do
36
+ Omnibus.stub(config: stub({
37
+ s3_bucket: 'test', s3_access_key: 'test', s3_secret_key: 'test'
38
+ }))
39
+
40
+ Omnibus.stub(projects: projects)
41
+ end
42
+
43
+ it 'lists all software with urls' do
44
+ tarball_software.should == software_with_urls
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,85 @@
1
+ require 'rake/dsl_definition'
2
+ require 'omnibus/software'
3
+
4
+ require 'spec_helper'
5
+
6
+ describe Omnibus::Software do
7
+
8
+ let(:project) do
9
+ p = mock(Omnibus::Project)
10
+ p.should_receive(:install_path).any_number_of_times.and_return("monkeys")
11
+ p
12
+ end
13
+
14
+ let(:software_name) { "erchef" }
15
+ let(:software_file){ software_path(software_name) }
16
+ let(:version_from_file){ "4b19a96d57bff9bbf4764d7323b92a0944009b9e" }
17
+ let(:software){ Omnibus::Software.load(software_file, project) }
18
+
19
+ before :each do
20
+ # We don't want to mess with any of this stuff for these
21
+ # tests... we're just looking at version info right now
22
+ Omnibus::Software.any_instance.stub(:render_tasks)
23
+ end
24
+
25
+ subject { software }
26
+
27
+ describe "#whitelist_file" do
28
+
29
+ it "appends to the whitelist_files array" do
30
+ software.whitelist_files.size.should equal 0
31
+ software.whitelist_file(/foo\/bar/)
32
+ software.whitelist_files.size.should equal 1
33
+ end
34
+
35
+ it "converts Strings to Regexp instances" do
36
+ software.whitelist_file "foo/bar"
37
+ software.whitelist_files.size.should equal 1
38
+ software.whitelist_files.first.should be_kind_of(Regexp)
39
+ end
40
+ end
41
+
42
+ context "testing version overrides" do
43
+
44
+ context "without overrides" do
45
+ its(:name){should eq(software_name)}
46
+ its(:version){should eq(version_from_file)}
47
+ its(:given_version){should eq(software.version)}
48
+ its(:override_version){should be_nil}
49
+ end
50
+
51
+ context "with overrides" do
52
+ let(:override_software_version){"6.6.6"}
53
+ let(:overrides) do
54
+ {override_software_name => override_software_version}
55
+ end
56
+ let(:software){Omnibus::Software.load(software_file, project, overrides)}
57
+
58
+ context "but not for this software" do
59
+ let(:override_software_name){"chaos_monkey"}
60
+
61
+ it "really should not have any overrides for this software" do
62
+ overrides.should_not have_key(software_name)
63
+ end
64
+
65
+ its(:version){should eq(version_from_file)}
66
+ its(:given_version){should eq(software.version)}
67
+ its(:override_version){should be_nil}
68
+ end
69
+
70
+ context "for this software" do
71
+ let(:override_software_name){software_name}
72
+
73
+ it "really should have an override for this software" do
74
+ overrides.should have_key(software_name)
75
+ end
76
+
77
+ its(:version){should eq(override_software_version)}
78
+ its(:override_version){should eq(software.version)}
79
+ its(:version){should_not eq(software.given_version)}
80
+ its(:given_version){should eq(version_from_file)}
81
+ end
82
+ end
83
+
84
+ end
85
+ end