Gentoo Archives: gentoo-commits

From: "Zac Medico (zmedico)" <zmedico@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] portage r13502 - main/branches/2.1.6/pym/_emerge
Date: Thu, 30 Apr 2009 07:12:13
Message-Id: E1LzQRH-00084p-9u@stork.gentoo.org
1 Author: zmedico
2 Date: 2009-04-30 07:12:10 +0000 (Thu, 30 Apr 2009)
3 New Revision: 13502
4
5 Modified:
6 main/branches/2.1.6/pym/_emerge/__init__.py
7 Log:
8 Add support in action_uninstall() for file -> package lookup. (trunk r13345)
9
10 Modified: main/branches/2.1.6/pym/_emerge/__init__.py
11 ===================================================================
12 --- main/branches/2.1.6/pym/_emerge/__init__.py 2009-04-30 07:11:29 UTC (rev 13501)
13 +++ main/branches/2.1.6/pym/_emerge/__init__.py 2009-04-30 07:12:10 UTC (rev 13502)
14 @@ -13606,15 +13606,44 @@
15
16 # For backward compat, some actions do not require leading '='.
17 ignore_missing_eq = action in ('clean', 'unmerge')
18 - vardb = trees[settings["ROOT"]]["vartree"].dbapi
19 + root = settings['ROOT']
20 + vardb = trees[root]['vartree'].dbapi
21 valid_atoms = []
22 + lookup_owners = []
23
24 # Ensure atoms are valid before calling unmerge().
25 # For backward compat, leading '=' is not required.
26 for x in files:
27 - if not (is_valid_package_atom(x) or \
28 - (ignore_missing_eq and is_valid_package_atom("=" + x))):
29 + if is_valid_package_atom(x) or \
30 + (ignore_missing_eq and is_valid_package_atom('=' + x)):
31
32 + try:
33 + valid_atoms.append(
34 + portage.dep_expand(x, mydb=vardb, settings=settings))
35 + except portage.exception.AmbiguousPackageName, e:
36 + msg = "The short ebuild name \"" + x + \
37 + "\" is ambiguous. Please specify " + \
38 + "one of the following " + \
39 + "fully-qualified ebuild names instead:"
40 + for line in textwrap.wrap(msg, 70):
41 + writemsg_level("!!! %s\n" % (line,),
42 + level=logging.ERROR, noiselevel=-1)
43 + for i in e[0]:
44 + writemsg_level(" %s\n" % colorize("INFORM", i),
45 + level=logging.ERROR, noiselevel=-1)
46 + writemsg_level("\n", level=logging.ERROR, noiselevel=-1)
47 + return 1
48 +
49 + elif x.startswith(os.sep):
50 + if not x.startswith(root):
51 + writemsg_level(("!!! '%s' does not start with" + \
52 + " $ROOT.\n") % x, level=logging.ERROR, noiselevel=-1)
53 + return 1
54 + # Queue these up since it's most efficient to handle
55 + # multiple files in a single iter_owners() call.
56 + lookup_owners.append(x)
57 +
58 + else:
59 msg = []
60 msg.append("'%s' is not a valid package atom." % (x,))
61 msg.append("Please check ebuild(5) for full details.")
62 @@ -13622,23 +13651,42 @@
63 level=logging.ERROR, noiselevel=-1)
64 return 1
65
66 - try:
67 - valid_atoms.append(
68 - portage.dep_expand(x, mydb=vardb, settings=settings))
69 - except portage.exception.AmbiguousPackageName, e:
70 - msg = "The short ebuild name \"" + x + \
71 - "\" is ambiguous. Please specify " + \
72 - "one of the following " + \
73 - "fully-qualified ebuild names instead:"
74 - for line in textwrap.wrap(msg, 70):
75 - writemsg_level("!!! %s\n" % (line,),
76 - level=logging.ERROR, noiselevel=-1)
77 - for i in e[0]:
78 - writemsg_level(" %s\n" % colorize("INFORM", i),
79 - level=logging.ERROR, noiselevel=-1)
80 - writemsg_level("\n", level=logging.ERROR, noiselevel=-1)
81 - return 1
82 + if lookup_owners:
83 + relative_paths = []
84 + search_for_multiple = False
85 + if len(lookup_owners) > 1:
86 + search_for_multiple = True
87
88 + for x in lookup_owners:
89 + if not search_for_multiple and os.path.isdir(x):
90 + search_for_multiple = True
91 + relative_paths.append(x[len(root):])
92 +
93 + owners = set()
94 + for pkg, relative_path in \
95 + vardb._owners.iter_owners(relative_paths):
96 + owners.add(pkg.mycpv)
97 + if not search_for_multiple:
98 + break
99 +
100 + if owners:
101 + for cpv in owners:
102 + slot = vardb.aux_get(cpv, ['SLOT'])[0]
103 + if not slot:
104 + # portage now masks packages with missing slot, but it's
105 + # possible that one was installed by an older version
106 + atom = portage.cpv_getkey(cpv)
107 + else:
108 + atom = '%s:%s' % (portage.cpv_getkey(cpv), slot)
109 + valid_atoms.append(portage.dep.Atom(atom))
110 + else:
111 + writemsg_level(("!!! '%s' is not claimed " + \
112 + "by any package.\n") % lookup_owners[0],
113 + level=logging.WARNING, noiselevel=-1)
114 +
115 + if files and not valid_atoms:
116 + return 1
117 +
118 if action in ('clean', 'unmerge') or \
119 (action == 'prune' and "--nodeps" in opts):
120 # When given a list of atoms, unmerge them in the order given.