omnibus 6.1.7 → 8.0.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +0 -4
- data/README.md +54 -12
- data/Rakefile +1 -1
- data/bin/omnibus +1 -1
- data/lib/omnibus.rb +2 -2
- data/lib/omnibus/build_version.rb +1 -1
- data/lib/omnibus/build_version_dsl.rb +6 -7
- data/lib/omnibus/builder.rb +10 -9
- data/lib/omnibus/changelog_printer.rb +7 -4
- data/lib/omnibus/cleaner.rb +4 -1
- data/lib/omnibus/cli.rb +2 -2
- data/lib/omnibus/cli/changelog.rb +25 -25
- data/lib/omnibus/compressor.rb +2 -2
- data/lib/omnibus/compressors/base.rb +2 -2
- data/lib/omnibus/compressors/dmg.rb +8 -6
- data/lib/omnibus/compressors/tgz.rb +2 -2
- data/lib/omnibus/config.rb +13 -3
- data/lib/omnibus/core_extensions/open_uri.rb +1 -1
- data/lib/omnibus/digestable.rb +2 -2
- data/lib/omnibus/download_helpers.rb +6 -2
- data/lib/omnibus/fetchers/file_fetcher.rb +1 -1
- data/lib/omnibus/fetchers/git_fetcher.rb +1 -0
- data/lib/omnibus/fetchers/net_fetcher.rb +3 -4
- data/lib/omnibus/fetchers/path_fetcher.rb +1 -1
- data/lib/omnibus/file_syncer.rb +1 -1
- data/lib/omnibus/generator.rb +2 -2
- data/lib/omnibus/generator_files/README.md.erb +20 -16
- data/lib/omnibus/generator_files/config/software/preparation.rb.erb +1 -1
- data/lib/omnibus/generator_files/omnibus.rb.erb +5 -4
- data/lib/omnibus/git_cache.rb +2 -2
- data/lib/omnibus/health_check.rb +3 -1
- data/lib/omnibus/licensing.rb +5 -6
- data/lib/omnibus/logger.rb +3 -2
- data/lib/omnibus/manifest.rb +2 -2
- data/lib/omnibus/metadata.rb +2 -2
- data/lib/omnibus/ohai.rb +1 -1
- data/lib/omnibus/package.rb +1 -1
- data/lib/omnibus/packager.rb +6 -14
- data/lib/omnibus/packagers/appx.rb +1 -2
- data/lib/omnibus/packagers/base.rb +2 -1
- data/lib/omnibus/packagers/bff.rb +6 -8
- data/lib/omnibus/packagers/deb.rb +7 -10
- data/lib/omnibus/packagers/ips.rb +3 -6
- data/lib/omnibus/packagers/makeself.rb +1 -2
- data/lib/omnibus/packagers/msi.rb +13 -12
- data/lib/omnibus/packagers/pkg.rb +125 -9
- data/lib/omnibus/packagers/rpm.rb +11 -12
- data/lib/omnibus/packagers/solaris.rb +5 -5
- data/lib/omnibus/packagers/windows_base.rb +7 -6
- data/lib/omnibus/project.rb +3 -2
- data/lib/omnibus/publisher.rb +2 -2
- data/lib/omnibus/publishers/artifactory_publisher.rb +2 -2
- data/lib/omnibus/publishers/s3_publisher.rb +6 -4
- data/lib/omnibus/s3_cache.rb +4 -2
- data/lib/omnibus/s3_helpers.rb +7 -7
- data/lib/omnibus/software.rb +68 -43
- data/lib/omnibus/sugarable.rb +5 -14
- data/lib/omnibus/templating.rb +2 -2
- data/lib/omnibus/thread_pool.rb +0 -2
- data/lib/omnibus/util.rb +4 -3
- data/lib/omnibus/version.rb +1 -1
- data/lib/omnibus/whitelist.rb +24 -1
- data/omnibus.gemspec +8 -9
- data/resources/ips/doc-transform.erb +1 -0
- data/resources/msi/CustomActionFastMsi.CA.dll +0 -0
- data/resources/msi/source.wxs.erb +2 -10
- data/resources/rpm/signing.erb +7 -10
- data/spec/functional/builder_spec.rb +2 -1
- data/spec/functional/fetchers/file_fetcher_spec.rb +4 -4
- data/spec/functional/fetchers/git_fetcher_spec.rb +4 -4
- data/spec/functional/fetchers/net_fetcher_spec.rb +5 -6
- data/spec/functional/fetchers/path_fetcher_spec.rb +4 -4
- data/spec/functional/licensing_spec.rb +5 -5
- data/spec/support/examples.rb +3 -4
- data/spec/support/path_helpers.rb +2 -2
- data/spec/unit/builder_spec.rb +9 -9
- data/spec/unit/changelogprinter_spec.rb +8 -6
- data/spec/unit/compressor_spec.rb +4 -4
- data/spec/unit/compressors/dmg_spec.rb +5 -2
- data/spec/unit/fetchers/net_fetcher_spec.rb +16 -17
- data/spec/unit/health_check_spec.rb +2 -6
- data/spec/unit/library_spec.rb +2 -1
- data/spec/unit/manifest_diff_spec.rb +2 -2
- data/spec/unit/manifest_spec.rb +1 -1
- data/spec/unit/metadata_spec.rb +14 -17
- data/spec/unit/omnibus_spec.rb +1 -1
- data/spec/unit/packager_spec.rb +6 -13
- data/spec/unit/packagers/bff_spec.rb +2 -2
- data/spec/unit/packagers/ips_spec.rb +1 -0
- data/spec/unit/packagers/msi_spec.rb +2 -2
- data/spec/unit/packagers/pkg_spec.rb +354 -0
- data/spec/unit/packagers/pkgsrc_spec.rb +1 -1
- data/spec/unit/packagers/rpm_spec.rb +5 -5
- data/spec/unit/packagers/solaris_spec.rb +7 -7
- data/spec/unit/project_spec.rb +7 -7
- data/spec/unit/publisher_spec.rb +1 -2
- data/spec/unit/publishers/artifactory_publisher_spec.rb +2 -4
- data/spec/unit/publishers/s3_publisher_spec.rb +2 -4
- data/spec/unit/s3_cacher_spec.rb +19 -6
- data/spec/unit/s3_helpers_spec.rb +22 -3
- data/spec/unit/software_spec.rb +59 -120
- data/spec/unit/util_spec.rb +1 -2
- metadata +21 -21
data/lib/omnibus/metadata.rb
CHANGED
@@ -14,7 +14,7 @@
|
|
14
14
|
# limitations under the License.
|
15
15
|
#
|
16
16
|
|
17
|
-
require "ffi_yajl"
|
17
|
+
require "ffi_yajl" unless defined?(FFI_Yajl)
|
18
18
|
|
19
19
|
module Omnibus
|
20
20
|
class Metadata
|
@@ -83,7 +83,7 @@ module Omnibus
|
|
83
83
|
data = File.read(path_for(package))
|
84
84
|
hash = FFI_Yajl::Parser.parse(data, symbolize_names: true)
|
85
85
|
|
86
|
-
|
86
|
+
# Ensure Platform version has been truncated
|
87
87
|
if hash[:platform_version] && hash[:platform]
|
88
88
|
hash[:platform_version] = truncate_platform_version(hash[:platform_version], hash[:platform])
|
89
89
|
end
|
data/lib/omnibus/ohai.rb
CHANGED
data/lib/omnibus/package.rb
CHANGED
data/lib/omnibus/packager.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
#
|
2
|
-
# Copyright 2014-
|
2
|
+
# Copyright 2014-2020, Chef Software Inc.
|
3
3
|
#
|
4
4
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
5
5
|
# you may not use this file except in compliance with the License.
|
@@ -46,6 +46,7 @@ module Omnibus
|
|
46
46
|
"amazon" => RPM,
|
47
47
|
"aix" => BFF,
|
48
48
|
"solaris" => Solaris,
|
49
|
+
"omnios" => IPS,
|
49
50
|
"ips" => IPS,
|
50
51
|
"windows" => [MSI, APPX],
|
51
52
|
"mac_os_x" => PKG,
|
@@ -65,25 +66,16 @@ module Omnibus
|
|
65
66
|
family = Ohai["platform_family"]
|
66
67
|
version = Ohai["platform_version"]
|
67
68
|
|
68
|
-
if family == "solaris2" &&
|
69
|
+
if family == "solaris2" && ChefUtils::VersionString.new(version).satisfies?(">= 5.11")
|
69
70
|
family = "ips"
|
70
|
-
elsif family == "solaris2" &&
|
71
|
+
elsif family == "solaris2" && ChefUtils::VersionString.new(version).satisfies?(">= 5.10")
|
71
72
|
family = "solaris"
|
72
73
|
end
|
73
74
|
if klass = PLATFORM_PACKAGER_MAP[family]
|
74
|
-
|
75
|
-
|
76
|
-
if package_types.include?(APPX) &&
|
77
|
-
!Chef::Sugar::Constraints::Version.new(version).satisfies?(">= 6.2")
|
78
|
-
log.warn(log_key) { "APPX generation is only supported on Windows versions 2012 and above" }
|
79
|
-
package_types -= [APPX]
|
80
|
-
end
|
81
|
-
|
82
|
-
package_types
|
75
|
+
klass.is_a?(Array) ? klass : [ klass ]
|
83
76
|
else
|
84
77
|
log.warn(log_key) do
|
85
|
-
"Could not determine packager for `#{family}
|
86
|
-
"to `makeself'!"
|
78
|
+
"Could not determine packager for `#{family}`, defaulting to `makeself`!"
|
87
79
|
end
|
88
80
|
[Makeself]
|
89
81
|
end
|
@@ -14,7 +14,7 @@
|
|
14
14
|
# limitations under the License.
|
15
15
|
#
|
16
16
|
|
17
|
-
require "fileutils"
|
17
|
+
require "fileutils" unless defined?(FileUtils)
|
18
18
|
|
19
19
|
module Omnibus
|
20
20
|
class Packager::Base
|
@@ -142,6 +142,7 @@ module Omnibus
|
|
142
142
|
unless val.is_a?(TrueClass) || val.is_a?(FalseClass)
|
143
143
|
raise InvalidValue.new(:skip_packager, "be TrueClass or FalseClass")
|
144
144
|
end
|
145
|
+
|
145
146
|
@skip_package ||= val
|
146
147
|
end
|
147
148
|
expose :skip_packager
|
@@ -153,12 +153,11 @@ module Omnibus
|
|
153
153
|
destination: "#{scripts_staging_dir}/config",
|
154
154
|
variables: {
|
155
155
|
name: project.name,
|
156
|
-
}
|
157
|
-
)
|
156
|
+
})
|
158
157
|
end
|
159
158
|
|
160
159
|
File.open(File.join(scripts_staging_dir, "config"), "a") do |file|
|
161
|
-
file.puts "mv '#{alt.gsub(/^#{staging_dir}/,
|
160
|
+
file.puts "mv '#{alt.gsub(/^#{staging_dir}/, "")}' '#{path.gsub(/^#{staging_dir}/, "")}'"
|
162
161
|
end
|
163
162
|
|
164
163
|
path = alt
|
@@ -189,8 +188,7 @@ module Omnibus
|
|
189
188
|
description: project.description,
|
190
189
|
files: files,
|
191
190
|
scripts: scripts,
|
192
|
-
}
|
193
|
-
)
|
191
|
+
})
|
194
192
|
|
195
193
|
# Print the full contents of the rendered template file for mkinstallp's use
|
196
194
|
log.debug(log_key) { "Rendered Template:\n" + File.read(File.join(staging_dir, "gen.template")) }
|
@@ -214,19 +212,19 @@ module Omnibus
|
|
214
212
|
# we will chown from 'project' on, rather than 'project/dir', which leaves
|
215
213
|
# project owned by the build user (which is incorrect)
|
216
214
|
# First - let's find out who we are.
|
217
|
-
shellout!("sudo chown -Rh 0:0 #{File.join(staging_dir, project.install_dir.match(
|
215
|
+
shellout!("sudo chown -Rh 0:0 #{File.join(staging_dir, project.install_dir.match(%r{^/?(\w+)}).to_s)}")
|
218
216
|
log.info(log_key) { "Creating .bff file" }
|
219
217
|
|
220
218
|
# Since we want the owner to be root, we need to sudo the mkinstallp
|
221
219
|
# command, otherwise it will not have access to the previously chowned
|
222
220
|
# directory.
|
223
|
-
shellout!("sudo /usr/sbin/mkinstallp -d #{staging_dir} -T #{File.join(staging_dir,
|
221
|
+
shellout!("sudo /usr/sbin/mkinstallp -d #{staging_dir} -T #{File.join(staging_dir, "gen.template")}")
|
224
222
|
|
225
223
|
# Print the full contents of the inventory file generated by mkinstallp
|
226
224
|
# from within the staging_dir's .info folder (where control files for the
|
227
225
|
# packaging process are kept.)
|
228
226
|
log.debug(log_key) do
|
229
|
-
"With .inventory file of:\n" + File.read("#{File.join( staging_dir,
|
227
|
+
"With .inventory file of:\n" + File.read("#{File.join( staging_dir, ".info", "#{safe_base_package_name}.inventory" )}")
|
230
228
|
end
|
231
229
|
|
232
230
|
# Copy the resulting package up to the package_dir
|
@@ -207,7 +207,7 @@ module Omnibus
|
|
207
207
|
if null?(val)
|
208
208
|
@compression_type || :gzip
|
209
209
|
else
|
210
|
-
unless val.is_a?(Symbol) &&
|
210
|
+
unless val.is_a?(Symbol) && %i{gzip xz none}.member?(val)
|
211
211
|
raise InvalidValue.new(:compression_type, "be a Symbol (:gzip, :xz, or :none)")
|
212
212
|
end
|
213
213
|
|
@@ -261,7 +261,7 @@ module Omnibus
|
|
261
261
|
@compression_strategy
|
262
262
|
else
|
263
263
|
unless val.is_a?(Symbol) &&
|
264
|
-
|
264
|
+
%i{filtered huffman rle fixed extreme}.member?(val)
|
265
265
|
raise InvalidValue.new(:compression_strategy, "be a Symbol (:filtered, "\
|
266
266
|
":huffman, :rle, :fixed, or :extreme)")
|
267
267
|
end
|
@@ -320,8 +320,7 @@ module Omnibus
|
|
320
320
|
conflicts: project.conflicts,
|
321
321
|
replaces: project.replaces,
|
322
322
|
dependencies: project.runtime_dependencies,
|
323
|
-
}
|
324
|
-
)
|
323
|
+
})
|
325
324
|
end
|
326
325
|
|
327
326
|
#
|
@@ -336,8 +335,7 @@ module Omnibus
|
|
336
335
|
destination: File.join(debian_dir, "conffiles"),
|
337
336
|
variables: {
|
338
337
|
config_files: project.config_files,
|
339
|
-
}
|
340
|
-
)
|
338
|
+
})
|
341
339
|
end
|
342
340
|
|
343
341
|
#
|
@@ -380,8 +378,7 @@ module Omnibus
|
|
380
378
|
destination: File.join(debian_dir, "md5sums"),
|
381
379
|
variables: {
|
382
380
|
md5sums: hash,
|
383
|
-
}
|
384
|
-
)
|
381
|
+
})
|
385
382
|
end
|
386
383
|
|
387
384
|
#
|
@@ -421,7 +418,7 @@ module Omnibus
|
|
421
418
|
#
|
422
419
|
# @return [void]
|
423
420
|
def sign_deb_file
|
424
|
-
|
421
|
+
unless signing_passphrase
|
425
422
|
log.info(log_key) { "Signing not enabled for .deb file" }
|
426
423
|
return
|
427
424
|
end
|
@@ -447,7 +444,7 @@ module Omnibus
|
|
447
444
|
# Create signature (as +root+)
|
448
445
|
gpg_command = "#{gpg} --armor --sign --detach-sign"
|
449
446
|
gpg_command << " --local-user '#{project.maintainer}'"
|
450
|
-
gpg_command << " --homedir #{ENV[
|
447
|
+
gpg_command << " --homedir #{ENV["HOME"]}/.gnupg" # TODO: Make this configurable
|
451
448
|
## pass the +signing_passphrase+ via +STDIN+
|
452
449
|
gpg_command << " --batch --no-tty"
|
453
450
|
## Check `gpg` for the compatibility/need of pinentry-mode
|
@@ -209,8 +209,7 @@ module Omnibus
|
|
209
209
|
destination: transform_file,
|
210
210
|
variables: {
|
211
211
|
pathdir: project.install_dir.split("/")[1],
|
212
|
-
}
|
213
|
-
)
|
212
|
+
})
|
214
213
|
end
|
215
214
|
|
216
215
|
#
|
@@ -242,8 +241,7 @@ module Omnibus
|
|
242
241
|
render_template_content(resource_path(symlinks_file),
|
243
242
|
{
|
244
243
|
projectdir: project.install_dir,
|
245
|
-
}
|
246
|
-
)
|
244
|
+
})
|
247
245
|
end
|
248
246
|
|
249
247
|
#
|
@@ -262,8 +260,7 @@ module Omnibus
|
|
262
260
|
description: project.description,
|
263
261
|
summary: project.friendly_name,
|
264
262
|
arch: safe_architecture,
|
265
|
-
}
|
266
|
-
)
|
263
|
+
})
|
267
264
|
|
268
265
|
# Append the contents of symlinks_file if it exists
|
269
266
|
if symlinks_file
|
@@ -14,7 +14,7 @@
|
|
14
14
|
# limitations under the License.
|
15
15
|
#
|
16
16
|
|
17
|
-
require "pathname"
|
17
|
+
require "pathname" unless defined?(Pathname)
|
18
18
|
require "omnibus/packagers/windows_base"
|
19
19
|
|
20
20
|
module Omnibus
|
@@ -181,10 +181,12 @@ module Omnibus
|
|
181
181
|
unless val.is_a?(TrueClass) || val.is_a?(FalseClass)
|
182
182
|
raise InvalidValue.new(:iwix_light_delay_validation, "be TrueClass or FalseClass")
|
183
183
|
end
|
184
|
+
|
184
185
|
@delay_validation ||= val
|
185
186
|
unless @delay_validation
|
186
187
|
return ""
|
187
188
|
end
|
189
|
+
|
188
190
|
"-sval"
|
189
191
|
end
|
190
192
|
expose :wix_light_delay_validation
|
@@ -225,6 +227,7 @@ module Omnibus
|
|
225
227
|
unless val.is_a?(TrueClass) || val.is_a?(FalseClass)
|
226
228
|
raise InvalidValue.new(:bundle_msi, "be TrueClass or FalseClass")
|
227
229
|
end
|
230
|
+
|
228
231
|
@bundle_msi ||= val
|
229
232
|
end
|
230
233
|
expose :bundle_msi
|
@@ -244,6 +247,7 @@ module Omnibus
|
|
244
247
|
unless val.is_a?(TrueClass) || val.is_a?(FalseClass)
|
245
248
|
raise InvalidValue.new(:fast_msi, "be TrueClass or FalseClass")
|
246
249
|
end
|
250
|
+
|
247
251
|
@fast_msi ||= val
|
248
252
|
end
|
249
253
|
expose :fast_msi
|
@@ -298,6 +302,7 @@ module Omnibus
|
|
298
302
|
|
299
303
|
raise "Could not find `#{search_pattern}'!" if file_paths.none?
|
300
304
|
raise "Multiple possible matches of `#{search_pattern}'! : #{file_paths}" if file_paths.count > 1
|
305
|
+
|
301
306
|
file_paths.first.relative_path_from(install_path).to_s
|
302
307
|
end
|
303
308
|
expose :gem_path
|
@@ -340,8 +345,7 @@ module Omnibus
|
|
340
345
|
name: project.package_name,
|
341
346
|
friendly_name: project.friendly_name,
|
342
347
|
maintainer: project.maintainer,
|
343
|
-
}
|
344
|
-
)
|
348
|
+
})
|
345
349
|
end
|
346
350
|
|
347
351
|
#
|
@@ -360,8 +364,7 @@ module Omnibus
|
|
360
364
|
parameters: parameters,
|
361
365
|
version: windows_package_version,
|
362
366
|
display_version: msi_display_version,
|
363
|
-
}
|
364
|
-
)
|
367
|
+
})
|
365
368
|
end
|
366
369
|
|
367
370
|
#
|
@@ -408,8 +411,7 @@ module Omnibus
|
|
408
411
|
hierarchy: hierarchy,
|
409
412
|
fastmsi: fast_msi,
|
410
413
|
wix_install_dir: wix_install_dir,
|
411
|
-
}
|
412
|
-
)
|
414
|
+
})
|
413
415
|
end
|
414
416
|
|
415
417
|
#
|
@@ -429,8 +431,7 @@ module Omnibus
|
|
429
431
|
version: windows_package_version,
|
430
432
|
display_version: msi_display_version,
|
431
433
|
msi: windows_safe_path(Config.package_dir, msi_name),
|
432
|
-
}
|
433
|
-
)
|
434
|
+
})
|
434
435
|
end
|
435
436
|
|
436
437
|
#
|
@@ -487,7 +488,7 @@ module Omnibus
|
|
487
488
|
-ext WixBalExtension
|
488
489
|
#{wix_extension_switches(wix_candle_extensions)}
|
489
490
|
-dOmnibusCacheDir="#{windows_safe_path(File.expand_path(Config.cache_dir))}"
|
490
|
-
"#{windows_safe_path(staging_dir,
|
491
|
+
"#{windows_safe_path(staging_dir, "bundle.wxs")}"
|
491
492
|
EOH
|
492
493
|
else
|
493
494
|
<<-EOH.split.join(" ").squeeze(" ").strip
|
@@ -496,7 +497,7 @@ module Omnibus
|
|
496
497
|
#{wix_candle_flags}
|
497
498
|
#{wix_extension_switches(wix_candle_extensions)}
|
498
499
|
-dProjectSourceDir="#{windows_safe_path(project.install_dir)}" "project-files.wxs"
|
499
|
-
"#{windows_safe_path(staging_dir,
|
500
|
+
"#{windows_safe_path(staging_dir, "source.wxs")}"
|
500
501
|
EOH
|
501
502
|
end
|
502
503
|
end
|
@@ -588,7 +589,7 @@ module Omnibus
|
|
588
589
|
# @return [String]
|
589
590
|
#
|
590
591
|
def wix_extension_switches(arr)
|
591
|
-
"#{arr.map { |e| "-ext '#{e}'" }.join(
|
592
|
+
"#{arr.map { |e| "-ext '#{e}'" }.join(" ")}"
|
592
593
|
end
|
593
594
|
end
|
594
595
|
end
|
@@ -44,8 +44,7 @@ module Omnibus
|
|
44
44
|
maintainer: project.maintainer,
|
45
45
|
build_version: project.build_version,
|
46
46
|
package_name: project.package_name,
|
47
|
-
}
|
48
|
-
)
|
47
|
+
})
|
49
48
|
|
50
49
|
# Render the welcome template
|
51
50
|
render_template(resource_path("welcome.html.erb"),
|
@@ -56,8 +55,7 @@ module Omnibus
|
|
56
55
|
maintainer: project.maintainer,
|
57
56
|
build_version: project.build_version,
|
58
57
|
package_name: project.package_name,
|
59
|
-
}
|
60
|
-
)
|
58
|
+
})
|
61
59
|
|
62
60
|
# "Render" the assets
|
63
61
|
copy_file(resource_path("background.png"), "#{resources_dir}/background.png")
|
@@ -66,6 +64,8 @@ module Omnibus
|
|
66
64
|
build do
|
67
65
|
write_scripts
|
68
66
|
|
67
|
+
sign_software_libs_and_bins
|
68
|
+
|
69
69
|
build_component_pkg
|
70
70
|
|
71
71
|
write_distribution_file
|
@@ -179,6 +179,67 @@ module Omnibus
|
|
179
179
|
end
|
180
180
|
end
|
181
181
|
|
182
|
+
def sign_software_libs_and_bins
|
183
|
+
if signing_identity
|
184
|
+
log.info(log_key) { "Finding libraries and binaries that require signing." }
|
185
|
+
|
186
|
+
bin_dirs = Set[]
|
187
|
+
lib_dirs = Set[]
|
188
|
+
binaries = Set[]
|
189
|
+
libraries = Set[]
|
190
|
+
|
191
|
+
# Capture lib_dirs and bin_dirs from each software
|
192
|
+
project.softwares.each do |software|
|
193
|
+
lib_dirs.merge(software.lib_dirs)
|
194
|
+
bin_dirs.merge(software.bin_dirs)
|
195
|
+
end
|
196
|
+
|
197
|
+
# Find all binaries in each bind_dir
|
198
|
+
bin_dirs.each do |dir|
|
199
|
+
binaries.merge Dir["#{dir}/*"]
|
200
|
+
end
|
201
|
+
# Filter out symlinks, non-files, and non-executables
|
202
|
+
log.debug(log_key) { " Filtering non-binary files:" }
|
203
|
+
binaries.select! { |bin| is_binary?(bin) }
|
204
|
+
|
205
|
+
# Use otool to find all libries that are used by our binaries
|
206
|
+
binaries.each do |bin|
|
207
|
+
libraries.merge find_linked_libs bin
|
208
|
+
end
|
209
|
+
|
210
|
+
# Find all libraries in each lib_dir and add any we missed with otool
|
211
|
+
lib_dirs.each do |dir|
|
212
|
+
libraries.merge Dir["#{dir}/*"]
|
213
|
+
end
|
214
|
+
|
215
|
+
# Filter Mach-O libraries and bundles
|
216
|
+
log.debug(log_key) { " Filtering non-library files:" }
|
217
|
+
libraries.select! { |lib| is_macho?(lib) }
|
218
|
+
|
219
|
+
# Use otool to find all libries that are used by our libraries
|
220
|
+
otool_libs = Set[]
|
221
|
+
libraries.each do |lib|
|
222
|
+
otool_libs.merge find_linked_libs lib
|
223
|
+
end
|
224
|
+
|
225
|
+
# Filter Mach-O libraries and bundles
|
226
|
+
otool_libs.select! { |lib| is_macho?(lib) }
|
227
|
+
libraries.merge otool_libs
|
228
|
+
|
229
|
+
log.info(log_key) { " Signing libraries:" } unless libraries.empty?
|
230
|
+
libraries.each do |library|
|
231
|
+
log.debug(log_key) { " Signing: #{library}" }
|
232
|
+
sign_library(library)
|
233
|
+
end
|
234
|
+
|
235
|
+
log.info(log_key) { " Signing binaries:" } unless binaries.empty?
|
236
|
+
binaries.each do |binary|
|
237
|
+
log.debug(log_key) { " Signing: #{binary}" }
|
238
|
+
sign_binary(binary, true)
|
239
|
+
end
|
240
|
+
end
|
241
|
+
end
|
242
|
+
|
182
243
|
#
|
183
244
|
# Construct the intermediate build product. It can be installed with the
|
184
245
|
# Installer.app, but doesn't contain the data needed to customize the
|
@@ -187,16 +248,20 @@ module Omnibus
|
|
187
248
|
# @return [void]
|
188
249
|
#
|
189
250
|
def build_component_pkg
|
190
|
-
command =
|
251
|
+
command = <<~EOH
|
191
252
|
pkgbuild \\
|
192
253
|
--identifier "#{safe_identifier}" \\
|
193
254
|
--version "#{safe_version}" \\
|
194
255
|
--scripts "#{scripts_dir}" \\
|
195
256
|
--root "#{project.install_dir}" \\
|
196
257
|
--install-location "#{project.install_dir}" \\
|
197
|
-
|
258
|
+
--preserve-xattr \\
|
198
259
|
EOH
|
199
260
|
|
261
|
+
command << %Q{ --sign "#{signing_identity}" \\\n} if signing_identity
|
262
|
+
command << %Q{ "#{component_pkg}"}
|
263
|
+
command << %Q{\n}
|
264
|
+
|
200
265
|
Dir.chdir(staging_dir) do
|
201
266
|
shellout!(command)
|
202
267
|
end
|
@@ -221,8 +286,7 @@ module Omnibus
|
|
221
286
|
identifier: safe_identifier,
|
222
287
|
version: safe_version,
|
223
288
|
component_pkg: component_pkg,
|
224
|
-
}
|
225
|
-
)
|
289
|
+
})
|
226
290
|
end
|
227
291
|
|
228
292
|
#
|
@@ -232,7 +296,7 @@ module Omnibus
|
|
232
296
|
# @return [void]
|
233
297
|
#
|
234
298
|
def build_product_pkg
|
235
|
-
command =
|
299
|
+
command = <<~EOH
|
236
300
|
productbuild \\
|
237
301
|
--distribution "#{staging_dir}/Distribution" \\
|
238
302
|
--resources "#{resources_dir}" \\
|
@@ -323,5 +387,57 @@ module Omnibus
|
|
323
387
|
converted
|
324
388
|
end
|
325
389
|
end
|
390
|
+
|
391
|
+
#
|
392
|
+
# Given a file path return any linked libraries.
|
393
|
+
#
|
394
|
+
# @param [String] file_path
|
395
|
+
# The path to a file
|
396
|
+
# @return [Array<String>]
|
397
|
+
# The linked libs
|
398
|
+
#
|
399
|
+
def find_linked_libs(file_path)
|
400
|
+
# Find all libaries for each bin
|
401
|
+
command = "otool -L #{file_path}"
|
402
|
+
|
403
|
+
stdout = shellout!(command).stdout
|
404
|
+
stdout.slice!(file_path)
|
405
|
+
stdout.scan(/#{install_dir}\S*/)
|
406
|
+
end
|
407
|
+
|
408
|
+
def sign_library(lib)
|
409
|
+
sign_binary(lib)
|
410
|
+
end
|
411
|
+
|
412
|
+
def sign_binary(bin, hardened_runtime = false)
|
413
|
+
command = "codesign -s '#{signing_identity}' '#{bin}'"
|
414
|
+
command << %q{ --options=runtime} if hardened_runtime
|
415
|
+
command << %Q{ --entitlements #{resource_path("entitlements.plist")}} if File.exist?(resource_path("entitlements.plist")) && hardened_runtime
|
416
|
+
## Force re-signing to deal with binaries that have the same sha.
|
417
|
+
command << %q{ --force}
|
418
|
+
command << %Q{\n}
|
419
|
+
|
420
|
+
shellout!(command)
|
421
|
+
end
|
422
|
+
|
423
|
+
def is_binary?(bin)
|
424
|
+
is_binary = File.file?(bin) &&
|
425
|
+
File.executable?(bin) &&
|
426
|
+
!File.symlink?(bin)
|
427
|
+
log.debug(log_key) { " removing non-binary file from signing: #{bin}" } unless is_binary
|
428
|
+
is_binary
|
429
|
+
end
|
430
|
+
|
431
|
+
def is_macho?(lib)
|
432
|
+
is_macho = false
|
433
|
+
if is_binary?(lib)
|
434
|
+
command = "file #{lib}"
|
435
|
+
|
436
|
+
stdout = shellout!(command).stdout
|
437
|
+
is_macho = stdout.match?(/Mach-O.*(library|bundle)/)
|
438
|
+
end
|
439
|
+
log.debug(log_key) { " removing non-Mach-O library file from signing: #{lib}" } unless is_macho
|
440
|
+
is_macho
|
441
|
+
end
|
326
442
|
end
|
327
443
|
end
|