omnibus 1.3.0 → 2.0.0.rc1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (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,7 +16,6 @@
16
16
  #
17
17
 
18
18
  module Omnibus
19
-
20
19
  class UnsupportedURIScheme < ArgumentError
21
20
  end
22
21
 
@@ -25,7 +24,6 @@ module Omnibus
25
24
 
26
25
  # Fetcher Implementation for HTTP and FTP hosted tarballs
27
26
  class NetFetcher < Fetcher
28
-
29
27
  name :net
30
28
 
31
29
  attr_reader :name
@@ -46,10 +44,10 @@ module Omnibus
46
44
  end
47
45
 
48
46
  def description
49
- s=<<-E
47
+ <<-E
50
48
  source URI: #{source_uri}
51
49
  checksum: #{@checksum}
52
- local location: #@project_file
50
+ local location: #{@project_file}
53
51
  E
54
52
  end
55
53
 
@@ -61,7 +59,6 @@ E
61
59
  !File.exists?(project_file) || Digest::MD5.file(project_file) != @checksum
62
60
  end
63
61
 
64
-
65
62
  def clean
66
63
  if File.exists?(project_dir)
67
64
  log "cleaning existing build from #{project_dir}"
@@ -75,31 +72,29 @@ E
75
72
  download
76
73
  verify_checksum!
77
74
  else
78
- log "Cached copy of source tarball up to date"
75
+ log 'Cached copy of source tarball up to date'
79
76
  end
80
77
  end
81
78
 
82
79
  def get_with_redirect(url, headers, limit = 10)
83
- raise ArgumentError, 'HTTP redirect too deep' if limit == 0
80
+ fail ArgumentError, 'HTTP redirect too deep' if limit == 0
84
81
  log "getting from #{url} with #{limit} redirects left"
85
82
 
86
- if !url.kind_of?(URI)
87
- url = URI.parse(url)
88
- end
83
+ url = URI.parse(url) unless url.kind_of?(URI)
89
84
 
90
85
  req = Net::HTTP::Get.new(url.request_uri, headers)
91
86
 
92
87
  http_client = if http_proxy && !excluded_from_proxy?(url.host)
93
- Net::HTTP::Proxy(http_proxy.host, http_proxy.port, http_proxy.user, http_proxy.password).new(url.host, url.port)
94
- else
95
- Net::HTTP.new(url.host, url.port)
96
- end
97
- http_client.use_ssl = (url.scheme == "https")
88
+ Net::HTTP::Proxy(http_proxy.host, http_proxy.port, http_proxy.user, http_proxy.password).new(url.host, url.port)
89
+ else
90
+ Net::HTTP.new(url.host, url.port)
91
+ end
92
+ http_client.use_ssl = (url.scheme == 'https')
98
93
 
99
94
  response = http_client.start { |http| http.request(req) }
100
95
  case response
101
96
  when Net::HTTPSuccess
102
- open(project_file, "wb") do |f|
97
+ open(project_file, 'wb') do |f|
103
98
  f.write(response.body)
104
99
  end
105
100
  when Net::HTTPRedirection
@@ -117,7 +112,7 @@ E
117
112
  # constructs a http_proxy uri from HTTP_PROXY* env vars
118
113
  def http_proxy
119
114
  @http_proxy ||= begin
120
- proxy = get_env('HTTP_PROXY') or return
115
+ proxy = get_env('HTTP_PROXY') || return
121
116
  proxy = "http://#{proxy}" unless proxy =~ /^https?:/
122
117
  uri = URI.parse(proxy)
123
118
  uri.user ||= get_env('HTTP_PROXY_USER')
@@ -130,14 +125,14 @@ E
130
125
  # the 'no_proxy' variable contains a list of host suffixes separated by comma
131
126
  # example: example.com,www.examle.org,localhost
132
127
  def excluded_from_proxy?(host)
133
- no_proxy = get_env('no_proxy') || ""
128
+ no_proxy = get_env('no_proxy') || ''
134
129
  no_proxy.split(/\s*,\s*/).any? { |pattern| host.end_with? pattern }
135
130
  end
136
131
 
137
132
  def download
138
133
  tries = 5
139
134
  begin
140
- log "\033[1;31m#{source[:warning]}\033[0m" if source.has_key?(:warning)
135
+ log "\033[1;31m#{source[:warning]}\033[0m" if source.key?(:warning)
141
136
  log "fetching #{project_file} from #{source_uri}"
142
137
 
143
138
  case source_uri.scheme
@@ -145,11 +140,11 @@ E
145
140
  headers = {
146
141
  'accept-encoding' => '',
147
142
  }
148
- if source.has_key?(:cookie)
143
+ if source.key?(:cookie)
149
144
  headers['Cookie'] = source[:cookie]
150
145
  end
151
146
  get_with_redirect(source_uri, headers)
152
- when "ftp"
147
+ when 'ftp'
153
148
  Net::FTP.open(source_uri.host) do |ftp|
154
149
  ftp.passive = true
155
150
  ftp.login
@@ -157,11 +152,12 @@ E
157
152
  ftp.close
158
153
  end
159
154
  else
160
- raise UnsupportedURIScheme, "Don't know how to download from #{source_uri}"
155
+ fail UnsupportedURIScheme, "Don't know how to download from #{source_uri}"
161
156
  end
162
- rescue Exception => e
163
- if ( tries -= 1 ) != 0
164
- log "retrying failed download..."
157
+ rescue Exception
158
+ tries = tries - 1
159
+ if tries != 0
160
+ log 'retrying failed download...'
165
161
  retry
166
162
  else
167
163
  raise
@@ -175,10 +171,10 @@ E
175
171
  def verify_checksum!
176
172
  actual_md5 = Digest::MD5.file(project_file)
177
173
  unless actual_md5 == @checksum
178
- log "Invalid MD5 for #@name"
174
+ log "Invalid MD5 for #{@name}"
179
175
  log "Expected: #{@checksum}"
180
176
  log "Actual: #{actual_md5}"
181
- raise InvalidSourceFile, "Checksum of downloaded file #{project_file} doesn't match expected"
177
+ fail InvalidSourceFile, "Checksum of downloaded file #{project_file} doesn't match expected"
182
178
  end
183
179
  end
184
180
 
@@ -189,11 +185,11 @@ E
189
185
  when Proc
190
186
  cmd.call
191
187
  when String
192
- shell = Mixlib::ShellOut.new(cmd, :live_stream => STDOUT)
188
+ shell = Mixlib::ShellOut.new(cmd, live_stream: STDOUT)
193
189
  shell.run_command
194
190
  shell.error!
195
191
  else
196
- raise "Don't know how to extract command for #{cmd.class} class"
192
+ fail "Don't know how to extract command for #{cmd.class} class"
197
193
  end
198
194
  rescue Exception => e
199
195
  ErrorReporter.new(e, self).explain("Failed to unpack archive at #{project_file} (#{e.class}: #{e.message.strip})")
@@ -201,21 +197,21 @@ E
201
197
  end
202
198
 
203
199
  def extract_cmd
204
- if project_file.end_with?(".gz") || project_file.end_with?(".tgz")
200
+ if project_file.end_with?('.gz') || project_file.end_with?('.tgz')
205
201
  "gzip -dc #{project_file} | ( cd #{source_dir} && tar -xf - )"
206
- elsif project_file.end_with?(".bz2")
202
+ elsif project_file.end_with?('.bz2')
207
203
  "bzip2 -dc #{project_file} | ( cd #{source_dir} && tar -xf - )"
208
- elsif project_file.end_with?(".7z")
204
+ elsif project_file.end_with?('.7z')
209
205
  "7z.exe x #{project_file} -o#{source_dir} -r -y"
210
- elsif project_file.end_with?(".zip")
206
+ elsif project_file.end_with?('.zip')
211
207
  "unzip #{project_file} -d #{source_dir}"
212
- elsif project_file.end_with?(".xz") || project_file.end_with?(".txz")
208
+ elsif project_file.end_with?('.xz') || project_file.end_with?('.txz')
213
209
  "xz -dc #{project_file} | ( cd #{source_dir} && tar -xf - )"
214
210
  else
215
- #if we don't recognize the extension, simply copy over the file
216
- Proc.new do
211
+ # if we don't recognize the extension, simply copy over the file
212
+ proc do
217
213
  log "#{project_file} not an archive. Copying to #{project_dir}"
218
- # hack hack hack, no project dir yet
214
+ # WARNING: hack hack hack, no project dir yet
219
215
  FileUtils.mkdir_p(project_dir)
220
216
  FileUtils.cp(project_file, project_dir)
221
217
  end
@@ -1,13 +1,13 @@
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");
6
6
  # you may not use this file except in compliance with the License.
7
7
  # You may obtain a copy of the License at
8
- #
8
+ #
9
9
  # http://www.apache.org/licenses/LICENSE-2.0
10
- #
10
+ #
11
11
  # Unless required by applicable law or agreed to in writing, software
12
12
  # distributed under the License is distributed on an "AS IS" BASIS,
13
13
  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -16,10 +16,8 @@
16
16
  #
17
17
 
18
18
  module Omnibus
19
-
20
19
  # Fetcher implementation for projects on the filesystem
21
20
  class PathFetcher < Fetcher
22
-
23
21
  name :path
24
22
 
25
23
  def initialize(software)
@@ -30,18 +28,18 @@ module Omnibus
30
28
  end
31
29
 
32
30
  def description
33
- s=<<-E
31
+ <<-E
34
32
  source path: #{@source[:path]}
35
33
  local location: #{@project_dir}
36
34
  E
37
35
  end
38
-
36
+
39
37
  def rsync
40
- if OHAI.platform == "windows"
38
+ if OHAI.platform == 'windows'
41
39
  # Robocopy's return code is 1 if it succesfully copies over the
42
40
  # files and 0 if the files are already existing at the destination
43
41
  sync_cmd = "robocopy #{@source[:path]}\\ #{@project_dir}\\ /MIR /S"
44
- shell = Mixlib::ShellOut.new(sync_cmd, :returns => [0, 1])
42
+ shell = Mixlib::ShellOut.new(sync_cmd, returns: [0, 1])
45
43
  else
46
44
  sync_cmd = "rsync --delete -a #{@source[:path]}/ #{@project_dir}/"
47
45
  shell = Mixlib::ShellOut.new(sync_cmd)
@@ -1,13 +1,13 @@
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");
6
6
  # you may not use this file except in compliance with the License.
7
7
  # You may obtain a copy of the License at
8
- #
8
+ #
9
9
  # http://www.apache.org/licenses/LICENSE-2.0
10
- #
10
+ #
11
11
  # Unless required by applicable law or agreed to in writing, software
12
12
  # distributed under the License is distributed on an "AS IS" BASIS,
13
13
  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -39,4 +39,3 @@ module Omnibus
39
39
  end
40
40
  end
41
41
  end
42
-
@@ -1,13 +1,13 @@
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");
6
6
  # you may not use this file except in compliance with the License.
7
7
  # You may obtain a copy of the License at
8
- #
8
+ #
9
9
  # http://www.apache.org/licenses/LICENSE-2.0
10
- #
10
+ #
11
11
  # Unless required by applicable law or agreed to in writing, software
12
12
  # distributed under the License is distributed on an "AS IS" BASIS,
13
13
  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -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");
@@ -17,38 +17,37 @@
17
17
 
18
18
  module Omnibus
19
19
  class HealthCheck
20
-
21
20
  WHITELIST_LIBS = [
22
- /ld-linux/,
23
- /libc\.so/,
24
- /libcrypt\.so/,
25
- /libdl/,
26
- /libfreebl\d\.so/,
27
- /libgcc_s\.so/,
28
- /libm\.so/,
29
- /libnsl\.so/,
30
- /libpthread/,
31
- /libresolv\.so/,
32
- /librt\.so/,
33
- /libstdc\+\+\.so/,
34
- /libutil\.so/,
35
- /linux-vdso.+/,
36
- /linux-gate\.so/
37
- ]
21
+ /ld-linux/,
22
+ /libc\.so/,
23
+ /libcrypt\.so/,
24
+ /libdl/,
25
+ /libfreebl\d\.so/,
26
+ /libgcc_s\.so/,
27
+ /libm\.so/,
28
+ /libnsl\.so/,
29
+ /libpthread/,
30
+ /libresolv\.so/,
31
+ /librt\.so/,
32
+ /libstdc\+\+\.so/,
33
+ /libutil\.so/,
34
+ /linux-vdso.+/,
35
+ /linux-gate\.so/,
36
+ ]
38
37
 
