index : builder | |
Archlinux32 build system | gitolite user |
summaryrefslogtreecommitdiff |
-rwxr-xr-x | bin/watch-build-logs | 26 |
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 |