omnibus 1.3.0 → 2.0.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (69) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +4 -1
  3. data/.rubocop.yml +30 -0
  4. data/.travis.yml +14 -3
  5. data/CHANGELOG.md +72 -49
  6. data/Gemfile +8 -5
  7. data/NOTICE +2 -2
  8. data/README.md +65 -7
  9. data/Rakefile +12 -3
  10. data/bin/makeself-header.sh +1 -1
  11. data/bin/makeself.sh +2 -2
  12. data/bin/omnibus +2 -2
  13. data/functional/fixtures/mac_pkg/files/mac_pkg/Resources/background.png +0 -0
  14. data/functional/fixtures/mac_pkg/files/mac_pkg/Resources/license.html +1 -0
  15. data/functional/fixtures/mac_pkg/files/mac_pkg/Resources/welcome.html +1 -0
  16. data/functional/fixtures/mac_pkg/package-scripts/functional-test-project/postinstall +4 -0
  17. data/functional/packagers/mac_pkg_spec.rb +72 -0
  18. data/lib/omnibus/artifact.rb +11 -13
  19. data/lib/omnibus/build_version.rb +18 -21
  20. data/lib/omnibus/builder.rb +37 -48
  21. data/lib/omnibus/clean_tasks.rb +3 -5
  22. data/lib/omnibus/cli/application.rb +46 -53
  23. data/lib/omnibus/cli/base.rb +16 -19
  24. data/lib/omnibus/cli/build.rb +13 -13
  25. data/lib/omnibus/cli/cache.rb +13 -15
  26. data/lib/omnibus/cli/release.rb +4 -9
  27. data/lib/omnibus/cli.rb +2 -4
  28. data/lib/omnibus/config.rb +43 -23
  29. data/lib/omnibus/exceptions.rb +35 -1
  30. data/lib/omnibus/fetcher.rb +9 -13
  31. data/lib/omnibus/fetchers/git_fetcher.rb +15 -19
  32. data/lib/omnibus/fetchers/net_fetcher.rb +34 -38
  33. data/lib/omnibus/fetchers/path_fetcher.rb +7 -9
  34. data/lib/omnibus/fetchers/s3_cache_fetcher.rb +3 -4
  35. data/lib/omnibus/fetchers.rb +3 -3
  36. data/lib/omnibus/health_check.rb +126 -127
  37. data/lib/omnibus/library.rb +11 -12
  38. data/lib/omnibus/overrides.rb +6 -8
  39. data/lib/omnibus/package_release.rb +20 -22
  40. data/lib/omnibus/packagers/mac_pkg.rb +285 -0
  41. data/lib/omnibus/project.rb +215 -110
  42. data/lib/omnibus/reports.rb +16 -24
  43. data/lib/omnibus/s3_cacher.rb +15 -21
  44. data/lib/omnibus/software.rb +178 -88
  45. data/lib/omnibus/util.rb +25 -13
  46. data/lib/omnibus/version.rb +2 -2
  47. data/lib/omnibus.rb +11 -13
  48. data/omnibus.gemspec +20 -18
  49. data/spec/artifact_spec.rb +55 -52
  50. data/spec/build_version_spec.rb +121 -129
  51. data/spec/config_spec.rb +40 -0
  52. data/spec/data/projects/chefdk.rb +41 -0
  53. data/spec/data/projects/sample.rb +10 -0
  54. data/spec/data/software/erchef.rb +12 -12
  55. data/spec/data/software/zlib.rb +67 -0
  56. data/spec/fetchers/git_fetcher_spec.rb +55 -48
  57. data/spec/fetchers/net_fetcher_spec.rb +72 -78
  58. data/spec/omnibus_spec.rb +59 -0
  59. data/spec/overrides_spec.rb +64 -64
  60. data/spec/package_release_spec.rb +65 -64
  61. data/spec/packagers/mac_pkg_spec.rb +261 -0
  62. data/spec/project_spec.rb +138 -0
  63. data/spec/s3_cacher_spec.rb +9 -10
  64. data/spec/software_spec.rb +71 -50
  65. data/spec/spec_helper.rb +14 -7
  66. metadata +68 -60
  67. data/.rspec +0 -1
  68. data/.yardopts +0 -6
  69. data/spec/software_dirs_spec.rb +0 -34
