25'ten fazla konu seçemezsiniz Konular bir harf veya rakamla başlamalı, kısa çizgiler ('-') içerebilir ve en fazla 35 karakter uzunluğunda olabilir.
 
 
 

275 satır
5.1 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. i*86) processor="i386" ;;
  87. esac
  88. # Windows defines a lot of crazy shit, try to make sense of it
  89. case "$PROCESSOR_ARCHITECTURE" in
  90. amd64|AMD64) processor="amd64" ;;
  91. x86|X86) processor="i386" ;;
  92. esac
  93. case "$PROCESSOR_ARCHITEW6432" in
  94. amd64|AMD64) processor="amd64" ;;
  95. x86|X86) processor="i386" ;;
  96. esac
  97. append "processor = $processor"
  98. append ""
  99. #
  100. # Authentication information
  101. #
  102. append "[authentication]"
  103. append "username = $1"
  104. append "password = $2"
  105. append ""
  106. #
  107. # Visual Studio configuration
  108. #
  109. # FIXME: we also need to check for the Visual Studio SDK
  110. append "[msvc]"
  111. if [ -n "$VS100COMNTOOLS" ]; then
  112. append "version = 10"
  113. elif [ -n "$VS110COMNTOOLS" ]; then
  114. append "version = 11"
  115. elif [ -n "$VS90COMNTOOLS" ]; then
  116. append "version = 9"
  117. fi
  118. append ""
  119. #
  120. # iOS development kit
  121. #
  122. append "[ios]"
  123. if [ -d "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS6.1.sdk" ]; then
  124. append "version = 6.1"
  125. fi
  126. append ""
  127. #
  128. # Xbox development kit
  129. #
  130. append "[xdk]"
  131. if [ -n "$XEDK" ]; then
  132. # FIXME: we don't know how to check the version
  133. append "version = 2.0.20675.0"
  134. fi
  135. append ""
  136. #
  137. # PS3 development kit
  138. #
  139. append "[ps3sdk]"
  140. # Try to "detect" the SNC compiler on Windows
  141. if [ -n "$SN_PS3_PATH" ]; then
  142. append "version = 410"
  143. fi
  144. # The setup is easier to detect on Linux
  145. if [ -f "$CELLSDK/version-SDK" ]; then
  146. append "version = $(cat "$CELLSDK/version-SDK")"
  147. fi
  148. append ""
  149. #
  150. # mingw32 / mingw-w64
  151. #
  152. append "[mingw64]"
  153. if x86_64-w64-mingw32-g++ --version >/dev/null 2>&1; then
  154. append "version = $(x86_64-w64-mingw32-g++ --version | sed -ne 's/.*g++ *([^)]*) *//p')"
  155. fi
  156. append ""
  157. append "[mingw32]"
  158. if i686-w64-mingw32-g++ --version >/dev/null 2>&1; then
  159. append "version = $(i686-w64-mingw32-g++ --version | sed -ne 's/.*g++ *([^)]*) *//p')"
  160. fi
  161. append ""
  162. #
  163. # Android NDK
  164. #
  165. append "[ndk]"
  166. if [ "$family" != "windows" ]; then
  167. if [ -f "$ANDROID_NDK_ROOT/RELEASE.TXT" ]; then
  168. append "version = $(cat "$ANDROID_NDK_ROOT/RELEASE.TXT")"
  169. fi
  170. fi
  171. append ""
  172. #
  173. # Google NaCl SDK
  174. #
  175. append "[pepper]"
  176. if [ "$family" != "windows" ]; then
  177. if [ -d "$NACL_SDK_ROOT" ]; then
  178. pepper_version=0
  179. for dir in "$NACL_SDK_ROOT/pepper_"*; do
  180. new_version="$(echo "$dir" | sed 's/.*_//')"
  181. if [ "$new_version" -gt "$pepper_version" ]; then
  182. pepper_version="$new_version"
  183. fi
  184. done
  185. if [ "$pepper_version" != 0 ]; then
  186. append "version = $pepper_version"
  187. fi
  188. fi
  189. fi
  190. append ""
  191. #
  192. # Raspberry Pi cross-compiler
  193. #
  194. append "[raspi]"
  195. if [ "$family" != "windows" ]; then
  196. if [ -d "$RASPI_SDK_ROOT/tools" ]; then
  197. append "version = 0"
  198. fi
  199. fi
  200. append ""
  201. #
  202. # Show what we just did here
  203. #
  204. cat "${conffile}"
  205. #
  206. # Fix system
  207. #
  208. if [ "$family" = "osx" ]; then
  209. # The version of Subversion shipped by Apple is antique; try to
  210. # use the one in /usr/local/bin instead.
  211. PATH="/usr/local/bin:$PATH"
  212. export PATH
  213. # HACK: the version of llvm-g++ shipped by Apple has an insane
  214. # memory leak; use clang++ instead.
  215. CC="clang"
  216. export CC
  217. CXX="clang++"
  218. export CXX
  219. fi
  220. #
  221. # Launch everything
  222. #
  223. while : ; do
  224. bitten-slave "$url" \
  225. -f "${conffile}" \
  226. --name "$name" \
  227. --work-dir="${builddir}"
  228. rm -rf "${builddir}"
  229. sleep 10
  230. done
  231. exit 0