class Omnibus::Packager::IPS

Public Instance Methods

create_ips_repo() click to toggle source

Create a local IPS repo for publishing

@return [void]

# File lib/omnibus/packagers/ips.rb, line 313
def create_ips_repo
  shellout!("pkgrepo create #{repo_dir}")
  log.info(log_key) { "Created IPS repo: #{repo_dir}" }
end
export_pkg_archive_file() click to toggle source

Convert a the published IPS pkg from the local repo into the more easily distributable ‘*.p5p` archive.

@return [void]

# File lib/omnibus/packagers/ips.rb, line 344
    def export_pkg_archive_file
      # The destination file cannot already exist
      File.delete(package_path) if File.exist?(package_path)
      shellout!("pkgrecv -s #{repo_dir} -a -d #{package_path} #{safe_base_package_name}")
      log.info(log_key) { "Exported IPS package archive: #{package_path}" }

      list_pkgarchive = shellout("pkgrepo list -s #{package_path} '*@latest'").stdout
      log.debug(log_key) do
        <<-EOH.strip
          IPS package archive contents:

            #{list_pkgarchive}
        EOH
      end
    end
fmri_package_name() click to toggle source

For more info about fmri see:

http://docs.oracle.com/cd/E23824_01/html/E21796/pkg-5.html
# File lib/omnibus/packagers/ips.rb, line 93
def fmri_package_name
  version = project.build_version.split(/[^\d]/)[0..2].join(".")
  platform = Ohai["platform_version"]
  "#{safe_base_package_name}@#{version},#{platform}-#{project.build_iteration}"
end
generate_pkg_contents() click to toggle source

Create the package contents using ‘pkgsend` and `pkgfmt`

@return [void]

# File lib/omnibus/packagers/ips.rb, line 281
def generate_pkg_contents
  shellout!("pkgsend generate #{source_dir} | pkgfmt > #{pkg_manifest_file}.1")
  shellout!("pkgmogrify -DARCH=`uname -p` #{pkg_manifest_file}.1 #{pkg_metadata_file} #{transform_file} | pkgfmt > #{pkg_manifest_file}.2")
end
generate_pkg_deps() click to toggle source

Generate the package deps

@return [void]

# File lib/omnibus/packagers/ips.rb, line 291
def generate_pkg_deps
  shellout!("pkgdepend generate -md #{source_dir} #{pkg_manifest_file}.2 | pkgfmt > #{pkg_manifest_file}.3")
  shellout!("pkgmogrify -DARCH=`uname -p` #{pkg_manifest_file}.3 #{transform_file} | pkgfmt > #{pkg_manifest_file}.4")
  shellout!("pkgdepend resolve -m #{pkg_manifest_file}.4")
  shellout!("pkgmogrify #{pkg_manifest_file}.4.res #{versionlock_file} > #{pkg_manifest_file}.5.res")
end
package_name() click to toggle source

@see Base#package_name

# File lib/omnibus/packagers/ips.rb, line 84
def package_name
  "#{safe_base_package_name}-#{project.build_version}-#{project.build_iteration}.#{safe_architecture}.p5p"
end
pkg_manifest_file() click to toggle source

The full path to the pkg manifest file on disk.

@return [String]

# File lib/omnibus/packagers/ips.rb, line 131
def pkg_manifest_file
  @pkg_manifest_file ||= File.join(staging_dir, "#{safe_base_package_name}.p5m")
end
pkg_metadata_file() click to toggle source

The full path to the pkg metadata file on disk.

@return [String]

# File lib/omnibus/packagers/ips.rb, line 122
def pkg_metadata_file
  @pkg_metadata_file ||= File.join(staging_dir, "gen.manifestfile")
end
publish_ips_pkg() click to toggle source

Publish the IPS pkg into the local IPS repo

@return [void]

# File lib/omnibus/packagers/ips.rb, line 323
    def publish_ips_pkg
      shellout!("pkgrepo -s #{repo_dir} set publisher/prefix=#{publisher_prefix}")
      shellout!("pkgsend publish -s #{repo_dir} -d #{source_dir} #{pkg_manifest_file}.5.res")
      log.info(log_key) { "Published IPS package to repo: #{repo_dir}" }

      repo_info = shellout("pkg list -afv -g #{repo_dir}").stdout
      log.debug(log_key) do
        <<-EOH.strip
          Published IPS package:

            #{repo_info}
        EOH
      end
    end
