source: trunk/build/run-bitten.sh @ 2217

Last change on this file since 2217 was 2088, checked in by sam, 7 years ago

build: honour the TMPDIR, TEMP etc. environment variables.

  • Property svn:executable set to *
File size: 4.5 KB
Line 
1#!/bin/sh
2
3tmpdir="$TMPDIR"
4if [ -z "${tmpdir}" ]; then tmpdir="$TEMP"; fi
5if [ -z "${tmpdir}" ]; then tmpdir="$TEMPDIR"; fi
6if [ -z "${tmpdir}" ]; then tmpdir="$TMP"; fi
7if [ -z "${tmpdir}" ]; then tmpdir="/tmp"; fi
8
9conffile="`mktemp -q "${tmpdir}/lol-bitten-XXXXXXXX" 2>/dev/null`"
10if [ "${conffile}" = "" ]; then
11    conffile="`mktemp 2>/dev/null`"
12fi
13builddir="${tmpdir}/lol-bitten-`whoami`"
14url="http://lol.zoy.org/builds"
15
16#
17# Utility functions
18#
19
20append() {
21    echo "$*" >> "${conffile}"
22}
23
24cleanup() {
25    rm -f "${conffile}"
26    rm -rf "${builddir}"
27}
28
29bailout() {
30    cleanup
31    # Exit gracefully
32    exit 0
33}
34
35trap bailout HUP INT QUIT ABRT KILL ALRM TERM
36
37#
38# Check for command line
39#
40
41if [ "$#" != 2 ]; then
42    echo "Usage: $0 <username> <password>"
43    exit 1
44fi
45
46#
47# Clean up working directory
48#
49cleanup
50if [ -e "${builddir}" ]; then
51    echo "Error: cannot get rid of ${builddir}"
52    exit 1
53fi
54
55#
56# Operating system information
57#
58
59append "[os]"
60append "name = `uname -srmo 2>/dev/null || uname -srm`"
61append "version = 0"
62family="`uname -s | tr A-Z a-z`"
63case "$family" in
64  mingw*) family="windows" ;;
65  darwin*) family="osx" ;;
66esac
67append "family = $family"
68# This random token prevents HTTP conflicts when several instances
69# are run from the same machine.
70append "token = $$$RANDOM"
71append ""
72
73#
74# Hardware information
75#
76
77append "[machine]"
78name="`uname -n | tr A-Z a-z | sed 's/[.].*//'`"
79case "$name" in
80  d*e*s*o*v*) name="putois" ;;
81esac
82append "name = $name"
83processor="`uname -m`"
84case "$processor" in
85  x86_64) processor="amd64" ;;
86  i*86) processor="i386" ;;
87esac
88# Windows defines a lot of crazy shit, try to make sense of it
89case "$PROCESSOR_ARCHITECTURE" in
90  amd64|AMD64) processor="amd64" ;;
91  x86|X86) processor="i386" ;;
92esac
93case "$PROCESSOR_ARCHITEW6432" in
94  amd64|AMD64) processor="amd64" ;;
95  x86|X86) processor="i386" ;;
96esac
97append "processor = $processor"
98append ""
99
100#
101# Authentication information
102#
103
104append "[authentication]"
105append "username = $1"
106append "password = $2"
107append ""
108
109#
110# Visual Studio configuration
111#
112
113# FIXME: we also need to check for the Visual Studio SDK
114append "[msvc]"
115if [ -n "$VS100COMNTOOLS" ]; then
116    append "version = 10"
117elif [ -n "$VS110COMNTOOLS" ]; then
118    append "version = 11"
119elif [ -n "$VS90COMNTOOLS" ]; then
120    append "version = 9"
121fi
122append ""
123
124#
125# Xbox development kit
126#
127
128append "[xdk]"
129if [ -n "$XEDK" ]; then
130    # FIXME: we don't know how to check the version
131    append "version = 2.0.20675.0"
132fi
133append ""
134
135#
136# PS3 development kit
137#
138
139append "[ps3sdk]"
140# Try to "detect" the SNC compiler on Windows
141if [ -n "$SN_PS3_PATH" ]; then
142    append "version = 410"
143fi
144# The setup is easier to detect on Linux
145if [ -f "$CELLSDK/version-SDK" ]; then
146    append "version = $(cat "$CELLSDK/version-SDK")"
147fi
148append ""
149
150#
151# mingw32 / mingw-w64
152#
153
154append "[mingw64]"
155if x86_64-w64-mingw32-g++ --version >/dev/null 2>&1; then
156    append "version = $(x86_64-w64-mingw32-g++ --version | sed -ne 's/.*g++ *([^)]*) *//p')"
157fi
158append ""
159
160append "[mingw32]"
161if i686-w64-mingw32-g++ --version >/dev/null 2>&1; then
162    append "version = $(i686-w64-mingw32-g++ --version | sed -ne 's/.*g++ *([^)]*) *//p')"
163fi
164append ""
165
166#
167# Android NDK
168#
169
170append "[ndk]"
171if [ "$family" != "windows" ]; then
172    if [ -f "$ANDROID_NDK_ROOT/RELEASE.TXT" ]; then
173        append "version = $(cat "$ANDROID_NDK_ROOT/RELEASE.TXT")"
174    fi
175fi
176append ""
177
178#
179# Google NaCl SDK
180#
181
182append "[pepper]"
183if [ "$family" != "windows" ]; then
184    if [ -d "$NACL_SDK_ROOT" ]; then
185        pepper_version=0
186        for dir in "$NACL_SDK_ROOT/pepper_"*; do
187            new_version="$(echo "$dir" | sed 's/.*_//')"
188            if [ "$new_version" -gt "$pepper_version" ]; then
189                pepper_version="$new_version"
190            fi
191        done
192        if [ "$pepper_version" != 0 ]; then
193            append "version = $pepper_version"
194        fi
195    fi
196fi
197append ""
198
199#
200# Raspberry Pi cross-compiler
201#
202
203append "[raspi]"
204if [ "$family" != "windows" ]; then
205    if [ -d "$RASPI_SDK_ROOT/tools" ]; then
206        append "version = 0"
207    fi
208fi
209append ""
210
211#
212# Show what we just did here
213#
214
215cat "${conffile}"
216
217#
218# Fix system
219#
220
221if [ "$family" = "osx" ]; then
222    # The version of Subversion shipped by Apple is antique; try to
223    # use the one in /usr/local/bin instead.
224    PATH="/usr/local/bin:$PATH"
225    export PATH
226fi
227
228#
229# Launch everything
230#
231
232while : ; do
233    bitten-slave "$url" \
234        -f "${conffile}" \
235        --name "$name" \
236        --work-dir="${builddir}"
237    rm -rf "${builddir}"
238    sleep 10
239done
240
241bailout
242
Note: See TracBrowser for help on using the repository browser.