@@ -1,5 +1,5 @@
1
1
  #
2
- # Copyright:: Copyright (c) 2012 Opscode, Inc.
2
+ # Copyright:: Copyright (c) 2012-2014 Chef Software, Inc.
3
3
  # License:: Apache License, Version 2.0
4
4
  #
5
5
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -19,7 +19,6 @@ require 'time'
19
19
  require 'omnibus/util'
20
20
 
21
21
  module Omnibus
22
-
23
22
  # Provides methods for generating Omnibus project build version
24
23
  # strings automatically from Git repository information.
25
24
  #
@@ -37,18 +36,18 @@ module Omnibus
37
36
  #
38
37
  # @see Omnibus::BuildVersion#semver
39
38
  # @see Time#strftime
40
- TIMESTAMP_FORMAT = "%Y%m%d%H%M%S"
39
+ TIMESTAMP_FORMAT = '%Y%m%d%H%M%S'
41
40
 
42
41
  # @deprecated Use {#semver} or {#git_describe} instead
43
42
  def self.full
44
- puts "#{self.name}.full is deprecated. Use #{self.name}.new.semver or #{self.name}.new.git_describe."
43
+ puts "#{name}.full is deprecated. Use #{name}.new.semver or #{name}.new.git_describe."
45
44
  Omnibus::BuildVersion.new.git_describe
46
45
  end
47
46
 
48
47
  # Create a new BuildVersion
49
48
  #
50
49
  # @param [String] path Path from which to read git version information
51
- def initialize(path=Omnibus.root)
50
+ def initialize(path = Omnibus.root)
52
51
  @path = path
53
52
  end
54
53
 
@@ -87,8 +86,8 @@ module Omnibus
87
86
  if prerelease_version?
88
87
  # ensure all dashes are dots per precedence rules (#12) in Semver
89
88
  # 2.0.0-rc.1
90
- prerelease = prerelease_tag.gsub("-", ".")
91
- build_tag << "-" << prerelease
89
+ prerelease = prerelease_tag.gsub('-', '.')
90
+ build_tag << '-' << prerelease
92
91
  end
93
92
 
94
93
  # BUILD VERSION
@@ -107,11 +106,11 @@ module Omnibus
107
106
  #
108
107
  # format: git.COMMITS_SINCE_TAG.GIT_SHA example: git.207.694b062
109
108
  unless commits_since_tag == 0
110
- build_version_items << ["git", commits_since_tag, git_sha_tag].join(".")
109
+ build_version_items << ['git', commits_since_tag, git_sha_tag].join('.')
111
110
  end
112
111
 
113
112
  unless build_version_items.empty?
114
- build_tag << "+" << build_version_items.join(".")
113
+ build_tag << '+' << build_version_items.join('.')
115
114
  end
116
115
 
117
116
  build_tag
@@ -130,17 +129,15 @@ module Omnibus
130
129
  # @return [String]
131
130
  def git_describe
132
131
  @git_describe ||= begin
133
- git_cmd = "git describe"
134
- cmd = shellout(git_cmd,
135
- :live_stream => nil,
136
- :cwd => @path)
132
+ git_cmd = 'git describe'
133
+ cmd = shellout(git_cmd, live_stream: nil, cwd: @path)
137
134
  if cmd.exitstatus == 0
138
135
  cmd.stdout.chomp
139
136
  else
140
- msg = "Could not extract version information from `git describe`. "
141
- msg << "Setting version to 0.0.0"
137
+ msg = 'Could not extract version information from `git describe`. '
138
+ msg << 'Setting version to 0.0.0'
142
139
  puts msg
