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

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