local count_upgrade = 0
local require_reboot = 0

file = io.open("/var/run/upgrade-list.txt","w")
if not file then
    print("error: can't open output file.")
    return
end

markupgrade()

for i, pkg in pairs(pkglist()) do 
	if statupgrade(pkg) then
		count_upgrade = count_upgrade + 1;
		file:write(pkgname(pkg).."\n")
	end
end
file:close()

file = io.open("/var/run/reboot-required", "r")
if file then
	file:close()
	require_reboot = 1
end

os.execute("/bin/dbus-send --system --dest=org.vinelinux.NotifyUpdate --type=method_call /org/vinelinux/NotifyUpdate org.vinelinux.NotifyUpdate.showMessage string:'"..count_upgrade.." "..require_reboot.."'")
