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.

release.sh 9.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327
  1. #!/bin/sh
  2. # Jar names of plugins to add to ALL installers. (* means all)
  3. plugins="ui_swing.jar ui_dummy.jar tabcompletion_bash.jar tabcompletion_mirc.jar dcc.jar dns.jar identd.jar lagdisplay.jar logging.jar systray.jar time.jar osd.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 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 "-c --channel [channel] Channel to pass to ant (if not passed, 'NONE', if passed without a value, 'STABLE')"
  44. echo " --compile Recompile the .jar file (otherwise use the existing file from dist/)"
  45. echo "---------------------"
  46. exit 0;
  47. }
  48. # Check for some CLI params
  49. LAST=""
  50. OPT=""
  51. BRANCH=""
  52. JARFILE=""
  53. JRE=""
  54. FULLJAR=""
  55. BUILDTARGET=""
  56. UPLOAD="0"
  57. TAG="0"
  58. TAGGED=""
  59. CHANNEL=""
  60. compileJar=""
  61. while test -n "$1"; do
  62. LAST=${1}
  63. case "$1" in
  64. --plugins|-p)
  65. shift
  66. plugins="${1}"
  67. ;;
  68. --target)
  69. shift
  70. BUILDTARGET="${1}"
  71. ;;
  72. --jar)
  73. shift
  74. JARFILE="--jar ${1} "
  75. ;;
  76. --fulljar)
  77. shift
  78. JARFILE="--jar ${1} "
  79. FULLJAR="1"
  80. ;;
  81. --jre|--jre64)
  82. JRE="${1} "
  83. ;;
  84. --plugins-linux|-pl)
  85. shift
  86. plugins_linux="${1}"
  87. ;;
  88. --plugins-windows|-pw)
  89. shift
  90. plugins_windows="${1}"
  91. ;;
  92. --plugins-osx|-po)
  93. shift
  94. plugins_osx="${1}"
  95. ;;
  96. --opt|-o)
  97. shift
  98. OPT="${1} "
  99. ;;
  100. --help|-h)
  101. showHelp;
  102. ;;
  103. --upload)
  104. UPLOAD="1";
  105. ;;
  106. --branch|-b)
  107. BRANCH="-b "
  108. ;;
  109. --compile)
  110. compileJar="--compile "
  111. ;;
  112. --tag|-t)
  113. if [ ${isSVN} -eq 1 ]; then
  114. shift
  115. REGEX="^[0-9]+(\.[0-9]+(\.[0-9]+)?)?$"
  116. CHECKTAG=`echo ${1} | egrep "${REGEX}"`
  117. if [ "" = "${CHECKTAG}" ]; then
  118. echo "Specified tag ("${1}") is invalid."
  119. exit 1;
  120. fi;
  121. TAGGED="-t ${1} "
  122. else
  123. TAGGED="-t "
  124. fi;
  125. # Always recompile if tagging
  126. compileJar="--compile "
  127. ;;
  128. --channel|-c)
  129. PASSEDPARAM=`echo "${2}" | grep -v ^- | grep -v " "`
  130. if [ "${PASSEDPARAM}" != "" ]; then
  131. shift
  132. CHANNEL="--channel ${PASSEDPARAM} ";
  133. else
  134. CHANNEL="--channel STABLE ";
  135. fi;
  136. # Always recompile if passing a channel
  137. compileJar="--compile "
  138. ;;
  139. esac
  140. shift
  141. done
  142. if [ ! -e output ]; then
  143. mkdir output
  144. fi;
  145. if [ "${plugins}" = "*" -o "${plugins_linux}" = "*" -o "${plugins_windows}" = "*" -o "${plugins_osx}" = "*" ]; then
  146. echo "Something is all.";
  147. allPlugins=""
  148. for thisfile in `ls -1 ../plugins/*.jar`; do
  149. allPlugins=${allPlugins}" ${thisfile##*/}"
  150. done
  151. if [ "${plugins}" = "*" ]; then plugins=${allPlugins}; fi
  152. if [ "${plugins_linux}" = "*" ]; then plugins_linux=${allPlugins}; fi
  153. if [ "${plugins_windows}" = "*" ]; then plugins_windows=${allPlugins}; fi
  154. if [ "${plugins_osx}" = "*" ]; then plugins_osx=${allPlugins}; fi
  155. fi;
  156. if [ ${isSVN} -eq 1 ]; then
  157. VERSION=""
  158. if [ "${LAST}" != "" ]; then
  159. if [ "${LAST}" = "trunk" ]; then
  160. VERSION="Trunk"
  161. RELEASE=""
  162. elif [ "${LAST}" = "this" ]; then
  163. # Work out what type of build this is!
  164. thisDIR=${PWD}
  165. cd ..
  166. tempDIR=${PWD##*/}
  167. if [ "${tempDIR}" = "trunk" ]; then
  168. VERSION="Trunk"
  169. echo "This is a trunk release.";
  170. else
  171. echo "This is not a trunk release.";
  172. VERSION=${tempDIR}
  173. cd ..
  174. tempDIR=${PWD##*/}
  175. if [ "${tempDIR}" = "tags" ]; then
  176. echo "Release of tag "${version}
  177. RELEASE="-r "${VERSION}
  178. TAG="1"
  179. elif [ "${tempDIR}" = "branches" ]; then
  180. echo "Release of branch "${version}
  181. BRANCH="-b "
  182. RELEASE="-r "${VERSION}
  183. else
  184. VERSION="Unknown"
  185. echo "Unknown release target - Building as trunk build"
  186. OPT="--current ${OPT}"
  187. fi
  188. fi;
  189. cd ${thisDIR}
  190. elif [ "${BRANCH}" != "" -a ! -e "../../branches/"${LAST} ]; then
  191. echo "Branch '"${LAST}"' not found."
  192. exit 1;
  193. elif [ "${BRANCH}" = "" -a ! -e "../../tags/"${LAST} ]; then
  194. echo "Tag '"${LAST}"' not found."
  195. exit 1;
  196. else
  197. RELEASE="-r "${LAST}
  198. fi
  199. else
  200. echo "Usage: ${0} [params] <release>"
  201. echo "Release can be either 'this', 'trunk' or a valid tag. (see ${0} --help for further information)"
  202. exit 1;
  203. fi
  204. else
  205. VERSION=`git branch | grep ^* | sed "s/^* //g"`
  206. if [ "${VERSION}" = "master" ]; then
  207. RELEASE=""
  208. else
  209. RELEASE="-r ${VERSION}"
  210. fi;
  211. fi;
  212. JAR=`which jar`
  213. JAVAC=`which javac`
  214. # OSX Users might have a non 1.6 javac, look specifically for it.
  215. if [ -e "/System/Library/Frameworks/JavaVM.framework/Versions/1.6.0/Commands/javac" ]; then
  216. JAVAC="/System/Library/Frameworks/JavaVM.framework/Versions/1.6.0/Commands/javac"
  217. elif [ -e "/System/Library/Frameworks/JavaVM.framework/Versions/1.6/Commands/javac" ]; then
  218. JAVAC="/System/Library/Frameworks/JavaVM.framework/Versions/1.6/Commands/javac"
  219. fi;
  220. THISDIR=${PWD}
  221. echo "================================================================"
  222. echo "Removing existing releases from output directory"
  223. echo "================================================================"
  224. rm -Rf output/*.run output/*.exe output/*.dmg
  225. # Copy default settings from www to trunk for compile (if they exist, and we are
  226. # building a new jar)
  227. REVERTLIST=""
  228. if [ "" = "${JARFILE}" ]; then
  229. if [ -e "${HOME}/www/updates/" ]; then
  230. echo "================================================================"
  231. echo "Applying settings update to this source"
  232. echo "================================================================"
  233. for updatedir in `ls -1 ../src/com/dmdirc/config/defaults/`; do
  234. src="${HOME}/www/updates/${updatedir}"
  235. if [ -e ${src} ]; then
  236. REVERTLIST=${REVERTLIST}" ../src/com/dmdirc/config/defaults/${updatedir}/"
  237. cp -Rfv ${src}/* ../src/com/dmdirc/config/defaults/${updatedir}/
  238. fi;
  239. done
  240. fi;
  241. fi;
  242. if [ "" = "${FULLJAR}" ]; then
  243. echo "================================================================"
  244. echo "Building Release Jar"
  245. echo "================================================================"
  246. cd jar
  247. ./makeJar.sh ${compileJar}${CHANNEL}${OPT}${JARFILE}${JRE}-c -k -s ${TAGGED}${BRANCH}${RELEASE} -p "${plugins}"
  248. RESULT=${?}
  249. cd ${THISDIR}
  250. if [ ${RESULT} -eq 0 ]; then
  251. JARNAME=`ls -1tr output | grep jar$ | tail -n 1`
  252. JARFILE="--jar ../output/${JARNAME} "
  253. else
  254. echo "Failed to build release jar, aborting."
  255. exit 1;
  256. fi;
  257. fi;
  258. if [ "linux" = "${BUILDTARGET}" -o "" = "${BUILDTARGET}" ]; then
  259. echo "================================================================"
  260. echo "Building linux installer"
  261. echo "================================================================"
  262. cd linux
  263. ./makeInstallerLinux.sh ${OPT}${JARFILE}${JRE}-k ${TAGGED}${BRANCH}${RELEASE} -p "${plugins_linux}"
  264. cd ${THISDIR}
  265. fi;
  266. if [ "windows" = "${BUILDTARGET}" -o "" = "${BUILDTARGET}" ]; then
  267. echo "================================================================"
  268. echo "Building Windows installer"
  269. echo "================================================================"
  270. cd windows
  271. ./makeInstallerWindows.sh ${OPT}${JARFILE}${JRE}-k -s ${TAGGED}${BRANCH}${RELEASE} -p "${plugins_windows}"
  272. cd ${THISDIR}
  273. fi;
  274. if [ "osx" = "${BUILDTARGET}" -o "" = "${BUILDTARGET}" ]; then
  275. echo "================================================================"
  276. echo "Building OSX Bundle"
  277. echo "================================================================"
  278. cd osx
  279. ./makeInstallerOSX.sh ${OPT}${JARFILE}-k -s ${TAGGED}${BRANCH}${RELEASE} -p "${plugins_osx}"
  280. cd ${THISDIR}
  281. fi;
  282. echo "================================================================"
  283. echo "Clean Up"
  284. echo "================================================================"
  285. # Now revert the trunk so as not to break updates.
  286. for updatedir in ${REVERTLIST}; do
  287. SVN=`which svn`
  288. ${SVN} revert ${updatedir}/*
  289. done;
  290. if [ "1" = "${UPLOAD}" -a "" != "${TAGGED}" ]; then
  291. echo "================================================================"
  292. echo "Uploading to GoogleCode"
  293. echo "================================================================"
  294. cd gcode
  295. sh uploads_release.sh -v ${VERSION}
  296. else
  297. echo "Not uploading to GoogleCode (Only tagged releases can be uploaded)"
  298. fi;
  299. echo "================================================================"
  300. echo "Release ready - see output folder"
  301. echo "================================================================"
  302. exit 0;