#!/usr/bin/env python #nice apt-get -s -o Debug::NoLocking=true upgrade | grep ^Inst import apt_pkg import os import sys SYNAPTIC_PINFILE = "/root/.synaptic/preferences" # be nice os.nice(19) # init apt_pkg.init() # get caches cache = apt_pkg.GetCache() depcache = apt_pkg.GetDepCache(cache) records = apt_pkg.GetPkgRecords(cache) # read the pin files depcache.ReadPinFile() # read the synaptic pins too if os.path.exists(SYNAPTIC_PINFILE): depcache.ReadPinFile(SYNAPTIC_PINFILE) # do the upgrade (not dist-upgrade!) depcache.Upgrade() for pkg in cache.Packages: if depcache.MarkedInstall(pkg): print "Upgradable: %s" % pkg.Name ver = pkg.CurrentVer print "Installed: %s " % ver ver = depcache.GetCandidateVer(pkg) print "Candidate: %s " % ver file, index = ver.FileList.pop(0) print "PkgFile: %s " % file print elif depcache.IsInstBroken(pkg) or depcache.IsNowBroken(pkg): print "Broken: %s " % pkg.Name print elif pkg.CurrentVer != None and depcache.IsUpgradable(pkg): print "Keept back: %s" % pkg.Name print print "Stats:" print "InstCount: %s" % depcache.InstCount print "BrokenCount: %s" % depcache.BrokenCount print "DelCount: %s" % depcache.DelCount # return the number of upgrades sys.exit(depcache.InstCount)