Gentoo Archives: gentoo-commits

From: "Zac Medico (zmedico)" <zmedico@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] portage r10262 - main/trunk/pym/_emerge
Date: Fri, 09 May 2008 03:41:44
Message-Id: E1JuJUM-0006nv-88@stork.gentoo.org
1 Author: zmedico
2 Date: 2008-05-09 03:41:41 +0000 (Fri, 09 May 2008)
3 New Revision: 10262
4
5 Modified:
6 main/trunk/pym/_emerge/__init__.py
7 Log:
8 If an uninstall task fails inside MergeTask.merge(), use an UninstallFailure
9 exception to handle it instead of allowing unmerge() to call exit().
10
11
12 Modified: main/trunk/pym/_emerge/__init__.py
13 ===================================================================
14 --- main/trunk/pym/_emerge/__init__.py 2008-05-09 03:00:41 UTC (rev 10261)
15 +++ main/trunk/pym/_emerge/__init__.py 2008-05-09 03:41:41 UTC (rev 10262)
16 @@ -5703,10 +5703,15 @@
17 mergecount += 1
18 pkg = x
19 metadata = pkg.metadata
20 +
21 if pkg.installed:
22 if not (buildpkgonly or fetchonly or pretend):
23 - unmerge(root_config, self.myopts, "unmerge",
24 - [pkg.cpv], mtimedb["ldpath"], clean_world=0)
25 + try:
26 + unmerge(root_config, self.myopts, "unmerge",
27 + [pkg.cpv], mtimedb["ldpath"], clean_world=0,
28 + raise_on_error=1)
29 + except UninstallFailure, e:
30 + return e.status
31 continue
32
33 if x[0]=="blocks":
34 @@ -6028,8 +6033,20 @@
35 sys.exit(0)
36 return os.EX_OK
37
38 +class UninstallFailure(portage.exception.PortageException):
39 + """
40 + An instance of this class is raised by unmerge() when
41 + an uninstallation fails.
42 + """
43 + status = 1
44 + def __init__(self, *pargs):
45 + portage.exception.PortageException.__init__(self, pargs)
46 + if pargs:
47 + self.status = pargs[0]
48 +
49 def unmerge(root_config, myopts, unmerge_action,
50 - unmerge_files, ldpath_mtimes, autoclean=0, clean_world=1, ordered=0):
51 + unmerge_files, ldpath_mtimes, autoclean=0,
52 + clean_world=1, ordered=0, raise_on_error=0):
53 settings = root_config.settings
54 sets = root_config.sets
55 vartree = root_config.trees["vartree"]
56 @@ -6407,6 +6424,8 @@
57 vartree=vartree, ldpath_mtimes=ldpath_mtimes)
58 if retval != os.EX_OK:
59 emergelog(xterm_titles, " !!! unmerge FAILURE: "+y)
60 + if raise_on_error:
61 + raise UninstallFailure(retval)
62 sys.exit(retval)
63 else:
64 if clean_world:
65
66 --
67 gentoo-commits@l.g.o mailing list