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,30 @@
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
+ # Adds source and build artifacts to Rake's CLEAN list, and install
19
+ # and cache artifacts to its CLOBBER list, ensuring that the `clean`
20
+ # and `clobber` Rake tasks do the right thing for Omnibus projects.
21
+ #
22
+ # @see https://github.com/jimweirich/rake/blob/master/lib/rake/clean.rb
23
+
24
+ require 'rake/clean'
25
+
26
+ ::CLEAN.include("#{Omnibus.config.source_dir}/**/*",
27
+ "#{Omnibus.config.build_dir}/**/*")
28
+
29
+ ::CLOBBER.include("#{Omnibus.config.cache_dir}/**/*",
30
+ "#{Omnibus.config.package_dir}/**/*")
@@ -0,0 +1,35 @@
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/cli/application'
19
+ require 'omnibus/cli/base'
20
+ require 'omnibus/cli/build'
21
+
22
+ module Omnibus
23
+ module CLI
24
+
25
+ class Error < StandardError
26
+ attr_reader :original
27
+
28
+ def initialize(msg, original=nil)
29
+ super(msg)
30
+ @original = original
31
+ end
32
+ end
33
+
34
+ end
35
+ end
@@ -0,0 +1,140 @@
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 'omnibus'
19
+ require 'omnibus/cli/base'
20
+ require 'omnibus/cli/build'
21
+ require 'omnibus/cli/cache'
22
+ require 'omnibus/cli/release'
23
+
24
+ module Omnibus
25
+ module CLI
26
+ class Application < Base
27
+
28
+ method_option :purge,
29
+ :type => :boolean,
30
+ :default => false,
31
+ :desc => "Remove ALL files generated during the build (including packages)."
32
+ method_option :path,
33
+ :aliases => [:p],
34
+ :type => :string,
35
+ :default => Dir.pwd,
36
+ :desc => "Path to the Omnibus project root."
37
+ desc "clean PROJECT", "Remove temporary files generated during the build process."
38
+ def clean(project_name)
39
+ project = load_project!(project_name)
40
+
41
+ deletion_list = []
42
+ deletion_list << Dir.glob("#{Omnibus.config.source_dir}/**/*")
43
+ deletion_list << Dir.glob("#{Omnibus.config.build_dir}/**/*")
44
+
45
+ if options[:purge]
46
+ deletion_list << Dir.glob("#{Omnibus.config.package_dir}/**/*")
47
+ deletion_list << Dir.glob("#{Omnibus.config.cache_dir}/**/*")
48
+ deletion_list << project.install_path if File.exist?(project.install_path)
49
+ end
50
+
51
+ deletion_list.flatten!
52
+ deletion_list.each{|f| remove_file(f) }
53
+ end
54
+
55
+ desc "project PROJECT", "Creates a skeletal Omnibus project"
56
+ def project(name)
57
+ name = name.chomp("/") # remove trailing slash if present
58
+ target = File.join(Dir.pwd, "omnibus-#{name}")
59
+ install_path = File.join("/opt", name)
60
+ opts = {
61
+ :name => name,
62
+ :install_path => install_path
63
+ }
64
+
65
+ # core project files
66
+ template(File.join("Gemfile.erb"), File.join(target, "Gemfile"), opts)
67
+ template(File.join("gitignore.erb"), File.join(target, ".gitignore"), opts)
68
+ template(File.join("README.md.erb"), File.join(target, "README.md"), opts)
69
+ template(File.join("omnibus.rb.example.erb"), File.join(target, "omnibus.rb.example"), opts)
70
+
71
+ # project definition
72
+ template(File.join("project.rb.erb"), File.join(target, "config", "projects", "#{name}.rb"), opts)
73
+
74
+ # example software definitions
75
+ config_software = File.join(target, "config", "software")
76
+ template(File.join("software", "c-example.rb.erb"),
77
+ File.join(config_software, "c-example.rb"), opts)
78
+ template(File.join("software", "erlang-example.rb.erb"),
79
+ File.join(config_software, "erlang-example.rb"), opts)
80
+ template(File.join("software", "ruby-example.rb.erb"),
81
+ File.join(config_software, "ruby-example.rb"), opts)
82
+
83
+ # Vagrant build lab
84
+ template(File.join("Berksfile.erb"), File.join(target, "Berksfile"), opts)
85
+ template(File.join("Vagrantfile.erb"), File.join(target, "Vagrantfile"), opts)
86
+
87
+ # render out stub packge scripts
88
+ %w{ makeselfinst postinst postrm }.each do |package_script|
89
+ script_path = File.join(target, "package-scripts", name, package_script)
90
+ template_path = File.join("package_scripts", "#{package_script}.erb")
91
+ # render the package script
92
+ template(template_path, script_path, opts)
93
+ # ensure the package script is executable
94
+ FileUtils.chmod(0755, script_path)
95
+ end
96
+ end
97
+
98
+ desc "version", "Display version information"
99
+ def version
100
+ say("Omnibus: #{Omnibus::VERSION}", :yellow)
101
+ end
102
+
103
+ ###########################################################################
104
+ # Subcommands
105
+ ###########################################################################
106
+
107
+ desc "build [COMMAND]", "Perform build-related tasks"
108
+ subcommand "build", Omnibus::CLI::Build
109
+
110
+ desc "cache [COMMAND]", "Perform cache management tasks"
111
+ subcommand "cache", Omnibus::CLI::Cache
112
+
113
+ desc "release [COMMAND]", "Perform release tasks"
114
+ subcommand "release", Omnibus::CLI::Release
115
+
116
+ ###########################################################################
117
+ # Class Methods
118
+ ###########################################################################
119
+
120
+ # Override start so we can catch and process any exceptions bubbling up
121
+ def self.start(*args)
122
+ begin
123
+ super
124
+ rescue => e
125
+ error_msg = "Something went wrong...the Omnibus just ran off the road!"
126
+ error_msg << "\n\nError raised was:\n\n\t#{$!}"
127
+ error_msg << "\n\nBacktrace:\n\n\t#{e.backtrace.join("\n\t")}"
128
+ if e.respond_to?(:original) && e.original
129
+ error_msg << "\n\nOriginal Error:\n\n\t#{e.original}"
130
+ error_msg << "\n\nOriginal Backtrace:\n\n\t#{e.original.backtrace.join("\n\t")}"
131
+ end
132
+ # TODO - we need a proper UI class
133
+ Thor::Base.shell.new.say(error_msg, :red)
134
+ exit 1
135
+ end
136
+ end
137
+
138
+ end
139
+ end
140
+ end
@@ -0,0 +1,118 @@
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 'omnibus/util'
19
+ require 'thor'
20
+
21
+ module Omnibus
22
+ module CLI
23
+ class Base < Thor
24
+ include Thor::Actions
25
+
26
+ class_option :config,
27
+ :aliases => [:c],
28
+ :type => :string,
29
+ :default => File.join(Dir.pwd, Omnibus::DEFAULT_CONFIG_FILENAME),
30
+ :desc => "Path to the Omnibus configuration file to use."
31
+
32
+ def initialize(args, options, config)
33
+ super(args, options, config)
34
+ $stdout.sync = true
35
+
36
+ # Don't try to initialize the Omnibus project for help commands. current_task renamed to current_command in Thor 0.18.0
37
+ current_command = config[:current_command] ? config[:current_command].name : config[:current_task].name
38
+ return if current_command == "help"
39
+
40
+ if config = @options[:config]
41
+ if config && File.exist?(@options[:config])
42
+ say("Using Omnibus configuration file #{config}", :green)
43
+ Omnibus.load_configuration(config)
44
+ elsif config
45
+ say("No configuration file `#{config}', using defaults", :yellow)
46
+ end
47
+ end
48
+
49
+ if path = @options[:path]
50
+ # TODO: merge in all relevant CLI options here, as they should
51
+ # override anything from a configuration file.
52
+ Omnibus::Config.project_root(path)
53
+ Omnibus::Config.append_timestamp(@options[:timestamp]) if @options.key?('timestamp')
54
+
55
+ unless Omnibus.project_files.any?
56
+ raise Omnibus::CLI::Error, "Given path '#{path}' does not appear to be a valid Omnibus project root."
57
+ end
58
+
59
+ begin
60
+ Omnibus.process_configuration
61
+ rescue => e
62
+ error_msg = "Could not load the Omnibus projects."
63
+ raise Omnibus::CLI::Error.new(error_msg, e)
64
+ end
65
+ end
66
+
67
+ end
68
+
69
+ ##################################################################
70
+ # Thor Overrides/Tweaks
71
+ ##################################################################
72
+
73
+ # Used by {Thor::Actions#template} to locate ERB templates
74
+ # @return [String]
75
+ def self.source_root
76
+ File.expand_path(File.join(File.dirname(__FILE__), '..', 'templates'))
77
+ end
78
+
79
+ # Forces command to exit with a 1 on any failure...so raise away.
80
+ def self.exit_on_failure?
81
+ true
82
+ end
83
+
84
+ # For some strange reason the +subcommand+ argument is disregarded when
85
+ # +Thor.banner+ is called by +Thor.command_help+:
86
+ #
87
+ # https://github.com/wycats/thor/blob/master/lib/thor.rb#L163-L164
88
+ #
89
+ # We'll override +Thor.banner+ and ensure subcommand is true when called
90
+ # for subcommands.
91
+ def self.banner(command, namespace = nil, subcommand = false)
92
+ # Main commands have an effective namespace of 'application' OR
93
+ # contain subcommands
94
+ if (self.namespace.split(':').last != 'application') || self.subcommands.empty?
95
+ subcommand = true
96
+ end
97
+ "#{basename} #{command.formatted_usage(self, $thor_runner, subcommand)}"
98
+ end
99
+
100
+ protected
101
+
102
+ ##################################################################
103
+ # Omnibus Helpers (should these be in Omnibus::Util?)
104
+ ##################################################################
105
+
106
+ def load_project!(project_name)
107
+ project = Omnibus.project(project_name)
108
+ unless project
109
+ error_msg = "I don't know anything about project '#{project_name}'."
110
+ error_msg << " Valid project names include: #{Omnibus.project_names.join(', ')}"
111
+ raise Omnibus::CLI::Error, error_msg
112
+ end
113
+ project
114
+ end
115
+
116
+ end
117
+ end
118
+ end
@@ -0,0 +1,62 @@
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 'omnibus/cli/base'
19
+
20
+ module Omnibus
21
+ module CLI
22
+ class Build < Base
23
+
24
+ namespace :build
25
+
26
+ class_option :path,
27
+ :aliases => [:p],
28
+ :type => :string,
29
+ :default => Dir.pwd,
30
+ :desc => "Path to the Omnibus project root."
31
+
32
+ method_option :timestamp,
33
+ :aliases => [:t],
34
+ :type => :boolean,
35
+ :default => true,
36
+ :desc => "Append timestamp information to the version identifier? Add a timestamp for build versions; leave it off for release and pre-release versions"
37
+ desc "project PROJECT", "Build the given Omnibus project"
38
+ def project(project_name)
39
+ project = load_project!(project_name)
40
+ project_task_name = "projects:#{project.name}"
41
+
42
+ unless options[:timestamp]
43
+ say("I won't append a timestamp to the version identifier.", :yellow)
44
+ end
45
+ say("Building #{project.name} #{project.build_version}", :green)
46
+
47
+ Rake::Task[project_task_name].invoke
48
+ end
49
+
50
+ desc "software PROJECT SOFTWARE", "Build the given software component"
51
+ def software(project_name, software_name)
52
+ project = load_project!(project_name)
53
+ software_task_name = "projects:#{project.name}:software:#{software_name}"
54
+
55
+ say("Building #{software_name} for #{project.name} project", :green)
56
+
57
+ Rake::Task[software_task_name].invoke
58
+ end
59
+
60
+ end
61
+ end
62
+ end
@@ -0,0 +1,60 @@
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 'omnibus/cli/base'
19
+ require 'omnibus/s3_cacher'
20
+
21
+ module Omnibus
22
+ module CLI
23
+ class Cache < Base
24
+
25
+ class_option :path,
26
+ :aliases => [:p],
27
+ :type => :string,
28
+ :default => Dir.pwd,
29
+ :desc => "Path to the Omnibus project root."
30
+
31
+ namespace :cache
32
+
33
+ desc "existing", "List source packages which exist in the cache"
34
+ def existing
35
+ S3Cache.new.list.each {|s| puts s.name}
36
+ end
37
+
38
+ desc "list", "List all cached files (by S3 key)"
39
+ def list
40
+ S3Cache.new.list_by_key.each {|k| puts k}
41
+ end
42
+
43
+ desc "missing", "Lists source packages that are required but not yet cached"
44
+ def missing
45
+ S3Cache.new.missing.each {|s| puts s.name}
46
+ end
47
+
48
+ desc "fetch", "Fetches missing source packages to local tmp dir"
49
+ def fetch
50
+ S3Cache.new.fetch_missing
51
+ end
52
+
53
+ desc "populate", "Populate the S3 Cache"
54
+ def populate
55
+ S3Cache.new.populate
56
+ end
57
+
58
+ end
59
+ end
60
+ end