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");
@@ -16,11 +16,9 @@
16
16
  #
17
17
 
18
18
  module Omnibus
19
-
20
19
  module Reports
21
20
  extend self
22
21
 
23
-
24
22
  PADDING = 3
25
23
 
26
24
  # Determine how wide a column should be, taking into account both
@@ -28,7 +26,7 @@ module Omnibus
28
26
  # will be stored in the column, the width is 0 (i.e., nothing
29
27
  # should be printed, not even the column header)
30
28
  def column_width(items, column_name)
31
- widest_item = items.max{|a,b| a.size <=> b.size}
29
+ widest_item = items.max { |a, b| a.size <=> b.size }
32
30
  if widest_item
33
31
  widest = (widest_item.size >= column_name.size) ? widest_item : column_name
34
32
  widest.size + PADDING
@@ -38,14 +36,13 @@ module Omnibus
38
36
  end
39
37
 
40
38
  def non_nil_values(hashes, selector_key)
41
- hashes.map{|v| v[selector_key]}.compact
39
+ hashes.map { |v| v[selector_key] }.compact
42
40
  end
43
41
 
44
42
  def pretty_version_map(project)
45
- out = ""
43
+ out = ''
46
44
  version_map = project.library.version_map
47
45
 
48
-
49
46
  # Pull out data to print out
50
47
  versions = non_nil_values(version_map.values, :version)
51
48
  guids = non_nil_values(version_map.values, :version_guid)
@@ -53,25 +50,23 @@ module Omnibus
53
50
  # We only want the versions that have truly been overridden;
54
51
  # because we want to output a column only if something was
55
52
  # overridden, but nothing if no packages were changed
56
- overridden_versions = non_nil_values(version_map.values.select{|v| v[:overridden]},
57
- :given_version)
58
-
53
+ overridden_versions = non_nil_values(version_map.values.select { |v| v[:overridden] }, :default_version)
59
54
 
60
55
  # Determine how wide the printed table columns need to be
61
- name_width = column_width(version_map.keys, "Component")
62
- version_width = column_width(versions, "Installed Version")
63
- guid_width = column_width(guids, "Version GUID")
64
- override_width = column_width(overridden_versions, "Overridden From")
56
+ name_width = column_width(version_map.keys, 'Component')
57
+ version_width = column_width(versions, 'Installed Version')
58
+ guid_width = column_width(guids, 'Version GUID')
59
+ override_width = column_width(overridden_versions, 'Overridden From')
65
60
 
66
61
  total_width = name_width + version_width + guid_width + override_width
67
- divider = "-" * total_width
62
+ divider = '-' * total_width
68
63
 
69
64
  # Print out the column headers
70
- out << "Component".ljust(name_width)
71
- out << "Installed Version".ljust(version_width)
72
- out << "Version GUID".ljust(guid_width)
65
+ out << 'Component'.ljust(name_width)
66
+ out << 'Installed Version'.ljust(version_width)
67
+ out << 'Version GUID'.ljust(guid_width)
73
68
  # Only print out column if something was overridden
74
- out << "Overridden From".ljust(override_width) if override_width > 0
69
+ out << 'Overridden From'.ljust(override_width) if override_width > 0
75
70
  out << "\n"
76
71
  out << divider << "\n"
77
72
 
@@ -80,20 +75,17 @@ module Omnibus
80
75
  version = version_map[name][:version]
81
76
  version_guid = version_map[name][:version_guid]
82
77
 
83
- given_version = version_map[name][:given_version]
78
+ default_version = version_map[name][:default_version]
84
79
  overridden = version_map[name][:overridden]
85
80
 
86
81
  out << "#{name}".ljust(name_width)
87
82
  out << version.to_s.ljust(version_width)
88
83
  out << version_guid.to_s.ljust(guid_width) if version_guid
89
84
  # Only print out column if something was overridden
90
- out << given_version.ljust(override_width) if overridden
85
+ out << default_version.ljust(override_width) if overridden
91
86
  out << "\n"
92
87
  end
93
88
  out
94
89
  end
95
-
96
90
  end
97
-
98
-
99
91
  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");
@@ -20,10 +20,7 @@ require 'uber-s3'
20
20
  require 'omnibus/fetchers'
21
21
 
22
22
  module Omnibus
23
-
24
-
25
23
  module SoftwareS3URLs
