commit:     8325458dc3fc907432f50d0710909cba9144834e
Author:     Matt Jolly <kangie <AT> gentoo <DOT> org>
AuthorDate: Wed Oct 23 03:47:39 2024 +0000
Commit:     Matt Jolly <kangie <AT> gentoo <DOT> org>
CommitDate: Wed Oct 23 03:48:04 2024 +0000
URL:        
https://gitweb.gentoo.org/proj/chromium-tools.git/commit/?id=8325458d

Fail after a (configurable) timeout

If we make it more than say 5 minutes we've probably gotten past
the point where GN would complain and any failures are likely to
require actual dev effort.

Just die with an error at that point to save on electricity.

Signed-off-by: Matt Jolly <kangie <AT> gentoo.org>

 iterate-over-ebuild.sh | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/iterate-over-ebuild.sh b/iterate-over-ebuild.sh
index 9d0d479..7cd0f64 100755
--- a/iterate-over-ebuild.sh
+++ b/iterate-over-ebuild.sh
@@ -9,6 +9,7 @@ package="${1%.ebuild}"
 tmpfile=$(mktemp)
 iter=0
 added=()
+timeout_secs=300
 
 # Trap for Ctrl+C
 trap 'cleanup' INT
@@ -20,6 +21,7 @@ cleanup() {
 }
 
 while true; do
+  start_time=$(date +%s)
   libs=()
   echo "[$(date)]: Processing $package; iteration $((++iter))"
   echo "So far, we've added:"
@@ -54,6 +56,15 @@ while true; do
     rm "$tmpfile"
     break
   fi
+
+  end_time=$(date +%s)
+  elapsed_time=$((end_time - start_time))
+  if [ $elapsed_time -gt $timeout_secs ]; then
+    echo "[$(date)]: Ebuild execution took longer than the timeout. This is 
likely a build failure that requires patching. Exiting."
+    echo "$tmpfile" for this iteration\'s logs.
+    exit 1
+  fi
+
   # Start with a clean slate for the next iteration
   rm "$tmpfile"
 done

Reply via email to