From ea34a0229e6ca5000bd7b5dda43409c56f793f18 Mon Sep 17 00:00:00 2001 From: Brad Warren Date: Mon, 5 Apr 2021 16:23:00 -0700 Subject: [PATCH] preserve logfiles --- tools/snap/build_remote.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/tools/snap/build_remote.py b/tools/snap/build_remote.py index 8fb754288..7d7e86233 100755 --- a/tools/snap/build_remote.py +++ b/tools/snap/build_remote.py @@ -28,6 +28,10 @@ CERTBOT_DIR = dirname(dirname(dirname(realpath(__file__)))) PLUGINS = [basename(path) for path in glob.glob(join(CERTBOT_DIR, 'certbot-dns-*'))] +def _snap_log_name(target: str, arch: str): + return f'{target}_{arch}.txt' + + def _execute_build( target: str, archs: Set[str], status: Dict[str, Dict[str, str]], workspace: str) -> Tuple[int, List[str]]: @@ -69,6 +73,11 @@ def _execute_build( for path in glob.glob(join(temp_workspace, '*.snap')): shutil.copy(path, workspace) + for arch in archs: + log_name = _snap_log_name(target, arch) + log_path = join(temp_workspace, log_name) + if exists(log_path) + shutil.copy(log_path, workspace) return process_state, process_output @@ -171,11 +180,12 @@ def _dump_failed_build_logs( if result != 'Successfully built': failures = True - build_output_path = join(workspace, f'{target}_{arch}.txt') + build_output_name = _snap_log_name(target, arch) + build_output_path = join(workspace, build_output_name) if not exists(build_output_path): build_output = f'No output has been dumped by snapcraft remote-build.' else: - with open(join(workspace, f'{target}_{arch}.txt')) as file_h: + with open(build_output_path) as file_h: build_output = file_h.read() print(f'Output for failed build target={target} arch={arch}')