Class: FPM::Package::Solaris

Inherits:
FPM::Package show all
Defined in:
lib/fpm/package/solaris.rb

Overview

TODO(sissel): Add dependency checking support. IIRC this has to be done as a ‘checkinstall’ step.

Instance Attribute Summary

Attributes inherited from FPM::Package

#attributes, #attrs, #category, #config_files, #conflicts, #dependencies, #description, #directories, #epoch, #iteration, #license, #maintainer, #name, #provides, #replaces, #scripts, #url, #vendor, #version

Instance Method Summary collapse

Methods inherited from FPM::Package

apply_options, #build_path, #cleanup, #cleanup_build, #cleanup_staging, #convert, #converted_from, default_attributes, #edit_file, #files, inherited, #initialize, #input, option, #script, #staging_path, #to_s, #type, type, types

Methods included from Util

#ar_cmd, #ar_cmd_deterministic?, #copied_entries, #copy_entry, #copy_metadata, #default_shell, #erbnew, #execmd, #expand_pessimistic_constraints, #logger, #program_exists?, #program_in_path?, #safesystem, #safesystemout, #tar_cmd, #tar_cmd_supports_sort_names_and_set_mtime?

Constructor Details

This class inherits a constructor from FPM::Package

Instance Method Details

#architectureObject



19
20
21
22
23
24
25
26
27
28
# File 'lib/fpm/package/solaris.rb', line 19

def architecture
  case @architecture
  when nil, "native"
    @architecture = %x{uname -p}.chomp
  end
  # "all" is a valid arch according to
  # http://www.bolthole.com/solaris/makeapackage.html

  return @architecture
end

#default_outputObject

def output



85
86
87
88
89
90
91
92
93
# File 'lib/fpm/package/solaris.rb', line 85

def default_output
  v = version
  v = "#{epoch}:#{v}" if epoch
  if iteration
    "#{name}_#{v}-#{iteration}_#{architecture}.#{type}"
  else
    "#{name}_#{v}_#{architecture}.#{type}"
  end
end

#output(output_path) ⇒ Object



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
# File 'lib/fpm/package/solaris.rb', line 34

def output(output_path)
  self.scripts.each do |name, path|
    case name
      when "pre-install"
        safesystem("cp", path, "./preinstall")
        File.chmod(0755, "./preinstall")
      when "post-install"
        safesystem("cp", path, "./postinstall")
        File.chmod(0755, "./postinstall")
      when "pre-uninstall"
        raise FPM::InvalidPackageConfiguration.new(
          "pre-uninstall is not supported by Solaris packages"
        )
      when "post-uninstall"
        raise FPM::InvalidPackageConfiguration.new(
          "post-uninstall is not supported by Solaris packages"
        )
    end # case name
  end # self.scripts.each

  template = template("solaris.erb")
  File.open("#{build_path}/pkginfo", "w") do |pkginfo|
    pkginfo.puts template.result(binding)
  end

  # Generate the package 'Prototype' file
  File.open("#{build_path}/Prototype", "w") do |prototype|
    prototype.puts("i pkginfo")
    prototype.puts("i preinstall") if self.scripts["pre-install"]
    prototype.puts("i postinstall") if self.scripts["post-install"]

    # TODO(sissel): preinstall/postinstall
    # strip @prefix, since BASEDIR will set prefix via the pkginfo file
    IO.popen("pkgproto #{staging_path}/#{@prefix}=").each_line do |line|
      type, klass, path, mode, user, group = line.split

      prototype.puts([type, klass, path, mode, attributes[:solaris_user], attributes[:solaris_group]].join(" "))
    end # popen "pkgproto ..."
  end # File prototype

  ::Dir.chdir staging_path do
    # Should create a package directory named by the package name.
    safesystem("pkgmk", "-o", "-f", "#{build_path}/Prototype", "-d", build_path)
  end


  # Convert the 'package directory' built above to a real solaris package.
  safesystem("pkgtrans", "-s", build_path, output_path, name)
  safesystem("cp", "#{build_path}/#{output_path}", output_path)
end

#specfile(builddir) ⇒ Object

def architecture



30
31
32
# File 'lib/fpm/package/solaris.rb', line 30

def specfile(builddir)
  "#{builddir}/pkginfo"
end