143
- "0.0.0"
140
+ '0.0.0'
144
141
  end
145
142
  end
146
143
  end
@@ -161,7 +158,7 @@ module Omnibus
161
158
  #
162
159
  # @return [String]
163
160
  def version_tag
164
- version_composition.join(".")
161
+ version_composition.join('.')
165
162
  end
166
163
 
167
164
  # Return a prerelease tag string (if it exists), as extracted from {#git_describe}.
@@ -245,11 +242,11 @@ module Omnibus
245
242
  @build_start_time ||= begin
246
243
  if !ENV['BUILD_ID'].nil?
247
244
  begin
248
- Time.strptime(ENV['BUILD_ID'], "%Y-%m-%d_%H-%M-%S")
245
+ Time.strptime(ENV['BUILD_ID'], '%Y-%m-%d_%H-%M-%S')
249
246
  rescue ArgumentError
250
- error_message = "BUILD_ID environment variable "
251
- error_message << "should be in YYYY-MM-DD_hh-mm-ss "
252
- error_message << "format."
247
+ error_message = 'BUILD_ID environment variable '
248
+ error_message << 'should be in YYYY-MM-DD_hh-mm-ss '
249
+ error_message << 'format.'
253
250
  raise ArgumentError, error_message
254
251
  end
255
252
  else
@@ -1,5 +1,5 @@
1
1
  #
2
- # Copyright:: Copyright (c) 2012 Opscode, Inc.
2
+ # Copyright:: Copyright (c) 2012-2014 Chef Software, Inc.
3
3
  # License:: Apache License, Version 2.0
4
4
  #
5
5
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -21,7 +21,6 @@ require 'ostruct'
21
21
 
22
22
  module Omnibus
23
23
  class Builder
24
-
25
24
  # Proxies method calls to either a Builder object or the Software that the
26
25
  # builder belongs to. Provides compatibility with our DSL where we never
27
26
  # yield objects to blocks and hopefully hides some of the confusion that
@@ -29,8 +28,6 @@ module Omnibus
29
28
  class DSLProxy
30
29
  extend Forwardable
31
30
 
32
- # @todo def_delegators :@builder, :patch, :command, :ruby, ...
33
-
34
31
  def_delegator :@builder, :patch
35
32
  def_delegator :@builder, :erb
36
33
  def_delegator :@builder, :command
@@ -65,13 +62,10 @@ module Omnibus
65
62
  super
66
63
  end
67
64
  end
68
-
69
65
  end
70
66
 
71
-
72
67
  # @todo code duplication with {Fetcher::ErrorReporter}
73
68
  class ErrorReporter
74
-
75
69
  # @todo fetcher isn't even used
76
70
  def initialize(error, fetcher)
77
71
  @error, @fetcher = error, fetcher
@@ -83,28 +77,29 @@ module Omnibus
83
77
  end
84
78
 
85
79
  def explain(why)
86
- $stderr.puts "* " * 40
80
+ $stderr.puts '* ' * 40
87
81
  $stderr.puts why
88
- $stderr.puts "Exception:"
82
+ $stderr.puts 'Exception:'
89
83
  $stderr.puts indent("#{e.class}: #{e.message.strip}", 2)
90
- Array(e.backtrace).each {|l| $stderr.puts indent(l, 4) }
91
- $stderr.puts "* " * 40
84
+ Array(e.backtrace).each { |l| $stderr.puts indent(l, 4) }
85
+ $stderr.puts '* ' * 40
92
86
  end
93
87
 
94
88
  private
95
89
 
96
90
  def indent(string, n)
97
- string.split("\n").map {|l| " ".rjust(n) << l }.join("\n")
91
+ string.split("\n").map { |l| ' '.rjust(n) << l }.join("\n")
98
92
  end
99
-
100
93
  end
101
94
 
