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

Author: zmedico
Date: 2008-05-09 03:41:41 +0000 (Fri, 09 May 2008)
New Revision: 10262

Modified:
   main/trunk/pym/_emerge/__init__.py
Log:
If an uninstall task fails inside MergeTask.merge(), use an UninstallFailure
exception to handle it instead of allowing unmerge() to call exit().


Modified: main/trunk/pym/_emerge/__init__.py
===================================================================
--- main/trunk/pym/_emerge/__init__.py	2008-05-09 03:00:41 UTC (rev 10261)
+++ main/trunk/pym/_emerge/__init__.py	2008-05-09 03:41:41 UTC (rev 10262)
@@ -5703,10 +5703,15 @@
 				mergecount += 1
 			pkg = x
 			metadata = pkg.metadata
+
 			if pkg.installed:
 				if not (buildpkgonly or fetchonly or pretend):
-					unmerge(root_config, self.myopts, "unmerge",
-						[pkg.cpv], mtimedb["ldpath"], clean_world=0)
+					try:
+						unmerge(root_config, self.myopts, "unmerge",
+							[pkg.cpv], mtimedb["ldpath"], clean_world=0,
+							raise_on_error=1)
+					except UninstallFailure, e:
+						return e.status
 				continue
 
 			if x[0]=="blocks":
@@ -6028,8 +6033,20 @@
 				sys.exit(0)
 		return os.EX_OK
 
+class UninstallFailure(portage.exception.PortageException):
+	"""
+	An instance of this class is raised by unmerge() when
+	an uninstallation fails.
+	"""
+	status = 1
+	def __init__(self, *pargs):
+		portage.exception.PortageException.__init__(self, pargs)
+		if pargs:
+			self.status = pargs[0]
+
 def unmerge(root_config, myopts, unmerge_action,
-	unmerge_files, ldpath_mtimes, autoclean=0, clean_world=1, ordered=0):
+	unmerge_files, ldpath_mtimes, autoclean=0,
+	clean_world=1, ordered=0, raise_on_error=0):
 	settings = root_config.settings
 	sets = root_config.sets
 	vartree = root_config.trees["vartree"]
@@ -6407,6 +6424,8 @@
 				vartree=vartree, ldpath_mtimes=ldpath_mtimes)
 			if retval != os.EX_OK:
 				emergelog(xterm_titles, " !!! unmerge FAILURE: "+y)
+				if raise_on_error:
+					raise UninstallFailure(retval)
 				sys.exit(retval)
 			else:
 				if clean_world:

-- 
gentoo-commits@lists.gentoo.org mailing list



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

only message in thread, other threads:[~2008-05-09  3:41 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-05-09  3:41 [gentoo-commits] portage r10262 - main/trunk/pym/_emerge 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