public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-commits] portage r11827 - in main/trunk/pym: _emerge portage/dbapi
@ 2008-11-08  0:55 Zac Medico (zmedico)
  0 siblings, 0 replies; only message in thread
From: Zac Medico (zmedico) @ 2008-11-08  0:55 UTC (permalink / raw
  To: gentoo-commits

Author: zmedico
Date: 2008-11-08 00:55:40 +0000 (Sat, 08 Nov 2008)
New Revision: 11827

Modified:
   main/trunk/pym/_emerge/__init__.py
   main/trunk/pym/portage/dbapi/vartree.py
Log:
Handle CommandNotFound exceptions if the scanelf binary happens to be missing,
and disable preserve-libs code in that case.


Modified: main/trunk/pym/_emerge/__init__.py
===================================================================
--- main/trunk/pym/_emerge/__init__.py	2008-11-07 22:18:33 UTC (rev 11826)
+++ main/trunk/pym/_emerge/__init__.py	2008-11-08 00:55:40 UTC (rev 11827)
@@ -11084,20 +11084,30 @@
 		print colorize("WARN", "!!!") + " existing preserved libs:"
 		plibdata = vardbapi.plib_registry.getPreservedLibs()
 		linkmap = vardbapi.linkmap
-
 		consumer_map = {}
-		search_for_owners = set()
-		for cpv in plibdata:
-			for f in plibdata[cpv]:
-				if f in consumer_map:
-					continue
-				consumers = list(linkmap.findConsumers(f))
-				consumers.sort()
-				consumer_map[f] = consumers
-				search_for_owners.update(consumers[:MAX_DISPLAY+1])
+		owners = {}
+		linkmap_broken = False
 
-		owners = vardbapi._owners.getFileOwnerMap(search_for_owners)
+		try:
+			linkmap.rebuild()
+		except portage.exception.CommandNotFound, e:
+			writemsg_level("!!! Command Not Found: %s\n" % (e,),
+				level=logging.ERROR, noiselevel=-1)
+			del e
+			linkmap_broken = True
+		else:
+			search_for_owners = set()
+			for cpv in plibdata:
+				for f in plibdata[cpv]:
+					if f in consumer_map:
+						continue
+					consumers = list(linkmap.findConsumers(f))
+					consumers.sort()
+					consumer_map[f] = consumers
+					search_for_owners.update(consumers[:MAX_DISPLAY+1])
 
+			owners = vardbapi._owners.getFileOwnerMap(search_for_owners)
+
 		for cpv in plibdata:
 			print colorize("WARN", ">>>") + " package: %s" % cpv
 			samefile_map = {}
@@ -11114,7 +11124,7 @@
 				for p in alt_paths:
 					print colorize("WARN", " * ") + " - %s" % (p,)
 				f = alt_paths[0]
-				consumers = consumer_map[f]
+				consumers = consumer_map.get(f, [])
 				for c in consumers[:MAX_DISPLAY]:
 					print colorize("WARN", " * ") + "     used by %s (%s)" % \
 						(c, ", ".join(x.mycpv for x in owners.get(c, [])))

Modified: main/trunk/pym/portage/dbapi/vartree.py
===================================================================
--- main/trunk/pym/portage/dbapi/vartree.py	2008-11-07 22:18:33 UTC (rev 11826)
+++ main/trunk/pym/portage/dbapi/vartree.py	2008-11-08 00:55:40 UTC (rev 11827)
@@ -249,6 +249,10 @@
 			return str(sorted(self.alt_paths))
 
 	def rebuild(self, exclude_pkgs=None, include_file=None):
+		"""
+		Raises CommandNotFound if there are preserved libs
+		and the scanelf binary is not available.
+		"""
 		root = self._root
 		root_len = len(root) - 1
 		self._clear_cache()
@@ -1734,6 +1738,7 @@
 		self.contentscache = None
 		self._contents_inodes = None
 		self._contents_basenames = None
+		self._linkmap_broken = False
 
 	def lockdb(self):
 		if self._lock_vdb:
@@ -2022,7 +2027,7 @@
 			# already called LinkageMap.rebuild() and passed it's NEEDED file
 			# in as an argument.
 			if not others_in_slot:
-				self.vartree.dbapi.linkmap.rebuild(exclude_pkgs=(self.mycpv,))
+				self._linkmap_rebuild(exclude_pkgs=(self.mycpv,))
 
 			# remove preserved libraries that don't have any consumers left
 			cpv_lib_map = self._find_unused_preserved_libs()
@@ -2467,12 +2472,26 @@
 
 		return False
 
+	def _linkmap_rebuild(self, **kwargs):
+		if self._linkmap_broken:
+			return
+		try:
+			self.vartree.dbapi.linkmap.rebuild(**kwargs)
+		except CommandNotFound, e:
+			self._linkmap_broken = True
+			self._display_merge("!!! Disabling preserve-libs " + \
+				"due to error: Command Not Found: %s\n" % (e,),
+				level=logging.ERROR, noiselevel=-1)
+
 	def _preserve_libs(self, srcroot, destroot, mycontents, counter, inforoot):
-		showMessage = self._display_merge
-		# read global reverse NEEDED map
+
 		linkmap = self.vartree.dbapi.linkmap
-		linkmap.rebuild(include_file=os.path.join(inforoot,
+		self._linkmap_rebuild(include_file=os.path.join(inforoot,
 			linkmap._needed_aux_key))
+		if self._linkmap_broken:
+			return
+
+		showMessage = self._display_merge
 		liblist = linkmap.listLibraryObjects()
 
 		# get list of libraries from old package instance
@@ -2616,6 +2635,9 @@
 		Find preserved libraries that don't have any consumers left.
 		"""
 
+		if self._linkmap_broken:
+			return {}
+
 		# Since preserved libraries can be consumers of other preserved
 		# libraries, use a graph to track consumer relationships.
 		plib_dict = self.vartree.dbapi.plib_registry.getPreservedLibs()
@@ -3357,7 +3379,7 @@
 
 		exclude_pkgs = set(dblnk.mycpv for dblnk in others_in_slot)
 		linkmap = self.vartree.dbapi.linkmap
-		linkmap.rebuild(exclude_pkgs=exclude_pkgs,
+		self._linkmap_rebuild(exclude_pkgs=exclude_pkgs,
 			include_file=os.path.join(inforoot, linkmap._needed_aux_key))
 
 		# These caches are populated during collision-protect and the data
@@ -3385,6 +3407,7 @@
 				continue
 			showMessage(">>> Safely unmerging already-installed instance...\n")
 			others_in_slot.remove(dblnk) # dblnk will unmerge itself now
+			dblnk._linkmap_broken = self._linkmap_broken
 			dblnk.unmerge(trimworld=0, ldpath_mtimes=prev_mtimes,
 				others_in_slot=others_in_slot)
 			# TODO: Check status and abort if necessary.
@@ -3434,9 +3457,6 @@
 		self.vartree.dbapi._add(self)
 		contents = self.getcontents()
 
-		# regenerate reverse NEEDED map
-		self.vartree.dbapi.linkmap.rebuild()
-
 		#do postinst script
 		self.settings["PORTAGE_UPDATE_ENV"] = \
 			os.path.join(self.dbpkgdir, "environment.bz2")
@@ -3473,7 +3493,7 @@
 
 		# For gcc upgrades, preserved libs have to be removed after the
 		# the library path has been updated.
-		self.vartree.dbapi.linkmap.rebuild()
+		self._linkmap_rebuild()
 		cpv_lib_map = self._find_unused_preserved_libs()
 		if cpv_lib_map:
 			self._remove_preserved_libs(cpv_lib_map)




^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2008-11-08  0:55 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-11-08  0:55 [gentoo-commits] portage r11827 - in main/trunk/pym: _emerge portage/dbapi Zac Medico (zmedico)

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox