From 8325458dc3fc907432f50d0710909cba9144834e Mon Sep 17 00:00:00 2001 From: Matt Jolly Date: Wed, 23 Oct 2024 13:47:39 +1000 Subject: 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 --- 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 -- cgit v1.2.3-65-gdbad