39
38
  ARCH_WHITELIST_LIBS = [
40
- /libc\.so/,
41
- /libcrypt\.so/,
42
- /libdb-5\.3\.so/,
43
- /libdl\.so/,
44
- /libffi\.so/,
45
- /libgdbm\.so/,
46
- /libm\.so/,
47
- /libnsl\.so/,
48
- /libpthread\.so/,
49
- /librt\.so/,
50
- /libutil\.so/
51
- ]
39
+ /libc\.so/,
40
+ /libcrypt\.so/,
41
+ /libdb-5\.3\.so/,
42
+ /libdl\.so/,
43
+ /libffi\.so/,
44
+ /libgdbm\.so/,
45
+ /libm\.so/,
46
+ /libnsl\.so/,
47
+ /libpthread\.so/,
48
+ /librt\.so/,
49
+ /libutil\.so/,
50
+ ]
52
51
 
53
52
  AIX_WHITELIST_LIBS = [
54
53
  /libpthread\.a/,
@@ -61,78 +60,78 @@ module Omnibus
61
60
  ]
62
61
 
63
62
  SOLARIS_WHITELIST_LIBS = [
64
- /libaio\.so/,
65
- /libavl\.so/,
66
- /libcrypt_[di]\.so/,
67
- /libcrypto.so/,
68
- /libcurses\.so/,
69
- /libdoor\.so/,
70
- /libgen\.so/,
71
- /libmd5\.so/,
72
- /libmd\.so/,
73
- /libmp\.so/,
74
- /libscf\.so/,
75
- /libsec\.so/,
76
- /libsocket\.so/,
77
- /libssl.so/,
78
- /libthread.so/,
79
- /libuutil\.so/,
80
- /libz.so/,
81
- # solaris 11 libraries:
82
- /libc\.so\.1/,
83
- /libm\.so\.2/,
84
- /libdl\.so\.1/,
85
- /libnsl\.so\.1/,
86
- /libpthread\.so\.1/,
87
- /librt\.so\.1/,
88
- /libcrypt\.so\.1/,
89
- /libgdbm\.so\.3/,
90
- # solaris 9 libraries:
91
- /libm\.so\.1/,
92
- /libc_psr\.so\.1/,
93
- /s9_preload\.so\.1/
94
- ]
63
+ /libaio\.so/,
64
+ /libavl\.so/,
65
+ /libcrypt_[di]\.so/,
66
+ /libcrypto.so/,
67
+ /libcurses\.so/,
68
+ /libdoor\.so/,
69
+ /libgen\.so/,
70
+ /libmd5\.so/,
71
+ /libmd\.so/,
72
+ /libmp\.so/,
73
+ /libscf\.so/,
74
+ /libsec\.so/,
75
+ /libsocket\.so/,
76
+ /libssl.so/,
77
+ /libthread.so/,
78
+ /libuutil\.so/,
79
+ /libz.so/,
80
+ # solaris 11 libraries:
81
+ /libc\.so\.1/,
82
+ /libm\.so\.2/,
83
+ /libdl\.so\.1/,
84
+ /libnsl\.so\.1/,
85
+ /libpthread\.so\.1/,
86
+ /librt\.so\.1/,
87
+ /libcrypt\.so\.1/,
88
+ /libgdbm\.so\.3/,
89
+ # solaris 9 libraries:
90
+ /libm\.so\.1/,
91
+ /libc_psr\.so\.1/,
92
+ /s9_preload\.so\.1/,
93
+ ]
95
94
 