102
95
  # @todo Look at using Bundler.with_clean_env{ ... } instead
103
- BUNDLER_BUSTER = { "RUBYOPT" => nil,
104
- "BUNDLE_BIN_PATH" => nil,
105
- "BUNDLE_GEMFILE" => nil,
106
- "GEM_PATH" => nil,
107
- "GEM_HOME" => nil }
96
+ BUNDLER_BUSTER = {
97
+ 'RUBYOPT' => nil,
98
+ 'BUNDLE_BIN_PATH' => nil,
99
+ 'BUNDLE_GEMFILE' => nil,
100
+ 'GEM_PATH' => nil,
101
+ 'GEM_HOME' => nil,
102
+ }
108
103
 
109
104
  attr_reader :build_commands
110
105
 
@@ -135,19 +130,19 @@ module Omnibus
135
130
  File.expand_path("#{root}/config/patches/#{name}/#{args[:source]}")
136
131
  end
137
132
 
138
- source = candidate_paths.find{|path| File.exists?(path) }
133
+ source = candidate_paths.find { |path| File.exists?(path) }
139
134
 
140
135
  unless source
141
- raise MissingPatch.new(args[:source], candidate_paths)
136
+ fail MissingPatch.new(args[:source], candidate_paths)
142
137
  end
143
138
 
144
139
  plevel = args[:plevel] || 1
145
- if args[:target]
140
+ if args[:target]
146
141
  target = File.expand_path("#{project_dir}/#{args[:target]}")
147
- @build_commands <<
142
+ @build_commands <<
148
143
  "cat #{source} | patch -p#{plevel} #{target}"
149
144
  else
150
- @build_commands <<
145
+ @build_commands <<
151
146
  "patch -d #{project_dir} -p#{plevel} -i #{source}"
152
147
  end
153
148
  end
@@ -158,12 +153,12 @@ module Omnibus
158
153
  source_path = File.expand_path("#{Omnibus.project_root}/config/templates/#{name}/#{args[:source]}")
159
154
 
160
155
  unless File.exists?(source_path)
161
- raise MissingTemplate.new(args[:source], "#{Omnibus.project_root}/config/templates/#{name}")
156
+ fail MissingTemplate.new(args[:source], "#{Omnibus.project_root}/config/templates/#{name}")
162
157
  end
163
158
 
164
159
  block do
165
- template = ERB.new(File.new(source_path).read, nil, "%")
166
- File.open(args[:dest], "w") do |file|
160
+ template = ERB.new(File.new(source_path).read, nil, '%')
161
+ File.open(args[:dest], 'w') do |file|
167
162
  file.write(template.result(OpenStruct.new(args[:vars]).instance_eval { binding }))
168
163
  end
169
164
 
@@ -212,6 +207,8 @@ module Omnibus
212
207
 
213
208
  def build
214
209
  log "building #{name}"
210
+ log "version overridden from #{@software.default_version} to " \
211
+ "#{@software.version}" if @software.overridden?
215
212
  time_it("#{name} build") do
216
213
  @build_commands.each do |cmd|
217
214
  execute(cmd)
@@ -248,8 +245,8 @@ module Omnibus
248
245
  shell = nil
249
246
  cmd_args = Array(cmd)
250
247
  options = {
251
- :cwd => project_dir,
252
- :timeout => 5400
248
+ cwd: project_dir,
249
+ timeout: 5400,
253
250
  }
254
251
  options[:live_stream] = STDOUT if ENV['DEBUG']
255
252
  if cmd_args.last.is_a? Hash
@@ -265,7 +262,7 @@ module Omnibus
265
262
  log "Executing: `#{cmd_string}` with #{cmd_opts_for_display}"
266
263
 
267
264
  shell = Mixlib::ShellOut.new(*cmd)
268
- shell.environment["HOME"] = "/tmp" unless ENV["HOME"]
265
+ shell.environment['HOME'] = '/tmp' unless ENV['HOME']
269
266
 
