omnibus 1.1.1 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,19 @@
1
+ ## 1.2.0 (July 12, 2013)
2
+
3
+ FEATURES:
4
+
5
+ * Add `whitelist_file` to software DSL. This allows an individual software
6
+ definition to declare files that should be ignored during health checking.
7
+
8
+ IMPROVEMENTS:
9
+
10
+ * Raise an exception if a project's dependency is not found.
11
+
12
+ BUG FIXES:
13
+
14
+ * Properly load a project's transitive dependencies.
15
+ * Ensure a component is only added to a library one time.
16
+
1
17
  ## 1.1.1 (July 2, 2013)
2
18
 
3
19
  BUG FIXES:
@@ -26,6 +26,7 @@ OHAI = o
26
26
  require 'omnibus/library'
27
27
  require 'omnibus/reports'
28
28
  require 'omnibus/config'
29
+ require 'omnibus/exceptions'
29
30
  require 'omnibus/software'
30
31
  require 'omnibus/project'
31
32
  require 'omnibus/fetchers'
@@ -183,15 +184,14 @@ module Omnibus
183
184
  # @return [void]
184
185
  #
185
186
  # @see Omnibus::Overrides#overrides
186
- def self.expand_software(overrides, software_files)
187
+ def self.expand_software(overrides, software_map)
187
188
  unless overrides.is_a? Hash
188
189
  raise ArgumentError, "Overrides argument must be a hash! You passed #{overrides.inspect}."
189
190
  end
190
191
 
191
- Omnibus.projects.each do |p|
192
- software_files.each do |f|
193
- s = Omnibus::Software.load(f, p, overrides)
194
- p.library.component_added(s) if p.dependency?(s.name)
192
+ Omnibus.projects.each do |project|
193
+ project.dependencies.each do |dependency|
194
+ recursively_load_dependency(dependency, project, overrides, software_map)
195
195
  end
196
196
  end
197
197
  end
@@ -205,12 +205,12 @@ module Omnibus
205
205
  expand_projects
206
206
 
207
207
  # Then do software
