omnibus 7.0.13 → 8.1.15

Sign up to get free protection for your applications and to get access to all the features.
Files changed (70) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +1 -6
  3. data/README.md +38 -6
  4. data/bin/omnibus +1 -1
  5. data/lib/omnibus.rb +2 -2
  6. data/lib/omnibus/build_version.rb +1 -1
  7. data/lib/omnibus/build_version_dsl.rb +5 -7
  8. data/lib/omnibus/builder.rb +16 -11
  9. data/lib/omnibus/cleaner.rb +1 -1
  10. data/lib/omnibus/cli.rb +2 -2
  11. data/lib/omnibus/cli/changelog.rb +1 -1
  12. data/lib/omnibus/compressors/base.rb +1 -1
  13. data/lib/omnibus/compressors/dmg.rb +5 -2
  14. data/lib/omnibus/compressors/tgz.rb +2 -2
  15. data/lib/omnibus/config.rb +1 -1
  16. data/lib/omnibus/core_extensions/open_uri.rb +1 -1
  17. data/lib/omnibus/digestable.rb +2 -2
  18. data/lib/omnibus/download_helpers.rb +6 -2
  19. data/lib/omnibus/fetchers/file_fetcher.rb +1 -1
  20. data/lib/omnibus/fetchers/net_fetcher.rb +1 -1
  21. data/lib/omnibus/fetchers/path_fetcher.rb +1 -1
  22. data/lib/omnibus/file_syncer.rb +1 -1
  23. data/lib/omnibus/generator.rb +2 -2
  24. data/lib/omnibus/generator_files/README.md.erb +2 -1
  25. data/lib/omnibus/git_cache.rb +2 -2
  26. data/lib/omnibus/health_check.rb +2 -0
  27. data/lib/omnibus/licensing.rb +2 -2
  28. data/lib/omnibus/logger.rb +1 -1
  29. data/lib/omnibus/manifest.rb +1 -1
  30. data/lib/omnibus/manifest_diff.rb +7 -13
  31. data/lib/omnibus/metadata.rb +8 -4
  32. data/lib/omnibus/ohai.rb +1 -1
  33. data/lib/omnibus/package.rb +1 -1
  34. data/lib/omnibus/packager.rb +6 -14
  35. data/lib/omnibus/packagers/base.rb +1 -1
  36. data/lib/omnibus/packagers/msi.rb +1 -1
  37. data/lib/omnibus/packagers/pkg.rb +14 -4
  38. data/lib/omnibus/packagers/rpm.rb +23 -9
  39. data/lib/omnibus/packagers/solaris.rb +1 -1
  40. data/lib/omnibus/project.rb +2 -2
  41. data/lib/omnibus/publishers/artifactory_publisher.rb +2 -2
  42. data/lib/omnibus/s3_cache.rb +1 -1
  43. data/lib/omnibus/s3_helpers.rb +1 -1
  44. data/lib/omnibus/software.rb +5 -16
  45. data/lib/omnibus/sugarable.rb +5 -14
  46. data/lib/omnibus/templating.rb +1 -1
  47. data/lib/omnibus/thread_pool.rb +0 -2
  48. data/lib/omnibus/util.rb +1 -1
  49. data/lib/omnibus/version.rb +1 -1
  50. data/lib/omnibus/whitelist.rb +22 -0
  51. data/omnibus.gemspec +8 -8
  52. data/resources/ips/doc-transform.erb +1 -0
  53. data/resources/msi/CustomActionFastMsi.CA.dll +0 -0
  54. data/resources/msi/source.wxs.erb +2 -10
  55. data/resources/pkg/distribution.xml.erb +1 -1
  56. data/resources/rpm/spec.erb +2 -2
  57. data/spec/functional/fetchers/net_fetcher_spec.rb +2 -11
  58. data/spec/support/path_helpers.rb +2 -2
  59. data/spec/unit/compressor_spec.rb +2 -2
  60. data/spec/unit/compressors/dmg_spec.rb +12 -9
  61. data/spec/unit/compressors/tgz_spec.rb +4 -4
  62. data/spec/unit/fetchers/net_fetcher_spec.rb +5 -1
  63. data/spec/unit/metadata_spec.rb +8 -6
  64. data/spec/unit/packager_spec.rb +7 -14
  65. data/spec/unit/packagers/ips_spec.rb +1 -0
  66. data/spec/unit/packagers/pkg_spec.rb +20 -4
  67. data/spec/unit/packagers/rpm_spec.rb +15 -5
  68. data/spec/unit/project_spec.rb +6 -6
  69. data/spec/unit/software_spec.rb +29 -120
  70. metadata +36 -16
