1 |
Author: zmedico |
2 |
Date: 2008-05-09 03:42:02 +0000 (Fri, 09 May 2008) |
3 |
New Revision: 10263 |
4 |
|
5 |
Modified: |
6 |
main/branches/2.1.2/bin/emerge |
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 |
(trunk r10262) |
11 |
|
12 |
|
13 |
Modified: main/branches/2.1.2/bin/emerge |
14 |
=================================================================== |
15 |
--- main/branches/2.1.2/bin/emerge 2008-05-09 03:41:41 UTC (rev 10262) |
16 |
+++ main/branches/2.1.2/bin/emerge 2008-05-09 03:42:02 UTC (rev 10263) |
17 |
@@ -5863,11 +5863,16 @@ |
18 |
mergecount += 1 |
19 |
pkg = x |
20 |
metadata = pkg.metadata |
21 |
+ |
22 |
if pkg.installed: |
23 |
if not (buildpkgonly or fetchonly or pretend): |
24 |
- unmerge(root_config.settings, self.myopts, |
25 |
- root_config.trees["vartree"], "unmerge", |
26 |
- [pkg.cpv], mtimedb["ldpath"], clean_world=0) |
27 |
+ try: |
28 |
+ unmerge(root_config.settings, self.myopts, |
29 |
+ root_config.trees["vartree"], "unmerge", |
30 |
+ [pkg.cpv], mtimedb["ldpath"], clean_world=0, |
31 |
+ raise_on_error=1) |
32 |
+ except UninstallFailure, e: |
33 |
+ return e.status |
34 |
continue |
35 |
|
36 |
if x[0]=="blocks": |
37 |
@@ -6186,8 +6191,20 @@ |
38 |
sys.exit(0) |
39 |
return os.EX_OK |
40 |
|
41 |
-def unmerge(settings, myopts, vartree, unmerge_action, unmerge_files, |
42 |
- ldpath_mtimes, autoclean=0, clean_world=1, ordered=0): |
43 |
+class UninstallFailure(portage_exception.PortageException): |
44 |
+ """ |
45 |
+ An instance of this class is raised by unmerge() when |
46 |
+ an uninstallation fails. |
47 |
+ """ |
48 |
+ status = 1 |
49 |
+ def __init__(self, *pargs): |
50 |
+ portage_exception.PortageException.__init__(self, pargs) |
51 |
+ if pargs: |
52 |
+ self.status = pargs[0] |
53 |
+ |
54 |
+def unmerge(settings, myopts, vartree, unmerge_action, |
55 |
+ unmerge_files, ldpath_mtimes, autoclean=0, |
56 |
+ clean_world=1, ordered=0, raise_on_error=0): |
57 |
candidate_catpkgs=[] |
58 |
global_unmerge=0 |
59 |
xterm_titles = "notitles" not in settings.features |
60 |
@@ -6518,6 +6535,8 @@ |
61 |
vartree=vartree, ldpath_mtimes=ldpath_mtimes) |
62 |
if retval != os.EX_OK: |
63 |
emergelog(xterm_titles, " !!! unmerge FAILURE: "+y) |
64 |
+ if raise_on_error: |
65 |
+ raise UninstallFailure(retval) |
66 |
sys.exit(retval) |
67 |
else: |
68 |
if clean_world: |
69 |
|
70 |
-- |
71 |
gentoo-commits@l.g.o mailing list |