208
- final_software_files = prefer_local_software(omnibus_software_files,
208
+ final_software_map = prefer_local_software(omnibus_software_files,
209
209
  software_files)
210
210
 
211
211
  overrides = Config.override_file ? Omnibus::Overrides.overrides : {}
212
212
 
213
- expand_software(overrides, final_software_files)
213
+ expand_software(overrides, final_software_map)
214
214
  end
215
215
 
216
216
  # Creates some additional Rake tasks beyond those generated in the
@@ -260,7 +260,7 @@ module Omnibus
260
260
  def self.prefer_local_software(omnibus_files, local_files)
261
261
  base = software_map(omnibus_files)
262
262
  local = software_map(local_files)
263
- base.merge(local).values
263
+ base.merge(local)
264
264
  end
265
265
 
266
266
  # Given a list of file paths, create a map of the basename (without
@@ -274,4 +274,31 @@ module Omnibus
274
274
  collection[software_name] = file
275
275
  end
276
276
  end
277
+
278
+ # Loads a project's dependency recursively, ensuring all transitive dependencies
279
+ # are also loaded.
280
+ #
281
+ # @param dependency_name [String]
282
+ # @param project [Omnibus::Project]
283
+ # @param overrides [Hash] a hash of version override information.
284
+ # @param software_map [Hash<String, String>]
285
+ #
286
+ # @return [void]
287
+ def self.recursively_load_dependency(dependency_name, project, overrides, software_map)
288
+ dep_file = software_map[dependency_name]
289
+
290
+ unless dep_file
291
+ raise MissingProjectDependency.new(dependency_name,
292
+ [File.join(project_root, Config.software_dir),
293
+ File.join(omnibus_software_root, 'config', 'software')])
294
+ end
295
+
296
+ dep_software = Omnibus::Software.load(dep_file, project, overrides)
297
+ project.library.component_added(dep_software)
298
+
299
+ # load any transitive deps for the component into the library also
300
+ dep_software.dependencies.each do |dep|
301
+ recursively_load_dependency(dep, project, overrides, software_map)
302
+ end
303
+ end
277
304
  end
@@ -125,4 +125,19 @@ module Omnibus
125
125
  """
126
126
  end
127
127
  end
128
+
129
+ class MissingProjectDependency < RuntimeError
130
+ def initialize(dep_name, search_paths)
131
+ @dep_name, @search_paths = dep_name, search_paths
132
+ end
133
+
134
+ def to_s
135
+ """
136
+ Attempting to load the project dependency '#{@dep_name}', but it was
137
+ not found at any of the following locations:
138
+
139
+ #{@search_paths.join("\n ")}
140
+ """
141
+ end
142
+ end
128
143
  end
@@ -133,25 +133,18 @@ module Omnibus
133
133
  /libutil\.so/
134
134
  ]
135
135
 
136
- WHITELIST_FILES = [
137
- /jre\/bin\/javaws/,
138
- /jre\/bin\/policytool/,
139
- /jre\/lib/,
140
- /jre\/plugin/
141
- ]
142
-
143
136
  def self.log(msg)
144
137
  puts "[health_check] #{msg}"
145
138
  end
146
139
 
147
- def self.run(install_dir)
140
+ def self.run(install_dir, whitelist_files = [])
148
141
  case OHAI.platform
149
142
  when "mac_os_x"
150
- bad_libs = health_check_otool(install_dir)
143
+ bad_libs = health_check_otool(install_dir, whitelist_files)
151
144
  when "aix"
152
- bad_libs = health_check_aix(install_dir)
145
+ bad_libs = health_check_aix(install_dir, whitelist_files)
153
146
  else
154
- bad_libs = health_check_ldd(install_dir)
147
+ bad_libs = health_check_ldd(install_dir, whitelist_files)
155
148
  end
156
149
 
157
150
  unresolved = []
@@ -199,7 +192,7 @@ module Omnibus
199
192
  end
200
193
  end
201
194
 
202
- def self.health_check_otool(install_dir)
195
+ def self.health_check_otool(install_dir, whitelist_files)
203
196
  otool_cmd = "find #{install_dir}/ -type f | egrep '\.(dylib|bundle)$' | xargs otool -L > otool.out 2>/dev/null"
204
197
  log "Executing `#{otool_cmd}`"
205
198
  shell = Mixlib::ShellOut.new(otool_cmd, :timeout => 3600)
@@ -217,7 +210,7 @@ module Omnibus
217
210
  when /^\s+(.+) \(.+\)$/
218
211
  linked = $1
219
212
  name = File.basename(linked)
220
- bad_libs = check_for_bad_library(install_dir, bad_libs, current_library, name, linked)
213
+ bad_libs = check_for_bad_library(install_dir, bad_libs, whitelist_files, current_library, name, linked)
221
214
  end
222
215
  end
223
216
 
@@ -226,7 +219,7 @@ module Omnibus
226
219
  bad_libs
227
220
  end
228
221
 
229
- def self.check_for_bad_library(install_dir, bad_libs, current_library, name, linked)
222
+ def self.check_for_bad_library(install_dir, bad_libs, whitelist_files, current_library, name, linked)
230
223
  safe = nil
231
224
 
232
225
  whitelist_libs = case OHAI.platform
@@ -248,7 +241,7 @@ module Omnibus
248
241
  whitelist_libs.each do |reg|
249
242
  safe ||= true if reg.match(name)
250
243
  end
251
- WHITELIST_FILES.each do |reg|
244
+ whitelist_files.each do |reg|
252
245
  safe ||= true if reg.match(current_library)
253
246
  end
254
247
 
@@ -271,7 +264,7 @@ module Omnibus
271
264
  bad_libs
272
265
  end
273
266
 
274
- def self.health_check_aix(install_dir)
267
+ def self.health_check_aix(install_dir, whitelist_files)
275
268
  #
276
269
  # ShellOut has GC turned off during execution, so when we're
277
270
  # executing extremely long commands with lots of output, we
@@ -297,7 +290,7 @@ module Omnibus
297
290
  when /^\s+(.+)$/
298
291
  name = $1
299
292
  linked = $1
300
- bad_libs = check_for_bad_library(install_dir, bad_libs, current_library, name, linked)
293
+ bad_libs = check_for_bad_library(install_dir, bad_libs, whitelist_files, current_library, name, linked)
301
294
  when /File is not an executable XCOFF file/ # ignore non-executable files
302
295
  else
303
296
  log "*** Line did not match for #{current_library}\n#{line}"
@@ -308,7 +301,7 @@ module Omnibus
308
301
  bad_libs
309
302
  end
310
303
 
311
- def self.health_check_ldd(install_dir)
304
+ def self.health_check_ldd(install_dir, whitelist_files)
312
305
  #
313
306
  # ShellOut has GC turned off during execution, so when we're
314
307
  # executing extremely long commands with lots of output, we
@@ -334,7 +327,7 @@ module Omnibus
334
327
  when /^\s+(.+) \=\>\s+(.+)( \(.+\))?$/
335
328
  name = $1
336
329
  linked = $2
337
- bad_libs = check_for_bad_library(install_dir, bad_libs, current_library, name, linked)
330
+ bad_libs = check_for_bad_library(install_dir, bad_libs, whitelist_files, current_library, name, linked)
338
331
  when /^\s+(.+) \(.+\)$/
339
332
  next
340
333
  when /^\s+statically linked$/
@@ -28,7 +28,7 @@ module Omnibus
28
28
  end
29
29
 
30
30
  def component_added(component)
31
- @components << component
31
+ @components << component unless @components.include?(component)
32
32
  end
33
33
 
34
34
  def version_map
@@ -700,7 +700,9 @@ module Omnibus
700
700
  if OHAI.platform == "windows"
701
701
  puts "Skipping health check on windows..."
702
702
  else
703
- Omnibus::HealthCheck.run(install_path)
703
+ # build a list of all whitelist files from all project dependencies
704
+ whitelist_files = library.components.map{|component| component.whitelist_files }.flatten
705
+ Omnibus::HealthCheck.run(install_path, whitelist_files)
704
706
  end
705
707
  end
706
708
  end
@@ -51,6 +51,7 @@ module Omnibus
51
51
 
52
52
  attr_reader :given_version
53
53
  attr_reader :override_version
54
+ attr_reader :whitelist_files
54
55
 
55
56
  def self.load(filename, project, overrides={})
56
57
  new(IO.read(filename), filename, project, overrides)
@@ -85,6 +86,7 @@ module Omnibus
85
86
  @builder = NullBuilder.new(self)
86
87
 
87
88
  @dependencies = Array.new
89
+ @whitelist_files = Array.new
88
90
  instance_eval(io, filename, 0)
89
91
 
90
92
  # Set override information after the DSL file has been consumed
@@ -153,6 +155,15 @@ module Omnibus
153
155
  @override_version || @given_version
154
156
  end
155
157
 
158
+ # Add an Omnibus software dependency.
159
+ #
160
+ # @param file [String, Regexp] the name of a file to ignore in the healthcheck
161
+ # @return [void]
162
+ def whitelist_file(file)
163
+ file = Regexp.new(file) unless file.kind_of?(Regexp)
164
+ @whitelist_files << file
165
+ end
166
+
156
167
  # Was this software version overridden externally, relative to the
157
168
  # version declared within the software DSL file?
158
169
  #
@@ -1,4 +1,4 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
- gem 'omnibus', '~> 1.0.0'
3
+ gem 'omnibus', '~> 1.2.0'
4
4
  gem 'omnibus-software', :git => 'git://github.com/opscode/omnibus-software.git', :branch => 'master'
@@ -16,5 +16,5 @@
16
16
  #
17
17
 
18
18
  module Omnibus
19
- VERSION = "1.1.1"
19
+ VERSION = "1.2.0"
20
20
  end
@@ -5,33 +5,47 @@ require 'spec_helper'
5
5
 
6
6
  describe Omnibus::Software do
7
7
 
8
- let(:project) do
8
+ let(:project) do
9
9
  p = mock(Omnibus::Project)
10
10
  p.should_receive(:install_path).any_number_of_times.and_return("monkeys")
11
11
  p
12
12
  end
13
13
 
14
- let(:software_name) {"erchef"}
14
+ let(:software_name) { "erchef" }
15
15
  let(:software_file){ software_path(software_name) }
16
- let(:version_from_file){"4b19a96d57bff9bbf4764d7323b92a0944009b9e"}
16
+ let(:version_from_file){ "4b19a96d57bff9bbf4764d7323b92a0944009b9e" }
17
+ let(:software){ Omnibus::Software.load(software_file, project) }
17
18
 
18
- context "testing version overrides" do
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
19
34
 
20
- before :each do
21
- # We don't want to mess with any of this stuff for these
22
- # tests... we're just looking at version info right now
23
- Omnibus::Software.any_instance.stub(:render_tasks)
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)
24
39
  end
40
+ end
41
+
42
+ context "testing version overrides" do
25
43
 
26
- subject{software}
27
-
28
44
  context "without overrides" do
29
- let(:software){Omnibus::Software.load(software_file, project)}
30
-
31
45
  its(:name){should eq(software_name)}
32
46
  its(:version){should eq(version_from_file)}
33
47
  its(:given_version){should eq(software.version)}
34
- its(:override_version){should be_nil}
48
+ its(:override_version){should be_nil}
35
49
  end
36
50
 
37
51
  context "with overrides" do
@@ -43,11 +57,11 @@ describe Omnibus::Software do
43
57
 
44
58
  context "but not for this software" do
45
59
  let(:override_software_name){"chaos_monkey"}
46
-
60
+
47
61
  it "really should not have any overrides for this software" do
48
62
  overrides.should_not have_key(software_name)
49
63
  end
50
-
64
+
51
65
  its(:version){should eq(version_from_file)}
52
66
  its(:given_version){should eq(software.version)}
53
67
  its(:override_version){should be_nil}
@@ -59,7 +73,7 @@ describe Omnibus::Software do
59
73
  it "really should have an override for this software" do
60
74
  overrides.should have_key(software_name)
61
75
  end
62
-
76
+
63
77
  its(:version){should eq(override_software_version)}
64
78
  its(:override_version){should eq(software.version)}
65
79
  its(:version){should_not eq(software.given_version)}
metadata CHANGED
@@ -1,18 +1,20 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: omnibus
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.1
4
+ version: 1.2.0
5
+ prerelease:
5
6
  platform: ruby
6
7
  authors:
7
8
  - Opscode
8
9
  autorequire:
9
10
  bindir: bin
10
11
  cert_chain: []
11
- date: 2013-07-02 00:00:00.000000000 Z
12
+ date: 2013-07-12 00:00:00.000000000 Z
12
13
  dependencies:
13
14
  - !ruby/object:Gem::Dependency
14
15
  name: mixlib-shellout
15
16
  requirement: !ruby/object:Gem::Requirement
17
+ none: false
16
18
  requirements:
17
19
  - - ~>
18
20
  - !ruby/object:Gem::Version
@@ -20,6 +22,7 @@ dependencies:
20
22
  type: :runtime
21
23
  prerelease: false
22
24
  version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
23
26
  requirements:
24
27
  - - ~>
25
28
  - !ruby/object:Gem::Version
@@ -27,6 +30,7 @@ dependencies:
27
30
  - !ruby/object:Gem::Dependency
28
31
  name: mixlib-config
29
32
  requirement: !ruby/object:Gem::Requirement
33
+ none: false
30
34
  requirements:
31
35
  - - ~>
32
36
  - !ruby/object:Gem::Version
@@ -34,6 +38,7 @@ dependencies:
34
38
  type: :runtime
35
39
  prerelease: false
36
40
  version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
37
42
  requirements:
38
43
  - - ~>
39
44
  - !ruby/object:Gem::Version
@@ -41,6 +46,7 @@ dependencies:
41
46
  - !ruby/object:Gem::Dependency
42
47
  name: ohai
43
48
  requirement: !ruby/object:Gem::Requirement
49
+ none: false
44
50
  requirements:
45
51
  - - ! '>='
46
52
  - !ruby/object:Gem::Version
@@ -48,6 +54,7 @@ dependencies:
48
54
  type: :runtime
49
55
  prerelease: false
50
56
  version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
51
58
  requirements:
52
59
  - - ! '>='
53
60
  - !ruby/object:Gem::Version
@@ -55,6 +62,7 @@ dependencies:
55
62
  - !ruby/object:Gem::Dependency
56
63
  name: rake
57
64
  requirement: !ruby/object:Gem::Requirement
65
+ none: false
58
66
  requirements:
59
67
  - - ! '>='
60
68
  - !ruby/object:Gem::Version
@@ -62,6 +70,7 @@ dependencies:
62
70
  type: :runtime
63
71
  prerelease: false
64
72
  version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
65
74
  requirements:
66
75
  - - ! '>='
67
76
  - !ruby/object:Gem::Version
@@ -69,6 +78,7 @@ dependencies:
69
78
  - !ruby/object:Gem::Dependency
70
79
  name: fpm
71
80
  requirement: !ruby/object:Gem::Requirement
81
+ none: false
72
82
  requirements:
73
83
  - - ~>
74
84
  - !ruby/object:Gem::Version
@@ -76,6 +86,7 @@ dependencies:
76
86
  type: :runtime
77
87
  prerelease: false
78
88
  version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
79
90
  requirements:
80
91
  - - ~>
81
92
  - !ruby/object:Gem::Version
@@ -83,6 +94,7 @@ dependencies:
83
94
  - !ruby/object:Gem::Dependency
84
95
  name: uber-s3
85
96
  requirement: !ruby/object:Gem::Requirement
97
+ none: false
86
98
  requirements:
87
99
  - - ! '>='
88
100
  - !ruby/object:Gem::Version
@@ -90,6 +102,7 @@ dependencies:
90
102
  type: :runtime
91
103
  prerelease: false
92
104
  version_requirements: !ruby/object:Gem::Requirement
105
+ none: false
93
106
  requirements:
94
107
  - - ! '>='
95
108
  - !ruby/object:Gem::Version
@@ -97,6 +110,7 @@ dependencies:
97
110
  - !ruby/object:Gem::Dependency
98
111
  name: thor
99
112
  requirement: !ruby/object:Gem::Requirement
113
+ none: false
100
114
  requirements:
101
115
  - - ! '>='
102
116
  - !ruby/object:Gem::Version
@@ -104,6 +118,7 @@ dependencies:
104
118
  type: :runtime
105
119
  prerelease: false
106
120
  version_requirements: !ruby/object:Gem::Requirement
121
+ none: false
107
122
  requirements:
108
123
  - - ! '>='
109
124
  - !ruby/object:Gem::Version
@@ -111,6 +126,7 @@ dependencies:
111
126
  - !ruby/object:Gem::Dependency
112
127
  name: rspec
113
128
  requirement: !ruby/object:Gem::Requirement
129
+ none: false
114
130
  requirements:
115
131
  - - ! '>='
116
132
  - !ruby/object:Gem::Version
@@ -118,6 +134,7 @@ dependencies:
118
134
  type: :development
119
135
  prerelease: false
120
136
  version_requirements: !ruby/object:Gem::Requirement
137
+ none: false
121
138
  requirements:
122
139
  - - ! '>='
123
140
  - !ruby/object:Gem::Version
@@ -125,6 +142,7 @@ dependencies:
125
142
  - !ruby/object:Gem::Dependency
126
143
  name: rspec_junit_formatter
127
144
  requirement: !ruby/object:Gem::Requirement
145
+ none: false
128
146
  requirements:
129
147
  - - ! '>='
130
148
  - !ruby/object:Gem::Version
@@ -132,6 +150,7 @@ dependencies:
132
150
  type: :development
133
151
  prerelease: false
134
152
  version_requirements: !ruby/object:Gem::Requirement
153
+ none: false
135
154
  requirements:
136
155
  - - ! '>='
137
156
  - !ruby/object:Gem::Version
@@ -214,26 +233,30 @@ files:
214
233
  homepage: https://github.com/opscode/omnibus-ruby
215
234
  licenses:
216
235
  - Apache 2.0
217
- metadata: {}
218
236
  post_install_message:
219
237
  rdoc_options: []
220
238
  require_paths:
221
239
  - lib
222
240
  required_ruby_version: !ruby/object:Gem::Requirement
241
+ none: false
223
242
  requirements:
224
243
  - - ! '>='
225
244
  - !ruby/object:Gem::Version
226
245
  version: 1.9.1
227
246
  required_rubygems_version: !ruby/object:Gem::Requirement
247
+ none: false
228
248
  requirements:
229
249
  - - ! '>='
230
250
  - !ruby/object:Gem::Version
231
251
  version: '0'
252
+ segments:
253
+ - 0
254
+ hash: -2339140264674066912
232
255
  requirements: []
233
256
  rubyforge_project:
234
- rubygems_version: 2.0.3
257
+ rubygems_version: 1.8.23
235
258
  signing_key:
236
- specification_version: 4
259
+ specification_version: 3
237
260
  summary: Omnibus helps you build self-installing, full-stack software builds.
238
261
  test_files:
239
262
  - spec/artifact_spec.rb
checksums.yaml DELETED
@@ -1,15 +0,0 @@
1
- ---
2
- !binary "U0hBMQ==":
3
- metadata.gz: !binary |-
4
- ZjM0YzUxNDMyZDFmNGRhYjJkMmY5YmQ4OGNjMWRkZjg0ODYwOTcxYw==
5
- data.tar.gz: !binary |-
6
- ZGYwZDEzMzNmYmU0ZjU2MmQzNTFmNTlkMGNkOTBiMjM5MDljYWU5ZQ==
7
- !binary "U0hBNTEy":
8
- metadata.gz: !binary |-
9
- YjRlYzQ0MDM1NzI5YmEyZWYxMWE4MDNmNmY4NTNlMmI2MDA3YTcyNWI1ZjEw
10
- ZmE0OTFjODAyMWZmMWNmNDYxMWI4N2VlNDE3ODc3NWJmNDNkYTFkMDI1YTM1
11
- ZjAzOWY2YzZjNGFhOTliZjk0M2RiYzkwZjVjMDhlZGI5OGQyYzk=
12
- data.tar.gz: !binary |-
13
- ZjRkNTY3YmJhOTE2NzE4MmIwZTFiOWRmNjgwMzViNDVlNmRjMjY5NGYwOGZk
14
- MDE3NmQ1Njk1Mjk4NDQ2MmU2Nzk5N2ZjMjYxZDI0YWQ1ZGIwMjgyM2ViOWM2
15
- MDYwZWRhZjNmOTQwYzEyMTQ0NzI0ZTI4NDNhMGExZDhlZmNjYmI=