96
95
  SMARTOS_WHITELIST_LIBS = [
97
- /libm.so/,
98
- /libpthread.so/,
99
- /librt.so/,
100
- /libsocket.so/,
101
- /libdl.so/,
102
- /libnsl.so/,
103
- /libgen.so/,
104
- /libmp.so/,
105
- /libmd.so/,
106
- /libc.so/,
107
- /libgcc_s.so/,
108
- /libstdc\+\+\.so/,
109
- /libcrypt.so/
110
- ]
96
+ /libm.so/,
97
+ /libpthread.so/,
98
+ /librt.so/,
99
+ /libsocket.so/,
100
+ /libdl.so/,
101
+ /libnsl.so/,
102
+ /libgen.so/,
103
+ /libmp.so/,
104
+ /libmd.so/,
105
+ /libc.so/,
106
+ /libgcc_s.so/,
107
+ /libstdc\+\+\.so/,
108
+ /libcrypt.so/,
109
+ ]
111
110
 
112
111
  MAC_WHITELIST_LIBS = [
113
- /libobjc\.A\.dylib/,
114
- /libSystem\.B\.dylib/,
115
- /CoreFoundation/,
116
- /Tcl$/,
117
- /Cocoa$/,
118
- /Carbon$/,
119
- /IOKit$/,
120
- /Tk$/,
121
- /libutil\.dylib/,
122
- /libffi\.dylib/,
123
- /libncurses\.5\.4\.dylib/,
124
- /libiconv/,
125
- /libstdc\+\+\.6\.dylib/
126
- ]
112
+ /libobjc\.A\.dylib/,
113
+ /libSystem\.B\.dylib/,
114
+ /CoreFoundation/,
115
+ /Tcl$/,
116
+ /Cocoa$/,
117
+ /Carbon$/,
118
+ /IOKit$/,
119
+ /Tk$/,
120
+ /libutil\.dylib/,
121
+ /libffi\.dylib/,
122
+ /libncurses\.5\.4\.dylib/,
123
+ /libiconv/,
124
+ /libstdc\+\+\.6\.dylib/,
125
+ ]
127
126
 
