2014-10-15 15:44:50 +02:00
|
|
|
apt_package_updates = nil
|
|
|
|
Facter.add("apt_has_updates") do
|
2014-06-26 15:50:11 +02:00
|
|
|
confine :osfamily => 'Debian'
|
2014-10-15 15:44:50 +02:00
|
|
|
if File.executable?("/usr/lib/update-notifier/apt-check")
|
2015-01-08 06:45:43 +01:00
|
|
|
apt_check_result = Facter::Util::Resolution.exec('/usr/lib/update-notifier/apt-check 2>&1')
|
|
|
|
if not apt_check_result.nil? and apt_check_result =~ /^\d+;\d+$/
|
|
|
|
apt_package_updates = apt_check_result.split(';')
|
|
|
|
end
|
2014-10-15 15:44:50 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
setcode do
|
2015-01-08 06:45:43 +01:00
|
|
|
if not apt_package_updates.nil? and apt_package_updates.length == 2
|
|
|
|
apt_package_updates != ['0', '0']
|
|
|
|
end
|
2014-10-15 15:44:50 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
Facter.add("apt_package_updates") do
|
|
|
|
confine :apt_has_updates => true
|
2014-06-26 15:50:11 +02:00
|
|
|
setcode do
|
2015-01-08 06:45:43 +01:00
|
|
|
packages = Facter::Util::Resolution.exec('/usr/lib/update-notifier/apt-check -p 2>&1').split("\n")
|
2014-10-15 15:44:50 +02:00
|
|
|
if Facter.version < '2.0.0'
|
|
|
|
packages.join(',')
|
|
|
|
else
|
|
|
|
packages
|
2014-06-26 15:50:11 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2014-10-15 15:44:50 +02:00
|
|
|
|
|
|
|
Facter.add("apt_updates") do
|
|
|
|
confine :apt_has_updates => true
|
|
|
|
setcode do
|
|
|
|
Integer(apt_package_updates[0])
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
Facter.add("apt_security_updates") do
|
|
|
|
confine :apt_has_updates => true
|
|
|
|
setcode do
|
|
|
|
Integer(apt_package_updates[1])
|
|
|
|
end
|
|
|
|
end
|