74
75
76
77
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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
|
# File 'lib/beaker/host/unix/pkg.rb', line 74
def install_package(name, cmdline_args = '', version = nil, opts = {})
case self['platform']
when /sles-/
execute("zypper --non-interactive --gpg-auto-import-keys in #{name}", opts)
when /el-4/
@logger.debug("Package installation not supported on rhel4")
when /fedora-(2[2-9]|3[0-9])/
if version
name = "#{name}-#{version}"
end
execute("dnf -y #{cmdline_args} install #{name}", opts)
when /cisco|fedora|centos|redhat|eos|el-/
if version
name = "#{name}-#{version}"
end
execute("yum -y #{cmdline_args} install #{name}", opts)
when /ubuntu|debian|cumulus|huaweios/
if version
name = "#{name}=#{version}"
end
update_apt_if_needed
execute("apt-get install --force-yes #{cmdline_args} -y #{name}", opts)
when /solaris-11/
if opts[:acceptable_exit_codes]
opts[:acceptable_exit_codes] << 4
else
opts[:acceptable_exit_codes] = [0, 4] unless opts[:accept_all_exit_codes]
end
execute("pkg #{cmdline_args} install #{name}", opts)
when /solaris-10/
if ! check_for_command('pkgutil')
noask_text = self.noask_file_text
noask_file = File.join(external_copy_base, 'noask')
create_remote_file(self, noask_file, noask_text)
execute("pkgadd -d http://get.opencsw.org/now -a #{noask_file} -n all", opts)
execute('/opt/csw/bin/pkgutil -U', opts)
execute('/opt/csw/bin/pkgutil -y -i pkgutil', opts)
end
execute("pkgutil -i -y #{cmdline_args} #{name}", opts)
when /openbsd/
begin
execute("pkg_add -I #{cmdline_args} #{name}", opts) do |command|
if command.stderr =~ /^Ambiguous: #{name} could be (.+)$/
name = $1.chomp.split(' ').collect { |x|
x =~ /-(\d[^-p]+)/
[x, $1]
}.select { |x|
Gem::Version.new(x[1]) < Gem::Version.new('2.2.0')
}.sort { |a,b|
Gem::Version.new(b[1]) <=> Gem::Version.new(a[1])
}.collect { |x|
x[0]
}.first
raise ArgumentException
end
command.stdout.split(/\n/).select { |x| x =~ /^\s+ln\s/ }.each do |ln|
execute(ln, opts)
end
end
rescue
retry
end
when /archlinux/
execute("pacman -S --noconfirm #{cmdline_args} #{name}", opts)
else
raise "Package #{name} cannot be installed on #{self}"
end
end
|