In order to avoid an unhandled InvalidAtom exception, validate atoms from
authorZac Medico <zmedico@gentoo.org>
Fri, 15 Aug 2008 17:19:50 +0000 (17:19 -0000)
committerZac Medico <zmedico@gentoo.org>
Fri, 15 Aug 2008 17:19:50 +0000 (17:19 -0000)
command line arguments before passing them to unmerge(). Thanks to Cardoe
for reporting.

svn path=/main/trunk/; revision=11413

pym/_emerge/__init__.py

index d219604495df260bf7cdc99135a644365ec22e9b..fcf4ab4a808629135febe25a7d7c262168f8e5a1 100644 (file)
@@ -13678,6 +13678,20 @@ def emerge_main():
        elif myaction in ("clean", "unmerge") or \
                (myaction == "prune" and "--nodeps" in myopts):
                validate_ebuild_environment(trees)
+
+               # Ensure atoms are valid before calling unmerge().
+               # For backward compat, leading '=' is not required.
+               for x in myfiles:
+                       if is_valid_package_atom(x) or \
+                               is_valid_package_atom("=" + x):
+                               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
+
                # When given a list of atoms, unmerge
                # them in the order given.
                ordered = myaction == "unmerge"