Class: FPM::Target::Solaris

Inherits:
Package
  • Object
show all
Defined in:
lib/fpm/target/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 Package

#category, #config_files, #conflicts, #dependencies, #description, #epoch, #iteration, #license, #maintainer, #name, #provides, #replaces, #scripts, #settings, #url, #version

Instance Method Summary collapse

Methods inherited from Package

#fixpath, #generate_specfile, #initialize, #needs_md5sums, #render_spec, #template, #type

Constructor Details

This class inherits a constructor from FPM::Package

Instance Method Details

#architectureObject



10
11
12
13
14
15
16
17
18
19
# File 'lib/fpm/target/solaris.rb', line 10

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

#build!(params) ⇒ Object



25
26
27
28
29
30
31
32
33
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
# File 'lib/fpm/target/solaris.rb', line 25

def build!(params)
  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

  # Unpack data.tar.gz so we can build a package from it.
  Dir.mkdir("data")
  safesystem("gzip -d data.tar.gz");
  Dir.chdir("data") do
    safesystem("tar -xf ../data.tar");
  end

  #system("(echo 'i pkginfo'; pkgproto data=/) > Prototype")

  # Generate the package 'Prototype' file
  # TODO(sissel): allow setting default file owner.
  File.open("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
    IO.popen("pkgproto data=/").each_line do |line|
      type, klass, path, mode, user, group = line.split
      # Override stuff in pkgproto
      # TODO(sissel): Make this tunable?
      user = "root"
      group = "root"
      prototype.puts([type, klass, path, mode, user, group].join(" "))
    end # popen "pkgproto ..."
  end # File prototype

  # Should create a package directory named by the package name.
  safesystem("pkgmk -o -d .")

  # Convert the 'package directory' built above to a real solaris package.
  safesystem("pkgtrans -s . #{params[:output]} #{name}")
end

#default_outputObject

def build



79
80
81
82
83
84
85
86
87
# File 'lib/fpm/target/solaris.rb', line 79

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

#specfile(builddir) ⇒ Object

def architecture



21
22
23
# File 'lib/fpm/target/solaris.rb', line 21

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