forked from sillsdev/FieldWorks
-
Notifications
You must be signed in to change notification settings - Fork 0
/
agent-build-fw.sh
executable file
·69 lines (62 loc) · 2.53 KB
/
agent-build-fw.sh
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
68
69
#!/bin/bash
###################################################
#
# Headless FieldWorks Build Script
#
# Original author: MarkS 2009-08
#
echo BUILD SCRIPT BEING USED:
cat "$0"
# Note that (false) does not quit the shell with 'set -e'. So (false) || false is needed.
# Check for required programs
REQUIRED_PROGRAMS="Xvfb Xephyr metacity"
for program in $REQUIRED_PROGRAMS
do
if ! { which $program > /dev/null; }; then
echo Error: FieldWorks build requires missing program \"$program\" to be installed.
exit 1
fi
done
# Get ready to build
. environ
export AssertUiEnabled=false # bypass assert message boxes for headless build
# Set environment variable to allow building on CI build agents without having to create
# /var/lib/fieldworks directory with correct permissions.
export FW_CommonAppData=$WORKSPACE/var/lib/fieldworks
# start ibus daemon just in case it's not yet running
/usr/bin/ibus-daemon --xim -d
# Set up a headless X server to run the graphical unit tests inside
# Avoid DISPLAY collisions with concurrent builds
let rand1=$RANDOM%50+20
let rand2=$RANDOM%50+20
# Run the tests inside Xephyr, and run Xephyr inside Xvfb.
export Xvfb_DISPLAY=:$rand1
while [ -e /tmp/.X${Xvfb_DISPLAY}-lock ]; do # Don't use an X display already in use
export Xvfb_DISPLAY=:$rand1
done
Xvfb -reset -terminate -screen 0 1280x1024x24 $Xvfb_DISPLAY & export Xvfb_PID=$!; sleep 3s
export Xephyr_DISPLAY=:$rand2
while [ -e /tmp/.X${Xephyr_DISPLAY}-lock ]; do # Don't use an X display already in use
export Xephyr_DISPLAY=:$rand2
done
DISPLAY=$Xvfb_DISPLAY Xephyr $Xephyr_DISPLAY -reset -terminate -screen 1280x1024 & export Xephyr_PID=$!; sleep 3s
export DISPLAY=$Xephyr_DISPLAY; metacity & sleep 3s
echo FieldWorks build using DISPLAY of $DISPLAY
# Upon exit, kill off Xvfb and Xephyr. This may not be necessary if Hudson cleans up whatever we start.
trap "{ echo Killing off Xvfb \(pid $Xvfb_PID\) and Xephyr \(pid $Xephyr_PID\) ...; kill $Xephyr_PID || (sleep 10s; kill -9 $Xephyr_PID); sleep 3s; kill $Xvfb_PID || (sleep 10s; kill -9 $Xvfb_PID); }" EXIT $EXIT_STATUS
# Build
echo Ready to start FieldWorks build
(cd Build && xbuild /t:refreshTargets)
case $1 in
release) (cd Build && xbuild /t:remakefw-jenkins /property:config=release);
;;
# the default operation is to rebuild with tests.
*) (cd Build && xbuild /t:remakefw-jenkins /property:action=test);
;;
build) (cd Build && xbuild /t:remakefw-jenkins);
;;
esac
EXIT_STATUS=$?
echo "FieldWorks build finished - exit status: $EXIT_STATUS"
exit $EXIT_STATUS
###################################################