Module: Omnibus::Packager

Includes:
Logging, Sugarable
Defined in:
lib/omnibus/packager.rb

Defined Under Namespace

Classes: APPX, BFF, Base, DEB, IPS, MSI, Makeself, PKG, PKGSRC, RPM, Solaris, WindowsBase

Constant Summary collapse

PLATFORM_PACKAGER_MAP =

The list of Ohai platform families mapped to the respective packager class.

Returns:

  • (Hash<String, Class>)
{
  "debian" => DEB,
  "fedora" => RPM,
  "suse" => RPM,
  "rhel" => RPM,
  "wrlinux" => RPM,
  "amazon" => RPM,
  "aix" => BFF,
  "solaris" => Solaris,
  "ips" => IPS,
  "windows" => [MSI, APPX],
  "mac_os_x" => PKG,
  "smartos" => PKGSRC,
}.freeze

Class Method Summary collapse

Methods included from Sugarable

extended, included, #node

Methods included from Logging

included

Class Method Details

.for_current_system[~Packager::Base]

Determine the packager(s) for the current system. This method returns the class, not an instance of the class.

Examples:

Packager.for_current_system #=> [Packager::RPM]

Returns:


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
# File 'lib/omnibus/packager.rb', line 64

def for_current_system
  family = Ohai["platform_family"]
  version = Ohai["platform_version"]

  if family == "solaris2" && Chef::Sugar::Constraints::Version.new(version).satisfies?(">= 5.11")
    family = "ips"
  elsif family == "solaris2" && Chef::Sugar::Constraints::Version.new(version).satisfies?(">= 5.10")
    family = "solaris"
  end
  if klass = PLATFORM_PACKAGER_MAP[family]
    package_types = klass.is_a?(Array) ? klass : [ klass ]

    if package_types.include?(APPX) &&
        !Chef::Sugar::Constraints::Version.new(version).satisfies?(">= 6.2")
      log.warn(log_key) { "APPX generation is only supported on Windows versions 2012 and above" }
      package_types -= [APPX]
    end

    package_types
  else
    log.warn(log_key) do
      "Could not determine packager for `#{family}', defaulting " \
      "to `makeself'!"
    end
    [Makeself]
  end
end