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

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