File: buildwatch.sh

package info (click to toggle)
openjdk-17 17.0.12%2B7-2~deb11u1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 761,492 kB
  • sloc: java: 5,260,864; xml: 1,291,612; cpp: 1,195,623; ansic: 417,064; asm: 404,978; objc: 20,747; sh: 15,482; javascript: 10,900; python: 6,402; makefile: 2,378; perl: 357; awk: 351; sed: 172; jsp: 24; csh: 3
file content (67 lines) | stat: -rw-r--r-- 1,997 bytes parent folder | download | duplicates (15)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#! /bin/sh

#
# Output something to stdout every so often so buildd won't kill
# the build when building 
#

builddir=$1

echo $$ > buildwatch.pid

time_unit="m"
timer=0
sleep_for=3
time_up_at=180
upd_every=30 # use a multiple of $sleep_for

reset_timer() { timer=0; }
inc_timer()   { timer=$(expr $timer + $sleep_for); }
time_up()     { [ $timer -ge $time_up_at ]; }
can_update()  { [ $(expr $timer % $upd_every) -eq 0 ]; }
do_sleep()    { sleep ${sleep_for}${time_unit} && inc_timer; }

is_running() { 
    ps x | grep -v grep | egrep -qs $@
    return $?
}

cleanup() {
    # find any hs_err_pid files generated during the build and print them out
    # this helps debugging what went wrong during builds
    find . -type f -name 'hs_err_pid*.log' -printf "[$0] === HOTSPOT ERROR LOG ===\n[$0] %p (last modification at %t)\n" -exec cat {} \;
}

for sig in INT QUIT HUP TERM; do trap "cleanup; trap - $sig EXIT; kill -s $sig "'"$$"' "$sig"; done
trap cleanup EXIT

while ! time_up; do
    if [ ! -f buildwatch.pid ]; then
        echo "[$0] pidfile removed" && break
    fi
    if ! is_running '/make'; then
        echo "[$0] no make process detected (build done?)" && break
    fi

    do_sleep
    can_update || continue

    new_noisy=$(ls -l test/jtreg_output-* 2>&1 | md5sum)
    new_quiet=$(ls -l $builddir/openjdk*/build/*/tmp/rt-orig.jar $builddir/openjdk*/build/*/lib/tools.jar $builddir/openjdk*/build/*/lib/ct.sym 2>&1 | md5sum)
    if [ -n "$old_noisy" -a "$old_noisy" != "$new_noisy" ]; then
        # jtreg updated test files, so it should be updating stdout in its own
        # keep quiet and restart timer
        reset_timer
    elif [ -n "$old_quiet" -a "$old_quiet" != "$new_quiet" ]; then
        reset_timer
        echo "[$0] assembling jar file ..."
    elif is_running '/cc1|jar|java|gij'; then
        echo "[$0] compiler/java/jar running ..."
        reset_timer
    fi
    old_noisy=$new_noisy
    old_quiet=$new_quiet
done

echo "[$0] exiting"
rm -f buildwatch.pid