Skip to content

Commit

Permalink
sync: rsync, git: respect --debug for gemato
Browse files Browse the repository at this point in the history
Respect --debug and pass it down to gemato so we get nice debugging output
when e.g. 'refreshing keys' is stuck.

Bug: https://bugs.gentoo.org/646194
Bug: https://bugs.gentoo.org/647696
Bug: https://bugs.gentoo.org/691666
Bug: https://bugs.gentoo.org/779766
Bug: https://bugs.gentoo.org/873133
Bug: https://bugs.gentoo.org/906875
Bug: projg2/gemato#7
Bug: projg2/gemato#25
Signed-off-by: Sam James <[email protected]>
  • Loading branch information
thesamesam committed Aug 17, 2023
1 parent ab71ec9 commit 9268a92
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 8 deletions.
15 changes: 13 additions & 2 deletions lib/portage/sync/modules/git/git.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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"""
Expand Down
11 changes: 9 additions & 2 deletions lib/portage/sync/modules/rsync/rsync.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down
12 changes: 8 additions & 4 deletions lib/portage/sync/syncbase.py
Original file line number Diff line number Diff line change
@@ -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

"""
Expand Down Expand Up @@ -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"]:
Expand All @@ -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

Expand Down

0 comments on commit 9268a92

Please sign in to comment.