diff options
-rw-r--r-- | pym/_emerge/actions.py | 25 | ||||
-rw-r--r-- | pym/portage/tests/resolver/ResolverPlayground.py | 2 | ||||
-rw-r--r-- | pym/portage/tests/resolver/test_depclean.py | 40 |
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() |