Fix Scanner not to override portdbapi._aux_cache_keys when generating
manifests, since spawn_nofetch requires additional keys.

Fixes: 87e32d4863f3 ("repoman: fix KeyError...during manifest generation (bug 
569942)")
X-Gentoo-Bug: 585388
X-Gentoo-Bug-url: https://bugs.gentoo.org/show_bug.cgi?id=585388
---
 repoman/pym/repoman/modules/commit/manifest.py | 91 +++++++++++++-------------
 repoman/pym/repoman/scanner.py                 | 12 +++-
 2 files changed, 53 insertions(+), 50 deletions(-)

diff --git a/repoman/pym/repoman/modules/commit/manifest.py 
b/repoman/pym/repoman/modules/commit/manifest.py
index 475dae4..b338a5b 100644
--- a/repoman/pym/repoman/modules/commit/manifest.py
+++ b/repoman/pym/repoman/modules/commit/manifest.py
@@ -33,55 +33,52 @@ class Manifest(object):
                @returns: dictionary
                '''
                self.generated_manifest = False
-               self.digest_only = self.options.mode != 'manifest-check' \
-                       and self.options.digest == 'y'
-               if self.options.mode in ("manifest", 'commit', 'fix') or 
self.digest_only:
-                       failed = False
-                       self.auto_assumed = set()
-                       fetchlist_dict = portage.FetchlistDict(
-                               checkdir, self.repoman_settings, self.portdb)
-                       if self.options.mode == 'manifest' and 
self.options.force:
-                               self._discard_dist_digests(checkdir, 
fetchlist_dict)
-                       self.repoman_settings["O"] = checkdir
-                       try:
-                               self.generated_manifest = digestgen(
-                                       mysettings=self.repoman_settings, 
myportdb=self.portdb)
-                       except portage.exception.PermissionDenied as e:
-                               self.generated_manifest = False
-                               writemsg_level(
-                                       "!!! Permission denied: '%s'\n" % (e,),
-                                       level=logging.ERROR, noiselevel=-1)
+               failed = False
+               self.auto_assumed = set()
+               fetchlist_dict = portage.FetchlistDict(
+                       checkdir, self.repoman_settings, self.portdb)
+               if self.options.mode == 'manifest' and self.options.force:
+                       self._discard_dist_digests(checkdir, fetchlist_dict)
+               self.repoman_settings["O"] = checkdir
+               try:
+                       self.generated_manifest = digestgen(
+                               mysettings=self.repoman_settings, 
myportdb=self.portdb)
+               except portage.exception.PermissionDenied as e:
+                       self.generated_manifest = False
+                       writemsg_level(
+                               "!!! Permission denied: '%s'\n" % (e,),
+                               level=logging.ERROR, noiselevel=-1)
 
-                       if not self.generated_manifest:
-                               writemsg_level(
-                                       "Unable to generate manifest.",
-                                       level=logging.ERROR, noiselevel=-1)
-                               failed = True
+               if not self.generated_manifest:
+                       writemsg_level(
+                               "Unable to generate manifest.",
+                               level=logging.ERROR, noiselevel=-1)
+                       failed = True
 
-                       if self.options.mode == "manifest":
-                               if not failed and self.options.force and 
self.auto_assumed and \
-                                       'assume-digests' in 
self.repoman_settings.features:
-                                       # Show which digests were assumed 
despite the --force option
-                                       # being given. This output will already 
have been shown by
-                                       # digestgen() if assume-digests is not 
enabled, so only show
-                                       # it here if assume-digests is enabled.
-                                       pkgs = list(fetchlist_dict)
-                                       pkgs.sort()
-                                       portage.writemsg_stdout(
-                                               "  digest.assumed %s" %
-                                               portage.output.colorize(
-                                                       "WARN", 
str(len(self.auto_assumed)).rjust(18)) + "\n")
-                                       for cpv in pkgs:
-                                               fetchmap = fetchlist_dict[cpv]
-                                               pf = portage.catsplit(cpv)[1]
-                                               for distfile in 
sorted(fetchmap):
-                                                       if distfile in 
self.auto_assumed:
-                                                               
portage.writemsg_stdout(
-                                                                       "   
%s::%s\n" % (pf, distfile))
-                               # continue, skip remaining main loop code
-                               return True
-                       elif failed:
-                               sys.exit(1)
+               if self.options.mode == "manifest":
+                       if not failed and self.options.force and 
self.auto_assumed and \
+                               'assume-digests' in 
self.repoman_settings.features:
+                               # Show which digests were assumed despite the 
--force option
+                               # being given. This output will already have 
been shown by
+                               # digestgen() if assume-digests is not enabled, 
so only show
+                               # it here if assume-digests is enabled.
+                               pkgs = list(fetchlist_dict)
+                               pkgs.sort()
+                               portage.writemsg_stdout(
+                                       "  digest.assumed %s" %
+                                       portage.output.colorize(
+                                               "WARN", 
str(len(self.auto_assumed)).rjust(18)) + "\n")
+                               for cpv in pkgs:
+                                       fetchmap = fetchlist_dict[cpv]
+                                       pf = portage.catsplit(cpv)[1]
+                                       for distfile in sorted(fetchmap):
+                                               if distfile in 
self.auto_assumed:
+                                                       portage.writemsg_stdout(
+                                                               "   %s::%s\n" % 
(pf, distfile))
+                       # continue, skip remaining main loop code
+                       return True
+               elif failed:
+                       sys.exit(1)
                return False
 
        def _discard_dist_digests(self, checkdir, fetchlist_dict):
diff --git a/repoman/pym/repoman/scanner.py b/repoman/pym/repoman/scanner.py
index f72af9c..d7cd81f 100644
--- a/repoman/pym/repoman/scanner.py
+++ b/repoman/pym/repoman/scanner.py
@@ -60,9 +60,15 @@ class Scanner(object):
 
                self.portdb = repo_settings.portdb
                self.portdb.settings = self.repo_settings.repoman_settings
+
+               digest_only = self.options.mode != 'manifest-check' \
+                       and self.options.digest == 'y'
+               self.generate_manifest = digest_only or self.options.mode in \
+                       ("manifest", 'commit', 'fix')
+
                # We really only need to cache the metadata that's necessary 
for visibility
                # filtering. Anything else can be discarded to reduce memory 
consumption.
-               if self.options.mode != "manifest" and self.options.digest != 
"y":
+               if not self.generate_manifest:
                        # Don't do this when generating manifests, since that 
uses
                        # additional keys if spawn_nofetch is called (RESTRICT 
and
                        # DEFINED_PHASES).
@@ -286,8 +292,8 @@ class Scanner(object):
                        if self.kwargs['checks']['ebuild_notadded']:
                                self.vcs_settings.status.check(checkdir, 
checkdir_relative, xpkg)
 
-                       manifester = manifest.Manifest(**self.kwargs)
-                       manifester.update_manifest(checkdir)
+                       if self.generate_manifest:
+                               
manifest.Manifest(**self.kwargs).update_manifest(checkdir)
                        checkdirlist = os.listdir(checkdir)
 
                        dynamic_data = {
-- 
2.7.4


Reply via email to