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.
 
 
 

256 satır
4.7 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. # mingw32 / mingw-w64
  132. #
  133. append "[mingw64]"
  134. if x86_64-w64-mingw32-g++ --version >/dev/null 2>&1; then
  135. append "version = $(x86_64-w64-mingw32-g++ --version | sed -ne 's/.*g++ *([^)]*) *//p')"
  136. fi
  137. append ""
  138. append "[mingw32]"
  139. if i686-w64-mingw32-g++ --version >/dev/null 2>&1; then
  140. append "version = $(i686-w64-mingw32-g++ --version | sed -ne 's/.*g++ *([^)]*) *//p')"
  141. fi
  142. append ""
  143. #
  144. # Emscripten
  145. #
  146. append "[emscripten]"
  147. if em++ --version >/dev/null 2>&1; then
  148. append "version = $(em++ --version | sed -ne 's/.*emcc.* \([0-9.]\{1,\}\).*/\1/p')"
  149. fi
  150. append ""
  151. #
  152. # Android NDK
  153. #
  154. append "[ndk]"
  155. if [ "$family" != "windows" ]; then
  156. if [ -f "$ANDROID_NDK_ROOT/RELEASE.TXT" ]; then
  157. append "version = $(cat "$ANDROID_NDK_ROOT/RELEASE.TXT")"
  158. fi
  159. fi
  160. append ""
  161. #
  162. # Google NaCl SDK
  163. #
  164. append "[pepper]"
  165. if [ "$family" != "windows" ]; then
  166. if [ -f "$NACL_SDK_ROOT/README" ]; then
  167. pepper_version=$(sed -ne 's/Version: //p' "$NACL_SDK_ROOT/README")
  168. if [ "x$pepper_version" != "x" ]; then
  169. append "version = $pepper_version"
  170. fi
  171. fi
  172. fi
  173. append ""
  174. #
  175. # Raspberry Pi cross-compiler
  176. #
  177. append "[raspi]"
  178. if [ "$family" != "windows" ]; then
  179. if [ -d "$RASPI_SDK_ROOT/tools" ]; then
  180. append "version = 0"
  181. fi
  182. fi
  183. append ""
  184. #
  185. # Show what we just did here
  186. #
  187. cat "${conffile}"
  188. #
  189. # Fix system
  190. #
  191. if [ "$family" = "osx" ]; then
  192. # The version of Subversion shipped by Apple is antique; try to
  193. # use the one in /usr/local/bin instead.
  194. PATH="/usr/local/bin:$PATH"
  195. export PATH
  196. # HACK: the version of llvm-g++ shipped by Apple has an insane
  197. # memory leak; use clang++ instead.
  198. CC="clang"
  199. export CC
  200. CXX="clang++"
  201. export CXX
  202. fi
  203. #
  204. # Launch everything
  205. #
  206. while : ; do
  207. bitten-slave "$url" \
  208. -f "${conffile}" \
  209. --name "$name" \
  210. --work-dir="${builddir}"
  211. rm -rf "${builddir}"
  212. sleep 10
  213. done
  214. exit 0