Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

makeInstallerLinux.sh 9.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399
  1. #!/bin/sh
  2. #
  3. # This script generates a .run file that will install DMDirc
  4. #
  5. # DMDirc - Open Source IRC Client
  6. # Copyright (c) 2006-2009 Chris Smith, Shane Mc Cormack, Gregory Holmes
  7. #
  8. # Permission is hereby granted, free of charge, to any person obtaining a copy
  9. # of this software and associated documentation files (the "Software"), to deal
  10. # in the Software without restriction, including without limitation the rights
  11. # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  12. # copies of the Software, and to permit persons to whom the Software is
  13. # furnished to do so, subject to the following conditions:
  14. #
  15. # The above copyright notice and this permission notice shall be included in
  16. # all copies or substantial portions of the Software.
  17. #
  18. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  19. # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  20. # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  21. # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  22. # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  23. # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  24. # SOFTWARE.
  25. # Final Name of the installer (without file extention)
  26. INSTALLERNAME=DMDirc-Setup
  27. # full name of the file to output to
  28. RUNNAME="${PWD}/${INSTALLERNAME}.run"
  29. # Find out what params we should pass to things.
  30. # Solaris has a nice and ancient version of grep in /usr/bin
  31. grep -na "" /dev/null >/dev/null 2>&1
  32. if [ $? -eq 2 ]; then
  33. GREPOPTS="-n"
  34. else
  35. GREPOPTS="-na"
  36. fi;
  37. # Solaris also has a crappy version of tail!
  38. tail -n +1 /dev/null >/dev/null 2>&1
  39. if [ $? -eq 2 ]; then
  40. TAILOPTS="+"
  41. else
  42. TAILOPTS="-n +"
  43. fi;
  44. # Check the which command exists, and if so make sure it behaves how we want
  45. # it to...
  46. WHICH=`which which 2>/dev/null`
  47. if [ "" = "${WHICH}" ]; then
  48. echo "which command not found. Aborting.";
  49. exit 0;
  50. else
  51. # Solaris sucks
  52. BADWHICH=`which /`
  53. if [ "${BADWHICH}" != "" ]; then
  54. echo "Replacing bad which command.";
  55. # "Which" on solaris gives non-empty results for commands that don't exist
  56. which() {
  57. OUT=`${WHICH} ${1}`
  58. if [ $? -eq 0 ]; then
  59. echo ${OUT}
  60. else
  61. echo ""
  62. fi;
  63. }
  64. fi;
  65. fi
  66. # Compress stuff!
  67. compress() {
  68. tar cvfh - $@ | gzip - 2>/dev/null >>${RUNNAME} || {
  69. echo "Compression failed."
  70. kill -15 $$;
  71. };
  72. }
  73. WGET=`which wget`
  74. FETCH=`which fetch`
  75. CURL=`which curl`
  76. getFile() {
  77. URL=${1}
  78. OUTPUT=${2}
  79. if [ "${WGET}" != "" ]; then
  80. ${WGET} -O ${OUTPUT} ${URL}
  81. elif [ "${FETCH}" != "" ]; then
  82. ${FETCH} -o ${OUTPUT} ${URL}
  83. elif [ "${CURL}" != "" ]; then
  84. ${CURL} -o ${OUTPUT} ${URL}
  85. fi;
  86. }
  87. # Go!
  88. echo "-----------"
  89. if [ -e "${RUNNAME}" ]; then
  90. echo "Removing existing .run file"
  91. rm -Rf ./*.run
  92. fi
  93. showHelp() {
  94. echo "This will generate a DMDirc installer for a unix based system."
  95. echo "The following command line arguments are known:"
  96. echo "---------------------"
  97. echo "-h, --help Help information"
  98. echo "-r, --release <version> Generate a file based on an svn tag (or branch with -b aswell)"
  99. echo "-b, --branch Release in -r is a branch "
  100. echo "-p, --plugins <plugins> What plugins to add to the jar file"
  101. echo "-c, --compile Recompile the .jar file"
  102. echo " --jre Include the JRE in this installer"
  103. echo " --jre64 Include the 64-Bit JRE in this installer"
  104. echo " --jar <file> use <file> as DMDirc.jar"
  105. echo " --current Use the current folder as the base for the build"
  106. echo "-t, --tag <tag> Tag to add to final exe name to distinguish this build from a standard build"
  107. echo "-k, --keep Keep the existing source tree when compiling"
  108. echo " (don't svn update beforehand)"
  109. echo "---------------------"
  110. exit 0;
  111. }
  112. # Check for some CLI params
  113. compileJar="false"
  114. updateSVN="true"
  115. isRelease=""
  116. finalTag=""
  117. BRANCH="0"
  118. plugins=""
  119. location="../../../"
  120. jarfile=""
  121. current=""
  122. jre=""
  123. jrename="jre" # Filename for JRE without the .bin
  124. while test -n "$1"; do
  125. case "$1" in
  126. --plugins|-p)
  127. shift
  128. plugins=${1}
  129. ;;
  130. --jar)
  131. shift
  132. jarfile=${1}
  133. ;;
  134. --jre)
  135. jre="http://www.dmdirc.com/getjava/linux/i686"
  136. ;;
  137. --jre64)
  138. jre="http://www.dmdirc.com/getjava/linux/x86_64"
  139. jrename="jre64"
  140. ;;
  141. --current)
  142. location="../../"
  143. current="1"
  144. ;;
  145. --compile|-c)
  146. compileJar="true"
  147. ;;
  148. --release|-r)
  149. shift
  150. isRelease=${1}
  151. ;;
  152. --tag|-t)
  153. shift
  154. finalTag=${1}
  155. RUNNAME="${PWD}/${INSTALLERNAME}-${1}.run"
  156. ;;
  157. --keep|-k)
  158. updateSVN="false"
  159. ;;
  160. --help|-h)
  161. showHelp;
  162. ;;
  163. --branch|-b)
  164. BRANCH="1"
  165. ;;
  166. esac
  167. shift
  168. done
  169. if [ "" = "${current}" ]; then
  170. jarPath="${location}trunk"
  171. else
  172. jarPath="${location}"
  173. fi
  174. if [ "${isRelease}" != "" ]; then
  175. if [ "${BRANCH}" != "0" ]; then
  176. if [ -e "${location}/${isRelease}" ]; then
  177. jarPath="${location}/${isRelease}"
  178. else
  179. echo "Branch "${isRelease}" not found."
  180. exit 1;
  181. fi
  182. else
  183. if [ -e "${location}/${isRelease}" ]; then
  184. jarPath="${location}/${isRelease}"
  185. else
  186. echo "Tag "${isRelease}" not found."
  187. exit 1;
  188. fi
  189. fi
  190. fi
  191. if [ "" = "${jarfile}" ]; then
  192. jarfile=${jarPath}"/dist/DMDirc.jar"
  193. if [ ! -e ${jarPath}"/dist/DMDirc.jar" -o "${compileJar}" = "true" ]; then
  194. echo "Creating jar.."
  195. OLDPWD=${PWD}
  196. cd ${jarPath}
  197. if [ "${updateSVN}" = "true" ]; then
  198. svn update
  199. fi
  200. rm -Rf build dist
  201. ant jar
  202. if [ ! -e "dist/DMDirc.jar" ]; then
  203. echo "There was an error creating the .jar file. Aborting."
  204. exit 1;
  205. fi;
  206. cd ${OLDPWD}
  207. fi;
  208. elif [ ! -e "${jarfile}" ]; then
  209. echo "Requested Jar file (${jarfile}) does not exist."
  210. exit 1;
  211. fi;
  212. if [ "" = "${plugins}" ]; then
  213. echo "Linking jar (${jarfile}).."
  214. ln -sf ${jarfile} "./DMDirc.jar"
  215. else
  216. echo "Copying jar (${jarfile}).."
  217. cp ${jarfile} "./DMDirc.jar"
  218. echo "Adding plugins to jar"
  219. ln -sf ${jarPath}"/plugins"
  220. pluginList=""
  221. for plugin in ${plugins}; do
  222. pluginList=${pluginList}" plugins/${plugin}"
  223. done
  224. jar -uvf "DMDirc.jar" ${pluginList}
  225. rm -Rf plugins;
  226. fi
  227. echo "Creating .run file"
  228. echo "Adding stub.."
  229. cat installerstub.sh > ${RUNNAME}
  230. # Add release info.
  231. awk '{gsub(/###ADDITIONAL_STUFF###/,"isRelease=\"'${isRelease}'\"");print}' ${RUNNAME} > ${RUNNAME}.tmp
  232. mv ${RUNNAME}.tmp ${RUNNAME}
  233. FILES="DMDirc.jar";
  234. echo "Compressing files.."
  235. for FILE in "getjre.sh" "installjre.sh" "progressbar.sh"; do
  236. if [ -e "${FILE}" ]; then
  237. FILES="${FILES} ${FILE}"
  238. fi
  239. done;
  240. if [ "" != "${jre}" ]; then
  241. if [ ! -e "../common/${jrename}.bin" ]; then
  242. echo "Downloading JRE to include in installer"
  243. getFile "${jre}" "../common/${jrename}.bin"
  244. fi
  245. ln -sf ../common/${jrename}.bin jre.bin
  246. FILES="${FILES} jre.bin"
  247. fi;
  248. if [ -e "setup.sh" ]; then
  249. FILES="${FILES} setup.sh"
  250. else
  251. echo "[WARNING] Creating setup-less archive. This will just extract and immediately delete the .jar file unless the -e flag is used"
  252. fi
  253. #if [ -e "../common/installer.jar" ]; then
  254. # ln -sf ../common/installer.jar ./installer.jar
  255. # FILES="${FILES} installer.jar"
  256. #else
  257. # echo "[WARNING] Creating installer-less archive - relying on setup.sh"
  258. #fi
  259. if [ -e ${jarPath}"/src/com/dmdirc/res/source/logo.svg" ]; then
  260. ln -sf ${jarPath}"/src/com/dmdirc/res/source/logo.svg" ./icon.svg
  261. FILES="${FILES} icon.svg"
  262. fi
  263. if [ "${isRelease}" != "" ]; then
  264. DOCSDIR=${jarPath}
  265. else
  266. DOCSDIR="../common"
  267. fi
  268. if [ -e "${DOCSDIR}/README.TXT" ]; then
  269. ln -sf "${DOCSDIR}/README.TXT" .
  270. FILES="${FILES} README.TXT"
  271. fi
  272. if [ -e "${DOCSDIR}/CHANGES.TXT" ]; then
  273. ln -sf "${DOCSDIR}/CHANGES.TXT" .
  274. FILES="${FILES} CHANGES.TXT"
  275. elif [ -e "${DOCSDIR}/CHANGELOG.TXT" ]; then
  276. ln -sf "${DOCSDIR}/CHANGELOG.TXT" .
  277. FILES="${FILES} CHANGELOG.TXT"
  278. fi
  279. if [ -e "${jarPath}/launcher/unix" ]; then
  280. ln -sf ${jarPath}/launcher/unix/DMDirc.sh .
  281. FILES="${FILES} DMDirc.sh"
  282. fi
  283. compress $FILES
  284. MD5BIN=`which md5sum`
  285. if [ "${MD5BIN}" = "" ]; then
  286. MD5BIN=`which md5`
  287. fi;
  288. AWK=`which awk`
  289. getMD5() {
  290. if [ "${MD5BIN}" != "" ]; then
  291. echo "test" | ${MD5BIN} -
  292. if [ $? -eq 0 ]; then
  293. echo "Linux-Style MD5SUM: ${MD5BIN}"
  294. getMD5Linux $@
  295. else
  296. echo "BSD-Style MD5SUM: ${MD5BIN}"
  297. getMD5BSD $@
  298. fi;
  299. fi;
  300. }
  301. getMD5Linux() {
  302. # Everything below the MD5SUM Line
  303. MD5LINE=`grep ${GREPOPTS} "^MD5=\".*\"$" ${1}`
  304. MD5LINE=$((${MD5LINE%%:*} + 1))
  305. MD5SUM=`tail ${TAILOPTS}${MD5LINE} "${1}" | ${MD5BIN} - | ${AWK} '{print $1}'`
  306. return;
  307. }
  308. getMD5BSD() {
  309. # Everything below the MD5SUM Line
  310. MD5LINE=`grep ${GREPOPTS} "^MD5=\".*\"$" ${1}`
  311. MD5LINE=$((${MD5LINE%%:*} + 1))
  312. MD5SUM=`tail ${TAILOPTS}${MD5LINE} "${1}" | ${MD5BIN} | ${AWK} '{print $1}'`
  313. return;
  314. }
  315. if [ "${MD5BIN}" != "" -a "${AWK}" != "" ]; then
  316. echo "Adding MD5.."
  317. MD5SUM=""
  318. getMD5 ${RUNNAME} ${MD5SUM}
  319. echo "SUM obtained is: ${MD5SUM}"
  320. LINENUM=`grep ${GREPOPTS} "^MD5=\"\"$" ${RUNNAME}`
  321. LINENUM=${LINENUM%%:*}
  322. head -n $((${LINENUM} -1)) ${RUNNAME} > ${RUNNAME}.tmp
  323. echo 'MD5="'${MD5SUM}'"' >> ${RUNNAME}.tmp
  324. tail ${TAILOPTS}$((${LINENUM} +1)) ${RUNNAME} >> ${RUNNAME}.tmp
  325. mv ${RUNNAME}.tmp ${RUNNAME}
  326. else
  327. echo "Not Adding MD5.."
  328. fi;
  329. echo "Chmodding"
  330. chmod a+x ${RUNNAME}
  331. if [ "${isRelease}" != "" ]; then
  332. if [ "${BRANCH}" = "1" ]; then
  333. isRelease=branch-${isRelease}
  334. fi;
  335. if [ "" != "${finalTag}" ]; then
  336. finalTag="-${finalTag}"
  337. fi;
  338. finalname=DMDirc-${isRelease}-Setup${finalTag}.run
  339. else
  340. finalname=${RUNNAME##*/}
  341. fi;
  342. if [ "" != "${jre}" ]; then
  343. finalname=`echo ${finalname} | sed "s/.run$/.${jrename}.run/"`
  344. fi;
  345. mv ${RUNNAME} ../output/${finalname}
  346. mv setup.sh setup.sh.tmp
  347. mv getjre.sh getjre.sh.tmp
  348. mv installjre.sh installjre.sh.tmp
  349. mv progressbar.sh progressbar.sh.tmp
  350. rm -f ${FILES}
  351. mv setup.sh.tmp setup.sh
  352. mv getjre.sh.tmp getjre.sh
  353. mv installjre.sh.tmp installjre.sh
  354. mv progressbar.sh.tmp progressbar.sh
  355. echo "-----------"
  356. echo "Done."
  357. echo "-----------"
  358. # and Done \o
  359. exit 0;