26
-
27
24
  class InsufficientSpecification < ArgumentError
28
25
  end
29
26
 
@@ -38,27 +35,25 @@ module Omnibus
38
35
  private
39
36
 
40
37
  def key_for_package(package)
41
- package.name or raise InsufficientSpecification, "Software must have a name to cache it in S3 (#{package.inspect})"
42
- package.version or raise InsufficientSpecification, "Software must set a version to cache it in S3 (#{package.inspect})"
43
- package.checksum or raise InsufficientSpecification, "Software must specify a checksum (md5) to cache it in S3 (#{package.inspect})"
38
+ package.name || fail(InsufficientSpecification, "Software must have a name to cache it in S3 (#{package.inspect})")
39
+ package.version || fail(InsufficientSpecification, "Software must set a version to cache it in S3 (#{package.inspect})")
40
+ package.checksum || fail(InsufficientSpecification, "Software must specify a checksum (md5) to cache it in S3 (#{package.inspect})")
44
41
  "#{package.name}-#{package.version}-#{package.checksum}"
45
42
  end
46
-
47
43
  end
48
44
 
49
45
  class S3Cache
50
-
51
46
  include SoftwareS3URLs
52
47
 
53
48
  def initialize
54
49
  unless config.s3_bucket && config.s3_access_key && config.s3_secret_key
55
- raise InvalidS3Configuration.new(config.s3_bucket, config.s3_access_key, config.s3_secret_key)
50
+ fail InvalidS3Configuration.new(config.s3_bucket, config.s3_access_key, config.s3_secret_key)
56
51
  end
57
52
  @client = UberS3.new(
58
- :access_key => config.s3_access_key,
59
- :secret_access_key => config.s3_secret_key,
60
- :bucket => config.s3_bucket,
61
- :adaper => :net_http
53
+ access_key: config.s3_access_key,
54
+ secret_access_key: config.s3_secret_key,
55
+ bucket: config.s3_bucket,
56
+ adapter: :net_http,
62
57
  )
63
58
  end
64
59
 
@@ -72,7 +67,7 @@ module Omnibus
72
67
 
73
68
  def list
74
69
  existing_keys = list_by_key
75
- tarball_software.select {|s| existing_keys.include?(key_for_package(s))}
70
+ tarball_software.select { |s| existing_keys.include?(key_for_package(s)) }
76
71
  end
77
72
 
78
73
  def list_by_key
@@ -81,12 +76,12 @@ module Omnibus
81
76
 
82
77
  def missing
83
78
  already_cached = list_by_key
84
- tarball_software.delete_if {|s| already_cached.include?(key_for_package(s))}
79
+ tarball_software.delete_if { |s| already_cached.include?(key_for_package(s)) }
85
80
  end
86
81
 
87
82
  def tarball_software
88
83
  Omnibus.projects.map do |project|
89
- project.library.select {|s| s.source && s.source.key?(:url)}
84
+ project.library.select { |s| s.source && s.source.key?(:url) }
90
85
  end.flatten
91
86
  end
92
87
 
@@ -98,7 +93,7 @@ module Omnibus
98
93
  content = IO.read(software.project_file)
99
94
 
100
95
  log "Uploading #{software.project_file} as #{config.s3_bucket}/#{key}"
101
- @client.store(key, content, :access => :public_read, :content_md5 => software.checksum)
96
+ @client.store(key, content, access: :public_read, content_md5: software.checksum)
102
97
  end
103
98
  end
104
99
 
@@ -121,7 +116,7 @@ module Omnibus
121
116
  fetcher.download
122
117
  fetcher.verify_checksum!
123
118
  else
124
- log "Cached copy up to date, skipping."
119
+ log 'Cached copy up to date, skipping.'
125
120
  end
126
121
  end
127
122
 
@@ -129,10 +124,9 @@ module Omnibus
129
124
  @bucket ||= begin
130
125
  b = UberS3::Bucket.new(@client, @client.bucket)
131
126
  # creating the bucket is idempotent, make sure it's created:
132
- @client.connection.put("/")
127
+ @client.connection.put('/')
133
128
  b
134
129
  end
135
130
  end
136
-
137
131
  end
138
132
  end
@@ -29,12 +29,12 @@ require 'omnibus/config'
29
29
  require 'rake'
