deselect = myopts.get('--deselect') != 'n'
required_sets = {}
required_sets['world'] = psets['world']
+ excluded_set = InternalPackageSet(initial_atoms=myopts.get('--exclude'))
# When removing packages, a temporary version of the world 'selected'
# set may be used which excludes packages that are intended to be
# by an argument atom since we don't want to clean any
# package if something depends on it.
for pkg in vardb:
- spinner.update()
+ if spinner:
+ spinner.update()
try:
if args_set.findAtomForPackage(pkg) is None:
protected_set.add("=" + pkg.cpv)
continue
+ if excluded_set:
+ required_sets['__excluded__'] = InternalPackageSet()
+
+ for pkg in vardb:
+ if spinner:
+ spinner.update()
+
+ try:
+ if excluded_set.findAtomForPackage(pkg):
+ required_sets['__excluded__'].add("=" + pkg.cpv)
+ except portage.exception.InvalidDependString as e:
+ show_invalid_depstring_notice(pkg,
+ pkg.metadata["PROVIDE"], str(e))
+ del e
+ required_sets['__excluded__'].add("=" + pkg.cpv)
+
success = resolver._complete_graph(required_sets={myroot:required_sets})
writemsg_level("\b\b... done!\n")
from portage.package.ebuild.config import config
from portage.package.ebuild.digestgen import digestgen
from portage._sets import load_default_config
+from portage._sets.base import InternalPackageSet
from portage.versions import catsplit
import _emerge
if options.get("--depclean"):
rval, cleanlist, ordered, req_pkg_count = \
calc_depclean(self.settings, self.trees, None,
- options, "depclean", atoms, None)
+ options, "depclean", InternalPackageSet(initial_atoms=atoms), None)
result = ResolverPlaygroundDepcleanResult( \
atoms, rval, cleanlist, ordered, req_pkg_count)
else:
self.assertEqual(test_case.test_success, True, test_case.fail_msg)
finally:
playground.cleanup()
+
+class DepcleanWithExcludeTestCase(TestCase):
+
+ def testepcleanWithExclude(self):
+
+ installed = {
+ "dev-libs/A-1": {},
+ "dev-libs/B-1": { "RDEPEND": "dev-libs/A" },
+ }
+
+ test_cases = (
+ #Without --exclude.
+ ResolverPlaygroundTestCase(
+ [],
+ options = {"--depclean": True},
+ success = True,
+ cleanlist = ["dev-libs/B-1", "dev-libs/A-1"]),
+ ResolverPlaygroundTestCase(
+ ["dev-libs/A"],
+ options = {"--depclean": True},
+ success = True,
+ cleanlist = []),
+ ResolverPlaygroundTestCase(
+ ["dev-libs/B"],
+ options = {"--depclean": True},
+ success = True,
+ cleanlist = ["dev-libs/B-1"]),
+
+ #With --exclude
+ ResolverPlaygroundTestCase(
+ [],
+ options = {"--depclean": True, "--exclude": ["dev-libs/A"]},
+ success = True,
+ cleanlist = ["dev-libs/B-1"]),
+ ResolverPlaygroundTestCase(
+ ["dev-libs/B"],
+ options = {"--depclean": True, "--exclude": ["dev-libs/B"]},
+ 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()
+
+class DepcleanWithExcludeAndSlotsTestCase(TestCase):
+
+ def testepcleanWithExcludeAndSlots(self):
+
+ installed = {
+ "dev-libs/Z-1": { "SLOT": 1},
+ "dev-libs/Z-2": { "SLOT": 2},
+ "dev-libs/Y-1": { "RDEPEND": "=dev-libs/Z-1", "SLOT": 1 },
+ "dev-libs/Y-2": { "RDEPEND": "=dev-libs/Z-2", "SLOT": 2 },
+ }
+
+ world = [ "dev-libs/Y" ]
+
+ test_cases = (
+ #Without --exclude.
+ ResolverPlaygroundTestCase(
+ [],
+ options = {"--depclean": True},
+ success = True,
+ cleanlist = ["dev-libs/Y-1", "dev-libs/Z-1"]),
+ ResolverPlaygroundTestCase(
+ [],
+ options = {"--depclean": True, "--exclude": ["dev-libs/Z"]},
+ success = True,
+ cleanlist = ["dev-libs/Y-1"]),
+ ResolverPlaygroundTestCase(
+ [],
+ options = {"--depclean": True, "--exclude": ["dev-libs/Y"]},
+ success = True,
+ cleanlist = []),
+ )
+
+ playground = ResolverPlayground(installed=installed, world=world)
+ 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()