@@ -14,8 +14,8 @@
14
14
  # limitations under the License.
15
15
  #
16
16
 
17
- require "digest"
18
- require "fileutils"
17
+ require "digest" unless defined?(Digest)
18
+ require "fileutils" unless defined?(FileUtils)
19
19
 
20
20
  module Omnibus
21
21
  class GitCache
@@ -428,6 +428,8 @@ module Omnibus
428
428
  ARCH_WHITELIST_LIBS
429
429
  when "mac_os_x"
430
430
  MAC_WHITELIST_LIBS
431
+ when "omnios"
432
+ OMNIOS_WHITELIST_LIBS
431
433
  when "solaris2"
432
434
  SOLARIS_WHITELIST_LIBS
433
435
  when "smartos"
@@ -14,8 +14,8 @@
14
14
  # limitations under the License.
15
15
  #
16
16
 
17
- require "uri"
18
- require "fileutils"
17
+ require "uri" unless defined?(URI)
18
+ require "fileutils" unless defined?(FileUtils)
19
19
  require "omnibus/download_helpers"
20
20
  require "license_scout/collector"
21
21
  require "license_scout/reporter"
@@ -17,7 +17,7 @@
17
17
  module Omnibus
18
18
  class Logger
19
19
 
20
- require "time"
20
+ require "time" unless defined?(Time.zone_offset)
21
21
 
22
22
  #
23
23
  # The amount of padding on the left column.
@@ -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 Manifest
@@ -25,28 +25,22 @@ module Omnibus
25
25
 
26
26
  def updated
27
27
  @updated ||=
28
- begin
29
- (first.entry_names & second.entry_names).collect do |name|
30
- diff(first.entry_for(name), second.entry_for(name))
31
- end.compact
32
- end
28
+ (first.entry_names & second.entry_names).collect do |name|
29
+ diff(first.entry_for(name), second.entry_for(name))
30
+ end.compact
33
31
  end
34
32
 
35
33
  def removed
36
34
  @removed ||=
37
- begin
38
- (first.entry_names - second.entry_names).collect do |name|
39
- removed_entry(first.entry_for(name))
40
- end
35
+ (first.entry_names - second.entry_names).collect do |name|
36
+ removed_entry(first.entry_for(name))
41
37
  end
42
38
  end
43
39
 
44
40
  def added
45
41
  @added ||=
46
- begin
47
- (second.entry_names - first.entry_names).collect do |name|
48
- new_entry(second.entry_for(name))
49
- end
42
+ (second.entry_names - first.entry_names).collect do |name|
43
+ new_entry(second.entry_for(name))
50
44
  end
51
45
  end
52
46
 
@@ -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
@@ -170,12 +170,16 @@ module Omnibus
170
170
  # rubocop:disable Lint/DuplicateCaseCondition
171
171
  def truncate_platform_version(platform_version, platform)
172
172
  case platform
173
- when "centos", "debian", "el", "fedora", "freebsd", "omnios", "pidora", "raspbian", "rhel", "sles", "suse", "smartos"
173
+ when "centos", "cumulus", "debian", "el", "fedora", "freebsd", "omnios", "pidora", "raspbian", "rhel", "sles", "suse", "smartos"
174
174
  # Only want MAJOR (e.g. Debian 7, OmniOS r151006, SmartOS 20120809T221258Z)
175
175
  platform_version.split(".").first
