commit:     3ce52c040169556129dac7d6746a3b5ae984443e
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Wed Dec 31 18:20:14 2025 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Wed Dec 31 18:20:14 2025 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=3ce52c04

qlop: support latest sync logging from Portage

Portage's logging in emerge.log is abysmal and randomly changing, making
it a tad bit complicated for tools to make sense of it.  Anyway, support
the lastest incarnation of the sync logging.

Bug: https://bugs.gentoo.org/965554
Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qlop.c | 26 +++++++++++++++++++-------
 1 file changed, 19 insertions(+), 7 deletions(-)

diff --git a/qlop.c b/qlop.c
index 93daf20..4c4ad36 100644
--- a/qlop.c
+++ b/qlop.c
@@ -331,6 +331,11 @@ New format:
 1431764460: === Sync completed for gentoo
 1431764493:  *** terminating.
 
+Latest format:
+1764512151: Started emerge on: Nov 30, 2025 15:15:51
+1764512151:  *** emerge --regex-search-auto=y --sync                           
 1764512151:  === sync
+1764512233:  *** terminating.
+
 *** packages
 
 1547475773:  >>> emerge (53 of 74) app-shells/bash-5.0 to /gentoo/prefix64/
@@ -679,6 +684,7 @@ static int do_emerge_log(
                        }
                        printf("\n");
                } else if (flags->do_sync && (
+                                       strpfx(p, "  *** terminating.") == 0 ||
                                        strpfx(p, " === Sync completed ") == 0 
||
                                        strcmp(p, "  === sync\n") == 0))
                {
@@ -692,14 +698,20 @@ static int do_emerge_log(
                                        continue;  /* sync without start, 
exclude */
                                elapsed = tstart - sync_start;
 
-                               p += 20;
-                               if (strpfx(p, "for ") == 0) {
-                                       p += 4;
-                               } else {  /* "with " */
-                                       p += 5;
+                               if (p[2] == '*' &&
+                                       (q = strchr(p, '\n')) != NULL)
+                               {
+                                       p = (char *)"sync";
+                               } else {
+                                       p += 20;
+                                       if (strpfx(p, "for ") == 0) {
+                                               p += 4;
+                                       } else {  /* "with " */
+                                               p += 5;
+                                       }
+                                       if ((q = strchr(p, '\n')) != NULL)
+                                               *q = '\0';
                                }
-                               if ((q = strchr(p, '\n')) != NULL)
-                                       *q = '\0';
 
                                if (flags->do_predict || flags->do_average ||
                                                flags->do_running)

Reply via email to