diff options
author | Sam James <sam@gentoo.org> | 2023-02-16 06:26:07 +0000 |
---|---|---|
committer | Sam James <sam@gentoo.org> | 2023-02-21 07:16:27 +0000 |
commit | 75a4f2c2e07c128fef4d9faf3a8fb9d67565239e (patch) | |
tree | 51f8765a4e9f1d4e4cdd18a9a8b1217a665cb05a /lib/_emerge/depgraph.py | |
parent | tests: resolver: add basic BDEPEND + IDEPEND tests (diff) | |
download | gentoo-portage-75a4f2c2e07c128fef4d9faf3a8fb9d67565239e.tar.xz gentoo-portage-75a4f2c2e07c128fef4d9faf3a8fb9d67565239e.zip |
emerge: add --update-if-installed
This adds a new emerge option '--update-if-installed'.
The use case for such an option is as follows:
- User finds out libfoo-1.2 is buggy.
- They want to upgrade all their systems if libfoo is installed.
- They don't want to install libfoo if it's not already installed.
Unfortunately, --update fails this last point, hence
the need for a new option.
Closes: https://github.com/gentoo/portage/pull/988
Signed-off-by: Sam James <sam@gentoo.org>
Diffstat (limited to 'lib/_emerge/depgraph.py')
-rw-r--r-- | lib/_emerge/depgraph.py | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/lib/_emerge/depgraph.py b/lib/_emerge/depgraph.py index 1631ed1264b..412dc7b6f2e 100644 --- a/lib/_emerge/depgraph.py +++ b/lib/_emerge/depgraph.py @@ -1,4 +1,4 @@ -# Copyright 1999-2021 Gentoo Authors +# Copyright 1999-2023 Gentoo Authors # Distributed under the terms of the GNU General Public License v2 import errno @@ -5019,6 +5019,21 @@ class depgraph: pkg, existing_node = self._select_package( myroot, atom, onlydeps=onlydeps ) + + # Is the package installed (at any version)? + if pkg and "update_if_installed" in self._dynamic_config.myparams: + package_is_installed = any( + self._iter_match_pkgs( + self._frozen_config.roots[myroot], "installed", atom + ) + ) + + # This package isn't eligible for selection in the + # merge list as the user passed --update-if-installed + # and it isn't installed. + if not package_is_installed: + continue + if not pkg: pprovided_match = False for virt_choice in virtuals.get(atom.cp, []): |