176
- when "aix", "alpine", "mac_os_x", "openbsd", "slackware", "solaris2", "opensuse", "opensuseleap", "ubuntu", "amazon"
177
- # Only want MAJOR.MINOR (e.g. Mac OS X 10.9, Ubuntu 12.04)
176
+ when "aix", "alpine", "openbsd", "slackware", "solaris2", "opensuse", "opensuseleap", "ubuntu", "amazon"
177
+ # Only want MAJOR.MINOR (e.g. Ubuntu 12.04)
178
178
  platform_version.split(".")[0..1].join(".")
179
+ when "mac_os_x", "darwin", "macos"
180
+ # If running macOS >= 11, use only MAJOR version. Otherwise, use MAJOR.MINOR
181
+ pv_bits = platform_version.split(".")
182
+ pv_bits[0].to_i >= 11 ? pv_bits[0] : pv_bits[0..1].join(".")
179
183
  when "arch", "gentoo", "kali"
180
184
  # Arch Linux / Gentoo do not have a platform_version ohai attribute, they are rolling release (lsb_release -r)
181
185
  "rolling"
data/lib/omnibus/ohai.rb CHANGED
@@ -14,7 +14,7 @@
14
14
  # limitations under the License.
15
15
  #
16
16
 
17
- require "ohai"
17
+ require "ohai" unless defined?(Ohai::System)
18
18
 
19
19
  module Omnibus
20
20
  class Ohai
@@ -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 Package
@@ -1,5 +1,5 @@
1
1
  #
2
- # Copyright 2014-2018 Chef Software, Inc.
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" && Chef::Sugar::Constraints::Version.new(version).satisfies?(">= 5.11")
69
+ if family == "solaris2" && ChefUtils::VersionString.new(version).satisfies?(">= 5.11")
69
70
  family = "ips"
70
- elsif family == "solaris2" && Chef::Sugar::Constraints::Version.new(version).satisfies?(">= 5.10")
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
- package_types = klass.is_a?(Array) ? klass : [ klass ]
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}', defaulting " \
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
@@ -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
@@ -125,7 +125,7 @@ module Omnibus
125
125
 
126
126
  # @see Base#package_name
127
127
  def package_name
128
- "#{safe_base_package_name}-#{safe_version}-#{safe_build_iteration}.pkg"
128
+ "#{safe_base_package_name}-#{safe_version}-#{safe_build_iteration}.#{safe_architecture}.pkg"
129
129
  end
130
130
 
131
131
  #
@@ -286,6 +286,7 @@ module Omnibus
286
286
  identifier: safe_identifier,
287
287
  version: safe_version,
288
288
  component_pkg: component_pkg,
289
+ host_architecture: safe_architecture,
289
290
  })
290
291
  end
291
292
 
@@ -320,6 +321,15 @@ module Omnibus
320
321
  "#{safe_base_package_name}-core.pkg"
321
322
  end
322
323
 
324
+ #
325
+ # Return the architecture
326
+ #
327
+ # @return [String]
328
+ #
329
+ def safe_architecture
330
+ @safe_architecture ||= Ohai["kernel"]["machine"]
331
+ end
332
+
323
333
  #
324
334
  # Return the PKG-ready base package name, removing any invalid characters.
325
335
  #
@@ -424,7 +434,7 @@ module Omnibus
424
434
  is_binary = File.file?(bin) &&
425
435
  File.executable?(bin) &&
426
436
  !File.symlink?(bin)
427
- log.debug(log_key) { " removing from signing: #{bin}" } unless is_binary
437
+ log.debug(log_key) { " removing non-binary file from signing: #{bin}" } unless is_binary
428
438
  is_binary
429
439
  end
430
440
 
@@ -434,9 +444,9 @@ module Omnibus
434
444
  command = "file #{lib}"
435
445
 
436
446
  stdout = shellout!(command).stdout
437
- is_macho = stdout.match?(/Mach-O.*library/) || stdout.match?(/Mach-O.*bundle/)
447
+ is_macho = stdout.match?(/Mach-O.*(library|bundle)/)
438
448
  end
439
- log.debug(log_key) { " removing from signing: #{lib}" } unless is_macho
449
+ log.debug(log_key) { " removing non-Mach-O library file from signing: #{lib}" } unless is_macho
440
450
  is_macho
441
451
  end