publisher_prefix(val = NULL) click to toggle source

The publisher prefix for the IPS package.

@example

identifier 'Chef'

@param [String] val

the package identifier

@return [String]

# File lib/omnibus/packagers/ips.rb, line 68
def publisher_prefix(val = NULL)
  if null?(val)
    @publisher_prefix || "Omnibus"
  else
    @publisher_prefix = val
  end
end
repo_dir() click to toggle source

The path to the publish/repo directory inside the staging directory.

@return [String]

# File lib/omnibus/packagers/ips.rb, line 140
def repo_dir
  @repo_dir ||= File.join(staging_dir, "publish", "repo")
end
safe_architecture() click to toggle source

The architecture for this IPS package.

@return [String]

# File lib/omnibus/packagers/ips.rb, line 180
def safe_architecture
  if intel?
    "i386"
  elsif sparc?
    "sparc"
  else
    Ohai["kernel"]["machine"]
  end
end
safe_base_package_name() click to toggle source

Return the IPS-ready base package name, converting any invalid characters to dashes (-).

@return [String]

# File lib/omnibus/packagers/ips.rb, line 159
def safe_base_package_name
  if project.package_name =~ /\A[a-z0-9\.\+\-]+\z/
    project.package_name.dup
  else
    converted = project.package_name.downcase.gsub(/[^a-z0-9\.\+\-]+/, "-")

    log.warn(log_key) do
      "The `name' component of IPS package names can only include " \
      "lowercase alphabetical characters (a-z), numbers (0-9), dots (.), " \
      "plus signs (+), and dashes (-). Converting `#{project.package_name}' to " \
      "`#{converted}'."
    end
    converted
  end
end
source_dir() click to toggle source

The path to the proto-install directory inside the staging directory.

@return [String]

# File lib/omnibus/packagers/ips.rb, line 149
def source_dir
  @source_dir ||= File.join(staging_dir, "proto_install")
end
transform_file() click to toggle source

The full path to the transform file on disk.

@return [String]

# File lib/omnibus/packagers/ips.rb, line 104
def transform_file
  @transform_file ||= File.join(staging_dir, "doc-transform")
end
validate_pkg_manifest() click to toggle source

Validate the generated package manifest using ‘pkglint`

@return [void]

# File lib/omnibus/packagers/ips.rb, line 303
def validate_pkg_manifest
  log.info(log_key) { "Validating package manifest" }
  shellout!("pkglint -c /tmp/lint-cache -r http://pkg.oracle.com/solaris/release #{pkg_manifest_file}.5.res")
end
versionlock_file() click to toggle source

The full path to the version-lock file on disk.

@return [String]

# File lib/omnibus/packagers/ips.rb, line 113
def versionlock_file
  @versionlock_file ||= File.join(staging_dir, "version-lock")
end
write_pkg_metadata() click to toggle source

Generate package metadata

Create the gen template for ‘pkgmogrify`

@return [void]

# File lib/omnibus/packagers/ips.rb, line 254
def write_pkg_metadata
  render_template(resource_path("gen.manifestfile.erb"),
    destination: pkg_metadata_file,
    variables: {
      name: safe_base_package_name,
      fmri_package_name: fmri_package_name,
      description: project.description,
      summary: project.friendly_name,
      arch: safe_architecture,
    })

  # Append the contents of symlinks_file if it exists
  if symlinks_file
    File.open(pkg_metadata_file, "a") do |symlink|
      symlink.write(render_symlinks)
    end
  end

  # Print the full contents of the rendered template file to generate package contents
  log.debug(log_key) { "Rendered Template:\n" + File.read(pkg_metadata_file) }
end
write_transform_file() click to toggle source

A set of transform rules that ‘pkgmogrify’ will apply to the package manifest.

@return [void]

# File lib/omnibus/packagers/ips.rb, line 207
def write_transform_file
  render_template(resource_path("doc-transform.erb"),
    destination: transform_file,
    variables: {
      pathdir: project.install_dir.split("/")[1],
    })
end
write_versionlock_file() click to toggle source

A version-lock rule that ‘pkgmogrify’ will apply to at the end of package manifest.

@return [void]

# File lib/omnibus/packagers/ips.rb, line 196
def write_versionlock_file
  transform_str = "<transform pkg depend -> default facet.version-lock.*> false>"
  File.write("#{staging_dir}/version-lock", transform_str)
end