commit: 8ee429229c9d501c2dabe4aac5d6aa891d94be2e Author: Jethro Donaldson <devel <AT> jro <DOT> nz> AuthorDate: Wed Dec 3 07:39:55 2025 +0000 Commit: Sam James <sam <AT> gentoo <DOT> org> CommitDate: Mon Feb 16 06:54:15 2026 +0000 URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=8ee42922
emerge: add --nobindeps command line option Shorthand for emerge --usepkg-include <pkgs> <pkgs> for installing from a binary package without allowing portage to pull any binary packages to satisfy dependencies. Has no effect without -k. Signed-off-by: Jethro Donaldson <devel <AT> jro.nz> Part-of: https://github.com/gentoo/portage/pull/1527 Signed-off-by: Sam James <sam <AT> gentoo.org> lib/_emerge/actions.py | 17 ++++ lib/_emerge/depgraph.py | 8 ++ lib/_emerge/main.py | 1 + .../tests/resolver/test_binpackage_selection.py | 90 ++++++++++++++++++++++ man/emerge.1 | 6 ++ 5 files changed, 122 insertions(+) diff --git a/lib/_emerge/actions.py b/lib/_emerge/actions.py index e5bd06a746..1136336916 100644 --- a/lib/_emerge/actions.py +++ b/lib/_emerge/actions.py @@ -2824,6 +2824,23 @@ def binpkg_selection_config(opts, settings): usepkg_exclude.remove(a) usepkg_include.remove(a) + # --nobindeps ignores all usepkg-include and usepkg-exclude settings + if "--nobindeps" in opts: + if not usepkg_exclude.isEmpty(): + writemsg( + "\n!!! The following --usepkg-exclude atoms are ignored due " + "to use of --nobindeps:\n" + "\n %s\n" % ("\n ".join(usepkg_exclude.getAtoms())) + ) + usepkg_exclude.clear() + if not usepkg_include.isEmpty(): + writemsg( + "\n!!! The following --usepkg-include atoms are ignored due " + "to use of --nobindeps:\n" + "\n %s\n" % ("\n ".join(usepkg_include.getAtoms())) + ) + usepkg_include.clear() + if not usepkg_exclude.isEmpty(): opts["--usepkg-exclude"] = list(usepkg_exclude) if not usepkg_include.isEmpty(): diff --git a/lib/_emerge/depgraph.py b/lib/_emerge/depgraph.py index 0c9276de07..96586e9c69 100644 --- a/lib/_emerge/depgraph.py +++ b/lib/_emerge/depgraph.py @@ -5271,6 +5271,14 @@ class depgraph: # is to allow the user to force a specific merge order. self._dynamic_config._initial_arg_list = args[:] + # set usepkg-include set to expanded args if --nobindeps is + # in effect, both usepkg-include and usepkg-exclude should + # be assumed empty at this point + if "--nobindeps" in self._frozen_config.myopts: + for arg in self._expand_set_args(args): + arg_cp = (a.cp for a in arg.pset.getAtoms()) + self._frozen_config.usepkg_include.update(arg_cp) + return self._resolve(myfavorites) def _gen_reinstall_sets(self): diff --git a/lib/_emerge/main.py b/lib/_emerge/main.py index ef532eefba..7a3371807d 100644 --- a/lib/_emerge/main.py +++ b/lib/_emerge/main.py @@ -31,6 +31,7 @@ options = [ "--noconfmem", "--newrepo", "--newuse", + "--nobindeps", "--nodeps", "--noreplace", "--nospinner", diff --git a/lib/portage/tests/resolver/test_binpackage_selection.py b/lib/portage/tests/resolver/test_binpackage_selection.py index eaecc03a49..2d6df54ee1 100644 --- a/lib/portage/tests/resolver/test_binpackage_selection.py +++ b/lib/portage/tests/resolver/test_binpackage_selection.py @@ -253,6 +253,65 @@ class UsePkgExcludeTestCase(BinPkgSelectionTestCase): "[binary]app-misc/foo-1.0", ], ), + # exclude all binary dependencies using --nobindeps + ResolverPlaygroundTestCase( + ["app-misc/foo"], + success=True, + options={"--usepkg": True, "--nobindeps": True}, + mergelist=[ + "app-misc/baz-1.0", + "app-misc/bar-1.0", + "[binary]app-misc/foo-1.0", + ], + ), + # --usebinpkg-exclude to have no effect on --nobindeps + ResolverPlaygroundTestCase( + ["app-misc/foo"], + success=True, + options={ + "--usepkg": True, + "--nobindeps": True, + "--usepkg-exclude": ["foo"], + }, + mergelist=[ + "app-misc/baz-1.0", + "app-misc/bar-1.0", + "[binary]app-misc/foo-1.0", + ], + ), + # --nobindeps should work for arguments that cannot normally be put + # on the --usepkg-include list, e.g. versions operators, repo, etc, + # and also sets, for which see testUsePkgExcludeUpdate(). + ResolverPlaygroundTestCase( + ["=app-misc/foo-1.0"], + success=True, + options={"--usepkg": True, "--nobindeps": True}, + mergelist=[ + "app-misc/baz-1.0", + "app-misc/bar-1.0", + "[binary]app-misc/foo-1.0", + ], + ), + ResolverPlaygroundTestCase( + [">app-misc/foo-0.9"], + success=True, + options={"--usepkg": True, "--nobindeps": True}, + mergelist=[ + "app-misc/baz-1.0", + "app-misc/bar-1.0", + "[binary]app-misc/foo-1.0", + ], + ), + ResolverPlaygroundTestCase( + ["app-misc/foo::test_repo"], + success=True, + options={"--usepkg": True, "--nobindeps": True}, + mergelist=[ + "app-misc/baz-1.0", + "app-misc/bar-1.0", + "[binary]app-misc/foo-1.0", + ], + ), ) self.runBinPkgSelectionTest(test_cases, binpkgs=binpkgs, ebuilds=ebuilds) @@ -341,6 +400,22 @@ class UsePkgExcludeTestCase(BinPkgSelectionTestCase): "[binary]app-misc/foo-1.1", ], ), + # world update with --nobindeps + ResolverPlaygroundTestCase( + ["@world"], + success=True, + options={ + "--update": True, + "--deep": True, + "--usepkg": True, + "--nobindeps": True, + }, + mergelist=[ + "app-misc/baz-1.1", + "app-misc/bar-1.1", + "[binary]app-misc/foo-1.1", + ], + ), ) self.runBinPkgSelectionTest( @@ -537,6 +612,21 @@ class UsePkgIncludeTestCase(BinPkgSelectionTestCase): "app-misc/foo-1.0", ], ), + # --usebinpkg-include to have no effect on --nobindeps + ResolverPlaygroundTestCase( + ["app-misc/foo"], + success=True, + options={ + "--usepkg": True, + "--nobindeps": True, + "--usepkg-include": ["app-misc/b*"], + }, + mergelist=[ + "app-misc/baz-1.0", + "app-misc/bar-1.0", + "[binary]app-misc/foo-1.0", + ], + ), ) self.runBinPkgSelectionTest(test_cases, binpkgs=binpkgs, ebuilds=ebuilds) diff --git a/man/emerge.1 b/man/emerge.1 index cc0a2c41fb..2006f1ba2e 100644 --- a/man/emerge.1 +++ b/man/emerge.1 @@ -741,6 +741,12 @@ been added to or removed from IUSE, see the related \fB\-\-changed\-use\fR option. If you would like to skip rebuilds for specific packages, see the \fB\-\-exclude\fR option. .TP +.BR \-\-nobindeps +Prefer ebuilds for any dependencies and select binary packages only for the +atoms or sets requested for install, i.e. those named on the command line. Has +no effect unless \fB-k\fR is also used or implied. Both \fB--usepkg-exclude\fR +and \fB--usepkg-include\fR are ignored when this option is used. +.TP .BR \-\-noconfmem Causes portage to disregard merge records indicating that a config file inside of a \fBCONFIG_PROTECT\fR directory has been merged already. Portage