270
267
  cmd_name = cmd_string.split(/\s+/).first
271
268
  time_it("#{cmd_name} command") do
@@ -281,8 +278,8 @@ module Omnibus
281
278
  ErrorReporter.new(e, self).explain("Failed to build #{name} while running `#{cmd_string}` with #{cmd_opts_for_display}")
282
279
  raise
283
280
  else
284
- time_to_sleep = 5 * (2 ** retries)
285
- retries +=1
281
+ time_to_sleep = 5 * (2**retries)
282
+ retries += 1
286
283
  log "Failed to execute cmd #{cmd} #{retries} time(s). Retrying in #{time_to_sleep}s."
287
284
  sleep(time_to_sleep)
288
285
  retry
@@ -297,7 +294,7 @@ module Omnibus
297
294
  # command as a string w/ opts
298
295
  ["#{str} #{cmd_args.first}", cmd_args.last]
299
296
  elsif cmd_args.size == 0
300
- raise ArgumentError, "I don't even"
297
+ fail ArgumentError, "I don't even"
301
298
  else
302
299
  # cmd given as argv array
303
300
  cmd_args.dup.unshift(str)
@@ -311,11 +308,10 @@ module Omnibus
311
308
  cmd_opts[:env] = cmd_opts[:env] ? BUNDLER_BUSTER.merge(cmd_opts[:env]) : BUNDLER_BUSTER
312
309
  cmd_args << cmd_opts
313
310
  else
314
- cmd_args << {:env => BUNDLER_BUSTER}
311
+ cmd_args << { env: BUNDLER_BUSTER }
315
312
  end
316
313
  end
317
314
 
318
-
319
315
  def time_it(what)
320
316
  start = Time.now
321
317
  yield
@@ -331,29 +327,22 @@ module Omnibus
331
327
  # Convert a hash to a string in the form `key=value`. It should work with
332
328
  # whatever input is given but is designed to make the options to ShellOut
333
329
  # look nice.
334
- def to_kv_str(hash, join_str=",")
335
- hash.inject([]) do |kv_pair_strs, (k,v)|
330
+ def to_kv_str(hash, join_str = ',')
331
+ hash.reduce([]) do |kv_pair_strs, (k, v)|
336
332
  val_str = case v
337
- when Hash
338
- %Q["#{to_kv_str(v, " ")}"]
339
- else
340
- v.to_s
341
- end
333
+ when Hash
334
+ %Q["#{to_kv_str(v, " ") }"]
335
+ else
336
+ v.to_s
337
+ end
342
338
  kv_pair_strs << "#{k}=#{val_str}"
343
339
  end.join(join_str)
344
340
  end
345
-
346
341
  end
347
342
 
348
- # @todo What's the point of this class? Can we not just detect that
349
- # there are no commands in {Omnibus::Builder#build} and output the
350
- # appropriate message? Seems like a lot of extra ceremony.
351
343
  class NullBuilder < Builder
352
-
353
344
  def build
354
345
  log "Nothing to build for #{name}"
355
346
  end
356
-
357
347
  end
358
-
359
348
  end
@@ -1,5 +1,5 @@
1
1
  #
2
- # Copyright:: Copyright (c) 2012 Opscode, Inc.
2
+ # Copyright:: Copyright (c) 2012-2014 Chef Software, Inc.
3
3
  # License:: Apache License, Version 2.0
4
4
  #
5
5
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -23,8 +23,6 @@
23
23
 
24
24
  require 'rake/clean'
25
25
 
26
- ::CLEAN.include("#{Omnibus.config.source_dir}/**/*",
27
- "#{Omnibus.config.build_dir}/**/*")
26
+ ::CLEAN.include("#{Omnibus.config.source_dir}/**/*", "#{Omnibus.config.build_dir}/**/*")
28
27
 
