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

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