Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

259 lignes
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://lol.zoy.org/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. # Xbox development kit
  121. #
  122. append "[xdk]"
  123. if [ -n "$XEDK" ]; then
  124. # FIXME: we don't know how to check the version
  125. append "version = 2.0.20675.0"
  126. fi
  127. append ""
  128. #
  129. # PS3 development kit
  130. #
  131. append "[ps3sdk]"
  132. # Try to "detect" the SNC compiler on Windows
  133. if [ -n "$SN_PS3_PATH" ]; then
  134. append "version = 410"
  135. fi
  136. # The setup is easier to detect on Linux
  137. if [ -f "$CELLSDK/version-SDK" ]; then
  138. append "version = $(cat "$CELLSDK/version-SDK")"
  139. fi
  140. append ""
  141. #
  142. # mingw32 / mingw-w64
  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. append "[mingw32]"
  150. if i686-w64-mingw32-g++ --version >/dev/null 2>&1; then
  151. append "version = $(i686-w64-mingw32-g++ --version | sed -ne 's/.*g++ *([^)]*) *//p')"
  152. fi
  153. append ""
  154. #
  155. # Android NDK
  156. #
  157. append "[ndk]"
  158. if [ "$family" != "windows" ]; then
  159. if [ -f "$ANDROID_NDK_ROOT/RELEASE.TXT" ]; then
  160. append "version = $(cat "$ANDROID_NDK_ROOT/RELEASE.TXT")"
  161. fi
  162. fi
  163. append ""
  164. #
  165. # Google NaCl SDK
  166. #
  167. append "[pepper]"
  168. if [ "$family" != "windows" ]; then
  169. if [ -d "$NACL_SDK_ROOT" ]; then
  170. pepper_version=0
  171. for dir in "$NACL_SDK_ROOT/pepper_"*; do
  172. new_version="$(echo "$dir" | sed 's/.*_//')"
  173. if [ "$new_version" -gt "$pepper_version" ]; then
  174. pepper_version="$new_version"
  175. fi
  176. done
  177. if [ "$pepper_version" != 0 ]; then
  178. append "version = $pepper_version"
  179. fi
  180. fi
  181. fi
  182. append ""
  183. #
  184. # Raspberry Pi cross-compiler
  185. #
  186. append "[raspi]"
  187. if [ "$family" != "windows" ]; then
  188. if [ -d "$RASPI_SDK_ROOT/tools" ]; then
  189. append "version = 0"
  190. fi
  191. fi
  192. append ""
  193. #
  194. # Show what we just did here
  195. #
  196. cat "${conffile}"
  197. #
  198. # Fix system
  199. #
  200. if [ "$family" = "osx" ]; then
  201. # The version of Subversion shipped by Apple is antique; try to
  202. # use the one in /usr/local/bin instead.
  203. PATH="/usr/local/bin:$PATH"
  204. export PATH
  205. fi
  206. #
  207. # Launch everything
  208. #
  209. while : ; do
  210. bitten-slave "$url" \
  211. -f "${conffile}" \
  212. --name "$name" \
  213. --work-dir="${builddir}"
  214. rm -rf "${builddir}"
  215. sleep 10
  216. done
  217. exit 0