128
127
  FREEBSD_WHITELIST_LIBS = [
129
- /libc\.so/,
130
- /libcrypt\.so/,
131
- /libm\.so/,
132
- /librt\.so/,
133
- /libthr\.so/,
134
- /libutil\.so/
135
- ]
128
+ /libc\.so/,
129
+ /libcrypt\.so/,
130
+ /libm\.so/,
131
+ /librt\.so/,
132
+ /libthr\.so/,
133
+ /libutil\.so/,
134
+ ]
136
135
 
137
136
  def self.log(msg)
138
137
  puts "[health_check] #{msg}"
@@ -140,9 +139,9 @@ module Omnibus
140
139
 
141
140
  def self.run(install_dir, whitelist_files = [])
142
141
  case OHAI.platform
143
- when "mac_os_x"
142
+ when 'mac_os_x'
144
143
  bad_libs = health_check_otool(install_dir, whitelist_files)
145
- when "aix"
144
+ when 'aix'
146
145
  bad_libs = health_check_aix(install_dir, whitelist_files)
147
146
  else
148
147
  bad_libs = health_check_ldd(install_dir, whitelist_files)
@@ -165,38 +164,38 @@ module Omnibus
165
164
  end
166
165
  end
167
166
  end
168
- log "*** Health Check Failed, Summary follows:"
169
- bad_omnibus_libs, bad_omnibus_bins = bad_libs.keys.partition { |k| k.include? "embedded/lib" }
170
- log "*** The following Omnibus-built libraries have unsafe or unmet dependencies:"
167
+ log '*** Health Check Failed, Summary follows:'
168
+ bad_omnibus_libs, bad_omnibus_bins = bad_libs.keys.partition { |k| k.include? 'embedded/lib' }
169
+ log '*** The following Omnibus-built libraries have unsafe or unmet dependencies:'
171
170
  bad_omnibus_libs.each { |lib| log " --> #{lib}" }