30
30
 
31
31
  module Omnibus
32
-
33
32
  # Omnibus software DSL reader
34
33
  class Software
35
34
  include Rake::DSL
36
35
 
37
36
  NULL_ARG = Object.new
37
+ UNINITIALIZED = Object.new
38
38
 
39
39
  # It appears that this is not used
40
40
  attr_reader :builder
@@ -49,18 +49,20 @@ module Omnibus
49
49
 
50
50
  attr_reader :project
51
51
 
52
- attr_reader :given_version
53
- attr_reader :override_version
52
+ attr_reader :version
53
+
54
+ attr_reader :overrides
55
+
54
56
  attr_reader :whitelist_files
55
57
 
56
- def self.load(filename, project, overrides={})
57
- new(IO.read(filename), filename, project, overrides)
58
+ def self.load(filename, project, repo_overrides = {})
59
+ new(IO.read(filename), filename, project, repo_overrides)
58
60
  end
59
61
 
60
62
  # @param io [String]
61
63
  # @param filename [String]
62
64
  # @param project [???] Is this a string or an Omnibus::Project?
63
- # @param overrides [Hash]
65
+ # @param repo_overrides [Hash]
64
66
  #
65
67
  # @see Omnibus::Overrides
66
68
  #
@@ -70,9 +72,9 @@ module Omnibus
70
72
  # project, and override hash directly? That is, why io AND a
71
73
  # filename, if the filename can always get you the contents you
72
74
  # need anyway?
73
- def initialize(io, filename, project, overrides={})
74
- @given_version = nil
75
- @override_version = nil
75
+ def initialize(io, filename, project, repo_overrides = {})
76
+ @version = nil
77
+ @overrides = UNINITIALIZED
76
78
  @name = nil
77
79
  @description = nil
78
80
  @source = nil
@@ -81,25 +83,58 @@ module Omnibus
81
83
  @source_config = filename
82
84
  @project = project
83
85
  @always_build = false
86
+ @repo_overrides = repo_overrides
84
87
 
85
88
  # Seems like this should just be Builder.new(self) instead
86
89
  @builder = NullBuilder.new(self)
87
90
 
88
- @dependencies = Array.new
89
- @whitelist_files = Array.new
91
+ @dependencies = []
92
+ @whitelist_files = []
90
93
  instance_eval(io, filename, 0)
91
94
 
92
- # Set override information after the DSL file has been consumed
93
- @override_version = overrides[name]
94
-
95
95
  render_tasks
96
96
  end
97
97
 
98
- def name(val=NULL_ARG)
98
+ # Retrieves the override_version
99
+ #
100
+ # @return [Hash]
101
+ #
102
+ # @todo: can't we just use #version here or are we testing this against nil? somewhere and
103
+ # not using #overridden?
104
+ def override_version
105
+ $stderr.puts 'The #override_version is DEPRECATED, please use #version or test with #overridden?'
106
+ overrides[:version]
107
+ end
108
+
109
+ # Retrieves the repo-level and project-level overrides for the software.
110
+ #
111
+ # @return [Hash]
112
+ def overrides
113
+ # deliberately not providing a setter since that feels like a shotgun pointed at a foot
114
+ if @overrides == UNINITIALIZED
115
+ # lazily initialized because we need the 'name' to be parsed first
116
+ @overrides = {}
117
+ @overrides = project.overrides[name.to_sym].dup if project.overrides[name.to_sym]
118
+ if @repo_overrides[name]
119
+ @overrides[:version] = @repo_overrides[name]
120
+ end
121
+ end
122
+ @overrides
123
+ end
124
+
125
+ # Sets or retreives the name of the software
126
+ #
127
+ # @param val [String] name of the Software
128
+ # @return [String]
129
+ def name(val = NULL_ARG)
99
130
  @name = val unless val.equal?(NULL_ARG)
100
- @name
131
+ @name || fail(MissingSoftwareConfiguration.new(name, 'name', 'libxslt'))
101
132
  end
102
133
 
134
+ # Sets the description of the software
135
+ #
136
+ # @param val [String] description of the Software
137
+ # @return [void]
103
138
  def description(val)
104
139
  @description = val
105
140
  end
@@ -125,7 +160,7 @@ module Omnibus
125
160
  #
126
161
  # @param val [Array<String>] a list of names of Software components
