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

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