Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

278 рядки
5.2 KiB

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