Class: Tpkg::OS::Solaris
Overview
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Tpkg::OS
#arch, create, #cron_dot_d_directory, #fqdn, #os, #os_name, #os_version, register_implementation, #remove_native_stub_pkg, #stub_native_pkg, #sudo_default?, #sys_v_init_links
Constructor Details
#initialize(options = {}) ⇒ Solaris
Returns a new instance of Solaris.
11
12
13
14
15
|
# File 'lib/tpkg/os/solaris.rb', line 11
def initialize(options={})
@pkginfocmd = options[:pkginfocmd] || options[:testcmd] || 'pkginfo'
@pkgutilcmd = options[:pkgutilcmd] || options[:testcmd] || '/opt/csw/bin/pkgutil'
super
end
|
Class Method Details
.supported? ⇒ Boolean
5
6
7
8
|
# File 'lib/tpkg/os/solaris.rb', line 5
def self.supported?
Facter.loadfacts
Facter['operatingsystem'].value == 'Solaris'
end
|
Instance Method Details
#available_native_packages(pkgname) ⇒ Object
20
21
22
23
24
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
|
# File 'lib/tpkg/os/solaris.rb', line 20
def available_native_packages(pkgname)
native_packages = []
cmd = "#{@pkginfocmd} -x #{pkgname}"
puts "available_native_packages running '#{cmd}'" if @debug
IO.popen(cmd) do |pipe|
name = nil
pipe.each_line do |line|
if line =~ /^\w/
name = line.split(' ').first
else
arch, solversion = line.split(' ')
version, package_version = solversion.split(',REV=')
native_packages <<
Tpkg.pkg_for_native_package(
name, version, package_version, :native_installed)
name = nil
end
end
end
if !$?.success?
raise "available_native_packages error running pkginfo"
end
if File.exist?(@pkgutilcmd)
cmd = "#{@pkgutilcmd} -a --parse #{pkgname}"
puts "available_native_packages running '#{cmd}'" if @debug
IO.popen(cmd) do |pipe|
pipe.each_line do |line|
shortname, name, solversion, size = line.chomp.split("\t")
next if name != pkgname
version, package_version = solversion.split(',REV=')
native_packages <<
Tpkg.pkg_for_native_package(
name, version, package_version, :native_available)
end
end
end
native_packages
end
|
#init_links(installed_path, tpkgfile) ⇒ Object
17
18
19
|
# File 'lib/tpkg/os/solaris.rb', line 17
def init_links(installed_path, tpkgfile)
sys_v_init_links(installed_path, tpkgfile, ['2', '3'], '/etc')
end
|
#install_native_package(pkg) ⇒ Object
81
82
83
84
85
86
87
88
89
90
|
# File 'lib/tpkg/os/solaris.rb', line 81
def install_native_package(pkg)
pkgname = native_pkg_to_install_string(pkg)
if File.exist?(@pkgutilcmd)
cmd = "#{@pkgutilcmd} -y -i #{pkgname}"
puts "Running '#{cmd}' to install native package" if @debug
system(cmd)
else
raise "No supported native package tool available on #{os}"
end
end
|
#native_pkg_to_install_string(pkg) ⇒ Object
71
72
73
74
75
76
77
78
79
80
|
# File 'lib/tpkg/os/solaris.rb', line 71
def native_pkg_to_install_string(pkg)
name = pkg[:metadata][:name]
version = pkg[:metadata][:version]
package_version = pkg[:metadata][:package_version]
pkgname = "#{name}-#{version}"
if package_version
pkgname << ",REV=#{package_version}"
end
pkgname
end
|
#upgrade_native_package(pkg) ⇒ Object
91
92
93
94
95
96
97
98
99
100
|
# File 'lib/tpkg/os/solaris.rb', line 91
def upgrade_native_package(pkg)
pkgname = native_pkg_to_install_string(pkg)
if File.exist?(@pkgutilcmd)
cmd = "#{@pkgutilcmd} -y -u #{pkgname}"
puts "Running '#{cmd}' to upgrade native package" if @debug
system(cmd)
else
raise "No supported native package tool available on #{os}"
end
end
|