127
162
  # @return [Array<String>]
128
- def dependencies(val=NULL_ARG)
163
+ def dependencies(val = NULL_ARG)
129
164
  @dependencies = val unless val.equal?(NULL_ARG)
130
165
  @dependencies
131
166
  end
@@ -140,19 +175,60 @@ module Omnibus
140
175
  #
141
176
  # @todo Consider changing this to accept two arguments instead
142
177
  # @todo This should throw an error if an invalid key is given, or
143
- # if more than one pair is given, or if no source value is ever
144
- # set.
145
- def source(val=NULL_ARG)
146
- @source = val unless val.equal?(NULL_ARG)
147
- @source
178
+ # if more than one pair is given
179
+ def source(val = NULL_ARG)
180
+ unless val.equal?(NULL_ARG)
181
+ @source ||= {}
182
+ @source.merge!(val)
183
+ end
184
+ apply_overrides(:source)
148
185
  end
149
186
 
150
- # Set a version from a software descriptor file, or receive the
151
- # effective version, taking into account any override information
152
- # (if set)
153
- def version(val=NULL_ARG)
154
- @given_version = val unless val.equal?(NULL_ARG)
155
- @override_version || @given_version
187
+ # Retieve the default_version of the software
188
+ #
189
+ # @return [String]
190
+ #
191
+ # @todo: remove this in favor of default_version
192
+ def given_version
193
+ $stderr.puts "Getting the default version via #given_version is DEPRECATED, please use 'default_version'"
194
+ default_version
195
+ end
196
+
197
+ # Set or retieve the default_version of the software to build
198
+ #
199
+ # @param val [String]
200
+ # @return [String]
201
+ def default_version(val = NULL_ARG)
202
+ @version = val unless val.equal?(NULL_ARG)
203
+ @version
204
+ end
205
+
206
+ # Evaluate a block only if the version matches.
207
+ #
208
+ # Note that passing only a string without a block will set the default_version but this
209
+ # behavior is deprecated and will be removed, use the default_version method instead.
210
+ #
211
+ # @param val [String] version of the software.
212
+ # @param block [Proc] block to run if the version we are building matches the argument.
213
+ # @return [void]
214
+ #
215
+ # @todo remove deprecated setting of version
216
+ def version(val = NULL_ARG)
217
+ if block_given?
218
+ if val.equal?(NULL_ARG)
219
+ fail 'block needs a version argument to apply against'
220
+ else
221
+ if val == apply_overrides(:version)
222
+ yield
223
+ end
224
+ end
225
+ else
226
+ unless val.equal?(NULL_ARG)
227
+ $stderr.puts "Setting the version via 'version' is DEPRECATED, please use 'default_version'"
228
+ @version = val
229
+ end
230
+ end
231
+ apply_overrides(:version)
156
232
  end
157
233
 
158
234
  # Add an Omnibus software dependency.
@@ -169,7 +245,8 @@ module Omnibus
169
245
  #
170
246
  # @return [Boolean]
171
247
  def overridden?
172
- @override_version && (@override_version != @given_version)
248
+ # note: using instance variables to bypass accessors that enforce overrides
249
+ @overrides.key?(:version) && (@overrides[:version] != @version)
173
250
  end
174
251
 
175
252
  # @todo see comments on {Omnibus::Fetcher#without_caching_for}
@@ -312,12 +389,12 @@ module Omnibus
312
389
  path = project_path.dup
313
390
  # split the path and remmove and empty strings
314
391
  if platform == 'windows'
315
- path.sub!(":", "")
316
- parts = path.split("\\") - [""]
317
- parts.join("_")
392
+ path.sub!(':', '')
393
+ parts = path.split('\\') - ['']
394
+ parts.join('_')
318
395
  else
319
- parts = path.split("/") - [""]
320
- parts.join("_")
396
+ parts = path.split('/') - ['']
397
+ parts.join('_')
321
398
  end
322
399
  end
323
400
 
@@ -351,16 +428,30 @@ module Omnibus
351
428
  # @return [String] Either "sparc" or "intel", as appropriate
352
429
  # @todo Is this used? Doesn't appear to be...
353
430
  def architecture
354
- OHAI.kernel['machine'] =~ /sun/ ? "sparc" : "intel"
431
+ OHAI.kernel['machine'] =~ /sun/ ? 'sparc' : 'intel'
355
432
  end
