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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631
  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=""
  242. # Icon Res file
  243. if [ -e ${jarPath}"/src/com/dmdirc/res/icon.ico" ]; then
  244. ln -sf ${jarPath}"/src/com/dmdirc/res/icon.ico" ./icon.ico
  245. FILES="${FILES} icon.ico"
  246. fi
  247. echo "icon.ico ICON icon.ico" > icon.rc
  248. # Other resources
  249. echo "extractor RCDATA extractor.exe" > files.rc
  250. COMPILER_IS_BROKEN="0";
  251. # Version Numbers
  252. if [ "" = "${1}" ]; then
  253. MAJORVER="0"
  254. MINORVER="0"
  255. RELEASE="0"
  256. TEXTVER="Trunk"
  257. PRIVATE="1"
  258. USER=`whoami`
  259. HOST=`hostname`
  260. DATE=`date`
  261. else
  262. MAJORVER=${1%%.*}
  263. SUBVER=${1#*.}
  264. DOT=`expr index "${SUBVER}" .`
  265. if [ "${DOT}" = "0" ]; then
  266. MINORVER=${SUBVER}
  267. RELEASE="0"
  268. else
  269. MINORVER=${SUBVER%%.*}
  270. RELEASE=${SUBVER##*.}
  271. fi
  272. TEXTVER=$1
  273. PRIVATE="0"
  274. fi;
  275. # Information for the below section:
  276. #
  277. # http://support.microsoft.com/kb/139491
  278. # http://msdn2.microsoft.com/en-us/library/aa381049.aspx
  279. # http://courses.cs.vt.edu/~cs3304/FreePascal/doc/prog/node14.html#SECTION001440000000000000000
  280. # http://tortoisesvn.tigris.org/svn/tortoisesvn/trunk/src/Resources/TortoiseShell.rc2
  281. echo "1 VERSIONINFO" > version.rc.1
  282. echo "FILEVERSION 1, 0, 0, 0" >> version.rc.1
  283. echo "PRODUCTVERSION ${MAJORVER}, ${MINORVER}, ${RELEASE}, 0" >> version.rc.1
  284. if [ "${PRIVATE}" = "1" ]; then
  285. if [ "${COMPILER_IS_BROKEN}" = "0" ]; then
  286. echo "FILEFLAGSMASK 0x000A" >> version.rc.1
  287. echo "FILEFLAGS 0x3f" >> version.rc.1
  288. else
  289. echo "FILEFLAGS 0x000A" >> version.rc.1
  290. fi;
  291. else
  292. echo "FILEFLAGSMASK 0" >> version.rc.1
  293. fi;
  294. echo "FILEOS 0x40004" >> version.rc.1
  295. echo "FILETYPE 1" >> version.rc.1
  296. echo "BEGIN" >> version.rc.1
  297. echo " BLOCK \"StringFileInfo\"" >> version.rc.1
  298. echo " BEGIN" >> version.rc.1
  299. echo " BLOCK \"040004E4\"" >> version.rc.1
  300. echo " BEGIN" >> version.rc.1
  301. echo " VALUE \"Comments\", \"http://www.dmdirc.com/\"" >> version.rc.1
  302. echo " VALUE \"CompanyName\", \"DMDirc\"" >> version.rc.1
  303. cat version.rc.1 > version.rc
  304. cat version.rc.1 > uninstallversion.rc
  305. rm version.rc.1
  306. echo " VALUE \"FileDescription\", \"Installer for DMDirc ${TEXTVER}\"" >> version.rc
  307. echo " VALUE \"FileDescription\", \"Uninstaller for DMDirc\"" >> uninstallversion.rc
  308. echo " VALUE \"FileVersion\", \"2.0\"" > version.rc.2
  309. echo " VALUE \"InternalName\", \"DMDirc.jar\"" >> version.rc.2
  310. echo " VALUE \"LegalCopyright\", \"Copyright (c) 2006-2008 Chris Smith, Shane Mc Cormack, Gregory Holmes\"" >> version.rc.2
  311. echo " VALUE \"OriginalFilename\", \"$2\"" >> version.rc.2
  312. echo " VALUE \"ProductName\", \"DMDirc\"" >> version.rc.2
  313. echo " VALUE \"ProductVersion\", \"${TEXTVER}\"" >> version.rc.2
  314. if [ "${PRIVATE}" = "1" ]; then
  315. echo " VALUE \"PrivateBuild\", \"Build by ${USER}@${HOST} on ${DATE}\"" >> version.rc.2
  316. fi;
  317. echo " END" >> version.rc.2
  318. echo " END" >> version.rc.2
  319. echo " BLOCK \"VarFileInfo\"" >> version.rc.2
  320. echo " BEGIN" >> version.rc.2
  321. echo " VALUE \"Translation\", 0x400, 1252" >> version.rc.2
  322. echo " END" >> version.rc.2
  323. echo "END" >> version.rc.2
  324. cat version.rc.2 >> version.rc
  325. cat version.rc.2 >> uninstallversion.rc
  326. rm version.rc.2
  327. echo "1 24 \"UAC.manifest\"" > UAC.rc
  328. # Build res files
  329. #windres -F pe-i386 -i version.rc -o version.res
  330. #windres -F pe-i386 -i files.rc -o files.res
  331. #windres -F pe-i386 -i icon.rc -o icon.res
  332. cat UAC.rc > uninstall.rc
  333. cat uninstallversion.rc >> all.rc
  334. cat icon.rc >> uninstall.rc
  335. windres -F pe-i386 -i uninstall.rc -o uninstall.res
  336. cat UAC.rc > all.rc
  337. cat version.rc >> all.rc
  338. cat files.rc >> all.rc
  339. cat icon.rc >> all.rc
  340. # Build later after extractor.exe exists
  341. cat UAC.rc > most.rc
  342. cat version.rc >> most.rc
  343. cat icon.rc >> most.rc
  344. windres -F pe-i386 -i most.rc -o most.res
  345. FILES="${FILES} DMDirc.jar Setup.exe";
  346. if [ "" != "${jre}" ]; then
  347. if [ ! -e "../common/${jrename}.exe" ]; then
  348. echo "Downloading JRE to include in installer"
  349. wget ${jre} -O ../common/${jrename}.exe
  350. fi
  351. ln -sf ../common/${jrename}.exe jre.exe
  352. FILES="${FILES} jre.exe"
  353. fi;
  354. DELETEFILES=${FILES}
  355. FPC=`which fpc`
  356. lazarusDir="/usr/share/lazarus"
  357. if [ ! -e "${lazarusDir}/lcl" ]; then
  358. lazarusDir="/usr/lib/lazarus/"
  359. fi;
  360. compilerFlags="-Sd -Twin32 ${compilerFlags}";
  361. extraFlags=""
  362. if [ ! -e "Setup.exe" -o "${compileSetup}" = "true" ]; then
  363. echo "Setup.exe does not exist. Lets try and compile it."
  364. if [ "${FPC}" = "" ]; then
  365. echo "FPC Compiler not found, Setup.exe can not be built."
  366. exit 1;
  367. else
  368. echo "Building Setup.exe..."
  369. extraFlags=""
  370. if [ -e "${lazarusDir}/lcl" ]; then
  371. echo "Using Lazarus"
  372. mkdir -p ${PWD}/lazarus-build
  373. 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/"
  374. else
  375. echo "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@";
  376. echo "@ Building installer *WITHOUT* lazarus. @";
  377. echo "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@";
  378. fi;
  379. ${FPC} ${compilerFlags} ${extraFlags} Setup.dpr
  380. if [ $? -ne 0 ]; then
  381. if [ -e "Setup.exe" -a "${useOldSetup}" = "true" ]; then
  382. echo "Unable to compile Setup.exe, using existing version."
  383. else
  384. echo "Unable to compile Setup.exe, terminating."
  385. exit 1;
  386. fi
  387. fi;
  388. fi
  389. fi
  390. ls
  391. if [ ! -e "Setup.exe" ]; then
  392. echo "Still can't find Setup.exe, terminating."
  393. exit 1;
  394. fi
  395. echo "Compressing files.."
  396. # Shortcut.exe is from http://www.optimumx.com/download/#Shortcut
  397. if [ ! -e Shortcut.exe ]; then
  398. wget http://binary.dmdirc.com/Shortcut.zip
  399. unzip -q Shortcut.zip Shortcut.exe
  400. rm Shortcut.zip
  401. fi
  402. FILES="${FILES} Shortcut.exe"
  403. DELETEFILES="${DELETEFILES} Shortcut.exe"
  404. if [ "${isRelease}" != "" ]; then
  405. DOCSDIR=${jarPath}
  406. else
  407. DOCSDIR="../common"
  408. fi
  409. if [ -e "${DOCSDIR}/README.TXT" ]; then
  410. ln -sf "${DOCSDIR}/README.TXT" .
  411. FILES="${FILES} README.TXT"
  412. DELETEFILES="${DELETEFILES} README.TXT"
  413. fi
  414. if [ -e "${DOCSDIR}/CHANGES.TXT" ]; then
  415. ln -sf "${DOCSDIR}/CHANGES.TXT" .
  416. FILES="${FILES} CHANGES.TXT"
  417. DELETEFILES="${DELETEFILES} CHANGES.TXT"
  418. elif [ -e "${DOCSDIR}/CHANGELOG.TXT" ]; then
  419. ln -sf "${DOCSDIR}/CHANGELOG.TXT" .
  420. FILES="${FILES} CHANGELOG.TXT"
  421. DELETEFILES="${DELETEFILES} CHANGELOG.TXT"
  422. fi
  423. if [ -e "${jarPath}/launcher/windows" ]; then
  424. # Try to compile all
  425. olddir=${PWD}
  426. cd "${jarPath}/launcher/windows/"
  427. sh compile.sh
  428. cd ${olddir}
  429. # Now add to file list.
  430. for thisfile in `ls -1 ${jarPath}/launcher/windows/*.exe`; do
  431. ln -sf ${thisfile} .
  432. FILES="${FILES} ${thisfile}"
  433. done
  434. fi
  435. ${FPC} ${compilerFlags} ${3}Uninstaller.dpr
  436. if [ -e "Uninstaller.exe" ]; then
  437. FILES="${FILES} Uninstaller.exe"
  438. # DELETEFILES="${DELETEFILES} Uninstaller.exe"
  439. fi
  440. # Add wget to allow downloading jre
  441. if [ ! -e "wget.exe" ]; then
  442. wget http://binary.dmdirc.com/wget.exe
  443. fi;
  444. if [ ! -e "wget.exe" ]; then
  445. echo "wget.exe not found, unable to continue."
  446. exit 1;
  447. fi;
  448. FILES="${FILES} wget.exe"
  449. compress $FILES
  450. echo "Creating config.."
  451. echo ";!@Install@!UTF-8!" > 7zip.conf
  452. if [ "${isRelease}" != "" ]; then
  453. echo "Title=\"DMDirc Installation "${isRelease}"\"" >> 7zip.conf
  454. # echo "BeginPrompt=\"Do you want to install DMDirc "${isRelease}"?\"" >> 7zip.conf
  455. else
  456. echo "Title=\"DMDirc Installation\"" > 7zip.conf
  457. # echo "BeginPrompt=\"Do you want to install DMDirc?\"" >> 7zip.conf
  458. fi;
  459. echo "ExecuteFile=\"Setup.exe\"" >> 7zip.conf
  460. echo ";!@InstallEnd@!" >> 7zip.conf
  461. if [ ! -e "7zS.sfx" ]; then
  462. echo "Obtaining sfx stub.."
  463. wget http://binary.dmdirc.com/7zS.sfx
  464. fi
  465. if [ ! -e "7zS.sfx" ]; then
  466. echo "7zS.sfx not found, unable to continue."
  467. exit 1;
  468. fi;
  469. echo "Creating .exe"
  470. cat 7zS.sfx 7zip.conf "${INTNAME}" > "${RUNNAME}"
  471. if [ "${isRelease}" != "" ]; then
  472. if [ "${BRANCH}" = "1" ]; then
  473. releaseTag=branch-${isRelease}
  474. else
  475. releaseTag=${isRelease};
  476. fi;
  477. ORIGNAME="DMDirc-${releaseTag}-Setup${finalTag}.exe"
  478. else
  479. ORIGNAME="${INSTALLNAME}${finalTag}.exe"
  480. fi;
  481. echo "Building launcher";
  482. MD5BIN=`which md5sum`
  483. AWK=`which awk`
  484. MD5SUM=""
  485. if [ "${MD5BIN}" != "" -a "${AWK}" != "" ]; then
  486. MD5SUM=`${MD5BIN} extractor.exe | ${AWK} '{print $1}'`
  487. fi
  488. echo "const" > consts.inc
  489. echo " MD5SUM: String = '${MD5SUM}';" >> consts.inc
  490. # Code to extract and launch resource
  491. echo "ExtractResource('extractor', 'dmdirc_extractor.exe', TempDir);" > ExtractCode.inc
  492. if [ "${MD5SUM}" != "" ]; then
  493. echo "if FindCmdLineSwitch('-nomd5') or FindCmdLineSwitch('nomd5') or checkMD5(TempDir+'dmdirc_extractor.exe') then begin" >> ExtractCode.inc
  494. echo -n " "; # Oh so important for code formatting!
  495. fi;
  496. echo "Launch(TempDir+'dmdirc_extractor.exe');" >> ExtractCode.inc
  497. if [ "${MD5SUM}" != "" ]; then
  498. echo "end" >> ExtractCode.inc
  499. echo "else begin" >> ExtractCode.inc
  500. echo " ErrorMessage := 'This copy of the DMDirc installer appears to be damaged and will now exit';" >> ExtractCode.inc
  501. echo " ErrorMessage := ErrorMessage+#13#10+'You may choose to skip this check and run it anyway by passing the /nomd5 parameter';" >> ExtractCode.inc
  502. echo " ErrorMessage := ErrorMessage+#13#10+'';" >> ExtractCode.inc
  503. echo " ErrorMessage := ErrorMessage+#13#10;" >> ExtractCode.inc
  504. echo " ErrorMessage := ErrorMessage+#13#10+'If you feel this is incorrect, or you require some further assistance,';" >> ExtractCode.inc
  505. echo " ErrorMessage := ErrorMessage+#13#10+'please feel free to contact us.';" >> ExtractCode.inc
  506. echo " " >> ExtractCode.inc
  507. echo " MessageBox(0, PChar(ErrorMessage), 'Sorry, setup is unable to continue', MB_OK + MB_ICONSTOP);" >> ExtractCode.inc
  508. echo "end;" >> ExtractCode.inc
  509. fi
  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;