blob: fc006957548ad55a9c3e3eed0d3dc1166a0e9e5e (
plain)
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
|
#!/bin/bash
set -e
cmd=$(echo "$@" | sed -e 's#"#\\"#g' -e "s#'#\\'#g")
dir=$(pwd)
if ! echo $dir | grep -q @spec@/benchspec; then
exec ssh @build_port@ @build_host@ "cd $(pwd); exec @cc_prefix@@cc@ $cmd"
fi
(
flock -s 123
if [ -f @count@ ] && [ "$(cat @count@)" -gt "0" ]; then
# Fast-track no-exclusive locking case.
ssh @build_port@ @build_host@ "cd $(pwd); exec @cc_prefix@@cc@ $cmd"
exit $?
fi
flock -x 123
touch @count@
n=$(cat @count@)
if [ x"$n" = x"" ]; then n="0"; fi
if [ x"$n" = x"0" ]; then
rsync -e "ssh @build_port@" --rsync-path "mkdir -p $dir; rsync" -az --delete $dir/ @build_host@:$dir/
fi
n=$(($n+1))
echo $n > @count@
exit 123
) 123>@lock@ | cat
res=${PIPESTATUS[0]}
if [ x"$res" != x"123" ]; then
exit $res
fi
(
flock -s 123
ssh @build_port@ @build_host@ "cd $(pwd); exec @cc_prefix@@cc@ $cmd" | cat
res=${PIPESTATUS[0]}
flock -x 123
n=$(cat @count@)
if ! [ $n -gt 0 ]; then exit 123; fi
n=$(($n-1))
echo $n > @count@
if [ x"$n" = x"0" ]; then
rsync -e "ssh @build_port@" -az --delete @build_host@:$dir/ $dir/
fi
exit $res
) 123>@lock@
|