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