Class: Omnibus::Packager::Solaris

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

Constant Summary collapse

SCRIPT_MAP =

Returns:

  • (Hash)
{
  # Default Omnibus naming
  postinst: "postinstall",
  postrm: "postremove",
  # Default Solaris naming
  postinstall: "postinstall",
  postremove: "postremove",
}.freeze

Constants included from Util

Util::SHELLOUT_OPTIONS

Constants included from NullArgumentable

NullArgumentable::NULL

Instance Attribute Summary

Attributes inherited from Base

#project

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_solaris_filevoid

This method returns an undefined value.

Generate the Solaris file using pkg*.



141
142
143
144
145
# File 'lib/omnibus/packagers/solaris.rb', line 141

def create_solaris_file
  shellout! "pkgmk -o -r #{install_dirname} -d #{staging_dir} -f #{staging_dir_path("Prototype")}"
  shellout! "pkgchk -vd #{staging_dir} #{project.package_name}"
  shellout! "pkgtrans #{staging_dir} #{package_path} #{project.package_name}"
end

#install_basenameObject



53
54
55
# File 'lib/omnibus/packagers/solaris.rb', line 53

def install_basename
  File.basename(project.install_dir)
end

#install_dirnameObject



49
50
51
# File 'lib/omnibus/packagers/solaris.rb', line 49

def install_dirname
  File.dirname(project.install_dir)
end

#package_nameObject

See Also:



41
42
43
# File 'lib/omnibus/packagers/solaris.rb', line 41

def package_name
  "#{project.package_name}-#{pkgmk_version}.#{safe_architecture}.solaris"
end

#pkgmk_versionObject



45
46
47
# File 'lib/omnibus/packagers/solaris.rb', line 45

def pkgmk_version
  "#{project.build_version}-#{project.build_iteration}"
end

#safe_architectureString

The architecture for this Solaris package.

Returns:

  • (String)


152
153
154
155
156
157
158
159
160
161
# File 'lib/omnibus/packagers/solaris.rb', line 152

def safe_architecture
  # The #i386? and #intel? helpers come from chef-sugar
  if intel?
    "i386"
  elsif sparc?
    "sparc"
  else
    Ohai["kernel"]["machine"]
  end
end

#write_pkginfo_fileObject

Generate a pkginfo file for solaris build



112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
# File 'lib/omnibus/packagers/solaris.rb', line 112

def write_pkginfo_file
  hostname = Socket.gethostname

  # http://docs.oracle.com/cd/E19683-01/816-0219/6m6njqbat/index.html
  pkginfo_content = <<-EOF.gsub(/^ {8}/, "")
    CLASSES=none
    TZ=PST
    PATH=/sbin:/usr/sbin:/usr/bin:/usr/sadm/install/bin
    BASEDIR=#{install_dirname}
    PKG=#{project.package_name}
    NAME=#{project.package_name}
    ARCH=#{safe_architecture}
    VERSION=#{pkgmk_version}
    CATEGORY=application
    DESC=#{project.description}
    VENDOR=#{project.maintainer}
    EMAIL=#{project.maintainer}
    PSTAMP=#{hostname}#{Time.now.utc.iso8601}
  EOF
  File.open staging_dir_path("pkginfo"), "w+" do |f|
    f.write pkginfo_content
  end
end

#write_prototype_fileObject

Generate a Prototype file for solaris build



78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
# File 'lib/omnibus/packagers/solaris.rb', line 78

def write_prototype_file
  shellout! "cd #{install_dirname} && find #{install_basename} -print > #{staging_dir_path("files")}"

  File.open staging_dir_path("files.clean"), "w+" do |fout|
    File.open staging_dir_path("files") do |fin|
      fin.each_line do |line|
        if line.chomp =~ /\s/
          log.warn(log_key) { "Skipping packaging '#{line}' file due to whitespace in filename" }
        else
          fout.write(line)
        end
      end
    end
  end

  # generate list of control files
  File.open staging_dir_path("Prototype"), "w+" do |f|
    f.write <<-EOF.gsub(/^ {10}/, "")
      i pkginfo
      i postinstall
      i postremove
    EOF
  end

  # generate the prototype's file list
  shellout! "cd #{install_dirname} && pkgproto < #{staging_dir_path("files.clean")} > #{staging_dir_path("Prototype.files")}"

  # fix up the user and group in the file list to root
  shellout! "awk '{ $5 = \"root\"; $6 = \"root\"; print }' < #{staging_dir_path("Prototype.files")} >> #{staging_dir_path("Prototype")}"
end

#write_scriptsvoid

This method returns an undefined value.

Copy all scripts in Omnibus::Project#package_scripts_path to the control directory of this repo.



63
64
65
66
67
68
69
70
71
72
73
# File 'lib/omnibus/packagers/solaris.rb', line 63

def write_scripts
  SCRIPT_MAP.each do |source, destination|
    source_path = File.join(project.package_scripts_path, source.to_s)

    next unless File.file?(source_path)

    destination_path = staging_dir_path(destination)
    log.debug(log_key) { "Adding script `#{source}' to `#{destination_path}'" }
    copy_file(source_path, destination_path)
  end
end