- if File.executable?("/usr/lib/update-notifier/apt-check")
- apt_package_updates = Facter::Util::Resolution.exec('/usr/lib/update-notifier/apt-check 2>/dev/null').split(';')
+ if File.executable?("/usr/bin/apt-get")
+ apt_get_result = Facter::Util::Resolution.exec('/usr/bin/apt-get -s -o Debug::NoLocking=true upgrade 2>&1')
+ if not apt_get_result.nil?
+ apt_package_updates = [[], []]
+ apt_get_result.each_line do |line|
+ if line =~ /^Inst\s/
+ package = line.gsub(/^Inst\s([^\s]+)\s.*/, '\1').strip
+ apt_package_updates[0].push(package)
+ security_matches = [
+ / Debian[^\s]+-updates /,
+ / Debian-Security:/,
+ / Ubuntu[^\s]+-security /,
+ / gNewSense[^\s]+-security /
+ ]
+ re = Regexp.union(security_matches)
+ if line.match(re)
+ apt_package_updates[1].push(package)
+ end
+ end
+ end
+ end