Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

makeInstallerWindows.sh 18KB

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