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.

makeInstallerWindows.sh 17KB

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