29
- ::CLOBBER.include("#{Omnibus.config.cache_dir}/**/*",
30
- "#{Omnibus.config.package_dir}/**/*")
28
+ ::CLOBBER.include("#{Omnibus.config.cache_dir}/**/*", "#{Omnibus.config.package_dir}/**/*")
@@ -1,5 +1,5 @@
1
1
  #
2
- # Copyright:: Copyright (c) 2013 Opscode, Inc.
2
+ # Copyright:: Copyright (c) 2013-2014 Chef Software, Inc.
3
3
  # License:: Apache License, Version 2.0
4
4
  #
5
5
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -24,17 +24,16 @@ require 'omnibus/cli/release'
24
24
  module Omnibus
25
25
  module CLI
26
26
  class Application < Base
27
-
28
27
  method_option :purge,
29
- :type => :boolean,
30
- :default => false,
31
- :desc => "Remove ALL files generated during the build (including packages)."
28
+ type: :boolean,
29
+ default: false,
30
+ desc: 'Remove ALL files generated during the build (including packages).'
32
31
  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."
32
+ aliases: [:p],
33
+ type: :string,
34
+ default: Dir.pwd,
35
+ desc: 'Path to the Omnibus project root.'
36
+ desc 'clean PROJECT', 'Remove temporary files generated during the build process.'
38
37
  def clean(project_name)
39
38
  project = load_project!(project_name)
40
39
 
@@ -49,45 +48,42 @@ module Omnibus
49
48
  end
50
49
 
51
50
  deletion_list.flatten!
52
- deletion_list.each{|f| remove_file(f) }
51
+ deletion_list.each { |f| remove_file(f) }
53
52
  end
54
53
 
55
- desc "project PROJECT", "Creates a skeletal Omnibus project"
54
+ desc 'project PROJECT', 'Creates a skeletal Omnibus project'
56
55
  def project(name)
57
- name = name.chomp("/") # remove trailing slash if present
56
+ name = name.chomp('/') # remove trailing slash if present
58
57
  target = File.join(Dir.pwd, "omnibus-#{name}")
59
- install_path = File.join("/opt", name)
58
+ install_path = File.join('/opt', name)
60
59
  opts = {
61
- :name => name,
62
- :install_path => install_path
60
+ name: name,
61
+ install_path: install_path,
63
62
  }
64
63
 
65
64
  # 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)
65
+ template(File.join('Gemfile.erb'), File.join(target, 'Gemfile'), opts)
66
+ template(File.join('gitignore.erb'), File.join(target, '.gitignore'), opts)
67
+ template(File.join('README.md.erb'), File.join(target, 'README.md'), opts)
68
+ template(File.join('omnibus.rb.example.erb'), File.join(target, 'omnibus.rb.example'), opts)
70
69
 
71
70
  # project definition
72
- template(File.join("project.rb.erb"), File.join(target, "config", "projects", "#{name}.rb"), opts)
71
+ template(File.join('project.rb.erb'), File.join(target, 'config', 'projects', "#{name}.rb"), opts)
73
72
 
74
73
  # 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)
74
+ config_software = File.join(target, 'config', 'software')
75
+ template(File.join('software', 'c-example.rb.erb'), File.join(config_software, 'c-example.rb'), opts)
76
+ template(File.join('software', 'erlang-example.rb.erb'), File.join(config_software, 'erlang-example.rb'), opts)
77
+ template(File.join('software', 'ruby-example.rb.erb'), File.join(config_software, 'ruby-example.rb'), opts)
82
78
 
83
79
  # 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)
80
+ template(File.join('Berksfile.erb'), File.join(target, 'Berksfile'), opts)
81
+ template(File.join('Vagrantfile.erb'), File.join(target, 'Vagrantfile'), opts)
86
82
 
87
83
  # render out stub packge scripts
