Add --binpkg-exclude option
[portage.git] / pym / _emerge / main.py
index ed07c092dbd6c3f178928413b49fccf7b5c173e2..26f37667a3ade05509d91c3cb2ea2f78d492877a 100644 (file)
@@ -556,19 +556,25 @@ def insert_optional_args(args):
 
        return new_args
 
-def _find_bad_atoms(atoms):
+def _find_bad_atoms(atoms, less_strict=False):
+       """
+       Declares all atoms as invalid that have an operator,
+       a use dependency, a blocker or a repo spec.
+       It accepts atoms with wildcards.
+       In less_strict mode it accepts operators and repo specs.
+       """
        bad_atoms = []
        for x in ' '.join(atoms).split():
                bad_atom = False
                try:
-                       atom = portage.dep.Atom(x, allow_wildcard=True)
+                       atom = portage.dep.Atom(x, allow_wildcard=True, allow_repo=less_strict)
                except portage.exception.InvalidAtom:
                        try:
-                               atom = portage.dep.Atom("*/"+x, allow_wildcard=True)
+                               atom = portage.dep.Atom("*/"+x, allow_wildcard=True, allow_repo=less_strict)
                        except portage.exception.InvalidAtom:
                                bad_atom = True
 
-               if bad_atom or atom.operator or atom.blocker or atom.use:
+               if bad_atom or (atom.operator and not less_strict) or atom.blocker or atom.use:
                        bad_atoms.append(x)
        return bad_atoms
 
@@ -644,6 +650,14 @@ def parse_opts(tmpcmdline, silent=False):
                        "choices"  : true_y_or_n
                },
 
+               "--buildpkg-exclude": {
+                       "help"   :"A space separated list of package atoms for which " + \
+                               "no binary packages should be built. This option overrides all " + \
+                               "possible ways to enable building of binary packages.",
+
+                       "action" : "append"
+               },
+
                "--config-root": {
                        "help":"specify the location for portage configuration files",
                        "action":"store"
@@ -967,6 +981,12 @@ def parse_opts(tmpcmdline, silent=False):
        else:
                myoptions.buildpkg = None
 
+       if myoptions.buildpkg_exclude:
+               bad_atoms = _find_bad_atoms(myoptions.buildpkg_exclude, less_strict=True)
+               if bad_atoms and not silent:
+                       parser.error("Invalid Atom(s) in --buildpkg-exclude parameter: '%s'\n" % \
+                               (",".join(bad_atoms),))
+
        if myoptions.changed_use is not False:
                myoptions.reinstall = "changed-use"
                myoptions.changed_use = False