442
452
  end
@@ -417,6 +417,10 @@ module Omnibus
417
417
  command << %{ -bb}
418
418
  command << %{ --buildroot #{staging_dir}/BUILD}
419
419
  command << %{ --define '_topdir #{staging_dir}'}
420
+ command << " #{spec_file}"
421
+
422
+ log.info(log_key) { "Creating .rpm file" }
423
+ shellout!("#{command}")
420
424
 
421
425
  if signing_passphrase
422
426
  log.info(log_key) { "Signing enabled for .rpm file" }
@@ -438,17 +442,18 @@ module Omnibus
438
442
  })
439
443
  end
440
444
 
441
- command << " --sign"
442
- command << " #{spec_file}"
443
-
445
+ sign_cmd = "rpmsign --addsign #{rpm_file}"
444
446
  with_rpm_signing do |signing_script|
445
- log.info(log_key) { "Creating .rpm file" }
446
- shellout!("#{signing_script} \"#{command}\"", environment: { "HOME" => home })
447
+ log.info(log_key) { "Signing the built rpm file" }
448
+
449
+ # RHEL 8 has gpg-agent running so we can skip the expect script since the agent
450
+ # takes care of the passphrase entering on the signing
451
+ if dist_tag != ".el8"
452
+ sign_cmd.prepend("#{signing_script} \"").concat("\"")
453
+ end
454
+
455
+ shellout!("#{sign_cmd}", environment: { "HOME" => home })
447
456
  end
448
- else
449
- log.info(log_key) { "Creating .rpm file" }
450
- command << " #{spec_file}"
451
- shellout!("#{command}")
452
457
  end
453
458
 
454
459
  FileSyncer.glob("#{staging_dir}/RPMS/**/*.rpm").each do |rpm|
@@ -483,6 +488,15 @@ module Omnibus
483
488
  "#{staging_dir}/SPECS/#{package_name}.spec"
484
489
  end
485
490
 
491
+ #
492
+ # The full path to the rpm file.
493
+ #
494
+ # @return [String]
495
+ #
496
+ def rpm_file
497
+ "#{staging_dir}/RPMS/#{safe_architecture}/#{package_name}"
498
+ end
499
+
486
500
  #
487
501
  # Render the rpm signing script with secure permissions, call the given
488
502
  # block with the path to the script, and ensure deletion of the script from
@@ -14,7 +14,7 @@
14
14
  # limitations under the License.
15
15
  #
16
16
 
17
- require "socket"
17
+ require "socket" unless defined?(Socket)
18
18
 
19
19
  module Omnibus
20
20
  class Packager::Solaris < Packager::Base
@@ -15,8 +15,8 @@
15
15
  # limitations under the License.
16
16
  #
17
17
 
18
- require "time"
19
- require "ffi_yajl"
18
+ require "time" unless defined?(Time.zone_offset)
19
+ require "ffi_yajl" unless defined?(FFI_Yajl)
20
20
  require "omnibus/manifest"
21
21
  require "omnibus/manifest_entry"
22
22
  require "omnibus/reports"
@@ -14,8 +14,8 @@
14
14
  # limitations under the License.
15
15
  #
16
16
 
17
- require "uri"
18
- require "benchmark"
17
+ require "uri" unless defined?(URI)
18
+ require "benchmark" unless defined?(Benchmark)
19
19
 
20
20
  module Omnibus
21
21
  class ArtifactoryPublisher < Publisher
@@ -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
  require "omnibus/s3_helpers"
19
19
 
20
20
  module Omnibus
@@ -17,7 +17,7 @@
17
17
  require "aws-sdk-s3"
18
18
  require "aws-sdk-core/credentials"
19
19
  require "aws-sdk-core/shared_credentials"
20
- require "base64"
20
+ require "base64" unless defined?(Base64)
21
21
 
22
22
  module Omnibus
23
23
  module S3Helpers
@@ -14,8 +14,8 @@
14
14
  # limitations under the License.
15
15
  #
16
16
 
17
- require "fileutils"
18
- require "uri"
17
+ require "fileutils" unless defined?(FileUtils)
18
+ require "uri" unless defined?(URI)
19
19
  require "omnibus/manifest_entry"