88
84
  %w{ makeselfinst preinst prerm 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")
85
+ script_path = File.join(target, 'package-scripts', name, package_script)
86
+ template_path = File.join('package_scripts', "#{package_script}.erb")
91
87
  # render the package script
92
88
  template(template_path, script_path, opts)
93
89
  # ensure the package script is executable
@@ -95,7 +91,7 @@ module Omnibus
95
91
  end
96
92
  end
97
93
 
98
- desc "version", "Display version information"
94
+ desc 'version', 'Display version information'
99
95
  def version
100
96
  say("Omnibus: #{Omnibus::VERSION}", :yellow)
101
97
  end
@@ -104,14 +100,14 @@ module Omnibus
104
100
  # Subcommands
105
101
  ###########################################################################
106
102
 
107
- desc "build [COMMAND]", "Perform build-related tasks"
108
- subcommand "build", Omnibus::CLI::Build
103
+ desc 'build [COMMAND]', 'Perform build-related tasks'
104
+ subcommand 'build', Omnibus::CLI::Build
109
105
 
110
- desc "cache [COMMAND]", "Perform cache management tasks"
111
- subcommand "cache", Omnibus::CLI::Cache
106
+ desc 'cache [COMMAND]', 'Perform cache management tasks'
107
+ subcommand 'cache', Omnibus::CLI::Cache
112
108
 
113
- desc "release [COMMAND]", "Perform release tasks"
114
- subcommand "release", Omnibus::CLI::Release
109
+ desc 'release [COMMAND]', 'Perform release tasks'
110
+ subcommand 'release', Omnibus::CLI::Release
115
111
 
116
112
  ###########################################################################
117
113
  # Class Methods
@@ -119,22 +115,19 @@ module Omnibus
119
115
 
120
116
  # Override start so we can catch and process any exceptions bubbling up
121
117
  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
118
+ super
119
+ rescue => e
120
+ error_msg = 'Something went wrong...the Omnibus just ran off the road!'
121
+ error_msg << "\n\nError raised was:\n\n\t#{$ERROR_INFO}"
122
+ error_msg << "\n\nBacktrace:\n\n\t#{e.backtrace.join("\n\t") }"
123
+ if e.respond_to?(:original) && e.original
124
+ error_msg << "\n\nOriginal Error:\n\n\t#{e.original}"
125
+ error_msg << "\n\nOriginal Backtrace:\n\n\t#{e.original.backtrace.join("\n\t") }"
135
126
  end
127
+ # TODO: we need a proper UI class
128
+ Thor::Base.shell.new.say(error_msg, :red)
129
+ exit 1
136
130
  end
137
-
138
131
  end
139
132
  end
140
133
  end
@@ -1,5 +1,5 @@
1
1
  #
2
- # Copyright:: Copyright (c) 2013 Opscode, Inc.
2
+ # Copyright:: Copyright (c) 2013-2014 Chef Software, Inc.
3
3
  # License:: Apache License, Version 2.0
4
4
  #
5
5
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -24,20 +24,21 @@ module Omnibus
24
24
  include Thor::Actions
25
25
 
26
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."
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
31
 
32
32
  def initialize(args, options, config)
33
33
  super(args, options, config)
34
34
  $stdout.sync = true
35
35
 
36
- # Don't try to initialize the Omnibus project for help commands. current_task renamed to current_command in Thor 0.18.0
36
+ # Don't try to initialize the Omnibus project for help commands.#
37
+ # current_task renamed to current_command in Thor 0.18.0
37
38
  current_command = config[:current_command] ? config[:current_command].name : config[:current_task].name
38
- return if current_command == "help"
39
+ return if current_command == 'help'
39
40
 
40
- if config = @options[:config]
41
+ if (config = @options[:config])
41
42
  if config && File.exist?(@options[:config])
42
43
  say("Using Omnibus configuration file #{config}", :green)
43
44
  Omnibus.load_configuration(config)
@@ -46,24 +47,23 @@ module Omnibus
46
47
  end
47
48
  end
48
49
 
49
- if path = @options[:path]
50
+ if (path = @options[:path])
50
51
  # TODO: merge in all relevant CLI options here, as they should
51
52
  # override anything from a configuration file.
52
53
  Omnibus::Config.project_root(path)
53
54
  Omnibus::Config.append_timestamp(@options[:timestamp]) if @options.key?('timestamp')
54
55
 
55
56
  unless Omnibus.project_files.any?
56
- raise Omnibus::CLI::Error, "Given path '#{path}' does not appear to be a valid Omnibus project root."
57
+ fail Omnibus::CLI::Error, "Given path '#{path}' does not appear to be a valid Omnibus project root."
57
58
  end
58
59
 
59
60
  begin
60
61
  Omnibus.process_configuration
61
62
  rescue => e
62
- error_msg = "Could not load the Omnibus projects."
63
+ error_msg = 'Could not load the Omnibus projects.'
63
64
  raise Omnibus::CLI::Error.new(error_msg, e)
64
65
  end
65
66
  end
66
-
67
67
  end
68
68
 
69
69
  ##################################################################
@@ -91,10 +91,8 @@ module Omnibus
91
91
  def self.banner(command, namespace = nil, subcommand = false)
92
92
  # Main commands have an effective namespace of 'application' OR
93
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)}"
94
+ subcommand = self.namespace.split(':').last != 'application' || subcommands.empty?
95
+ "#{basename} #{command.formatted_usage(self, $thor_runner, subcommand) }"
98
96
  end
