Class: FPM::Package::OSXpkg

Inherits:
FPM::Package show all
Defined in:
lib/fpm/package/osxpkg.rb

Overview

Use an OS X pkg built with pkgbuild.

Supports input and output. Requires pkgbuild and (for input) pkgutil, part of a standard OS X install in 10.7 and higher.

Constant Summary collapse

SCRIPT_MAP =

Map of what scripts are named.

{
  :before_install     => "preinstall",
  :after_install      => "postinstall",
}
POSTINSTALL_ACTIONS =
[ "logout", "restart", "shutdown" ]
OWNERSHIP_OPTIONS =
["recommended", "preserve", "preserve-other"]

Instance Attribute Summary

Attributes inherited from FPM::Package

#architecture, #attributes, #attrs, #category, #config_files, #conflicts, #dependencies, #description, #directories, #epoch, #iteration, #license, #maintainer, #name, #provides, #replaces, #scripts, #url, #vendor, #version

Instance Method Summary collapse

Methods inherited from FPM::Package

apply_options, #build_path, #cleanup, #cleanup_build, #cleanup_staging, #convert, #converted_from, default_attributes, #edit_file, #files, inherited, #initialize, option, #script, #staging_path, type, #type, types

Methods included from Util

#ar_cmd, #ar_cmd_deterministic?, #copied_entries, #copy_entry, #copy_metadata, #default_shell, #execmd, #expand_pessimistic_constraints, #logger, #mknod_w, #program_exists?, #program_in_path?, #safesystem, #safesystemout, #tar_cmd, #tar_cmd_supports_sort_names_and_set_mtime?

Constructor Details

This class inherits a constructor from FPM::Package

Instance Method Details

#identifierObject

return the identifier by prepending the reverse-domain prefix to the package name, else return just the name


60
61
62
63
64
65
66
# File 'lib/fpm/package/osxpkg.rb', line 60

def identifier
  identifier = name.dup
  if self.attributes[:osxpkg_identifier_prefix]
    identifier.insert(0, "#{self.attributes[:osxpkg_identifier_prefix]}.")
  end
  identifier
end

#input(input_path) ⇒ Object

Take a flat package as input


118
119
120
121
122
123
124
125
126
127
128
# File 'lib/fpm/package/osxpkg.rb', line 118

def input(input_path)
  # TODO: Fail if it's a Distribution pkg or old-fashioned
  expand_dir = File.join(build_path, "expand")
  # expand_dir must not already exist for pkgutil --expand
  safesystem("pkgutil --expand #{input_path} #{expand_dir}")

  extract_info(input_path)

  # extract Payload
  safesystem("tar -xz -f #{expand_dir}/Payload -C #{staging_path}")
end

#output(output_path) ⇒ Object

Output a pkgbuild pkg.


131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
# File 'lib/fpm/package/osxpkg.rb', line 131

def output(output_path)
  output_check(output_path)

  temp_info = pkginfo_template_path

  args = ["--identifier", identifier,
          "--info", temp_info,
          "--version", version.to_s,
          "--ownership", attributes[:osxpkg_ownership]]

  if self.attributes[:osxpkg_payload_free?]
    args << "--nopayload"
  else
    args += ["--root", staging_path]
  end

  if attributes[:before_install_given?] or attributes[:after_install_given?]
    write_scripts
    args += ["--scripts", scripts_path]
  end
  args << output_path

  safesystem("pkgbuild", *args)
  FileUtils.remove_file(temp_info)
end

#to_s(format = nil) ⇒ Object


159
160
161
# File 'lib/fpm/package/osxpkg.rb', line 159

def to_s(format=nil)
  return super(format.nil? ? "NAME-VERSION.EXTENSION" : format)
end