172
- log "*** The following Omnibus-built binaries have unsafe or unmet dependencies:"
171
+ log '*** The following Omnibus-built binaries have unsafe or unmet dependencies:'
173
172
  bad_omnibus_bins.each { |bin| log " --> #{bin}" }
174
173
  if unresolved.length > 0
175
- log "*** The following requirements could not be resolved:"
176
- unresolved.each { |lib| log " --> #{lib}"}
174
+ log '*** The following requirements could not be resolved:'
175
+ unresolved.each { |lib| log " --> #{lib}" }
177
176
  end
178
177
  if unreliable.length > 0
179
- log "*** The following libraries cannot be guaranteed to be on target systems:"
180
- unreliable.each { |lib| log " --> #{lib}"}
178
+ log '*** The following libraries cannot be guaranteed to be on target systems:'
179
+ unreliable.each { |lib| log " --> #{lib}" }
181
180
  end
182
- log "*** The precise failures were:"
181
+ log '*** The precise failures were:'
183
182
  detail.each do |line|
184
183
  item, dependency, location, count = line.split('|')
185
- reason = location =~ /not found/ ? "Unresolved dependency" : "Unsafe dependency"
184
+ reason = location =~ /not found/ ? 'Unresolved dependency' : 'Unsafe dependency'
186
185
  log " --> #{item}"
