omnibus 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (62) hide show
  1. checksums.yaml +15 -0
  2. data/.gitignore +9 -0
  3. data/.rspec +1 -0
  4. data/.yardopts +7 -0
  5. data/CHANGELOG.md +3 -0
  6. data/Gemfile +9 -0
  7. data/LICENSE +201 -0
  8. data/NOTICE +9 -0
  9. data/README.md +186 -0
  10. data/Rakefile +7 -0
  11. data/bin/makeself-header.sh +401 -0
  12. data/bin/makeself.sh +407 -0
  13. data/bin/omnibus +11 -0
  14. data/lib/omnibus.rb +280 -0
  15. data/lib/omnibus/build_version.rb +281 -0
  16. data/lib/omnibus/builder.rb +323 -0
  17. data/lib/omnibus/clean_tasks.rb +30 -0
  18. data/lib/omnibus/cli.rb +35 -0
  19. data/lib/omnibus/cli/application.rb +136 -0
  20. data/lib/omnibus/cli/base.rb +112 -0
  21. data/lib/omnibus/cli/build.rb +66 -0
  22. data/lib/omnibus/cli/cache.rb +60 -0
  23. data/lib/omnibus/config.rb +186 -0
  24. data/lib/omnibus/exceptions.rb +54 -0
  25. data/lib/omnibus/fetcher.rb +184 -0
  26. data/lib/omnibus/fetchers.rb +22 -0
  27. data/lib/omnibus/fetchers/git_fetcher.rb +212 -0
  28. data/lib/omnibus/fetchers/net_fetcher.rb +191 -0
  29. data/lib/omnibus/fetchers/path_fetcher.rb +65 -0
  30. data/lib/omnibus/fetchers/s3_cache_fetcher.rb +42 -0
  31. data/lib/omnibus/health_check.rb +260 -0
  32. data/lib/omnibus/library.rb +70 -0
  33. data/lib/omnibus/overrides.rb +69 -0
  34. data/lib/omnibus/project.rb +566 -0
  35. data/lib/omnibus/reports.rb +99 -0
  36. data/lib/omnibus/s3_cacher.rb +136 -0
  37. data/lib/omnibus/software.rb +430 -0
  38. data/lib/omnibus/templates/Berksfile.erb +3 -0
  39. data/lib/omnibus/templates/Gemfile.erb +4 -0
  40. data/lib/omnibus/templates/README.md.erb +102 -0
  41. data/lib/omnibus/templates/Vagrantfile.erb +95 -0
  42. data/lib/omnibus/templates/gitignore.erb +8 -0
  43. data/lib/omnibus/templates/omnibus.rb.example.erb +5 -0
  44. data/lib/omnibus/templates/package_scripts/makeselfinst.erb +27 -0
  45. data/lib/omnibus/templates/package_scripts/postinst.erb +17 -0
  46. data/lib/omnibus/templates/package_scripts/postrm.erb +9 -0
  47. data/lib/omnibus/templates/project.rb.erb +21 -0
  48. data/lib/omnibus/templates/software/c-example.rb.erb +42 -0
  49. data/lib/omnibus/templates/software/erlang-example.rb.erb +38 -0
  50. data/lib/omnibus/templates/software/ruby-example.rb.erb +24 -0
  51. data/lib/omnibus/util.rb +61 -0
  52. data/lib/omnibus/version.rb +20 -0
  53. data/omnibus.gemspec +34 -0
  54. data/spec/build_version_spec.rb +228 -0
  55. data/spec/data/overrides/bad_line.overrides +3 -0
  56. data/spec/data/overrides/good.overrides +5 -0
  57. data/spec/data/overrides/with_dupes.overrides +4 -0
  58. data/spec/data/software/erchef.rb +40 -0
  59. data/spec/overrides_spec.rb +114 -0
  60. data/spec/software_spec.rb +71 -0
  61. data/spec/spec_helper.rb +28 -0
  62. metadata +239 -0