356
433
 
357
434
  private
358
435
 
436
+ # Apply overrides in the @overrides hash that mask instance variables
437
+ # that are set by parsing the DSL
438
+ #
439
+ def apply_overrides(attr)
440
+ val = instance_variable_get(:"@#{attr}")
441
+ if val.is_a?(Hash) || overrides[attr].is_a?(Hash)
442
+ val ||= {}
443
+ override = overrides[attr] || {}
444
+ val.merge(override)
445
+ else
446
+ overrides[attr] || val
447
+ end
448
+ end
449
+
359
450
  # @todo What?!
360
451
  # @todo It seems that this is not used... remove it
361
452
  # @deprecated Use something else (?)
362
453
  def command(*args)
363
- raise "Method Moved."
454
+ fail 'Method Moved.'
364
455
  end
365
456
 
366
457
  def execute_build(fetcher)
@@ -371,71 +462,70 @@ module Omnibus
371
462
 
372
463
  def render_tasks
373
464
  namespace "projects:#{@project.name}" do
374
- namespace :software do
375
- fetcher = Fetcher.for(self)
376
-
377
- #
378
- # set up inter-project dependencies
379
- #
380
- (@dependencies - [@name]).uniq.each do |dep|
381
- task @name => dep
382
- file manifest_file => manifest_file_from_name(dep)
383
- end
465
+ namespace :software do
466
+ fetcher = Fetcher.for(self)
467
+
468
+ #
469
+ # set up inter-project dependencies
470
+ #
471
+ (@dependencies - [@name]).uniq.each do |dep|
472
+ task @name => dep
473
+ file manifest_file => manifest_file_from_name(dep)
474
+ end
384
475
 
385
- directory source_dir
386
- directory cache_dir
387
- directory build_dir
388
- directory project_dir
389
- namespace @name do
390
- task :fetch => [ build_dir, source_dir, cache_dir, project_dir ] do
391
- if !File.exists?(fetch_file) || fetcher.fetch_required?
392
- # force build to run if we need to do an updated fetch
393
- fetcher.fetch
394
- touch fetch_file
476
+ directory source_dir
477
+ directory cache_dir
478
+ directory build_dir
479
+ directory project_dir
480
+ namespace @name do
481
+ task fetch: [build_dir, source_dir, cache_dir, project_dir] do
482
+ if !File.exists?(fetch_file) || fetcher.fetch_required?
483
+ # force build to run if we need to do an updated fetch
484
+ fetcher.fetch
485
+ touch fetch_file
486
+ end
395
487
  end
396
- end
397
488
 
398
- task :build => :fetch do
399
- if !always_build? && uptodate?(manifest_file, [fetch_file])
400
- # if any direct deps have been built for any reason, we will need to
401
- # clean/build ourselves
402
- (@dependencies - [@name]).uniq.each do |dep|
403
- unless uptodate?(manifest_file, [manifest_file_from_name(dep)])
404
- execute_build(fetcher)
405
- break
489
+ task build: :fetch do
490
+ if !always_build? && uptodate?(manifest_file, [fetch_file])
491
+ # if any direct deps have been built for any reason, we will need to
492
+ # clean/build ourselves
493
+ (@dependencies - [@name]).uniq.each do |dep|
494
+ unless uptodate?(manifest_file, [manifest_file_from_name(dep)])
495
+ execute_build(fetcher)
496
+ break
497
+ end
406
498
  end
407
- end
408
499
 
409
- else
410
- # if fetch has occurred, or the component is configured to
411
- # always build, do a clean and build.
412
- execute_build(fetcher)
500
+ else
501
+ # if fetch has occurred, or the component is configured to
502
+ # always build, do a clean and build.
503
+ execute_build(fetcher)
504
+ end
413
505
  end
414
506
  end
415
- end
416
507
 
417
- #
418
- # make the manifest file dependent on the latest file in the
419
- # source tree in order to shrink the multi-thousand-node
420
- # dependency graph that Rake was generating
421
- #
422
- latest_file = FileList["#{project_dir}/**/*"].sort { |a,b|
423
- File.mtime(a) <=> File.mtime(b)
424
- }.last
508
+ #
509
+ # make the manifest file dependent on the latest file in the
510
+ # source tree in order to shrink the multi-thousand-node
511
+ # dependency graph that Rake was generating
512
+ #
513
+ latest_file = FileList["#{project_dir}/**/*"].sort do |a, b|
514
+ File.mtime(a) <=> File.mtime(b)
515
+ end.last
425
516
 
