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.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330
  1. #!/bin/sh
  2. # Jar names of plugins to add to ALL installers. (* means all)
  3. plugins="ui_swing.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. # Remove plugins added by createAllPluginJar
  157. zip -d dist/DMDirc.jar plugins plugins/*
  158. if [ ${isSVN} -eq 1 ]; then
  159. VERSION=""
  160. if [ "${LAST}" != "" ]; then
  161. if [ "${LAST}" = "trunk" ]; then
  162. VERSION="Trunk"
  163. RELEASE=""
  164. elif [ "${LAST}" = "this" ]; then
  165. # Work out what type of build this is!
  166. thisDIR=${PWD}
  167. cd ..
  168. tempDIR=${PWD##*/}
  169. if [ "${tempDIR}" = "trunk" ]; then
  170. VERSION="Trunk"
  171. echo "This is a trunk release.";
  172. else
  173. echo "This is not a trunk release.";
  174. VERSION=${tempDIR}
  175. cd ..
  176. tempDIR=${PWD##*/}
  177. if [ "${tempDIR}" = "tags" ]; then
  178. echo "Release of tag "${version}
  179. RELEASE="-r "${VERSION}
  180. TAG="1"
  181. elif [ "${tempDIR}" = "branches" ]; then
  182. echo "Release of branch "${version}
  183. BRANCH="-b "
  184. RELEASE="-r "${VERSION}
  185. else
  186. VERSION="Unknown"
  187. echo "Unknown release target - Building as trunk build"
  188. OPT="--current ${OPT}"
  189. fi
  190. fi;
  191. cd ${thisDIR}
  192. elif [ "${BRANCH}" != "" -a ! -e "../../branches/"${LAST} ]; then
  193. echo "Branch '"${LAST}"' not found."
  194. exit 1;
  195. elif [ "${BRANCH}" = "" -a ! -e "../../tags/"${LAST} ]; then
  196. echo "Tag '"${LAST}"' not found."
  197. exit 1;
  198. else
  199. RELEASE="-r "${LAST}
  200. fi
  201. else
  202. echo "Usage: ${0} [params] <release>"
  203. echo "Release can be either 'this', 'trunk' or a valid tag. (see ${0} --help for further information)"
  204. exit 1;
  205. fi
  206. else
  207. VERSION=`git branch | grep ^* | sed "s/^* //g"`
  208. if [ "${VERSION}" = "master" ]; then
  209. RELEASE=""
  210. else
  211. RELEASE="-r ${VERSION}"
  212. fi;
  213. fi;
  214. JAR=`which jar`
  215. JAVAC=`which javac`
  216. # OSX Users might have a non 1.6 javac, look specifically for it.
  217. if [ -e "/System/Library/Frameworks/JavaVM.framework/Versions/1.6.0/Commands/javac" ]; then
  218. JAVAC="/System/Library/Frameworks/JavaVM.framework/Versions/1.6.0/Commands/javac"
  219. elif [ -e "/System/Library/Frameworks/JavaVM.framework/Versions/1.6/Commands/javac" ]; then
  220. JAVAC="/System/Library/Frameworks/JavaVM.framework/Versions/1.6/Commands/javac"
  221. fi;
  222. THISDIR=${PWD}
  223. echo "================================================================"
  224. echo "Removing existing releases from output directory"
  225. echo "================================================================"
  226. rm -Rf output/*.run output/*.exe output/*.dmg
  227. # Copy default settings from www to trunk for compile (if they exist, and we are
  228. # building a new jar)
  229. REVERTLIST=""
  230. if [ "" = "${JARFILE}" ]; then
  231. if [ -e "${HOME}/www/updates/" ]; then
  232. echo "================================================================"
  233. echo "Applying settings update to this source"
  234. echo "================================================================"
  235. for updatedir in `ls -1 ../src/com/dmdirc/config/defaults/`; do
  236. src="${HOME}/www/updates/${updatedir}"
  237. if [ -e ${src} ]; then
  238. REVERTLIST=${REVERTLIST}" ../src/com/dmdirc/config/defaults/${updatedir}/"
  239. cp -Rfv ${src}/* ../src/com/dmdirc/config/defaults/${updatedir}/
  240. fi;
  241. done
  242. fi;
  243. fi;
  244. if [ "" = "${FULLJAR}" ]; then
  245. echo "================================================================"
  246. echo "Building Release Jar"
  247. echo "================================================================"
  248. cd jar
  249. ./makeJar.sh ${compileJar}${CHANNEL}${OPT}${JARFILE}${JRE}-c -k -s ${TAGGED}${BRANCH}${RELEASE} -p "${plugins}"
  250. RESULT=${?}
  251. cd ${THISDIR}
  252. if [ ${RESULT} -eq 0 ]; then
  253. JARNAME=`ls -1tr output | grep jar$ | tail -n 1`
  254. JARFILE="--jar ../output/${JARNAME} "
  255. else
  256. echo "Failed to build release jar, aborting."
  257. exit 1;
  258. fi;
  259. fi;
  260. if [ "linux" = "${BUILDTARGET}" -o "" = "${BUILDTARGET}" ]; then
  261. echo "================================================================"
  262. echo "Building linux installer"
  263. echo "================================================================"
  264. cd linux
  265. ./makeInstallerLinux.sh ${OPT}${JARFILE}${JRE}-k ${TAGGED}${BRANCH}${RELEASE} -p "${plugins_linux}"
  266. cd ${THISDIR}
  267. fi;
  268. if [ "windows" = "${BUILDTARGET}" -o "" = "${BUILDTARGET}" ]; then
  269. echo "================================================================"
  270. echo "Building Windows installer"
  271. echo "================================================================"
  272. cd windows
  273. ./makeInstallerWindows.sh ${OPT}${JARFILE}${JRE}-k -s ${TAGGED}${BRANCH}${RELEASE} -p "${plugins_windows}"
  274. cd ${THISDIR}
  275. fi;
  276. if [ "osx" = "${BUILDTARGET}" -o "" = "${BUILDTARGET}" ]; then
  277. echo "================================================================"
  278. echo "Building OSX Bundle"
  279. echo "================================================================"
  280. cd osx
  281. ./makeInstallerOSX.sh ${OPT}${JARFILE}-k -s ${TAGGED}${BRANCH}${RELEASE} -p "${plugins_osx}"
  282. cd ${THISDIR}
  283. fi;
  284. echo "================================================================"
  285. echo "Clean Up"
  286. echo "================================================================"
  287. # Now revert the trunk so as not to break updates.
  288. for updatedir in ${REVERTLIST}; do
  289. SVN=`which svn`
  290. ${SVN} revert ${updatedir}/*
  291. done;
  292. if [ "1" = "${UPLOAD}" -a "" != "${TAGGED}" ]; then
  293. echo "================================================================"
  294. echo "Uploading to GoogleCode"
  295. echo "================================================================"
  296. cd gcode
  297. sh uploads_release.sh -v ${VERSION}
  298. else
  299. echo "Not uploading to GoogleCode (Only tagged releases can be uploaded)"
  300. fi;
  301. echo "================================================================"
  302. echo "Release ready - see output folder"
  303. echo "================================================================"
  304. exit 0;