diff --git a/lib/portage/sync/modules/git/git.py b/lib/portage/sync/modules/git/git.py index 46194ad6cf..0b46bd9238 100644 --- a/lib/portage/sync/modules/git/git.py +++ b/lib/portage/sync/modules/git/git.py @@ -1,4 +1,4 @@ -# Copyright 2005-2022 Gentoo Authors +# Copyright 2005-2023 Gentoo Authors # Distributed under the terms of the GNU General Public License v2 import logging @@ -416,7 +416,16 @@ def verify_head(self, revision="-1") -> bool: ) return False - openpgp_env = self._get_openpgp_env(self.repo.sync_openpgp_key_path) + opts = self.options.get("emerge_config").opts + debug = "--debug" in opts + + openpgp_env = self._get_openpgp_env(self.repo.sync_openpgp_key_path, debug) + logging.getLogger("gemato").setLevel(logging.DEBUG) + + if debug: + old_level = logging.getLogger().getEffectiveLevel() + logging.getLogger().setLevel(logging.DEBUG) + logging.getLogger("gemato").setLevel(logging.DEBUG) try: out = EOutput() @@ -475,6 +484,8 @@ def verify_head(self, revision="-1") -> bool: finally: if openpgp_env is not None: openpgp_env.close() + if debug: + logging.getLogger().setLevel(old_level) def retrieve_head(self, **kwargs) -> tuple[int, bool]: """Get information about the head commit""" diff --git a/lib/portage/sync/modules/rsync/rsync.py b/lib/portage/sync/modules/rsync/rsync.py index aca51f2533..b095d6cb86 100644 --- a/lib/portage/sync/modules/rsync/rsync.py +++ b/lib/portage/sync/modules/rsync/rsync.py @@ -1,4 +1,4 @@ -# Copyright 1999-2020 Gentoo Authors +# Copyright 1999-2023 Gentoo Authors # Distributed under the terms of the GNU General Public License v2 import datetime @@ -147,11 +147,16 @@ def update(self): else: self.max_age = 0 + debug = "--debug" in opts + if debug: + old_level = logging.getLogger().getEffectiveLevel() + logging.getLogger().setLevel(logging.DEBUG) + openpgp_env = None if self.verify_metamanifest and gemato is not None: # Use isolated environment if key is specified, # system environment otherwise - openpgp_env = self._get_openpgp_env(self.repo.sync_openpgp_key_path) + openpgp_env = self._get_openpgp_env(self.repo.sync_openpgp_key_path, debug) try: # Load and update the keyring early. If it fails, then verification @@ -484,6 +489,8 @@ def update(self): self.repo_storage.abort_update() if openpgp_env is not None: openpgp_env.close() + if debug: + logging.getLogger().setLevel(old_level) def _process_exitcode(self, exitcode, syncuri, out, maxretries): if exitcode == 0: diff --git a/lib/portage/sync/syncbase.py b/lib/portage/sync/syncbase.py index 44d94524a5..b7228a38a6 100644 --- a/lib/portage/sync/syncbase.py +++ b/lib/portage/sync/syncbase.py @@ -1,4 +1,4 @@ -# Copyright 2014-2020 Gentoo Authors +# Copyright 2014-2023 Gentoo Authors # Distributed under the terms of the GNU General Public License v2 """ @@ -328,7 +328,7 @@ def noisy_refresh_keys(): loop.run_until_complete(decorated_func()) out.eend(0) - def _get_openpgp_env(self, openpgp_key_path=None): + def _get_openpgp_env(self, openpgp_key_path=None, debug=False): if gemato is not None: # Override global proxy setting with one provided in emerge configuration if "http_proxy" in self.spawn_kwargs["env"]: @@ -337,9 +337,13 @@ def _get_openpgp_env(self, openpgp_key_path=None): proxy = None if openpgp_key_path: - openpgp_env = gemato.openpgp.OpenPGPEnvironment(proxy=proxy) + openpgp_env = gemato.openpgp.OpenPGPEnvironment( + proxy=proxy, debug=debug + ) else: - openpgp_env = gemato.openpgp.OpenPGPSystemEnvironment(proxy=proxy) + openpgp_env = gemato.openpgp.OpenPGPSystemEnvironment( + proxy=proxy, debug=debug + ) return openpgp_env