def refresh
case @next_refresh
when :none
return nil
when :installed
reset_installed
opts=" --installed"
when :all
reset
opts=" --options --installed-provides"
when :provides
reset
opts=" --options --all-provides"
else
raise ArgumentError, "Unexpected value in next_refresh: #{@next_refresh}"
end
if @extra_repo_control
opts << " #{@extra_repo_control}"
end
one_line = false
error = nil
helper = ::File.join(::File.dirname(__FILE__), 'yum-dump.py')
status = popen4("/usr/bin/python #{helper}#{opts}", :waitlast => true) do |pid, stdin, stdout, stderr|
stdout.each do |line|
one_line = true
line.chomp!
if line =~ %r{\[option (.*)\] (.*)}
if $1 == "installonlypkgs"
@allow_multi_install = $2.split
else
raise Chef::Exceptions::Package, "Strange, unknown option line '#{line}' from yum-dump.py"
end
next
end
if line =~ %r{^(\S+) ([0-9]+) (\S+) (\S+) (\S+) \[(.*)\] ([i,a,r]) (\S+)$}
name = $1
epoch = $2
version = $3
release = $4
arch = $5
provides = parse_provides($6)
type = $7
repoid = $8
else
Chef::Log.warn("Problem parsing line '#{line}' from yum-dump.py! " +
"Please check your yum configuration.")
next
end
case type
when "i"
available = false
installed = true
when "a"
available = true
installed = false
when "r"
available = true
installed = true
end
pkg = RPMDbPackage.new(name, epoch, version, release, arch, provides, installed, available, repoid)
@rpmdb << pkg
end
error = stderr.readlines
end
if status.exitstatus != 0
raise Chef::Exceptions::Package, "Yum failed - #{status.inspect} - returns: #{error}"
else
unless one_line
Chef::Log.warn("Odd, no output from yum-dump.py. Please check " +
"your yum configuration.")
end
end
@next_refresh = :none
end