summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--man/emerge.15
-rw-r--r--pym/_emerge/depgraph.py24
-rw-r--r--pym/_emerge/help.py7
-rw-r--r--pym/_emerge/main.py35
4 files changed, 71 insertions, 0 deletions
diff --git a/man/emerge.1 b/man/emerge.1
index f451e2f6..a0ba4b70 100644
--- a/man/emerge.1
+++ b/man/emerge.1
@@ -359,6 +359,11 @@ dependency tree, as though no packages are currently
installed. You should run this with \fB\-\-pretend\fR
first to make sure the result is what you expect.
.TP
+.BR "\-\-exclude " ATOMS
+A comma separated list of package names or slot atoms.
+Emerge won't install any ebuild or binary package that
+matches any of the given package atoms.
+.TP
.BR "\-\-fail\-clean[=n]"
Clean up temporary files after a build failure. This is
particularly useful if you have \fBPORTAGE_TMPDIR\fR on
diff --git a/pym/_emerge/depgraph.py b/pym/_emerge/depgraph.py
index c3e180fa..005c2979 100644
--- a/pym/_emerge/depgraph.py
+++ b/pym/_emerge/depgraph.py
@@ -93,6 +93,24 @@ class _frozen_depgraph_config(object):
self._required_set_names = set(["world"])
+ self.excluded_pkgs = InternalPackageSet()
+ for x in myopts.get("--exclude", []):
+ cat = x.cp.split("/")[0]
+ if cat == "null":
+ pkgname = x.cp.split("/")[1]
+ for myroot in trees:
+ for tree in ("porttree", "bintree"):
+ if tree == "bintree" and not "--usepkg" in myopts:
+ continue
+ db = self.trees[myroot][tree].dbapi
+ for cat in db.categories:
+ if db.cp_list(cat + "/" + pkgname):
+ atom = portage.dep.Atom(str(x).replace("null", cat))
+ self.excluded_pkgs.add(atom)
+ else:
+ self.excluded_pkgs.add(x)
+
+
class _dynamic_depgraph_config(object):
def __init__(self, depgraph, myparams, allow_backtracking,
@@ -2173,6 +2191,8 @@ class depgraph(object):
mreasons.append('backtracking: %s' % \
', '.join(sorted(backtrack_reasons)))
backtrack_mask = True
+ if not mreasons and self._frozen_config.excluded_pkgs.findAtomForPackage(pkg):
+ mreasons = ["exclude option"]
if mreasons:
masked_pkg_instances.add(pkg)
if atom.use:
@@ -2451,6 +2471,10 @@ class depgraph(object):
# The package has been masked by the backtracking logic
continue
+ if not pkg.installed and \
+ self._frozen_config.excluded_pkgs.findAtomForPackage(pkg):
+ continue
+
if dont_miss_updates:
higher_version_rejected = False
for rejected in packages_with_invalid_use_config:
diff --git a/pym/_emerge/help.py b/pym/_emerge/help.py
index a62bc08a..bf95a05e 100644
--- a/pym/_emerge/help.py
+++ b/pym/_emerge/help.py
@@ -378,6 +378,13 @@ def help(myopts, havecolor=1):
for line in wrap(desc, desc_width):
print(desc_indent + line)
print()
+ print(" " + green("--exclude") + " " + turquoise("ATOMS"))
+ desc = "A comma separated list of package names or slot atoms. " + \
+ "Emerge won't install any ebuild or binary package that " + \
+ "matches any of the given package atoms."
+ for line in wrap(desc, desc_width):
+ print(desc_indent + line)
+ print()
print(" "+green("--fail-clean[=n]"))
desc = "Clean up temporary files after a build failure. This is " + \
"particularly useful if you have PORTAGE_TMPDIR on " + \
diff --git a/pym/_emerge/main.py b/pym/_emerge/main.py
index 21888f59..11dc9a4f 100644
--- a/pym/_emerge/main.py
+++ b/pym/_emerge/main.py
@@ -560,6 +560,14 @@ def parse_opts(tmpcmdline, silent=False):
"choices" : ("True", "n")
},
+ "--exclude": {
+ "help" :"A comma separated list of package names or slot atoms. " + \
+ "Emerge won't install any ebuild or binary package that " + \
+ "matches any of the given package atoms.",
+
+ "action" : "store"
+ },
+
"--fail-clean": {
"help" : "clean temp files after build failure",
"type" : "choice",
@@ -724,6 +732,33 @@ def parse_opts(tmpcmdline, silent=False):
else:
myoptions.complete_graph = None
+ if myoptions.exclude:
+ exclude = []
+ bad_atoms = []
+ for x in myoptions.exclude.split(","):
+ bad_atom = False
+ try:
+ atom = portage.dep.Atom(x)
+ except portage.exception.InvalidAtom:
+ try:
+ atom = portage.dep.Atom("null/"+x)
+ except portage.exception.InvalidAtom:
+ bad_atom = True
+
+ if bad_atom:
+ bad_atoms.append(x)
+ else:
+ if atom.operator or atom.blocker or atom.use:
+ bad_atoms.append(x)
+ else:
+ exclude.append(atom)
+
+ if bad_atoms and not silent:
+ writemsg("!!! Invalid Atom(s) in --exclude parameter: '%s' (only package names and slot atoms allowed)\n" % \
+ (",".join(bad_atoms),), noiselevel=-1)
+
+ myoptions.exclude = exclude
+
if myoptions.fail_clean == "True":
myoptions.fail_clean = True