From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id 4E08915803E for ; Thu, 4 Jan 2024 16:00:50 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 7A0F72BC013; Thu, 4 Jan 2024 16:00:49 +0000 (UTC) Received: from smtp.gentoo.org (woodpecker.gentoo.org [140.211.166.183]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 96B9D2BC013 for ; Thu, 4 Jan 2024 16:00:48 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 874AA343082 for ; Thu, 4 Jan 2024 16:00:47 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id F1227AE5 for ; Thu, 4 Jan 2024 16:00:45 +0000 (UTC) From: "Zac Medico" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Zac Medico" Message-ID: <1704348805.0ff49114cec79edce723da1190087a41699f6b2f.zmedico@gentoo> Subject: [gentoo-commits] proj/portage:master commit in: lib/_emerge/ X-VCS-Repository: proj/portage X-VCS-Files: lib/_emerge/Binpkg.py lib/_emerge/BinpkgPrefetcher.py lib/_emerge/Scheduler.py X-VCS-Directories: lib/_emerge/ X-VCS-Committer: zmedico X-VCS-Committer-Name: Zac Medico X-VCS-Revision: 0ff49114cec79edce723da1190087a41699f6b2f X-VCS-Branch: master Date: Thu, 4 Jan 2024 16:00:45 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-Archives-Salt: 870f0904-cff2-41b4-ad45-10a400ef39b2 X-Archives-Hash: bbc70ba1f0f0c3a0e5c13c3095502e70 commit: 0ff49114cec79edce723da1190087a41699f6b2f Author: Zac Medico gentoo org> AuthorDate: Thu Jan 4 05:12:24 2024 +0000 Commit: Zac Medico gentoo org> CommitDate: Thu Jan 4 06:13:25 2024 +0000 URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=0ff49114 binarytree: Handle inject failures Capture stdout and stderr for logging purposes during binarytree inject calls, and use the inject return value to report success or failure. For failures prior to pkg_pretend, use an eerror/elog message to indicate that the binary package is not usable. Move corresponding elog_process call to a finally block so that it is called for all pkg_pretend failures. Bug: https://bugs.gentoo.org/921327 Signed-off-by: Zac Medico gentoo.org> lib/_emerge/Binpkg.py | 34 ++++++++++++++++++++++++++++++---- lib/_emerge/BinpkgPrefetcher.py | 36 +++++++++++++++++++++++++++++------- lib/_emerge/Scheduler.py | 36 +++++++++++++++++++++++------------- 3 files changed, 82 insertions(+), 24 deletions(-) diff --git a/lib/_emerge/Binpkg.py b/lib/_emerge/Binpkg.py index 9b1036538a..299ae7fbc9 100644 --- a/lib/_emerge/Binpkg.py +++ b/lib/_emerge/Binpkg.py @@ -1,6 +1,8 @@ -# Copyright 1999-2023 Gentoo Authors +# Copyright 1999-2024 Gentoo Authors # Distributed under the terms of the GNU General Public License v2 +import io +import sys import functools import _emerge.emergelog from _emerge.EbuildPhase import EbuildPhase @@ -244,12 +246,36 @@ class Binpkg(CompositeTask): pkg_count = self.pkg_count if self._fetched_pkg: - pkg_path = self._bintree.getname( - self._bintree.inject( + stdout_orig = sys.stdout + stderr_orig = sys.stderr + out = io.StringIO() + try: + sys.stdout = out + sys.stderr = out + + injected_pkg = self._bintree.inject( pkg.cpv, current_pkg_path=self._fetched_pkg, allocated_pkg_path=self._pkg_allocated_path, - ), + ) + finally: + sys.stdout = stdout_orig + sys.stderr = stderr_orig + + output_value = out.getvalue() + if output_value: + self.scheduler.output( + output_value, + log_path=self.settings.get("PORTAGE_LOG_FILE"), + background=self.background, + ) + + if injected_pkg is None: + self._async_unlock_builddir(returncode=1) + return + + pkg_path = self._bintree.getname( + injected_pkg, allocate_new=False, ) else: diff --git a/lib/_emerge/BinpkgPrefetcher.py b/lib/_emerge/BinpkgPrefetcher.py index 37dbe0a40f..ed68d2852c 100644 --- a/lib/_emerge/BinpkgPrefetcher.py +++ b/lib/_emerge/BinpkgPrefetcher.py @@ -1,6 +1,9 @@ -# Copyright 1999-2009 Gentoo Foundation +# Copyright 1999-2024 Gentoo Authors # Distributed under the terms of the GNU General Public License v2 +import io +import sys + from _emerge.BinpkgFetcher import BinpkgFetcher from _emerge.CompositeTask import CompositeTask from _emerge.BinpkgVerifier import BinpkgVerifier @@ -45,12 +48,31 @@ class BinpkgPrefetcher(CompositeTask): self.wait() return - self._bintree.inject( - self.pkg.cpv, - current_pkg_path=self.pkg_path, - allocated_pkg_path=self.pkg_allocated_path, - ) + stdout_orig = sys.stdout + stderr_orig = sys.stderr + out = io.StringIO() + try: + sys.stdout = out + sys.stderr = out + + injected_pkg = self._bintree.inject( + self.pkg.cpv, + current_pkg_path=self.pkg_path, + allocated_pkg_path=self.pkg_allocated_path, + ) + + finally: + sys.stdout = stdout_orig + sys.stderr = stderr_orig + + output_value = out.getvalue() + if output_value: + self.scheduler.output( + output_value, + log_path=self.scheduler.fetch.log_file, + background=self.background, + ) self._current_task = None - self.returncode = os.EX_OK + self.returncode = 1 if injected_pkg is None else os.EX_OK self.wait() diff --git a/lib/_emerge/Scheduler.py b/lib/_emerge/Scheduler.py index 620d513511..ae01214d32 100644 --- a/lib/_emerge/Scheduler.py +++ b/lib/_emerge/Scheduler.py @@ -1,4 +1,4 @@ -# Copyright 1999-2023 Gentoo Authors +# Copyright 1999-2024 Gentoo Authors # Distributed under the terms of the GNU General Public License v2 from collections import deque @@ -984,11 +984,19 @@ class Scheduler(PollScheduler): current_task = None if fetched: - bintree.inject( + if not bintree.inject( x.cpv, current_pkg_path=fetched, allocated_pkg_path=fetcher.pkg_allocated_path, - ) + ): + eerror( + "Binary package is not usable", + phase="pretend", + key=x.cpv, + ) + failures += 1 + self._record_pkg_failure(x, settings, 1) + continue infloc = os.path.join(build_dir_path, "build-info") ensure_dirs(infloc) @@ -1046,20 +1054,22 @@ class Scheduler(PollScheduler): if ret != os.EX_OK: failures += 1 self._record_pkg_failure(x, settings, ret) - portage.elog.elog_process(x.cpv, settings) finally: if current_task is not None: if current_task.isAlive(): current_task.cancel() - if current_task.returncode == os.EX_OK: - clean_phase = EbuildPhase( - background=False, - phase="clean", - scheduler=sched_iface, - settings=settings, - ) - clean_phase.start() - await clean_phase.async_wait() + + portage.elog.elog_process(x.cpv, settings) + + if current_task is not None and current_task.returncode == os.EX_OK: + clean_phase = EbuildPhase( + background=False, + phase="clean", + scheduler=sched_iface, + settings=settings, + ) + clean_phase.start() + await clean_phase.async_wait() await build_dir.async_unlock() self._deallocate_config(settings)