Class: Omnibus::Packager::IPS

Inherits:
Base
  • Object
show all
Defined in:
lib/omnibus/packagers/ips.rb

Constant Summary

Constants included from Util

Util::SHELLOUT_OPTIONS

Constants included from NullArgumentable

NullArgumentable::NULL

Instance Attribute Summary

Attributes inherited from Base

#project

DSL methods collapse

Instance Method Summary collapse

Methods inherited from Base

build, #exclusions, id, #id, #initialize, #install_dir, #package_path, #resource_path, #resources_path, #run!, setup, #skip_packager, #staging_dir, #staging_dir_path

Methods included from Util

#compiler_safe_path, #copy_file, #create_directory, #create_file, #create_link, included, #path_key, #remove_directory, #remove_file, #retry_block, #shellout, #shellout!, #windows_safe_path

Methods included from Templating

included, #render_template, #render_template_content

Methods included from Sugarable

extended, included, #node

Methods included from NullArgumentable

included, #null?

Methods included from Logging

included

Methods included from Instrumentation

#measure

Methods included from Digestable

#digest, #digest_directory, included

Constructor Details

This class inherits a constructor from Omnibus::Packager::Base

Instance Method Details

#create_ips_repovoid

This method returns an undefined value.

Create a local IPS repo for publishing



316
317
318
319
# File 'lib/omnibus/packagers/ips.rb', line 316

def create_ips_repo
  shellout!("pkgrepo create #{repo_dir}")
  log.info(log_key) { "Created IPS repo: #{repo_dir}" }
end

#export_pkg_archive_filevoid

This method returns an undefined value.

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



347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
# File 'lib/omnibus/packagers/ips.rb', line 347

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_nameObject

For more info about fmri see:

http://docs.oracle.com/cd/E23824_01/html/E21796/pkg-5.html


93
94
95
96
97
# 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_contentsvoid

This method returns an undefined value.

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



281
282
283
284
# 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 #{} #{transform_file} | pkgfmt > #{pkg_manifest_file}.2")
end

#generate_pkg_depsvoid

This method returns an undefined value.

Generate the package deps



291
292
293
294
295
296
297
298
299
# 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")
  # extra step added to truncate bash and other version requirements that may cause conflicts on
  # Solaris patch versions slightly older than the OS that the build is running on.
  shellout!("pkgmogrify -DARCH=`uname -p` #{pkg_manifest_file}.4.res #{transform_file} | pkgfmt > #{pkg_manifest_file}.4.res-transformed")
  shellout!("pkgmogrify #{pkg_manifest_file}.4.res-transformed #{versionlock_file} > #{pkg_manifest_file}.5.res")
end

#package_nameObject

See Also:



84
85
86
# 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_fileString

The full path to the pkg manifest file on disk.

Returns:

  • (String)


131
132
133
# 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_fileString

The full path to the pkg metadata file on disk.

Returns:

  • (String)


122
123
124
# File 'lib/omnibus/packagers/ips.rb', line 122

def 
  @pkg_metadata_file ||= File.join(staging_dir, "gen.manifestfile")
end

#publish_ips_pkgvoid

This method returns an undefined value.

Publish the IPS pkg into the local IPS repo



326
327
328
329
330
331
332
333
334
335
336
337
338
339
# File 'lib/omnibus/packagers/ips.rb', line 326

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) ⇒ String

The publisher prefix for the IPS package.

Examples:

identifier 'Chef'

Parameters:

  • val (String) (defaults to: NULL)

    the package identifier

Returns:

  • (String)


68
69
70
71
72
73
74
# 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

Returns:

  • (String)


240
241
242
243
244
245
# File 'lib/omnibus/packagers/ips.rb', line 240

def render_symlinks
  render_template_content(resource_path(symlinks_file),
    {
      projectdir: project.install_dir,
    })
end

#repo_dirString

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

Returns:

  • (String)


140
141
142
# File 'lib/omnibus/packagers/ips.rb', line 140

def repo_dir
  @repo_dir ||= File.join(staging_dir, "publish", "repo")
end

#safe_architectureString

The architecture for this IPS package.

Returns:

  • (String)


180
181
182
183
184
185
186
187
188
# 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_nameString

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

Returns:

  • (String)


159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
# 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_dirString

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

Returns:

  • (String)


149
150
151
# 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”) #=> Omnibus::Packager::IPS.“/path/to/omnibus-toolchain/resources/omnibus-toolchain/ips/omnibus-toolchain-symlinks“/path/to/omnibus-toolchain/resources/omnibus-toolchain/ips/omnibus-toolchain-symlinks.erb” OR Omnibus::Packager::IPS.“/path/to/omnibus-toolchain/resources/omnibus-toolchain/ips/symlinks“/path/to/omnibus-toolchain/resources/omnibus-toolchain/ips/symlinks.erb”

Returns:

  • (String)


224
225
226
227
228
229
230
# 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

#transform_fileString

The full path to the transform file on disk.

Returns:

  • (String)


104
105
106
# File 'lib/omnibus/packagers/ips.rb', line 104

def transform_file
  @transform_file ||= File.join(staging_dir, "doc-transform")
end

#validate_pkg_manifestvoid

This method returns an undefined value.

Validate the generated package manifest using ‘pkglint`



306
307
308
309
# File 'lib/omnibus/packagers/ips.rb', line 306

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_fileString

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

Returns:

  • (String)


113
114
115
# File 'lib/omnibus/packagers/ips.rb', line 113

def versionlock_file
  @versionlock_file ||= File.join(staging_dir, "version-lock")
end

#write_pkg_metadatavoid

This method returns an undefined value.

Generate package metadata

Create the gen template for ‘pkgmogrify`



254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
# File 'lib/omnibus/packagers/ips.rb', line 254

def 
  render_template(resource_path("gen.manifestfile.erb"),
    destination: ,
    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(, "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() }
end

#write_transform_filevoid

This method returns an undefined value.

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



207
208
209
210
211
212
213
# 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_filevoid

This method returns an undefined value.

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



196
197
198
199
# 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