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.
- checksums.yaml +7 -0
- data/.gitignore +4 -1
- data/.rubocop.yml +30 -0
- data/.travis.yml +14 -3
- data/CHANGELOG.md +72 -49
- data/Gemfile +8 -5
- data/NOTICE +2 -2
- data/README.md +65 -7
- data/Rakefile +12 -3
- data/bin/makeself-header.sh +1 -1
- data/bin/makeself.sh +2 -2
- data/bin/omnibus +2 -2
- data/functional/fixtures/mac_pkg/files/mac_pkg/Resources/background.png +0 -0
- data/functional/fixtures/mac_pkg/files/mac_pkg/Resources/license.html +1 -0
- data/functional/fixtures/mac_pkg/files/mac_pkg/Resources/welcome.html +1 -0
- data/functional/fixtures/mac_pkg/package-scripts/functional-test-project/postinstall +4 -0
- data/functional/packagers/mac_pkg_spec.rb +72 -0
- data/lib/omnibus/artifact.rb +11 -13
- data/lib/omnibus/build_version.rb +18 -21
- data/lib/omnibus/builder.rb +37 -48
- data/lib/omnibus/clean_tasks.rb +3 -5
- data/lib/omnibus/cli/application.rb +46 -53
- data/lib/omnibus/cli/base.rb +16 -19
- data/lib/omnibus/cli/build.rb +13 -13
- data/lib/omnibus/cli/cache.rb +13 -15
- data/lib/omnibus/cli/release.rb +4 -9
- data/lib/omnibus/cli.rb +2 -4
- data/lib/omnibus/config.rb +43 -23
- data/lib/omnibus/exceptions.rb +35 -1
- data/lib/omnibus/fetcher.rb +9 -13
- data/lib/omnibus/fetchers/git_fetcher.rb +15 -19
- data/lib/omnibus/fetchers/net_fetcher.rb +34 -38
- data/lib/omnibus/fetchers/path_fetcher.rb +7 -9
- data/lib/omnibus/fetchers/s3_cache_fetcher.rb +3 -4
- data/lib/omnibus/fetchers.rb +3 -3
- data/lib/omnibus/health_check.rb +126 -127
- data/lib/omnibus/library.rb +11 -12
- data/lib/omnibus/overrides.rb +6 -8
- data/lib/omnibus/package_release.rb +20 -22
- data/lib/omnibus/packagers/mac_pkg.rb +285 -0
- data/lib/omnibus/project.rb +215 -110
- data/lib/omnibus/reports.rb +16 -24
- data/lib/omnibus/s3_cacher.rb +15 -21
- data/lib/omnibus/software.rb +178 -88
- data/lib/omnibus/util.rb +25 -13
- data/lib/omnibus/version.rb +2 -2
- data/lib/omnibus.rb +11 -13
- data/omnibus.gemspec +20 -18
- data/spec/artifact_spec.rb +55 -52
- data/spec/build_version_spec.rb +121 -129
- data/spec/config_spec.rb +40 -0
- data/spec/data/projects/chefdk.rb +41 -0
- data/spec/data/projects/sample.rb +10 -0
- data/spec/data/software/erchef.rb +12 -12
- data/spec/data/software/zlib.rb +67 -0
- data/spec/fetchers/git_fetcher_spec.rb +55 -48
- data/spec/fetchers/net_fetcher_spec.rb +72 -78
- data/spec/omnibus_spec.rb +59 -0
- data/spec/overrides_spec.rb +64 -64
- data/spec/package_release_spec.rb +65 -64
- data/spec/packagers/mac_pkg_spec.rb +261 -0
- data/spec/project_spec.rb +138 -0
- data/spec/s3_cacher_spec.rb +9 -10
- data/spec/software_spec.rb +71 -50
- data/spec/spec_helper.rb +14 -7
- metadata +68 -60
- data/.rspec +0 -1
- data/.yardopts +0 -6
- data/spec/software_dirs_spec.rb +0 -34
@@ -1,5 +1,5 @@
|
|
1
1
|
#
|
2
|
-
# Copyright:: Copyright (c) 2012
|
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
|
-
|
47
|
+
<<-E
|
50
48
|
source URI: #{source_uri}
|
51
49
|
checksum: #{@checksum}
|
52
|
-
local location:
|
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
|
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
|
-
|
80
|
+
fail ArgumentError, 'HTTP redirect too deep' if limit == 0
|
84
81
|
log "getting from #{url} with #{limit} redirects left"
|
85
82
|
|
86
|
-
|
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
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
http_client.use_ssl = (url.scheme ==
|
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,
|
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')
|
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.
|
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.
|
143
|
+
if source.key?(:cookie)
|
149
144
|
headers['Cookie'] = source[:cookie]
|
150
145
|
end
|
151
146
|
get_with_redirect(source_uri, headers)
|
152
|
-
when
|
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
|
-
|
155
|
+
fail UnsupportedURIScheme, "Don't know how to download from #{source_uri}"
|
161
156
|
end
|
162
|
-
rescue Exception
|
163
|
-
|
164
|
-
|
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
|
174
|
+
log "Invalid MD5 for #{@name}"
|
179
175
|
log "Expected: #{@checksum}"
|
180
176
|
log "Actual: #{actual_md5}"
|
181
|
-
|
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, :
|
188
|
+
shell = Mixlib::ShellOut.new(cmd, live_stream: STDOUT)
|
193
189
|
shell.run_command
|
194
190
|
shell.error!
|
195
191
|
else
|
196
|
-
|
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?(
|
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?(
|
202
|
+
elsif project_file.end_with?('.bz2')
|
207
203
|
"bzip2 -dc #{project_file} | ( cd #{source_dir} && tar -xf - )"
|
208
|
-
elsif project_file.end_with?(
|
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?(
|
206
|
+
elsif project_file.end_with?('.zip')
|
211
207
|
"unzip #{project_file} -d #{source_dir}"
|
212
|
-
elsif project_file.end_with?(
|
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
|
-
|
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
|
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
|
-
|
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 ==
|
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, :
|
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
|
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
|
-
|
data/lib/omnibus/fetchers.rb
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
#
|
2
|
-
# Copyright:: Copyright (c) 2012
|
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.
|
data/lib/omnibus/health_check.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
#
|
2
|
-
# Copyright:: Copyright (c) 2012
|
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
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
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
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
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
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
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
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
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
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
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
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
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
|
142
|
+
when 'mac_os_x'
|
144
143
|
bad_libs = health_check_otool(install_dir, whitelist_files)
|
145
|
-
when
|
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
|
169
|
-
bad_omnibus_libs, bad_omnibus_bins = bad_libs.keys.partition { |k| k.include?
|
170
|
-
log
|
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
|
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
|
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
|
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
|
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/ ?
|
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
|
-
|
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, :
|
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 =
|
209
|
+
current_library = Regexp.last_match[1]
|
211
210
|
when /^\s+(.+) \(.+\)$/
|
212
|
-
linked =
|
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] ==
|
250
|
-
log " --> Provided by: #{linked}" if ARGV[0] ==
|
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] ==
|
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].
|
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] ==
|
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, :
|
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 =
|
290
|
-
|
288
|
+
current_library = Regexp.last_match[1]
|
289
|
+
log "*** Analysing dependencies for #{current_library}" if ARGV[0] == 'verbose'
|
291
290
|
when /^\s+(.+)$/
|
292
|
-
name =
|
293
|
-
linked =
|
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, :
|
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 =
|
327
|
-
|
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 =
|
330
|
-
linked =
|
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
|