187
186
  log " DEPENDS ON: #{dependency}"
188
187
  log " COUNT: #{count}"
189
188
  log " PROVIDED BY: #{location}"
190
189
  log " FAILED BECAUSE: #{reason}"
191
190
  end
192
- raise "Health Check Failed"
191
+ fail 'Health Check Failed'
193
192
  end
194
193
  end
195
194
 
196
195
  def self.health_check_otool(install_dir, whitelist_files)
197
196
  otool_cmd = "find #{install_dir}/ -type f | egrep '\.(dylib|bundle)$' | xargs otool -L > otool.out 2>/dev/null"
198
197
  log "Executing `#{otool_cmd}`"
199
- shell = Mixlib::ShellOut.new(otool_cmd, :timeout => 3600)
198
+ shell = Mixlib::ShellOut.new(otool_cmd, timeout: 3600)
200
199
  shell.run_command
201
200
 
202
201
  otool_output = File.read('otool.out')
@@ -207,9 +206,9 @@ module Omnibus
207
206
  otool_output.each_line do |line|
208
207
  case line
209
208
  when /^(.+):$/
210
- current_library = $1
209
+ current_library = Regexp.last_match[1]
211
210
  when /^\s+(.+) \(.+\)$/
212
- linked = $1
211
+ linked = Regexp.last_match[1]
213
212
  name = File.basename(linked)
214
213
  bad_libs = check_for_bad_library(install_dir, bad_libs, whitelist_files, current_library, name, linked)
215
214
  end
@@ -246,20 +245,20 @@ module Omnibus
246
245
  safe ||= true if reg.match(current_library)
247
246
  end
248
247
 
249
- log " --> Dependency: #{name}" if ARGV[0] == "verbose"
250
- log " --> Provided by: #{linked}" if ARGV[0] == "verbose"
248
+ log " --> Dependency: #{name}" if ARGV[0] == 'verbose'
249
+ log " --> Provided by: #{linked}" if ARGV[0] == 'verbose'
251
250
 
