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.

makeInstallerWindows.sh 19KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712
  1. #!/bin/sh
  2. #
  3. # This script generates a .exe file that will install DMDirc
  4. #
  5. # DMDirc - Open Source IRC Client
  6. # Copyright (c) 2006-2010 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. # Name of the extractor
  26. RUNNAME=extractor.exe
  27. # Name of the installer (without .exe)
  28. INSTALLNAME=DMDirc-Setup
  29. # Name of the internal file
  30. INTNAME=extractor.7z
  31. # full name of the files to output to
  32. RUNNAME="${PWD}/${RUNNAME}"
  33. INTNAME="${PWD}/${INTNAME}"
  34. # Get 7zip path
  35. ZIP=`which 7z`
  36. # Are we a git working copy, or SVN?
  37. if [ -e ".svn" ]; then
  38. isSVN=1
  39. else
  40. isSVN=0
  41. fi;
  42. if [ "" = "${ZIP}" ]; then
  43. echo "7Zip not found, failing."
  44. exit 1;
  45. fi
  46. # Compress stuff!
  47. compress() {
  48. ${ZIP} a -yl ${INTNAME} $@ 2>/dev/null || {
  49. echo "Compression failed."
  50. kill -15 $$;
  51. };
  52. }
  53. # Get signcode path
  54. SIGNCODE=`which signcode`
  55. if [ "" = "${SIGNCODE}" ]; then
  56. echo "Signcode not found. EXE's will not be digitally signed."
  57. fi
  58. # Sign stuff!
  59. signexe() {
  60. return;
  61. if [ "" != "${SIGNCODE}" ]; then
  62. if [ -e "../signing/DMDirc.spc" -a -e "../signing/DMDirc.pvk" ]; then
  63. echo "Digitally Signing EXE (${@})..."
  64. ${SIGNCODE} -spc "../signing/DMDirc.spc" -v "../signing/DMDirc.pvk" -i "http://www.dmdirc.com/" -n "DMDirc Installer" $@ 2>/dev/null || {
  65. kill -15 $$;
  66. };
  67. rm ${@}.sig
  68. rm ${@}.bak
  69. fi
  70. fi
  71. }
  72. WGET=`which wget`
  73. FETCH=`which fetch`
  74. CURL=`which curl`
  75. getFile() {
  76. URL=${1}
  77. OUTPUT=${2}
  78. if [ "${WGET}" != "" ]; then
  79. ${WGET} -O ${OUTPUT} ${URL}
  80. elif [ "${FETCH}" != "" ]; then
  81. ${FETCH} -o ${OUTPUT} ${URL}
  82. elif [ "${CURL}" != "" ]; then
  83. ${CURL} -o ${OUTPUT} ${URL}
  84. fi;
  85. }
  86. # Check for some CLI params
  87. compileJar="false"
  88. updateSVN="true"
  89. compileSetup="false"
  90. useOldSetup="false"
  91. isRelease=""
  92. useUPX="false"
  93. finalTag=""
  94. signEXE="true"
  95. compilerFlags="-Xs -XX -O2 -Or -Op1"
  96. BRANCH="0"
  97. plugins=""
  98. if [ $isSVN -eq 1 ]; then
  99. location="../../../"
  100. current=""
  101. else
  102. location="../../"
  103. current="1"
  104. fi;
  105. jarfile=""
  106. jre=""
  107. jrename="jre" # Filename for JRE without the .exe
  108. TAGGED=""
  109. showHelp() {
  110. echo "This will generate a DMDirc installer for a windows based system."
  111. echo "The following command line arguments are known:"
  112. echo "---------------------"
  113. echo "-h, --help Help information"
  114. echo "-r, --release <version> Generate a file based on an svn tag (or branch with -b as well)"
  115. echo "-b, --branch Release in -r is a branch "
  116. echo "-s, --setup Recompile the .exe file"
  117. echo "-o, If setup.exe compile fails, use old version"
  118. echo "-p, --plugins <plugins> What plugins to add to the jar file"
  119. echo "-c, --compile Recompile the .jar file"
  120. echo "-u, --unsigned Don't sign the exe"
  121. echo "-e, --extra <tag> Tag to add to final exe name to distinguish this build from a standard build"
  122. echo "-f, --flags <flags> Extra flags to pass to the compiler"
  123. echo " --jre Include the JRE in this installer"
  124. echo " --jar <file> use <file> as DMDirc.jar"
  125. echo " --current Use the current folder as the base for the build"
  126. # This is not in the help cos its crappy really, and makes little/no difference to the
  127. # exe size unless debugging information is added using --flags, in which case the person
  128. # probably is Dataforce and knows about this flag anyway
  129. # echo " --upx UPX binary if UPX is available on the path,"
  130. # echo " (Compression Level: 4 for signed exe, 9 for unsigned)"
  131. echo "-k, --keep Keep the existing source tree when compiling"
  132. echo " (don't svn update beforehand)"
  133. echo "---------------------"
  134. exit 0;
  135. }
  136. while test -n "$1"; do
  137. case "$1" in
  138. --plugins|-p)
  139. shift
  140. plugins=${1}
  141. ;;
  142. --jar)
  143. shift
  144. jarfile=${1}
  145. ;;
  146. --jre)
  147. jre="http://www.dmdirc.com/getjava/windows/all"
  148. ;;
  149. --jre64)
  150. # No specific jre64 for windows.
  151. echo "No specific 64ibt JRE for windows, exiting"
  152. exit 1;
  153. ;;
  154. --current)
  155. location="../../"
  156. current="1"
  157. ;;
  158. --compile|-c)
  159. compileJar="true"
  160. ;;
  161. --setup|-s)
  162. compileSetup="true"
  163. ;;
  164. -o)
  165. useOldSetup="true"
  166. ;;
  167. --release|-r)
  168. shift
  169. isRelease=${1}
  170. ;;
  171. --extra|-e)
  172. shift
  173. finalTag="-${1}"
  174. ;;
  175. --flags|-f)
  176. shift
  177. compilerFlags="${1} "
  178. ;;
  179. --upx)
  180. useUPX="true"
  181. ;;
  182. --unsigned|-u)
  183. signEXE="false"
  184. ;;
  185. --keep|-k)
  186. updateSVN="false"
  187. ;;
  188. --help|-h)
  189. showHelp;
  190. ;;
  191. --branch|-b)
  192. BRANCH="1"
  193. ;;
  194. --tag|-t)
  195. shift
  196. if [ ${isSVN} -eq 1 ]; then
  197. REGEX="^[0-9]+(\.[0-9]+(\.[0-9]+)?)?$"
  198. CHECKTAG=`echo ${1} | egrep "${REGEX}"`
  199. if [ "" = "${CHECKTAG}" ]; then
  200. echo "Specified tag ("${1}") is invalid."
  201. exit 1;
  202. fi;
  203. TAGGED="${1}"
  204. else
  205. TAGGED=`git describe --tags`
  206. TAGGED=${TAGGED%%-*}
  207. fi;
  208. ;;
  209. esac
  210. shift
  211. done
  212. # Go!
  213. echo "-----------"
  214. if [ -e "${RUNNAME}" ]; then
  215. echo "Removing existing .exe file"
  216. rm -Rf "${RUNNAME}"
  217. fi
  218. if [ -e "${INTNAME}" ]; then
  219. echo "Removing existing .7z file"
  220. rm -Rf "${INTNAME}"
  221. fi
  222. echo "Creating .7z file"
  223. if [ "" = "${current}" ]; then
  224. jarPath="${location}trunk"
  225. else
  226. jarPath="${location}"
  227. fi
  228. if [ "${isRelease}" != "" ]; then
  229. if [ $isSVN -eq 1 ]; then
  230. if [ "${BRANCH}" != "0" ]; then
  231. if [ -e "${location}/${isRelease}" ]; then
  232. jarPath="${location}/${isRelease}"
  233. else
  234. echo "Branch "${isRelease}" not found."
  235. exit 1;
  236. fi
  237. else
  238. if [ -e "${location}/${isRelease}" ]; then
  239. jarPath="${location}/${isRelease}"
  240. else
  241. echo "Tag "${isRelease}" not found."
  242. exit 1;
  243. fi
  244. fi
  245. fi
  246. fi
  247. if [ "" = "${jarfile}" ]; then
  248. jarfile=${jarPath}"/dist/DMDirc.jar"
  249. if [ ! -e ${jarPath}"/dist/DMDirc.jar" -o "${compileJar}" = "true" ]; then
  250. echo "Creating jar.."
  251. OLDPWD=${PWD}
  252. cd ${jarPath}
  253. if [ "${updateSVN}" = "true" ]; then
  254. svn update
  255. fi
  256. rm -Rf build dist
  257. ant jar
  258. if [ ! -e "dist/DMDirc.jar" ]; then
  259. echo "There was an error creating the .jar file. Aborting."
  260. exit 1;
  261. fi;
  262. cd ${OLDPWD}
  263. fi;
  264. elif [ ! -e "${jarfile}" ]; then
  265. echo "Requested Jar file (${jarfile}) does not exist."
  266. exit 1;
  267. fi;
  268. if [ "" = "${plugins}" ]; then
  269. echo "Linking jar (${jarfile}).."
  270. ln -sf ${jarfile} "./DMDirc.jar"
  271. else
  272. echo "Copying jar (${jarfile}).."
  273. cp ${jarfile} "./DMDirc.jar"
  274. echo "Adding plugins to jar"
  275. ln -sf ${jarPath}"/plugins"
  276. pluginList=""
  277. for plugin in ${plugins}; do
  278. pluginList=${pluginList}" plugins/${plugin}"
  279. done
  280. jar -uvf "DMDirc.jar" ${pluginList}
  281. rm -Rf plugins;
  282. fi
  283. if [ $isSVN -eq 1 -o "${TAGGED}" = "" ]; then
  284. echo " ReleaseNumber: String = '${isRelease}';" > SetupConsts.inc
  285. else
  286. echo " ReleaseNumber: String = '${TAGGED}';" > SetupConsts.inc
  287. fi;
  288. FILES=""
  289. # Icon Res file
  290. if [ -e ${jarPath}"/src/com/dmdirc/res/icon.ico" ]; then
  291. ln -sf ${jarPath}"/src/com/dmdirc/res/icon.ico" ./icon.ico
  292. FILES="${FILES} icon.ico"
  293. fi
  294. echo "icon.ico ICON icon.ico" > icon.rc
  295. # Other resources
  296. echo "extractor RCDATA extractor.exe" > files.rc
  297. COMPILER_IS_BROKEN="0";
  298. if [ $isSVN -eq 1 -o "${TAGGED}" = "" ]; then
  299. NUM="${1}"
  300. else
  301. NUM="${TAGGED}"
  302. fi;
  303. # Version Numbers
  304. if [ "" = "${NUM}" ]; then
  305. MAJORVER="0"
  306. MINORVER="0"
  307. RELEASE="0"
  308. EXTRAVER="0"
  309. TEXTVER="${isRelease}"
  310. PRIVATE="1"
  311. USER=`whoami`
  312. HOST=`hostname`
  313. DATE=`date`
  314. else
  315. MAJORVER=${NUM%%.*}
  316. SUBVER=${NUM#*.}
  317. EXTRAVER="0"
  318. DOT=`expr index "${SUBVER}" .`
  319. if [ "${DOT}" = "0" ]; then
  320. MINORVER=${SUBVER}
  321. RELEASE="0"
  322. else
  323. MINORVER=${SUBVER%%.*}
  324. END=${SUBVER##*.}
  325. RELEASE=${END##*[^0-9]}
  326. fi
  327. TEXTVER=$NUM
  328. PRIVATE="0"
  329. fi;
  330. # Information for the below section:
  331. #
  332. # http://support.microsoft.com/kb/139491
  333. # http://msdn2.microsoft.com/en-us/library/aa381049.aspx
  334. # http://courses.cs.vt.edu/~cs3304/FreePascal/doc/prog/node14.html#SECTION001440000000000000000
  335. # http://tortoisesvn.tigris.org/svn/tortoisesvn/trunk/src/Resources/TortoiseShell.rc2
  336. echo "1 VERSIONINFO" > version.rc.1
  337. echo "FILEVERSION 1, 0, 0, 0" >> version.rc.1
  338. echo "PRODUCTVERSION ${MAJORVER}, ${MINORVER}, ${RELEASE}, ${EXTRAVER}" >> version.rc.1
  339. if [ "${PRIVATE}" = "1" ]; then
  340. if [ "${COMPILER_IS_BROKEN}" = "0" ]; then
  341. echo "FILEFLAGSMASK 0x000A" >> version.rc.1
  342. echo "FILEFLAGS 0x3f" >> version.rc.1
  343. else
  344. echo "FILEFLAGS 0x000A" >> version.rc.1
  345. fi;
  346. else
  347. echo "FILEFLAGSMASK 0" >> version.rc.1
  348. fi;
  349. echo "FILEOS 0x40004" >> version.rc.1
  350. echo "FILETYPE 1" >> version.rc.1
  351. echo "BEGIN" >> version.rc.1
  352. echo " BLOCK \"StringFileInfo\"" >> version.rc.1
  353. echo " BEGIN" >> version.rc.1
  354. echo " BLOCK \"040004E4\"" >> version.rc.1
  355. echo " BEGIN" >> version.rc.1
  356. echo " VALUE \"Comments\", \"http://www.dmdirc.com/\"" >> version.rc.1
  357. echo " VALUE \"CompanyName\", \"DMDirc\"" >> version.rc.1
  358. cat version.rc.1 > version.rc
  359. cat version.rc.1 > uninstallversion.rc
  360. rm version.rc.1
  361. echo " VALUE \"FileDescription\", \"Installer for DMDirc ${TEXTVER}\"" >> version.rc
  362. echo " VALUE \"FileDescription\", \"Uninstaller for DMDirc\"" >> uninstallversion.rc
  363. echo " VALUE \"FileVersion\", \"2.0\"" > version.rc.2
  364. echo " VALUE \"InternalName\", \"DMDirc.jar\"" >> version.rc.2
  365. echo " VALUE \"LegalCopyright\", \"Copyright (c) 2006-2010 Chris Smith, Shane Mc Cormack, Gregory Holmes\"" >> version.rc.2
  366. echo " VALUE \"OriginalFilename\", \"$2\"" >> version.rc.2
  367. echo " VALUE \"ProductName\", \"DMDirc\"" >> version.rc.2
  368. echo " VALUE \"ProductVersion\", \"${TEXTVER}\"" >> version.rc.2
  369. if [ "${PRIVATE}" = "1" ]; then
  370. echo " VALUE \"PrivateBuild\", \"Build by ${USER}@${HOST} on ${DATE}\"" >> version.rc.2
  371. fi;
  372. echo " END" >> version.rc.2
  373. echo " END" >> version.rc.2
  374. echo " BLOCK \"VarFileInfo\"" >> version.rc.2
  375. echo " BEGIN" >> version.rc.2
  376. echo " VALUE \"Translation\", 0x400, 1252" >> version.rc.2
  377. echo " END" >> version.rc.2
  378. echo "END" >> version.rc.2
  379. cat version.rc.2 >> version.rc
  380. cat version.rc.2 >> uninstallversion.rc
  381. rm version.rc.2
  382. echo "1 24 \"UAC.manifest\"" > UAC.rc
  383. echo "1 24 \"UAC_uninstaller.manifest\"" > UAC_uninstaller.rc
  384. # Build res files
  385. #windres -F pe-i386 -i version.rc -o version.res
  386. #windres -F pe-i386 -i files.rc -o files.res
  387. #windres -F pe-i386 -i icon.rc -o icon.res
  388. # UAC really needs to match the product name / description properly
  389. # so we have a special one for the uninstaller
  390. cat UAC_uninstaller.rc > uninstall.rc
  391. # Next line seems to be silly because we add a version resource
  392. # later as all.rc is not for the uninstaller.
  393. # cat uninstallversion.rc >> all.rc
  394. cat uninstallversion.rc >> uninstall.rc
  395. cat icon.rc >> uninstall.rc
  396. windres -F pe-i386 -i uninstall.rc -o uninstall.res
  397. cat UAC.rc > all.rc
  398. cat version.rc >> all.rc
  399. cat files.rc >> all.rc
  400. cat icon.rc >> all.rc
  401. # Build later after extractor.exe exists
  402. cat UAC.rc > most.rc
  403. cat version.rc >> most.rc
  404. cat icon.rc >> most.rc
  405. windres -F pe-i386 -i most.rc -o most.res
  406. FILES="${FILES} DMDirc.jar Setup.exe";
  407. if [ "" != "${jre}" ]; then
  408. if [ ! -e "../common/${jrename}.exe" ]; then
  409. echo "Downloading JRE to include in installer"
  410. getFile "${jre}" "../common/${jrename}.exe"
  411. fi
  412. ln -sf ../common/${jrename}.exe jre.exe
  413. FILES="${FILES} jre.exe"
  414. fi;
  415. DELETEFILES=${FILES}
  416. if [ "" != "${DMDIRC_FPC}" ]; then
  417. FPC=${DMDIRC_FPC}
  418. else
  419. FPC=`which fpc`
  420. fi;
  421. lazarusDir="/usr/share/lazarus"
  422. if [ ! -e "${lazarusDir}/lcl" ]; then
  423. lazarusDir="/usr/lib/lazarus/"
  424. fi;
  425. compilerFlags="-Sd -Twin32 ${compilerFlags}";
  426. extraFlags=""
  427. if [ ! -e "Setup.exe" -o "${compileSetup}" = "true" ]; then
  428. echo "Setup.exe does not exist. Lets try and compile it."
  429. if [ "${FPC}" = "" ]; then
  430. echo "FPC Compiler not found, Setup.exe can not be built."
  431. exit 1;
  432. else
  433. echo "Building Setup.exe..."
  434. extraFlags="-dKOL -Fu${PWD}/../../libwin/kolfpc -Fu{$PWD}/../../libwin/lcore -Fu{$PWD} -Fu${PWD}/../../libwin"
  435. ${FPC} ${compilerFlags} ${extraFlags} Setup.dpr
  436. if [ $? -ne 0 ]; then
  437. if [ -e "Setup.exe" -a "${useOldSetup}" = "true" ]; then
  438. echo "Unable to compile Setup.exe, using existing version."
  439. else
  440. echo "Unable to compile Setup.exe, terminating."
  441. exit 1;
  442. fi
  443. fi;
  444. fi
  445. fi
  446. ls
  447. if [ ! -e "Setup.exe" ]; then
  448. echo "Still can't find Setup.exe, terminating."
  449. exit 1;
  450. fi
  451. echo "Compressing files.."
  452. # Shortcut.exe is from http://www.optimumx.com/download/#Shortcut
  453. if [ ! -e Shortcut.exe ]; then
  454. getFile "http://binary.dmdirc.com/Shortcut.zip" "Shortcut.zip"
  455. unzip -q Shortcut.zip Shortcut.exe
  456. rm Shortcut.zip
  457. fi
  458. FILES="${FILES} Shortcut.exe"
  459. DELETEFILES="${DELETEFILES} Shortcut.exe"
  460. if [ "${isRelease}" != "" ]; then
  461. DOCSDIR=${jarPath}
  462. else
  463. DOCSDIR="../common"
  464. fi
  465. if [ -e "${DOCSDIR}/README.TXT" ]; then
  466. ln -sf "${DOCSDIR}/README.TXT" .
  467. FILES="${FILES} README.TXT"
  468. DELETEFILES="${DELETEFILES} README.TXT"
  469. fi
  470. if [ -e "${DOCSDIR}/CHANGES.TXT" ]; then
  471. ln -sf "${DOCSDIR}/CHANGES.TXT" .
  472. FILES="${FILES} CHANGES.TXT"
  473. DELETEFILES="${DELETEFILES} CHANGES.TXT"
  474. elif [ -e "${DOCSDIR}/CHANGELOG.TXT" ]; then
  475. ln -sf "${DOCSDIR}/CHANGELOG.TXT" .
  476. FILES="${FILES} CHANGELOG.TXT"
  477. DELETEFILES="${DELETEFILES} CHANGELOG.TXT"
  478. fi
  479. if [ -e "${jarPath}/launcher/windows" ]; then
  480. # Try to compile all
  481. olddir=${PWD}
  482. cd "${jarPath}/launcher/windows/"
  483. sh compile.sh
  484. cd ${olddir}
  485. # Now add to file list.
  486. for thisfile in `ls -1 ${jarPath}/launcher/windows/*.exe`; do
  487. ln -sf ${thisfile} .
  488. FILES="${FILES} ${thisfile}"
  489. done
  490. fi
  491. extraFlags="-dKOL -Fu${PWD}/../../libwin/kolfpc -Fu{$PWD} -Fu${PWD}/../../libwin"
  492. ${FPC} ${compilerFlags} ${extraFlags} ${3}Uninstaller.dpr
  493. if [ -e "Uninstaller.exe" ]; then
  494. FILES="${FILES} Uninstaller.exe"
  495. # DELETEFILES="${DELETEFILES} Uninstaller.exe"
  496. fi
  497. # Add wget to allow downloading jre
  498. if [ ! -e "wget.exe" ]; then
  499. getFile "http://binary.dmdirc.com/wget.exe" "wget.exe"
  500. fi;
  501. if [ ! -e "wget.exe" ]; then
  502. echo "wget.exe not found, unable to continue."
  503. exit 1;
  504. fi;
  505. FILES="${FILES} wget.exe"
  506. compress $FILES
  507. echo "Creating config.."
  508. echo ";!@Install@!UTF-8!" > 7zip.conf
  509. if [ "${isRelease}" != "" ]; then
  510. echo "Title=\"DMDirc Installation "${isRelease}"\"" >> 7zip.conf
  511. echo "BeginPrompt=\"Do you want to install DMDirc "${isRelease}"?\"" >> 7zip.conf
  512. elif [ "${TAGGED}" != "" ]; then
  513. echo "Title=\"DMDirc Installation "${TAGGED}"\"" >> 7zip.conf
  514. echo "BeginPrompt=\"Do you want to install DMDirc "${TAGGED}"?\"" >> 7zip.conf
  515. else
  516. echo "Title=\"DMDirc Installation\"" >> 7zip.conf
  517. echo "BeginPrompt=\"Do you want to install DMDirc?\"" >> 7zip.conf
  518. fi;
  519. echo "ExecuteFile=\"Setup.exe\"" >> 7zip.conf
  520. echo ";!@InstallEnd@!" >> 7zip.conf
  521. if [ ! -e "7zS.sfx" ]; then
  522. echo "Obtaining sfx stub.."
  523. getFile "http://binary.dmdirc.com/7zS.sfx" "7zS.sfx"
  524. fi
  525. if [ ! -e "7zS.sfx" ]; then
  526. echo "7zS.sfx not found, unable to continue."
  527. exit 1;
  528. fi;
  529. echo "Creating .exe"
  530. cat 7zS.sfx 7zip.conf "${INTNAME}" > "${RUNNAME}"
  531. doRename=0
  532. if [ "${isRelease}" != "" ]; then
  533. doRename=1
  534. elif [ $isSVN -eq 0 -a "${TAGGED}" != "" ]; then
  535. doRename=1
  536. fi;
  537. if [ ${doRename} -eq 1 ]; then
  538. if [ $isSVN -eq 1 ]; then
  539. if [ "${BRANCH}" = "1" ]; then
  540. releaseTag=branch-${isRelease}
  541. else
  542. releaseTag=${isRelease}
  543. fi;
  544. else
  545. if [ "${TAGGED}" = "" ]; then
  546. releaseTag=branch-${isRelease}
  547. else
  548. releaseTag=${TAGGED}
  549. fi;
  550. fi
  551. ORIGNAME="DMDirc-${releaseTag}-Setup${finalTag}.exe"
  552. else
  553. ORIGNAME="${INSTALLNAME}${finalTag}.exe"
  554. fi;
  555. echo "Building launcher";
  556. MD5BIN=`which md5sum`
  557. AWK=`which awk`
  558. MD5SUM=""
  559. if [ "${MD5BIN}" != "" -a "${AWK}" != "" ]; then
  560. MD5SUM=`${MD5BIN} extractor.exe | ${AWK} '{print $1}'`
  561. fi
  562. echo "const" > consts.inc
  563. echo " MD5SUM: String = '${MD5SUM}';" >> consts.inc
  564. # Code to extract and launch resource
  565. echo "ExtractResource('extractor', 'dmdirc_extractor.exe', TempDir);" > ExtractCode.inc
  566. if [ "${MD5SUM}" != "" ]; then
  567. echo "if FindCmdLineSwitch('-nomd5') or FindCmdLineSwitch('nomd5') or checkMD5(TempDir+'dmdirc_extractor.exe') then begin" >> ExtractCode.inc
  568. echo -n " "; # Oh so important for code formatting!
  569. fi;
  570. echo "Launch(TempDir+'dmdirc_extractor.exe');" >> ExtractCode.inc
  571. if [ "${MD5SUM}" != "" ]; then
  572. echo "end" >> ExtractCode.inc
  573. echo "else begin" >> ExtractCode.inc
  574. echo " ErrorMessage := 'This copy of the DMDirc installer appears to be damaged and will now exit';" >> ExtractCode.inc
  575. echo " ErrorMessage := ErrorMessage+#13#10+'You may choose to skip this check and run it anyway by passing the /nomd5 parameter';" >> ExtractCode.inc
  576. echo " ErrorMessage := ErrorMessage+#13#10+'';" >> ExtractCode.inc
  577. echo " ErrorMessage := ErrorMessage+#13#10;" >> ExtractCode.inc
  578. echo " ErrorMessage := ErrorMessage+#13#10+'If you feel this is incorrect, or you require some further assistance,';" >> ExtractCode.inc
  579. echo " ErrorMessage := ErrorMessage+#13#10+'please feel free to contact us.';" >> ExtractCode.inc
  580. echo " " >> ExtractCode.inc
  581. echo " MessageBox(0, PChar(ErrorMessage), 'Sorry, setup is unable to continue', MB_OK + MB_ICONSTOP);" >> ExtractCode.inc
  582. echo "end;" >> ExtractCode.inc
  583. fi
  584. windres -F pe-i386 -i all.rc -o all.res
  585. ${FPC} ${compilerFlags} ${3}Launcher.dpr
  586. if [ $? -ne 0 ]; then
  587. if [ -e "Launcher.exe" ]; then
  588. echo "Unable to compile Launcher.exe, using existing version."
  589. else
  590. echo "Unable to compile Launcher.exe, terminating."
  591. exit 1;
  592. fi
  593. fi
  594. rm -f *.res
  595. rm -f *.rc
  596. rm -f *.inc
  597. rm -f *.ppu
  598. FULLINSTALLER="${PWD}/${INSTALLNAME}${finalTag}.exe"
  599. mv Launcher.exe ${FULLINSTALLER}
  600. if [ "${useUPX}" = "true" ]; then
  601. UPX=`which upx`
  602. if [ "${UPX}" != "" ]; then
  603. if [ "${signEXE}" = "true" ]; then
  604. ${UPX} -4 ${FULLINSTALLER}
  605. else
  606. ${UPX} -9 ${FULLINSTALLER}
  607. fi
  608. fi
  609. fi
  610. echo "Chmodding.."
  611. chmod a+x ${FULLINSTALLER}
  612. if [ "${signEXE}" = "true" ]; then
  613. echo "Signing.."
  614. signexe ${FULLINSTALLER}
  615. else
  616. echo "Not Signing.."
  617. fi;
  618. if [ "" != "${jre}" ]; then
  619. ORIGNAME=`echo ${ORIGNAME} | sed "s/.exe$/.${jrename}.exe/"`
  620. fi;
  621. mv ${FULLINSTALLER} ../output/${ORIGNAME}
  622. # Quick hack to prevent deleting of 2 important files in ${FILES}
  623. mv Setup.exe Setup.exe.tmp
  624. mv Shortcut.exe Shortcut.exe.tmp
  625. rm -f ${DELETEFILES}
  626. rm -f ./7zip.conf
  627. rm -f ./*.o
  628. rm -f ./*.or
  629. rm -f ${RUNNAME}
  630. rm -f ${INTNAME}
  631. rm -f icon.ico
  632. # And un-hack
  633. mv Setup.exe.tmp Setup.exe
  634. mv Shortcut.exe.tmp Shortcut.exe
  635. echo "-----------"
  636. echo "Done."
  637. echo "-----------"
  638. # and Done \o
  639. exit 0;