You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

233 lines
4.2 KiB

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