20
20
 
21
21
  module Omnibus
@@ -525,7 +525,7 @@ module Omnibus
525
525
  return if final_version.nil?
526
526
 
527
527
  begin
528
- Chef::Sugar::Constraints::Version.new(final_version)
528
+ ChefUtils::VersionString.new(final_version)
529
529
  rescue ArgumentError
530
530
  log.warn(log_key) do
531
531
  "Version #{final_version} for software #{name} was not parseable. " \
@@ -718,19 +718,8 @@ module Omnibus
718
718
  "CC" => "clang",
719
719
  "CXX" => "clang++",
720
720
  "LDFLAGS" => "-L#{install_dir}/embedded/lib",
721
- "CFLAGS" => "-I#{install_dir}/embedded/include -O2 -D_FORTIFY_SOURCE=2 -fstack-protector",
721
+ "CFLAGS" => "-I#{install_dir}/embedded/include -O3 -D_FORTIFY_SOURCE=2 -fstack-protector",
722
722
  }
723
- when "suse"
724
- suse_flags = {
725
- "LDFLAGS" => "-Wl,-rpath,#{install_dir}/embedded/lib -L#{install_dir}/embedded/lib",
726
- "CFLAGS" => "-I#{install_dir}/embedded/include -O2 -D_FORTIFY_SOURCE=2 -fstack-protector",
727
- }
728
- # Enable gcc version 4.8 if it is available
729
- if which("gcc-4.8") && platform_version.satisfies?("< 12")
730
- suse_flags["CC"] = "gcc-4.8"
731
- suse_flags["CXX"] = "g++-4.8"
732
- end
733
- suse_flags
734
723
  when "windows"
735
724
  arch_flag = windows_arch_i386? ? "-m32" : "-m64"
736
725
  opt_flag = windows_arch_i386? ? "-march=i686" : "-march=x86-64"
@@ -750,7 +739,7 @@ module Omnibus
750
739
  else
751
740
  {
752
741
  "LDFLAGS" => "-Wl,-rpath,#{install_dir}/embedded/lib -L#{install_dir}/embedded/lib",
753
- "CFLAGS" => "-I#{install_dir}/embedded/include -O2 -D_FORTIFY_SOURCE=2 -fstack-protector",
742
+ "CFLAGS" => "-I#{install_dir}/embedded/include -O3 -D_FORTIFY_SOURCE=2 -fstack-protector",
754
743
  }
755
744
  end
756
745
 
@@ -1,5 +1,5 @@
1
1
  #
2
- # Copyright 2014-2018 Chef Software, Inc.
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.
@@ -14,31 +14,22 @@
14
14
  # limitations under the License.
15
15
  #
16
16
 
17
- require "chef/sugar/architecture"
18
- require "chef/sugar/cloud"
19
- require "chef/sugar/constraints"
20
- require "chef/sugar/ip"
21
- require "chef/sugar/init"
22
- require "chef/sugar/platform"
23
- require "chef/sugar/platform_family"
24
- require "chef/sugar/ruby"
25
- require "chef/sugar/shell"
26
- require "chef/sugar/vagrant"
17
+ require "chef-utils" unless defined?(ChefUtils::CANARY)
27
18
 
28
19
  module Omnibus
29
20
  module Sugarable
30
21
  def self.extended(base)
31
- base.send(:extend, Chef::Sugar::DSL)
22
+ base.send(:extend, ChefUtils)
32
23
  base.send(:extend, Omnibus::Sugar)
33
24
  end
34
25
 
35
26
  def self.included(base)
36
- base.send(:include, Chef::Sugar::DSL)
27
+ base.send(:include, ChefUtils)
37
28
  base.send(:include, Omnibus::Sugar)
38
29
 
39
30
  if base < Cleanroom
40
31
  # Make all the "sugars" available in the cleanroom (DSL)
41
- Chef::Sugar::DSL.instance_methods.each do |instance_method|
32
+ ChefUtils.instance_methods.each do |instance_method|
42
33
  base.send(:expose, instance_method)
43
34
  end
44
35