252
251
  if !safe && linked !~ Regexp.new(install_dir)
253
- log " -> FAILED: #{current_library} has unsafe dependencies" if ARGV[0] == "verbose"
252
+ log " -> FAILED: #{current_library} has unsafe dependencies" if ARGV[0] == 'verbose'
254
253
  bad_libs[current_library] ||= {}
255
254
  bad_libs[current_library][name] ||= {}
256
- if bad_libs[current_library][name].has_key?(linked)
255
+ if bad_libs[current_library][name].key?(linked)
257
256
  bad_libs[current_library][name][linked] += 1
258
257
  else
259
258
  bad_libs[current_library][name][linked] = 1
260
259
  end
261
260
  else
262
- log " -> PASSED: #{name} is either whitelisted or safely provided." if ARGV[0] == "verbose"
261
+ log " -> PASSED: #{name} is either whitelisted or safely provided." if ARGV[0] == 'verbose'
263
262
  end
264
263
 
265
264
  bad_libs
@@ -275,7 +274,7 @@ module Omnibus
275
274
  ldd_cmd = "find #{install_dir}/ -type f | xargs file | grep \"RISC System\" | awk -F: '{print $1}' | xargs -n 1 ldd > ldd.out 2>/dev/null"
276
275
 
277
276
  log "Executing `#{ldd_cmd}`"
278
- shell = Mixlib::ShellOut.new(ldd_cmd, :timeout => 3600)
277
+ shell = Mixlib::ShellOut.new(ldd_cmd, timeout: 3600)
279
278
  shell.run_command
280
279
 
281
280
  ldd_output = File.read('ldd.out')
@@ -286,11 +285,11 @@ module Omnibus
286
285
  ldd_output.each_line do |line|
287
286
  case line
288
287
  when /^(.+) needs:$/
289
- current_library = $1
290
- log "*** Analysing dependencies for #{current_library}" if ARGV[0] == "verbose"
288
+ current_library = Regexp.last_match[1]
289
+ log "*** Analysing dependencies for #{current_library}" if ARGV[0] == 'verbose'
291
290
  when /^\s+(.+)$/
292
- name = $1
293
- linked = $1
291
+ name = Regexp.last_match[1]
292
+ linked = Regexp.last_match[1]
294
293
  bad_libs = check_for_bad_library(install_dir, bad_libs, whitelist_files, current_library, name, linked)
295
294
  when /File is not an executable XCOFF file/ # ignore non-executable files
296
295
  else
@@ -312,7 +311,7 @@ module Omnibus
312
311
  ldd_cmd = "find #{install_dir}/ -type f | xargs ldd > ldd.out 2>/dev/null"
313
312
 
314
313
  log "Executing `#{ldd_cmd}`"
315
- shell = Mixlib::ShellOut.new(ldd_cmd, :timeout => 3600)
314
+ shell = Mixlib::ShellOut.new(ldd_cmd, timeout: 3600)
316
315
  shell.run_command
317
316
 
318
317
  ldd_output = File.read('ldd.out')
@@ -323,11 +322,11 @@ module Omnibus
323
322
  ldd_output.each_line do |line|
324
323
  case line
325
324
  when /^(.+):$/
326
- current_library = $1
327
- log "*** Analysing dependencies for #{current_library}" if ARGV[0] == "verbose"
325
+ current_library = Regexp.last_match[1]
326
+ log "*** Analysing dependencies for #{current_library}" if ARGV[0] == 'verbose'
328
327
  when /^\s+(.+) \=\>\s+(.+)( \(.+\))?$/
329
- name = $1
330
- linked = $2
328
+ name = Regexp.last_match[1]
329
+ linked = Regexp.last_match[2]
331
330
  bad_libs = check_for_bad_library(install_dir, bad_libs, whitelist_files, current_library, name, linked)
332
331
  when /^\s+(.+) \(.+\)$/
333
332
  next