Bug #288083 - Always warn about installed packages masked by license, since
authorZac Medico <zmedico@gentoo.org>
Sun, 15 Nov 2009 23:40:00 +0000 (23:40 -0000)
committerZac Medico <zmedico@gentoo.org>
Sun, 15 Nov 2009 23:40:00 +0000 (23:40 -0000)
the user likely wants to adjust ACCEPT_LICENSE. For updates masked by license,
warn if --complete-graph or --deep is given, since otherwise it is likely a
waste of time.

svn path=/main/trunk/; revision=14822

pym/_emerge/depgraph.py
pym/_emerge/visible.py

index 77248ea651dab9332e703dd7d5770bbf299fb0b6..fe0276818de65ea25c2f09606a391d5ac65f87b0 100644 (file)
@@ -152,6 +152,7 @@ class _dynamic_depgraph_config(object):
                self._pprovided_args = []
                self._missing_args = []
                self._masked_installed = set()
+               self._masked_license_updates = set()
                self._unsatisfied_deps_for_display = []
                self._unsatisfied_blockers_for_display = None
                self._circular_deps_for_display = None
@@ -2773,7 +2774,9 @@ class depgraph(object):
                        "--nodeps" in self._frozen_config.myopts:
                        return True
 
-               #if "deep" in self._dynamic_config.myparams:
+               complete = "complete" in self._dynamic_config.myparams
+               deep = "deep" in self._dynamic_config.myparams
+
                if True:
                        # Pull in blockers from all installed packages that haven't already
                        # been pulled into the depgraph.  This is not enabled by default
@@ -2785,6 +2788,8 @@ class depgraph(object):
                                vardb = self._frozen_config.trees[myroot]["vartree"].dbapi
                                portdb = self._frozen_config.trees[myroot]["porttree"].dbapi
                                pkgsettings = self._frozen_config.pkgsettings[myroot]
+                               root_config = self._frozen_config.roots[myroot]
+                               dbs = self._dynamic_config._filtered_trees[myroot]["dbs"]
                                final_db = self._dynamic_config.mydbapi[myroot]
 
                                blocker_cache = BlockerCache(myroot, vardb)
@@ -2797,10 +2802,34 @@ class depgraph(object):
                                        # Check for masked installed packages. Only warn about
                                        # packages that are in the graph in order to avoid warning
                                        # about those that will be automatically uninstalled during
-                                       # the merge process or by --depclean.
+                                       # the merge process or by --depclean. Always warn about
+                                       # packages masked by license, since the user likely wants
+                                       # to adjust ACCEPT_LICENSE.
                                        if pkg in final_db:
                                                if pkg_in_graph and not visible(pkgsettings, pkg):
                                                        self._dynamic_config._masked_installed.add(pkg)
+                                               elif pkgsettings._getMissingLicenses(pkg.cpv, pkg.metadata):
+                                                       self._dynamic_config._masked_installed.add(pkg)
+                                               elif complete or deep:
+                                                       # Check for upgrades in the same slot that are
+                                                       # masked due to a LICENSE change in a newer
+                                                       # version that is not masked for any other reason.
+                                                       # Only do this for complete or deep graphs since
+                                                       # otherwise it is likely a waste of time.
+                                                       for db, pkg_type, built, installed, db_keys in dbs:
+                                                               if installed:
+                                                                       continue
+                                                               for upgrade_pkg in self._iter_match_pkgs(
+                                                                       root_config, pkg_type, pkg.slot_atom):
+                                                                       if upgrade_pkg <= pkg:
+                                                                               break
+                                                                       if not visible(pkgsettings,
+                                                                               upgrade_pkg, ignore=('LICENSE',)):
+                                                                               continue
+                                                                       if pkgsettings._getMissingLicenses(
+                                                                               upgrade_pkg.cpv, upgrade_pkg.metadata):
+                                                                               self._dynamic_config._masked_license_updates.add(upgrade_pkg)
+                                                                               break
 
                                        blocker_atoms = None
                                        blockers = None
@@ -4830,6 +4859,21 @@ class depgraph(object):
                                msg.append("package.provided entry exists.\n\n")
                        sys.stderr.write("".join(msg))
 
+               masked_packages = []
+               for pkg in self._dynamic_config._masked_license_updates:
+                       root_config = pkg.root_config
+                       pkgsettings = self._frozen_config.pkgsettings[pkg.root]
+                       mreasons = get_masking_status(pkg, pkgsettings, root_config)
+                       masked_packages.append((root_config, pkgsettings,
+                               pkg.cpv, pkg.metadata, mreasons))
+               if masked_packages:
+                       writemsg("\n" + colorize("BAD", "!!!") + \
+                               " The following updates are masked by LICENSE changes:\n",
+                               noiselevel=-1)
+                       show_masked_packages(masked_packages)
+                       show_mask_docs()
+                       writemsg("\n", noiselevel=-1)
+
                masked_packages = []
                for pkg in self._dynamic_config._masked_installed:
                        root_config = pkg.root_config
@@ -4838,11 +4882,12 @@ class depgraph(object):
                        masked_packages.append((root_config, pkgsettings,
                                pkg.cpv, pkg.metadata, mreasons))
                if masked_packages:
-                       sys.stderr.write("\n" + colorize("BAD", "!!!") + \
-                               " The following installed packages are masked:\n")
+                       writemsg("\n" + colorize("BAD", "!!!") + \
+                               " The following installed packages are masked:\n",
+                               noiselevel=-1)
                        show_masked_packages(masked_packages)
                        show_mask_docs()
-                       print()
+                       writemsg("\n", noiselevel=-1)
 
        def saveNomergeFavorites(self):
                """Find atoms in favorites that are not in the mergelist and add them
index ee74910c2bc617bd9a4cce0d19137b4fdaf7c0ae..c50768dfbcad3b7e37e080a85f2e5cd1937b6b6e 100644 (file)
@@ -4,7 +4,7 @@
 
 import portage
 
-def visible(pkgsettings, pkg):
+def visible(pkgsettings, pkg, ignore=None):
        """
        Check if a package is visible. This can raise an InvalidDependString
        exception if LICENSE is invalid.
@@ -38,7 +38,8 @@ def visible(pkgsettings, pkg):
                return False
        try:
                if pkgsettings._getMissingLicenses(pkg.cpv, pkg.metadata):
-                       return False
+                       if ignore is None or 'LICENSE' not in ignore:
+                               return False
        except portage.exception.InvalidDependString:
                return False
        return True