426
- file manifest_file => (file latest_file)
517
+ file manifest_file => (file latest_file)
427
518
 
428
- file fetch_file => "#{name}:fetch"
429
- file manifest_file => "#{name}:build"
519
+ file fetch_file => "#{name}:fetch"
520
+ file manifest_file => "#{name}:build"
430
521
 
431
- file fetch_file => (file @source_config)
432
- file manifest_file => (file fetch_file)
522
+ file fetch_file => (file @source_config)
523
+ file manifest_file => (file fetch_file)
433
524
 
434
- desc "fetch and build #{@name} for #{@project.name}"
435
- task @name => manifest_file
436
- end
525
+ desc "fetch and build #{@name} for #{@project.name}"
526
+ task @name => manifest_file
527
+ end
437
528
  end
438
529
  end
439
-
440
530
  end
441
531
  end
data/lib/omnibus/util.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  #
2
- # Author:: Seth Chisamore (<schisamo@opscode.com>)
3
- # Copyright:: Copyright (c) 2013 Opscode, Inc.
2
+ # Author:: Seth Chisamore (<schisamo@getchef.com>)
3
+ # Copyright:: Copyright (c) 2013-2014 Chef Software, Inc.
4
4
  # License:: Apache License, Version 2.0
5
5
  #
6
6
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -20,26 +20,38 @@ require 'mixlib/shellout'
20
20
 
21
21
  module Omnibus
22
22
  #
23
- # @author Seth Chisamore (<schisamo@opscode.com>)
23
+ # @author Seth Chisamore (<schisamo@getchef.com>)
24
24
  #
25
25
  module Util
26
26
  # Shells out and runs +command+.
27
27
  #
28
- # @param command [String]
29
- # @param opts [Hash] the options passed to the initializer of the
30
- # +Mixlib::ShellOut+ instance.
28
+ # @overload shellout(command, opts={})
29
+ # @param command [String]
30
+ # @param opts [Hash] the options passed to the initializer of the
31
+ # +Mixlib::ShellOut+ instance.
32
+ # @overload shellout(command_fragments, opts={})
33
+ # @param command [Array<String>] command argv as individual strings
34
+ # @param opts [Hash] the options passed to the initializer of the
35
+ # +Mixlib::ShellOut+ instance.
31
36
  # @return [Mixlib::ShellOut] the underlying +Mixlib::ShellOut+ instance
32
37
  # which which has +stdout+, +stderr+, +status+, and +exitstatus+
33
38
  # populated with results of the command.
34
39
  #
35
- def shellout(command, opts={})
40
+ def shellout(*command_fragments)
36
41
  STDOUT.sync = true
42
+
43
+ opts = if command_fragments.last.kind_of?(Hash)
44
+ command_fragments.pop
45
+ else
46
+ {}
47
+ end
48
+
37
49
  default_options = {
38
- :live_stream => STDOUT,
39
- :timeout => 7200, # 2 hours
40
- :environment => {}
50
+ live_stream: STDOUT,
51
+ timeout: 7200, # 2 hours
52
+ environment: {},
41
53
  }
42
- cmd = Mixlib::ShellOut.new(command, default_options.merge(opts))
54
+ cmd = Mixlib::ShellOut.new(*command_fragments, default_options.merge(opts))
43
55
  cmd.run_command
44
56
  cmd
45
57
  end
@@ -52,8 +64,8 @@ module Omnibus
52
64
  # @raise [Mixlib::ShellOut::ShellCommandFailed] if +exitstatus+ is not in
53
65
  # the list of +valid_exit_codes+.
54
66
  #
55
- def shellout!(command, opts={})
56
- cmd = shellout(command, opts)
67
+ def shellout!(*command_fragments)
68
+ cmd = shellout(*command_fragments)
57
69
  cmd.error!
58
70
  cmd
59
71
  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");
@@ -16,5 +16,5 @@
16
16
  #
17
17
 
18
18
  module Omnibus
19
- VERSION = "1.3.0"
19
+ VERSION = '2.0.0.rc1'
20
20
  end