From 7d757300f1da30c9e8f0fdf33827f69d8f1d334e Mon Sep 17 00:00:00 2001 From: Zac Medico Date: Fri, 15 Aug 2008 17:34:33 +0000 Subject: [PATCH] Validate atoms from command line args before calling action_depclean(). svn path=/main/trunk/; revision=11414 --- pym/_emerge/__init__.py | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/pym/_emerge/__init__.py b/pym/_emerge/__init__.py index fcf4ab4a8..a7ab256a3 100644 --- a/pym/_emerge/__init__.py +++ b/pym/_emerge/__init__.py @@ -13701,6 +13701,34 @@ def emerge_main(): post_emerge(root_config, myopts, mtimedb, os.EX_OK) elif myaction in ("depclean", "prune"): + + # Ensure atoms are valid before calling unmerge(). + vardb = trees[settings["ROOT"]]["vartree"].dbapi + for x in myfiles: + if is_valid_package_atom(x): + try: + portage.dep_expand(x, mydb=vardb, settings=settings) + except ValueError, e: + msg = "The short ebuild name \"" + x + \ + "\" is ambiguous. Please specify " + \ + "one of the following " + \ + "fully-qualified ebuild names instead:" + for line in textwrap.wrap(msg, 70): + writemsg_level("!!! %s\n" % (line,), + level=logging.ERROR, noiselevel=-1) + for i in e[0]: + writemsg_level(" %s\n" % colorize("INFORM", i), + level=logging.ERROR, noiselevel=-1) + writemsg_level("\n", level=logging.ERROR, noiselevel=-1) + return 1 + continue + 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 + validate_ebuild_environment(trees) action_depclean(settings, trees, mtimedb["ldpath"], myopts, myaction, myfiles, spinner) -- 2.26.2