Class: Omnibus::Packager::IPS
Constant Summary
Constants included from Util
Constants included from NullArgumentable
Instance Attribute Summary
Attributes inherited from Base
DSL methods collapse
-
#publisher_prefix(val = NULL) ⇒ String
The publisher prefix for the IPS package.
Methods inherited from Base
Instance Method Summary collapse
-
#create_ips_repo ⇒ void
Create a local IPS repo for publishing.
-
#export_pkg_archive_file ⇒ void
Convert a the published IPS pkg from the local repo into the more easily distributable
*.p5parchive. -
#fmri_package_name ⇒ Object
For more info about fmri see:.
-
#generate_pkg_contents ⇒ void
Create the package contents using
pkgsendandpkgfmt. -
#generate_pkg_deps ⇒ void
Generate the package deps.
- #package_name ⇒ Object
-
#pkg_manifest_file ⇒ String
The full path to the pkg manifest file on disk.
-
#pkg_metadata_file ⇒ String
The full path to the pkg metadata file on disk.
-
#publish_ips_pkg ⇒ void
Publish the IPS pkg into the local IPS repo.
-
#render_symlinks ⇒ String
A set of symbolic links to installed commands that `pkgmogrify' will apply to the package manifest.
-
#repo_dir ⇒ String
The path to the
publish/repodirectory inside the staging directory. -
#safe_architecture ⇒ String
The architecture for this IPS package.
-
#safe_base_package_name ⇒ String
Return the IPS-ready base package name, converting any invalid characters to dashes (+-+).
-
#source_dir ⇒ String
The path to the
proto-installdirectory inside the staging directory. -
#symlinks_file ⇒ String
The name of the project specific template if it exists The resource exists locally.
-
#transform_file ⇒ String
The full path to the transform file on disk.
-
#validate_pkg_manifest ⇒ void
Validate the generated package manifest using
pkglint. -
#versionlock_file ⇒ String
The full path to the version-lock file on disk.
-
#write_pkg_metadata ⇒ void
Generate package metadata.
-
#write_transform_file ⇒ void
A set of transform rules that `pkgmogrify' will apply to the package manifest.
-
#write_versionlock_file ⇒ void
A version-lock rule that `pkgmogrify' will apply to at the end of package manifest.
Methods inherited from Base
build, #exclusions, id, #id, #initialize, #package_path, #resource_path, #resources_path, #run!, setup, #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
Methods included from NullArgumentable
Methods included from Logging
Methods included from Instrumentation
Methods included from Digestable
#digest, #digest_directory, included
Constructor Details
This class inherits a constructor from Omnibus::Packager::Base
Instance Method Details
#create_ips_repo ⇒ void
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_file ⇒ void
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 " IPS package archive contents:\n\n \#{list_pkgarchive}\n EOH\n end\nend\n".strip |
#fmri_package_name ⇒ Object
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_contents ⇒ void
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 #{pkg_metadata_file} #{transform_file} | pkgfmt > #{pkg_manifest_file}.2") end |
#generate_pkg_deps ⇒ void
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_name ⇒ Object
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_file ⇒ String
The full path to the pkg manifest file on disk.
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_file ⇒ String
The full path to the pkg metadata file on disk.
122 123 124 |
# File 'lib/omnibus/packagers/ips.rb', line 122 def ||= File.join(staging_dir, "gen.manifestfile") end |
#publish_ips_pkg ⇒ void
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 " Published IPS package:\n\n \#{repo_info}\n EOH\n end\nend\n".strip |
#publisher_prefix(val = NULL) ⇒ String
The publisher prefix for the IPS package.
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 |
#render_symlinks ⇒ String
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
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_dir ⇒ String
The path to the publish/repo directory inside the staging directory.
140 141 142 |
# File 'lib/omnibus/packagers/ips.rb', line 140 def repo_dir @repo_dir ||= File.join(staging_dir, "publish", "repo") end |
#safe_architecture ⇒ String
The architecture for this IPS package.
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_name ⇒ String
Return the IPS-ready base package name, converting any invalid characters to dashes (+-+).
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_dir ⇒ String
The path to the proto-install directory inside the staging directory.
149 150 151 |
# File 'lib/omnibus/packagers/ips.rb', line 149 def source_dir @source_dir ||= File.join(staging_dir, "proto_install") end |
#symlinks_file ⇒ String
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"
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_file ⇒ String
The full path to the transform file on disk.
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_manifest ⇒ void
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_file ⇒ String
The full path to the version-lock file on disk.
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_metadata ⇒ void
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_file ⇒ void
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_file ⇒ void
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 |