class Omnibus::Packager::IPS
Public Instance Methods
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
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
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
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 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
@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
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
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 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
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
A set of symbolic links to installed commands that ‘pkgmogrify’ will apply to the package manifest. Is called only when “#{safe_base_package_name}-symlinks.erb” or “symlinks.erb” template resource exists locally
@return [String]
# File lib/omnibus/packagers/ips.rb, line 240 def render_symlinks render_template_content(resource_path(symlinks_file), { projectdir: project.install_dir, }) end
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
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
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
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
The name of the project specific template if it exists The resource exists locally. For example for project omnibus-toolchain resource_path(“#{safe_base_package_name}-symlinks.erb”) #=> {“/path/to/omnibus-toolchain/resources/omnibus-toolchain/ips/omnibus-toolchain-symlinks.erb”} OR {“/path/to/omnibus-toolchain/resources/omnibus-toolchain/ips/symlinks.erb”}
@return [String]
# File lib/omnibus/packagers/ips.rb, line 224 def symlinks_file if File.exist?(resource_path("#{safe_base_package_name}-symlinks.erb")) "#{safe_base_package_name}-symlinks.erb" elsif File.exist?(resource_path("symlinks.erb")) "symlinks.erb" end end
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 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
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
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
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
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