public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
From: "Zac Medico" <zmedico@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/portage:master commit in: lib/_emerge/
Date: Thu,  4 Jan 2024 16:00:45 +0000 (UTC)	[thread overview]
Message-ID: <1704348805.0ff49114cec79edce723da1190087a41699f6b2f.zmedico@gentoo> (raw)

commit:     0ff49114cec79edce723da1190087a41699f6b2f
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Thu Jan  4 05:12:24 2024 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> 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 <zmedico <AT> 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)


             reply	other threads:[~2024-01-04 16:00 UTC|newest]

Thread overview: 166+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-04 16:00 Zac Medico [this message]
  -- strict thread matches above, loose matches on Subject: below --
2024-09-29 22:52 [gentoo-commits] proj/portage:master commit in: lib/_emerge/ Zac Medico
2024-09-11  1:39 Sam James
2024-09-11  1:39 Sam James
2024-08-14 16:05 Zac Medico
2024-08-14 15:17 Zac Medico
2024-08-02 13:38 James Le Cuirot
2024-05-26 23:28 Sam James
2024-05-26 23:28 Sam James
2024-05-26 23:28 Sam James
2024-05-26 18:02 Zac Medico
2024-05-21 16:08 Zac Medico
2024-05-13  5:43 Sam James
2024-05-04 12:05 Sam James
2024-03-28 14:48 Zac Medico
2024-03-09 23:31 Zac Medico
2024-02-24 20:03 Zac Medico
2024-02-21 16:00 Zac Medico
2024-02-21 16:00 Zac Medico
2024-02-21 16:00 Zac Medico
2024-01-17 12:53 Zac Medico
2024-01-03 19:59 Sam James
2023-12-30 21:45 Zac Medico
2023-12-27 13:30 Sam James
2023-12-26 22:03 Zac Medico
2023-12-19  4:15 Zac Medico
2023-12-10 22:29 Sam James
2023-12-04  6:45 Sam James
2023-11-29 20:05 Zac Medico
2023-11-29 19:56 Zac Medico
2023-11-29  0:33 Zac Medico
2023-11-28 22:51 Zac Medico
2023-11-25  6:33 Zac Medico
2023-11-14  4:24 Zac Medico
2023-11-11  7:23 Sam James
2023-11-10 16:04 Zac Medico
2023-11-06 15:58 Sam James
2023-10-22 22:51 Zac Medico
2023-10-22 22:09 Sam James
2023-10-22  4:38 Zac Medico
2023-10-14 20:01 Zac Medico
2023-10-05  4:45 Zac Medico
2023-09-21 15:47 Sam James
2023-09-21 15:47 Sam James
2023-09-15 10:36 Sam James
2023-09-15 10:36 Sam James
2023-07-11  5:02 Sam James
2023-06-29  8:19 Sam James
2023-06-29  8:19 Sam James
2023-06-29  8:19 Sam James
2023-06-14  5:06 Sam James
2023-06-14  5:03 Sam James
2023-06-14  1:44 Sam James
2023-05-23  2:59 Sam James
2023-02-18  0:00 Sam James
2023-02-17  1:23 Sam James
2023-01-10 15:12 Sam James
2022-11-28 15:32 Zac Medico
2022-11-28 15:32 Zac Medico
2022-09-25 19:12 Mike Gilbert
2022-09-25  1:36 Sam James
2022-09-20  3:39 Sam James
2022-09-18 18:35 Mike Gilbert
2022-08-13 17:56 Sam James
2022-06-17 17:05 Mike Gilbert
2022-06-07 23:48 Mike Gilbert
2022-04-22 23:08 Mike Gilbert
2022-03-27 23:07 Sam James
2022-03-06 19:25 Zac Medico
2022-02-14 21:51 Sam James
2021-12-04  4:56 Michał Górny
2021-10-28  4:52 Sam James
2021-10-28  4:07 Sam James
2021-09-21  5:51 Zac Medico
2021-09-21  5:51 Zac Medico
2021-06-13 22:41 Zac Medico
2021-05-24  6:33 Zac Medico
2021-05-24  6:33 Zac Medico
2021-05-24  6:33 Zac Medico
2021-05-16 22:29 Zac Medico
2021-05-08 17:54 Zac Medico
2021-05-01 22:47 Zac Medico
2021-05-01 22:47 Zac Medico
2020-12-03 23:20 Zac Medico
2020-09-21  5:54 Zac Medico
2020-08-09 21:48 Zac Medico
2020-08-09  0:15 Zac Medico
2020-08-04  3:11 Zac Medico
2020-08-03 23:28 Zac Medico
2020-08-03 23:28 Zac Medico
2020-08-03 21:42 Zac Medico
2020-08-03 21:42 Zac Medico
2020-08-03 21:42 Zac Medico
2020-08-03 19:30 Zac Medico
2020-08-03 19:30 Zac Medico
2020-08-03 19:30 Zac Medico
2020-08-03 19:30 Zac Medico
2020-08-03 19:30 Zac Medico
2020-08-03 19:30 Zac Medico
2020-08-03 19:30 Zac Medico
2020-07-22 20:42 Zac Medico
2020-07-18 23:54 Zac Medico
2020-06-24  5:41 Zac Medico
2020-06-23 18:00 Zac Medico
2020-04-09 20:48 Zac Medico
2020-04-09  6:48 Zac Medico
2020-04-08  5:56 Zac Medico
2020-04-08  5:56 Zac Medico
2020-04-08  5:56 Zac Medico
2020-04-08  5:56 Zac Medico
2020-04-08  5:56 Zac Medico
2020-04-08  5:56 Zac Medico
2020-04-08  5:56 Zac Medico
2020-04-08  5:56 Zac Medico
2020-04-08  5:56 Zac Medico
2020-04-08  5:56 Zac Medico
2020-04-08  5:56 Zac Medico
2020-04-08  5:56 Zac Medico
2020-03-23  1:51 Zac Medico
2020-03-23  0:42 Zac Medico
2020-03-22 20:56 Zac Medico
2020-03-07 22:18 Zac Medico
2020-03-07 20:14 Zac Medico
2020-03-06  3:36 Zac Medico
2020-03-06  3:04 Zac Medico
2020-03-05 17:39 Zac Medico
2020-03-05  8:26 Zac Medico
2020-03-04 10:28 Zac Medico
2020-03-03  5:47 Zac Medico
2020-03-02  3:54 Zac Medico
2020-03-01 20:31 Zac Medico
2020-03-01 18:36 Zac Medico
2020-03-01  2:17 Zac Medico
2020-03-01  1:47 Zac Medico
2020-03-01  0:57 Zac Medico
2020-02-29 22:49 Zac Medico
2020-02-29 21:48 Zac Medico
2020-02-29 18:52 Zac Medico
2020-02-29  8:39 Zac Medico
2020-02-24  6:07 Zac Medico
2020-02-22  0:06 Zac Medico
2020-02-18  6:45 Zac Medico
2020-02-18  0:21 Zac Medico
2020-02-17 23:14 Zac Medico
2020-02-11 20:49 Zac Medico
2020-02-10  5:11 Zac Medico
2020-02-03 20:34 Zac Medico
2020-02-03 20:30 Zac Medico
2019-12-26 21:22 Zac Medico
2019-12-23 23:34 Zac Medico
2019-11-28  1:43 Zac Medico
2019-11-25  6:38 Zac Medico
2019-11-18  2:56 Zac Medico
2019-11-17 21:04 Zac Medico
2019-11-16  9:23 Zac Medico
2019-10-27 19:33 Zac Medico
2019-10-23 17:03 Zac Medico
2019-09-01  1:09 Zac Medico
2019-08-06  3:14 Zac Medico
2019-07-08  6:49 Zac Medico
2019-04-24 18:54 Zac Medico
2019-04-21  1:02 Zac Medico
2019-01-21 21:59 Zac Medico
2018-11-25  8:25 Zac Medico
2018-10-06  1:03 Zac Medico
2018-08-02 18:45 Zac Medico

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1704348805.0ff49114cec79edce723da1190087a41699f6b2f.zmedico@gentoo \
    --to=zmedico@gentoo.org \
    --cc=gentoo-commits@lists.gentoo.org \
    --cc=gentoo-dev@lists.gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox