Commits

Michał Górny committed d8c1006

Add portdb matching in order to avoid supplying bad atoms to portage.

Comments (0)

Files changed (2)

SmartLiveRebuild/core.py

 		self._bashproc.communicate()
 		self._tmpf.close()
 
-def SmartLiveRebuild(opts, db = None, saveuid = False, settings = None):
+def SmartLiveRebuild(opts, db = None, portdb = None, saveuid = False, settings = None):
 	if settings is None:
 		settings = portage.settings
 	if db is None:
 		db = portage.db[settings['ROOT']]['vartree'].dbapi
+	if portdb is None:
+		portdb = portage.db[settings['ROOT']]['porttree'].dbapi
 
 	if not opts.color:
 		out.monochromize()
 				packages = ['-'.join(pkgsplit(x)[0:2]) for x in packages]
 			packages = ['>=%s' % x for x in packages]
 
+		# Check portdb for matches. Drop unmatched packages.
+		for p in list(packages):
+			if not portdb.match(p):
+				out.err('No packages matching %s in portdb, skipping.' % p)
+				packages.remove(p)
+
 		if len(packages) < 1:
 			out.s1('No updates found')
 		else:

SmartLiveRebuild/sets.py

 	_operations = ["merge"]
 	description = "Package set containing live packages awaiting update"
 
-	def __init__(self, opts, dbapi, settings):
+	def __init__(self, opts, vardbapi, portdbapi, settings):
 		self._options = opts
-		self._dbapi = dbapi
+		self._dbapi = vardbapi
+		self._portdb = portdbapi
 		self._settings = settings
 		PackageSet.__init__(self)
 
 		try:
 			if packages is None:
 				packages = SmartLiveRebuild(self._options,
-						db = self._dbapi, saveuid = True, settings = self._settings)
+						db = self._dbapi, portdb = self._portdb,
+						saveuid = True, settings = self._settings)
 		except SLRFailure:
 			pass
 		else:
 		c.parse_configfiles()
 		c.apply_dict(options)
 
-		db = trees['vartree'].dbapi
+		vardb = trees['vartree'].dbapi
+		portdb = trees['porttree'].dbapi
 
-		return cls(c.get_options(), db, settings)
+		return cls(c.get_options(), vardb, portdb, settings)