summaryrefslogtreecommitdiffstats
path: root/pym
diff options
context:
space:
mode:
authorSebastian Luther <SebastianLuther@gmx.de>2012-02-26 09:49:13 +0100
committerZac Medico <zmedico@gentoo.org>2012-02-26 01:44:16 -0800
commitc9a0df701f983b41fd0f1aac7bb4536f771846cb (patch)
tree7fd7690c79ceb7c7d318acaf4251b187094a75e9 /pym
parent0279590c2351cf4e757e15bbbfc5546205e16533 (diff)
downloadportage-c9a0df701f983b41fd0f1aac7bb4536f771846cb.tar.gz
portage-c9a0df701f983b41fd0f1aac7bb4536f771846cb.tar.bz2
portage-c9a0df701f983b41fd0f1aac7bb4536f771846cb.zip
Reorganize how autounmask allows changes to be made
This patch does not change emerge's behaviour.
Diffstat (limited to 'pym')
-rw-r--r--pym/_emerge/depgraph.py109
1 files changed, 57 insertions, 52 deletions
diff --git a/pym/_emerge/depgraph.py b/pym/_emerge/depgraph.py
index bb3bf4adf..a05c17e93 100644
--- a/pym/_emerge/depgraph.py
+++ b/pym/_emerge/depgraph.py
@@ -3504,42 +3504,63 @@ class depgraph(object):
return False
return True
+ class _AutounmaskLevel(object):
+ __slots__ = ("allow_use_changes", "allow_unstable_keywords", "allow_license_changes", "allow_unmasks")
+
+ def __init__(self):
+ self.allow_use_changes = False
+ self.allow_unstable_keywords = False
+ self.allow_license_changes = False
+ self.allow_unmasks = False
+
+ def _autounmask_levels(self):
+
+ if self._dynamic_config._autounmask is not True:
+ return
+
+ autounmask_keep_masks = self._frozen_config.myopts.get("--autounmask-keep-masks", "n") != "n"
+ autounmask_level = self._AutounmaskLevel()
+
+ autounmask_level.allow_use_changes = True
+
+ for only_use_changes in (True, False):
+
+ autounmask_level.allow_unstable_keywords = (not only_use_changes)
+ autounmask_level.allow_license_changes = (not only_use_changes)
+
+ for allow_unmasks in (False, True):
+ if allow_unmasks and (only_use_changes or autounmask_keep_masks):
+ continue
+
+ autounmask_level.allow_unmasks = allow_unmasks
+
+ yield autounmask_level
+
+
def _select_pkg_highest_available_imp(self, root, atom, onlydeps=False):
pkg, existing = self._wrapped_select_pkg_highest_available_imp(root, atom, onlydeps=onlydeps)
default_selection = (pkg, existing)
- autounmask_keep_masks = self._frozen_config.myopts.get("--autounmask-keep-masks", "n") != "n"
-
- if self._dynamic_config._autounmask is True:
+ def reset_pkg(pkg):
if pkg is not None and \
pkg.installed and \
not self._want_installed_pkg(pkg):
pkg = None
- for only_use_changes in True, False:
+ if self._dynamic_config._autounmask is True:
+ reset_pkg(pkg)
+
+ for autounmask_level in self._autounmask_levels():
if pkg is not None:
break
- for allow_unmasks in (False, True):
- if allow_unmasks and (only_use_changes or autounmask_keep_masks):
- continue
-
- if pkg is not None:
- break
+ pkg, existing = \
+ self._wrapped_select_pkg_highest_available_imp(
+ root, atom, onlydeps=onlydeps,
+ autounmask_level=autounmask_level)
- pkg, existing = \
- self._wrapped_select_pkg_highest_available_imp(
- root, atom, onlydeps=onlydeps,
- allow_use_changes=True,
- allow_unstable_keywords=(not only_use_changes),
- allow_license_changes=(not only_use_changes),
- allow_unmasks=allow_unmasks)
-
- if pkg is not None and \
- pkg.installed and \
- not self._want_installed_pkg(pkg):
- pkg = None
+ reset_pkg(pkg)
if self._dynamic_config._need_restart:
return None, None
@@ -3551,8 +3572,7 @@ class depgraph(object):
return pkg, existing
- def _pkg_visibility_check(self, pkg, allow_unstable_keywords=False,
- allow_license_changes=False, allow_unmasks=False, trust_graph=True):
+ def _pkg_visibility_check(self, pkg, autounmask_level=None, trust_graph=True):
if pkg.visible:
return True
@@ -3565,7 +3585,7 @@ class depgraph(object):
# as though they are visible.
return True
- if not self._dynamic_config._autounmask:
+ if not self._dynamic_config._autounmask or autounmask_level is None:
return False
pkgsettings = self._frozen_config.pkgsettings[pkg.root]
@@ -3615,10 +3635,10 @@ class depgraph(object):
return True
#We treat missing keywords in the same way as masks.
- if (masked_by_unstable_keywords and not allow_unstable_keywords) or \
- (masked_by_missing_keywords and not allow_unmasks) or \
- (masked_by_p_mask and not allow_unmasks) or \
- (missing_licenses and not allow_license_changes):
+ if (masked_by_unstable_keywords and not autounmask_level.allow_unstable_keywords) or \
+ (masked_by_missing_keywords and not autounmask_level.allow_unmasks) or \
+ (masked_by_p_mask and not autounmask_level.allow_unmasks) or \
+ (missing_licenses and not autounmask_level.allow_license_changes):
#We are not allowed to do the needed changes.
return False
@@ -3733,8 +3753,7 @@ class depgraph(object):
self._dynamic_config._need_restart = True
return new_use
- def _wrapped_select_pkg_highest_available_imp(self, root, atom, onlydeps=False, \
- allow_use_changes=False, allow_unstable_keywords=False, allow_license_changes=False, allow_unmasks=False):
+ def _wrapped_select_pkg_highest_available_imp(self, root, atom, onlydeps=False, autounmask_level=None):
root_config = self._frozen_config.roots[root]
pkgsettings = self._frozen_config.pkgsettings[root]
dbs = self._dynamic_config._filtered_trees[root]["dbs"]
@@ -3861,10 +3880,7 @@ class depgraph(object):
# _dep_check_composite_db, in order to prevent
# incorrect choices in || deps like bug #351828.
- if not self._pkg_visibility_check(pkg, \
- allow_unstable_keywords=allow_unstable_keywords,
- allow_license_changes=allow_license_changes,
- allow_unmasks=allow_unmasks):
+ if not self._pkg_visibility_check(pkg, autounmask_level):
continue
# Enable upgrade or downgrade to a version
@@ -3904,19 +3920,13 @@ class depgraph(object):
pkg_eb_visible = False
for pkg_eb in self._iter_match_pkgs(pkg.root_config,
"ebuild", Atom("=%s" % (pkg.cpv,))):
- if self._pkg_visibility_check(pkg_eb, \
- allow_unstable_keywords=allow_unstable_keywords,
- allow_license_changes=allow_license_changes,
- allow_unmasks=allow_unmasks):
+ if self._pkg_visibility_check(pkg_eb, autounmask_level):
pkg_eb_visible = True
break
if not pkg_eb_visible:
continue
else:
- if not self._pkg_visibility_check(pkg_eb, \
- allow_unstable_keywords=allow_unstable_keywords,
- allow_license_changes=allow_license_changes,
- allow_unmasks=allow_unmasks):
+ if not self._pkg_visibility_check(pkg_eb, autounmask_level):
continue
# Calculation of USE for unbuilt ebuilds is relatively
@@ -3946,7 +3956,7 @@ class depgraph(object):
if atom.use:
matched_pkgs_ignore_use.append(pkg)
- if allow_use_changes and not pkg.built:
+ if autounmask_level and autounmask_level.allow_use_changes and not pkg.built:
target_use = {}
for flag in atom.use.enabled:
target_use[flag] = True
@@ -4169,21 +4179,16 @@ class depgraph(object):
if avoid_update:
for pkg in matched_packages:
- if pkg.installed and self._pkg_visibility_check(pkg, \
- allow_unstable_keywords=allow_unstable_keywords,
- allow_license_changes=allow_license_changes,
- allow_unmasks=allow_unmasks):
+ if pkg.installed and self._pkg_visibility_check(pkg, autounmask_level):
return pkg, existing_node
visible_matches = []
if matched_oldpkg:
visible_matches = [pkg.cpv for pkg in matched_oldpkg \
- if self._pkg_visibility_check(pkg, allow_unstable_keywords=allow_unstable_keywords,
- allow_license_changes=allow_license_changes, allow_unmasks=allow_unmasks)]
+ if self._pkg_visibility_check(pkg, autounmask_level)]
if not visible_matches:
visible_matches = [pkg.cpv for pkg in matched_packages \
- if self._pkg_visibility_check(pkg, allow_unstable_keywords=allow_unstable_keywords,
- allow_license_changes=allow_license_changes, allow_unmasks=allow_unmasks)]
+ if self._pkg_visibility_check(pkg, autounmask_level)]
if visible_matches:
bestmatch = portage.best(visible_matches)
else: