summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSebastian Luther <SebastianLuther@gmx.de>2011-01-24 14:40:27 +0100
committerZac Medico <zmedico@gentoo.org>2011-02-02 15:10:06 -0800
commitfe5729e07d1ee33d2368fc2e7ebaa53399608174 (patch)
treed6f2aecde133dbbe235d46c55d4c2b8af75359e3
parent59ed24dd2ff8f0a2c2c6d921035a1a042c6c8e3f (diff)
downloadportage-fe5729e07d1ee33d2368fc2e7ebaa53399608174.tar.gz
portage-fe5729e07d1ee33d2368fc2e7ebaa53399608174.tar.bz2
portage-fe5729e07d1ee33d2368fc2e7ebaa53399608174.zip
Wildcard support for -c/-C
-rw-r--r--pym/_emerge/actions.py25
-rw-r--r--pym/portage/tests/resolver/ResolverPlayground.py2
-rw-r--r--pym/portage/tests/resolver/test_depclean.py40
3 files changed, 65 insertions, 2 deletions
diff --git a/pym/_emerge/actions.py b/pym/_emerge/actions.py
index 1ea2510d2..84f75568b 100644
--- a/pym/_emerge/actions.py
+++ b/pym/_emerge/actions.py
@@ -31,6 +31,8 @@ from portage.cache.cache_errors import CacheError
from portage.const import GLOBAL_CONFIG_PATH, NEWS_LIB_PATH
from portage.const import _ENABLE_DYN_LINK_MAP
from portage.dbapi.dep_expand import dep_expand
+from portage.dep import Atom, extended_cp_match
+from portage.exception import InvalidAtom
from portage.output import blue, bold, colorize, create_color_func, darkgreen, \
red, yellow
good = create_color_func("GOOD")
@@ -2443,7 +2445,6 @@ def action_sync(settings, trees, mtimedb, myopts, myaction):
def action_uninstall(settings, trees, ldpath_mtimes,
opts, action, files, spinner):
-
# For backward compat, some actions do not require leading '='.
ignore_missing_eq = action in ('clean', 'unmerge')
root = settings['ROOT']
@@ -2486,6 +2487,28 @@ def action_uninstall(settings, trees, ldpath_mtimes,
elif x.startswith(SETPREFIX) and action == "deselect":
valid_atoms.append(x)
+ elif "*" in x:
+ try:
+ ext_atom = Atom(x, allow_repo=True, allow_wildcard=True)
+ except InvalidAtom:
+ msg = []
+ msg.append("'%s' is not a valid package atom." % (x,))
+ msg.append("Please check ebuild(5) for full details.")
+ writemsg_level("".join("!!! %s\n" % line for line in msg),
+ level=logging.ERROR, noiselevel=-1)
+ return 1
+
+ for cp in vardb.cp_all():
+ if extended_cp_match(ext_atom.cp, cp):
+ atom = cp
+ if ext_atom.slot:
+ atom += ":" + ext_atom.slot
+ if ext_atom.repo:
+ atom += "::" + ext_atom.repo
+
+ if vardb.match(atom):
+ valid_atoms.append(Atom(atom))
+
else:
msg = []
msg.append("'%s' is not a valid package atom." % (x,))
diff --git a/pym/portage/tests/resolver/ResolverPlayground.py b/pym/portage/tests/resolver/ResolverPlayground.py
index e3253e4af..1fd5abf67 100644
--- a/pym/portage/tests/resolver/ResolverPlayground.py
+++ b/pym/portage/tests/resolver/ResolverPlayground.py
@@ -425,7 +425,7 @@ class ResolverPlayground(object):
if options.get("--depclean"):
rval, cleanlist, ordered, req_pkg_count = \
calc_depclean(self.settings, self.trees, None,
- options, "depclean", InternalPackageSet(initial_atoms=atoms), None)
+ options, "depclean", InternalPackageSet(initial_atoms=atoms, allow_wildcard=True), None)
result = ResolverPlaygroundDepcleanResult( \
atoms, rval, cleanlist, ordered, req_pkg_count)
else:
diff --git a/pym/portage/tests/resolver/test_depclean.py b/pym/portage/tests/resolver/test_depclean.py
index 18e0b87e4..ba70144b8 100644
--- a/pym/portage/tests/resolver/test_depclean.py
+++ b/pym/portage/tests/resolver/test_depclean.py
@@ -243,3 +243,43 @@ class DepcleanWithExcludeAndSlotsTestCase(TestCase):
self.assertEqual(test_case.test_success, True, test_case.fail_msg)
finally:
playground.cleanup()
+
+class DepcleanAndWildcardsTestCase(TestCase):
+
+ def testDepcleanAndWildcards(self):
+
+ installed = {
+ "dev-libs/A-1": { "RDEPEND": "dev-libs/B" },
+ "dev-libs/B-1": {},
+ }
+
+ test_cases = (
+ ResolverPlaygroundTestCase(
+ ["*/*"],
+ options = {"--depclean": True},
+ success = True,
+ cleanlist = ["dev-libs/A-1", "dev-libs/B-1"]),
+ ResolverPlaygroundTestCase(
+ ["dev-libs/*"],
+ options = {"--depclean": True},
+ success = True,
+ cleanlist = ["dev-libs/A-1", "dev-libs/B-1"]),
+ ResolverPlaygroundTestCase(
+ ["*/A"],
+ options = {"--depclean": True},
+ success = True,
+ cleanlist = ["dev-libs/A-1"]),
+ ResolverPlaygroundTestCase(
+ ["*/B"],
+ options = {"--depclean": True},
+ success = True,
+ cleanlist = []),
+ )
+
+ playground = ResolverPlayground(installed=installed)
+ try:
+ for test_case in test_cases:
+ playground.run_TestCase(test_case)
+ self.assertEqual(test_case.test_success, True, test_case.fail_msg)
+ finally:
+ playground.cleanup()