@@ -0,0 +1,20 @@
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
+ module Omnibus
19
+ VERSION = "1.0.0"
20
+ end
data/omnibus.gemspec ADDED
@@ -0,0 +1,34 @@
1
+ # -*- encoding: utf-8 -*-
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'omnibus/version'
5
+
6
+ Gem::Specification.new do |gem|
7
+ gem.name = "omnibus"
8
+ gem.version = Omnibus::VERSION
9
+ gem.license = "Apache 2.0"
10
+ gem.author = "Opscode"
11
+ gem.email = "info@opscode.com"
12
+ gem.description = "Omnibus helps you build self-installing, full-stack software builds."
13
+ gem.summary = gem.description
14
+ gem.homepage = "https://github.com/opscode/opscode-ruby"
15
+
16
+ gem.required_ruby_version = ">= 1.9.1"
17
+
18
+ gem.files = `git ls-files`.split($/)
19
+ gem.bindir = "bin"
20
+ gem.executables = %w(omnibus)
21
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
22
+ gem.require_paths = ["lib"]
23
+
24
+ gem.add_dependency "mixlib-shellout", "~> 1.0"
25
+ gem.add_dependency "mixlib-config", "~> 1.1.2"
26
+ gem.add_dependency "ohai", ">= 0.6.12"
27
+ gem.add_dependency "rake", ">= 0.9"
28
+ gem.add_dependency "fpm", "= 0.3.11"
29
+ gem.add_dependency "uber-s3"
30
+ gem.add_dependency "thor", ">= 0.16.0"
31
+
32
+ gem.add_development_dependency "rspec"
33
+ gem.add_development_dependency "rspec_junit_formatter"
34
+ end
@@ -0,0 +1,228 @@
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/build_version'
19
+ require 'spec_helper'
20
+
21
+ describe Omnibus::BuildVersion do
22
+
23
+ let(:git_describe){ "11.0.0-alpha1-207-g694b062" }
24
+ let(:valid_semver_regex){/^\d+\.\d+\.\d+(\-[\dA-Za-z\-\.]+)?(\+[\dA-Za-z\-\.]+)?$/}
25
+ let(:valid_git_describe_regex){/^\d+\.\d+\.\d+(\-[A-Za-z0-9\-\.]+)?(\-\d+\-g[0-9a-f]+)?$/}
26
+
27
+ subject(:build_version){ Omnibus::BuildVersion.new }
28
+
29
+ before :each do
30
+ ENV['BUILD_ID'] = nil
31
+ ENV['OMNIBUS_APPEND_TIMESTAMP'] = nil
32
+ Omnibus::BuildVersion.any_instance.stub(:shellout)
33
+ .and_return(mock("ouput",
34
+ :stdout => git_describe,
35
+ :exitstatus => 0))
36
+ end
37
+
38
+ describe "git describe parsing" do
39
+
40
+ # we prefer our git tags to be SemVer compliant
41
+
42
+ # release version
43
+ context "11.0.1" do
44
+ let(:git_describe){ "11.0.1" }
45
+ its(:version_tag){ should == "11.0.1" }
46
+ its(:prerelease_tag){ should be_nil }
47
+ its(:git_sha_tag){ should be_nil }
48
+ its(:commits_since_tag){ should == 0 }
49
+ its(:development_version?){ should be_true }
50
+ its(:prerelease_version?){ should be_false }
51
+ end
52
+
53
+ # SemVer compliant prerelease version
54
+ context "11.0.0-alpha.2" do
55
+ let(:git_describe){ "11.0.0-alpha.2" }
56
+ its(:version_tag){ should == "11.0.0" }
57
+ its(:prerelease_tag){ should == "alpha.2" }
58
+ its(:git_sha_tag){ should be_nil }
59
+ its(:commits_since_tag){ should == 0 }
60
+ its(:development_version?){ should be_false }
61
+ its(:prerelease_version?){ should be_true }
62
+ end
63
+
64
+ # full git describe string
65
+ context "11.0.0-alpha.3-59-gf55b180" do
66
+ let(:git_describe){ "11.0.0-alpha.3-59-gf55b180" }
67
+ its(:version_tag){ should == "11.0.0" }
68
+ its(:prerelease_tag){ should == "alpha.3" }
69
+ its(:git_sha_tag){ should == "f55b180" }
70
+ its(:commits_since_tag){ should == 59 }
71
+ its(:development_version?){ should be_false }
72
+ its(:prerelease_version?){ should be_true }
73
+ end
74
+
75
+ # Degenerate git tag formats
76
+
77
+ # RubyGems compliant git tag
78
+ context "10.16.0.rc.0" do
79
+ let(:git_describe){ "10.16.0.rc.0" }
80
+ its(:version_tag){ should == "10.16.0" }
81
+ its(:prerelease_tag){ should == "rc.0" }
82
+ its(:git_sha_tag){ should be_nil }
83
+ its(:commits_since_tag){ should == 0 }
84
+ its(:development_version?){ should be_false }
85
+ its(:prerelease_version?){ should be_true }
86
+ end
87
+
88
+ # dash seperated prerelease
89
+ context "11.0.0-alpha-2" do
90
+ let(:git_describe){ "11.0.0-alpha-2" }
91
+ its(:version_tag){ should == "11.0.0" }
92
+ its(:prerelease_tag){ should == "alpha-2" }
93
+ its(:git_sha_tag){ should be_nil }
94
+ its(:commits_since_tag){ should == 0 }
95
+ its(:development_version?){ should be_false }
96
+ its(:prerelease_version?){ should be_true }
97
+ end
98
+
99
+ # dash seperated prerelease full git describe string
100
+ context "11.0.0-alpha-2-59-gf55b180" do
101
+ let(:git_describe){ "11.0.0-alpha-2-59-gf55b180" }
102
+ its(:version_tag){ should == "11.0.0" }
103
+ its(:prerelease_tag){ should == "alpha-2" }
104
+ its(:git_sha_tag){ should == "f55b180" }
105
+ its(:commits_since_tag){ should == 59 }
106
+ its(:development_version?){ should be_false }
107
+ its(:prerelease_version?){ should be_true }
108
+ end
109
+
110
+ # WTF git tag
111
+ context "11.0.0-alpha2" do
112
+ let(:git_describe){ "11.0.0-alpha2" }
113
+ its(:version_tag){ should == "11.0.0" }
114
+ its(:prerelease_tag){ should == "alpha2" }
115
+ its(:git_sha_tag){ should be_nil }
116
+ its(:commits_since_tag){ should == 0 }
117
+ its(:development_version?){ should be_false }
118
+ its(:prerelease_version?){ should be_true }
119
+ end
120
+ end
121
+
122
+ describe "semver output" do
123
+ let(:today_string){ Time.now.utc.strftime("%Y%m%d") }
124
+
125
+ it "generates a valid semver version" do
126
+ build_version.semver.should =~ valid_semver_regex
127
+ end
128
+
129
+ it "generates a version matching format 'MAJOR.MINOR.PATCH-PRERELEASE+TIMESTAMP.git.COMMITS_SINCE.GIT_SHA'" do
130
+ build_version.semver.should =~ /11.0.0-alpha1\+#{today_string}[0-9]+.git.207.694b062/
131
+ end
132
+
133
+ it "uses ENV['BUILD_ID'] to generate timestamp if set" do
134
+ ENV['BUILD_ID'] = "2012-12-25_16-41-40"
135
+ build_version.semver.should == "11.0.0-alpha1+20121225164140.git.207.694b062"
136
+ end
137
+
138
+ it "fails on invalid ENV['BUILD_ID'] values" do
139
+ ENV['BUILD_ID'] = "AAAA"
140
+ expect { build_version.semver }.to raise_error(ArgumentError)
141
+ end
142
+
143
+ context "prerelease version with dashes" do
144
+ let(:git_describe){ "11.0.0-alpha-3-207-g694b062" }
145
+
146
+ it "converts all dashes to dots" do
147
+ build_version.semver.should =~ /11.0.0-alpha.3\+#{today_string}[0-9]+.git.207.694b062/
148
+ end
149
+ end
150
+
151
+ context "exact version" do
152
+ let(:git_describe){ "11.0.0-alpha2" }
153
+
154
+ it "appends a timestamp with no git info" do
155
+ build_version.semver.should =~ /11.0.0-alpha2\+#{today_string}[0-9]+/
156
+ end
157
+ end
158
+
159
+ describe "ENV['OMNIBUS_APPEND_TIMESTAMP'] usage" do
160
+
161
+ let(:git_describe){ "11.0.0-alpha-3-207-g694b062" }
162
+
163
+ it "appends a timestamp if not set" do
164
+ build_version.semver.should =~ /11.0.0-alpha.3\+#{today_string}[0-9]+.git.207.694b062/
165
+ end
166
+
167
+ context "appends a timestamp if set to a truthy value" do
168
+ ["true","t","yes","y",1].each do |truthy|
169
+ let(:value) { truthy }
170
+ before { ENV['OMNIBUS_APPEND_TIMESTAMP'] = value.to_s }
171
+
172
+ it "with #{truthy}" do
173
+ build_version.semver.should =~ /11.0.0-alpha.3\+#{today_string}[0-9]+.git.207.694b062/
174
+ end
175
+ end
176
+ end
177
+
178
+ context "does not append a timestamp if set to a falsey value" do
179
+ ["false","f","no","n",0].each do |falsey|
180
+ let(:value) { falsey }
181
+ before { ENV['OMNIBUS_APPEND_TIMESTAMP'] = value.to_s }
182
+
183
+ it "with #{falsey}" do
184
+ build_version.semver.should =~ /11.0.0-alpha.3\+git.207.694b062/
185
+ end
186
+ end
187
+ end
188
+
189
+ end
190
+ end
191
+
192
+ describe "git describe output" do
193
+ it "generates a valid git describe version" do
194
+ build_version.git_describe.should =~ valid_git_describe_regex
195
+ end
196
+
197
+ it "generates a version matching format 'MAJOR.MINOR.PATCH-PRELEASE.COMMITS_SINCE-gGIT_SHA'" do
198
+ build_version.git_describe.should == git_describe
199
+ end
200
+ end
201
+
202
+ describe "deprecated full output" do
203
+ it "generates a valid git describe version" do
204
+ Omnibus::BuildVersion.full.should =~ valid_git_describe_regex
205
+ end
206
+
207
+ it "outputs a deprecation message" do
208
+ Omnibus::BuildVersion.should_receive(:puts).with(/is deprecated/)
209
+ Omnibus::BuildVersion.full
210
+ end
211
+ end
212
+
213
+ describe "`git describe` command failure" do
214
+ before do
215
+ stderr =<<-STDERR
216
+ fatal: No tags can describe '809ea1afcce67e1148c1bf0822d40a7ef12c380e'.
217
+ Try --always, or create some tags.
218
+ STDERR
219
+ build_version.stub(:shellout)
220
+ .and_return(mock("ouput",
221
+ :stderr => stderr,
222
+ :exitstatus => 128))
223
+ end
224
+ it "sets the version to 0.0.0" do
225
+ build_version.git_describe.should eq("0.0.0")
226
+ end
227
+ end
228
+ end
@@ -0,0 +1,3 @@
1
+ foo 1.0.0
2
+ THIS IS A BAD LINE
3
+ bar 1.0.0
@@ -0,0 +1,5 @@
1
+ foo 1.2.3
2
+ bar 0.0.1
3
+ baz deadbeefdeadbeefdeadbeefdeadbeef
4
+ spunky master
5
+ monkey release
@@ -0,0 +1,4 @@
1
+ foo 1.0.0
2
+ erchef 1.0.0
3
+ bar 1.0.0
4
+ erchef 2.0.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,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