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

Last change on this file since 2083 was 2083, checked in by sam, 8 years ago

build: always use the same build directory in run-bitten.sh to
avoid leaving gigabytes of cruft behind us, and do our best to
clean up afterwards.

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