From 4231d5d4f5fd903a20021eece669996d814babd5 Mon Sep 17 00:00:00 2001 From: Tasos Sahanidis Date: Wed, 7 Feb 2024 10:16:48 +0200 Subject: bin/watch-build-logs: Add new script to watch build logs --- bin/watch-build-logs | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100755 bin/watch-build-logs diff --git a/bin/watch-build-logs b/bin/watch-build-logs new file mode 100755 index 0000000..064dc85 --- /dev/null +++ b/bin/watch-build-logs @@ -0,0 +1,26 @@ +#!/usr/bin/env bash +trap 'echo ""; kill -- -$$' INT + +# shellcheck source=../lib/load-configuration +. "${0%/*}/../lib/load-configuration" + +runtail() { + # tail will quit with follow=name when the file is deleted + # thus no manual cleanup is needed + tail --follow=name "$1" -n +1 2>/dev/null & +} + +# Check if we're already building something, and if so, tail it before we wait for new files +CURRENTLOG=$(printf '%s\n' "$work_dir/"tmp.build-packages.*/*.build-log | sort | tail -n 1) +if [[ -f $CURRENTLOG ]]; then + runtail "$CURRENTLOG" +fi + +inotifywait -P -r -m "$work_dir" -e create --include '(\.build-log$)|(tmp\.build-packages\.[a-zA-Z0-9]+$)' --format '%w%f' -q | + while read -r FILE; do + if [[ -z $FILE || -d $FILE ]]; then + continue + fi + + runtail "$FILE" + done -- cgit v1.2.3-54-g00ecf