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.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303
  1. #!/bin/sh
  2. # Jar names of plugins to add to ALL installers. (* means all)
  3. plugins="ui_swing.jar ui_dummy.jar dcc.jar dns.jar identd.jar lagdisplay.jar logging.jar systray.jar timeplugin.jar osdplugin.jar"
  4. # Additional Jar names of plugins to add to only Windows installers. (* means all)
  5. plugins_windows=""
  6. # Additional Jar names of plugins to add to only linux installers. (* means all)
  7. plugins_linux=""
  8. # Additional Jar names of plugins to add to only osx installers. (* means all)
  9. plugins_osx=""
  10. # Are we a git working copy, or SVN?
  11. if [ -e ".svn" ]; then
  12. isSVN=1
  13. else
  14. isSVN=0
  15. fi;
  16. showHelp() {
  17. echo "This will generate the different DMDirc installers."
  18. if [ ${isSVN} -eq 1 ]; then
  19. echo "Usage: ${0} [params] <release>"
  20. echo "Release can be either 'trunk', 'this', a valid tag, or a branch (if -b is passed)"
  21. else
  22. echo "Usage: ${0} [params]"
  23. fi;
  24. echo "The following params are known:"
  25. echo "---------------------"
  26. if [ ${isSVN} -eq 1 ]; then
  27. echo "-b, --branch <release> is a branch"
  28. else
  29. echo "-t, --tag <release> This is a tagged release"
  30. fi;
  31. echo " --jar <file> Use <file> instead of compiling a jar."
  32. echo " --fulljar <file> Use <file> instead of compiling a jar, and don't run makeJar on it."
  33. echo " --jre Include a jre in the installers."
  34. echo " --jre64 Include a 64bit jre in the installers."
  35. echo " --target <target> Build only a specific target. <target> should be one of 'windows', 'linux' or 'osx'."
  36. echo "-p, --plugins <plugins> Plugins to add to all the jars."
  37. echo "-pl, --plugins-linux <plugins> Plugins to linux installer."
  38. echo "-pw, --plugins-windows <plugins> Plugins to windows installer."
  39. echo "-po --plugins-osx <plugins> Plugins to osx installer."
  40. echo "-h, --help Help information"
  41. echo "-o, --opt <options> Additional options to pass to the make*Installer.sh files"
  42. echo " --upload Try to upload to google code when done (Only works on tags)"
  43. echo "---------------------"
  44. exit 0;
  45. }
  46. # Check for some CLI params
  47. LAST=""
  48. OPT=""
  49. BRANCH=""
  50. JARFILE=""
  51. JRE=""
  52. FULLJAR=""
  53. BUILDTARGET=""
  54. UPLOAD="0"
  55. TAG="0"
  56. TAGGED=""
  57. while test -n "$1"; do
  58. LAST=${1}
  59. case "$1" in
  60. --plugins|-p)
  61. shift
  62. plugins="${1}"
  63. ;;
  64. --target)
  65. shift
  66. BUILDTARGET="${1}"
  67. ;;
  68. --jar)
  69. shift
  70. JARFILE="--jar ${1} "
  71. ;;
  72. --fulljar)
  73. shift
  74. JARFILE="--jar ${1} "
  75. FULLJAR="1"
  76. ;;
  77. --jre|--jre64)
  78. JRE="${1} "
  79. ;;
  80. --plugins-linux|-pl)
  81. shift
  82. plugins_linux="${1}"
  83. ;;
  84. --plugins-windows|-pw)
  85. shift
  86. plugins_windows="${1}"
  87. ;;
  88. --plugins-osx|-po)
  89. shift
  90. plugins_osx="${1}"
  91. ;;
  92. --opt|-o)
  93. shift
  94. OPT="${1} "
  95. ;;
  96. --help|-h)
  97. showHelp;
  98. ;;
  99. --upload)
  100. UPLOAD="1";
  101. ;;
  102. --branch|-b)
  103. BRANCH="-b "
  104. ;;
  105. --tag|-t)
  106. shift
  107. REGEX="^[0-9]+(\.[0-9]+(\.[0-9]+)?)?$"
  108. CHECKTAG=`echo ${1} | egrep "${REGEX}"`
  109. if [ "" = "${CHECKTAG}" ]; then
  110. echo "Specified tag ("${1}") is invalid."
  111. exit 1;
  112. fi;
  113. TAGGED="-t ${1} "
  114. ;;
  115. esac
  116. shift
  117. done
  118. if [ ! -e output ]; then
  119. mkdir output
  120. fi;
  121. if [ "${plugins}" = "*" -o "${plugins_linux}" = "*" -o "${plugins_windows}" = "*" -o "${plugins_osx}" = "*" ]; then
  122. echo "Something is all.";
  123. allPlugins=""
  124. for thisfile in `ls -1 ../plugins/*.jar`; do
  125. allPlugins=${allPlugins}" ${thisfile##*/}"
  126. done
  127. if [ "${plugins}" = "*" ]; then plugins=${allPlugins}; fi
  128. if [ "${plugins_linux}" = "*" ]; then plugins_linux=${allPlugins}; fi
  129. if [ "${plugins_windows}" = "*" ]; then plugins_windows=${allPlugins}; fi
  130. if [ "${plugins_osx}" = "*" ]; then plugins_osx=${allPlugins}; fi
  131. fi;
  132. if [ ${isSVN} -eq 1 ]; then
  133. VERSION=""
  134. if [ "${LAST}" != "" ]; then
  135. if [ "${LAST}" = "trunk" ]; then
  136. VERSION="Trunk"
  137. RELEASE=""
  138. elif [ "${LAST}" = "this" ]; then
  139. # Work out what type of build this is!
  140. thisDIR=${PWD}
  141. cd ..
  142. tempDIR=${PWD##*/}
  143. if [ "${tempDIR}" = "trunk" ]; then
  144. VERSION="Trunk"
  145. echo "This is a trunk release.";
  146. else
  147. echo "This is not a trunk release.";
  148. VERSION=${tempDIR}
  149. cd ..
  150. tempDIR=${PWD##*/}
  151. if [ "${tempDIR}" = "tags" ]; then
  152. echo "Release of tag "${version}
  153. RELEASE="-r "${VERSION}
  154. TAG="1"
  155. elif [ "${tempDIR}" = "branches" ]; then
  156. echo "Release of branch "${version}
  157. BRANCH="-b "
  158. RELEASE="-r "${VERSION}
  159. else
  160. VERSION="Unknown"
  161. echo "Unknown release target - Building as trunk build"
  162. OPT="--current ${OPT}"
  163. fi
  164. fi;
  165. cd ${thisDIR}
  166. elif [ "${BRANCH}" != "" -a ! -e "../../branches/"${LAST} ]; then
  167. echo "Branch '"${LAST}"' not found."
  168. exit 1;
  169. elif [ "${BRANCH}" = "" -a ! -e "../../tags/"${LAST} ]; then
  170. echo "Tag '"${LAST}"' not found."
  171. exit 1;
  172. else
  173. RELEASE="-r "${LAST}
  174. fi
  175. else
  176. echo "Usage: ${0} [params] <release>"
  177. echo "Release can be either 'this', 'trunk' or a valid tag. (see ${0} --help for further information)"
  178. exit 1;
  179. fi
  180. else
  181. VERSION=`git branch | grep ^* | sed "s/^* //g"`
  182. if [ "${VERSION}" = "master" ]; then
  183. RELEASE=""
  184. else
  185. RELEASE="-r ${VERSION}"
  186. fi;
  187. fi;
  188. JAR=`which jar`
  189. JAVAC=`which javac`
  190. # OSX Users might have a non 1.6 javac, look specifically for it.
  191. if [ -e "/System/Library/Frameworks/JavaVM.framework/Versions/1.6.0/Commands/javac" ]; then
  192. JAVAC="/System/Library/Frameworks/JavaVM.framework/Versions/1.6.0/Commands/javac"
  193. elif [ -e "/System/Library/Frameworks/JavaVM.framework/Versions/1.6/Commands/javac" ]; then
  194. JAVAC="/System/Library/Frameworks/JavaVM.framework/Versions/1.6/Commands/javac"
  195. fi;
  196. THISDIR=${PWD}
  197. echo "================================================================"
  198. echo "Removing existing releases from output directory"
  199. echo "================================================================"
  200. rm -Rf output/*.run output/*.exe output/*.dmg
  201. # Copy default settings from www to trunk for compile (if they exist, and we are
  202. # building a new jar)
  203. REVERTLIST=""
  204. if [ "" = "${JARFILE}" ]; then
  205. if [ -e "${HOME}/www/updates/" ]; then
  206. echo "================================================================"
  207. echo "Applying settings update to this source"
  208. echo "================================================================"
  209. for updatedir in `ls -1 ../src/com/dmdirc/config/defaults/`; do
  210. src="${HOME}/www/updates/${updatedir}"
  211. if [ -e ${src} ]; then
  212. REVERTLIST=${REVERTLIST}" ../src/com/dmdirc/config/defaults/${updatedir}/"
  213. cp -Rfv ${src}/* ../src/com/dmdirc/config/defaults/${updatedir}/
  214. fi;
  215. done
  216. fi;
  217. fi;
  218. if [ "" = "${FULLJAR}" ]; then
  219. echo "================================================================"
  220. echo "Building Release Jar"
  221. echo "================================================================"
  222. cd jar
  223. ./makeJar.sh ${OPT}${JARFILE}${JRE}-c -k -s ${TAGGED}${BRANCH}${RELEASE} -p "${plugins}"
  224. RESULT=${?}
  225. cd ${THISDIR}
  226. if [ ${RESULT} -eq 0 ]; then
  227. JARNAME=`ls -1tr output | grep jar$ | tail -n 1`
  228. JARFILE="--jar ../output/${JARNAME} "
  229. else
  230. echo "Failed to build release jar, aborting."
  231. exit 1;
  232. fi;
  233. fi;
  234. if [ "linux" = "${BUILDTARGET}" -o "" = "${BUILDTARGET}" ]; then
  235. echo "================================================================"
  236. echo "Building linux installer"
  237. echo "================================================================"
  238. cd linux
  239. ./makeInstallerLinux.sh ${OPT}${JARFILE}${JRE}-k ${TAGGED}${BRANCH}${RELEASE} -p "${plugins_linux}"
  240. cd ${THISDIR}
  241. fi;
  242. if [ "windows" = "${BUILDTARGET}" -o "" = "${BUILDTARGET}" ]; then
  243. echo "================================================================"
  244. echo "Building Windows installer"
  245. echo "================================================================"
  246. cd windows
  247. ./makeInstallerWindows.sh ${OPT}${JARFILE}${JRE}-k -s ${TAGGED}${BRANCH}${RELEASE} -p "${plugins_windows}"
  248. cd ${THISDIR}
  249. fi;
  250. if [ "osx" = "${BUILDTARGET}" -o "" = "${BUILDTARGET}" ]; then
  251. echo "================================================================"
  252. echo "Building OSX Bundle"
  253. echo "================================================================"
  254. cd osx
  255. ./makeInstallerOSX.sh ${OPT}${JARFILE}-k -s ${TAGGED}${BRANCH}${RELEASE} -p "${plugins_osx}"
  256. cd ${THISDIR}
  257. fi;
  258. echo "================================================================"
  259. echo "Clean Up"
  260. echo "================================================================"
  261. # Now revert the trunk so as not to break updates.
  262. for updatedir in ${REVERTLIST}; do
  263. SVN=`which svn`
  264. ${SVN} revert ${updatedir}/*
  265. done;
  266. if [ "1" = "${UPLOAD}" -a "1" = "${TAG}" ]; then
  267. echo "================================================================"
  268. echo "Uploading to GoogleCode"
  269. echo "================================================================"
  270. cd gcode
  271. sh uploads_release.sh -v ${VERSION}
  272. else
  273. echo "Not uploading to GoogleCode"
  274. fi;
  275. echo "================================================================"
  276. echo "Release ready - see output folder"
  277. echo "================================================================"
  278. exit 0;