99
97
 
100
98
  protected
@@ -107,12 +105,11 @@ module Omnibus
107
105
  project = Omnibus.project(project_name)
108
106
  unless project
109
107
  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
108
+ error_msg << " Valid project names include: #{Omnibus.project_names.join(', ') }"
109
+ fail Omnibus::CLI::Error, error_msg
112
110
  end
113
111
  project
114
112
  end
115
-
116
113
  end
117
114
  end
118
115
  end
@@ -1,5 +1,5 @@
1
1
  #
2
- # Copyright:: Copyright (c) 2013 Opscode, Inc.
2
+ # Copyright:: Copyright (c) 2013-2014 Chef Software, Inc.
3
3
  # License:: Apache License, Version 2.0
4
4
  #
5
5
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -20,21 +20,22 @@ require 'omnibus/cli/base'
20
20
  module Omnibus
21
21
  module CLI
22
22
  class Build < Base
23
-
24
23
  namespace :build
25
24
 
26
25
  class_option :path,
27
- :aliases => [:p],
28
- :type => :string,
29
- :default => Dir.pwd,
30
- :desc => "Path to the Omnibus project root."
26
+ aliases: [:p],
27
+ type: :string,
28
+ default: Dir.pwd,
29
+ desc: 'Path to the Omnibus project root.'
31
30
 
32
31
  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"
32
+ aliases: [:t],
33
+ type: :boolean,
34
+ default: true,
35
+ desc: 'Append timestamp information to the version ' \
36
+ 'identifier? Add a timestamp for build versions; ' \
37
+ 'leave it off for release and pre-release versions'
38
+ desc 'project PROJECT', 'Build the given Omnibus project'
38
39
  def project(project_name)
39
40
  project = load_project!(project_name)
40
41
  project_task_name = "projects:#{project.name}"
@@ -47,7 +48,7 @@ module Omnibus
47
48
  Rake::Task[project_task_name].invoke
48
49
  end
49
50
 
50
- desc "software PROJECT SOFTWARE", "Build the given software component"
51
+ desc 'software PROJECT SOFTWARE', 'Build the given software component'
51
52
  def software(project_name, software_name)
52
53
  project = load_project!(project_name)
53
54
  software_task_name = "projects:#{project.name}:software:#{software_name}"
@@ -56,7 +57,6 @@ module Omnibus
56
57
 
57
58
  Rake::Task[software_task_name].invoke
58
59
  end
59
-
60
60
  end
61
61
  end
62
62
  end