Browse Source

Installer moved into trunk


git-svn-id: http://svn.dmdirc.com/trunk@2741 00569f92-eb28-0410-84fd-f71c24880f
tags/0.5.5
Shane Mc Cormack 16 years ago
parent
commit
5bd229158b

+ 481
- 0
installer/linux/makeInstallerLinux.sh View File

@@ -0,0 +1,481 @@
1
+#!/bin/sh
2
+#
3
+# This script generates a .run file that will install DMDirc
4
+#
5
+# DMDirc - Open Source IRC Client
6
+# Copyright (c) 2006-2007 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
+
26
+# Final Name of the installer (without file extention)
27
+INSTALLERNAME=DMDirc-Setup
28
+# Location of .run stub start
29
+STARTLINE=`grep -n "^###START INCLUDE###$" $0`
30
+STARTLINE=$((${STARTLINE%%:*} + 1))
31
+# full name of the file to output to
32
+RUNNAME="${PWD}/${INSTALLERNAME}.run"
33
+
34
+# Compress stuff!
35
+compress() {
36
+	tar cvfh - $@ | gzip - 2>/dev/null >>${RUNNAME} || {
37
+		echo "Compression failed."
38
+		kill -15 $$;
39
+	};
40
+}
41
+
42
+# Go!
43
+echo "-----------"
44
+if [ -e "${RUNNAME}" ]; then
45
+	echo "Removing existing .run file"
46
+	rm -Rf ./*.run
47
+fi
48
+
49
+showHelp() {
50
+	echo "This will generate a DMDirc installer for a unix based system."
51
+	echo "The following command line arguments are known:"
52
+	echo "---------------------"
53
+	echo "-h, --help                Help information"
54
+	echo "-r, --release [version]   Generate a file based on an svn tag (or branch with -b aswell)"
55
+	echo "-b, --branch              Release in -r is a branch "
56
+	echo "-c, --compile             Recompile the .jar file"
57
+	echo "-t, --tag [tag]           Tag to add to final exe name to distinguish this build from a standard build"
58
+	echo "-k, --keep                Keep the existing source tree when compiling"
59
+	echo "                          (don't svn update beforehand)"
60
+	echo "---------------------"
61
+	exit 0;
62
+}
63
+
64
+# Check for some CLI params
65
+compileJar="false"
66
+updateSVN="true"
67
+isRelease=""
68
+finalTag=""
69
+BRANCH="0"
70
+location="../../../"
71
+while test -n "$1"; do
72
+	case "$1" in
73
+		--compile|-c)
74
+			compileJar="true"
75
+			;;
76
+		--release|-r)
77
+			shift
78
+			isRelease=${1}
79
+			;;
80
+		--tag|-t)
81
+			shift
82
+			RUNNAME="${PWD}/${INSTALLERNAME}-${1}.run"
83
+			;;
84
+		--keep|-k)
85
+			updateSVN="false"
86
+			;;
87
+		--help|-h)
88
+			showHelp;
89
+			;;
90
+		--branch|-b)
91
+			BRANCH="1"
92
+			;;
93
+	esac
94
+	shift
95
+done
96
+
97
+jarPath="${location}trunk"
98
+if [ "${isRelease}" != "" ]; then
99
+	if [ "${BRANCH}" != "0" ]; then
100
+		if [ -e "${location}branches/"${isRelease} ]; then
101
+			jarPath="${location}branches/"${isRelease}
102
+		else
103
+			echo "Branch "${isRelease}" not found."
104
+			exit 1;
105
+		fi
106
+	else
107
+		if [ -e "${location}tags/"${isRelease} ]; then
108
+			jarPath="${location}tags/"${isRelease}
109
+		else
110
+			echo "Tag "${isRelease}" not found."
111
+			exit 1;
112
+		fi
113
+	fi
114
+fi
115
+
116
+if [ ! -e ${jarPath}"/dist/DMDirc.jar" -o "${compileJar}" = "true" ]; then
117
+	echo "Creating jar.."
118
+	OLDPWD=${PWD}
119
+	cd ${jarPath}
120
+	if [ "${updateSVN}" = "true" ]; then
121
+		svn update
122
+	fi
123
+	rm -Rf build dist
124
+	ant jar
125
+	if [ ! -e "dist/DMDirc.jar" ]; then
126
+		echo "There was an error creating the .jar file. Aborting."
127
+		exit 0;
128
+	fi;
129
+	cd ${OLDPWD}
130
+fi;
131
+
132
+echo "Linking jar.."
133
+ln -s ${jarPath}"/dist/DMDirc.jar" "./DMDirc.jar"
134
+
135
+echo "Creating .run file"
136
+echo "Adding stub.."
137
+tail -n +${STARTLINE} $0 > ${RUNNAME}
138
+
139
+# Add release info.
140
+awk '{gsub(/###ADDITIONAL_STUFF###/,"isRelease=\"'${isRelease}'\"");print}' ${RUNNAME} > ${RUNNAME}.tmp
141
+mv ${RUNNAME}.tmp ${RUNNAME}
142
+
143
+FILES="DMDirc.jar";
144
+echo "Compressing files.."
145
+if [ -e "setup.sh" ]; then
146
+	FILES="${FILES} setup.sh"
147
+else
148
+	echo "[WARNING] Creating setup-less archive. This will just extract and immediately delete the .jar file unless the -e flag is used"
149
+fi 
150
+
151
+if [ -e "../common/installer.jar" ]; then
152
+	ln -s ../common/installer.jar ./installer.jar
153
+	FILES="${FILES} installer.jar"
154
+else
155
+	echo "[WARNING] Creating installer-less archive - relying on setup.sh"
156
+fi 
157
+
158
+if [ -e ${jarPath}"/src/com/dmdirc/res/logo.svg" ]; then
159
+	ln -s ${jarPath}"/src/com/dmdirc/res/logo.svg" ./icon.svg
160
+	FILES="${FILES} icon.svg"
161
+fi
162
+
163
+if [ "${isRelease}" != "" ]; then
164
+	DOCSDIR=${jarPath}
165
+else
166
+	DOCSDIR="../common"
167
+fi
168
+
169
+if [ -e "${DOCSDIR}/README.TXT" ]; then
170
+	ln -s "${DOCSDIR}/README.TXT" .
171
+	FILES="${FILES} README.TXT"
172
+fi
173
+
174
+if [ -e "${DOCSDIR}/CHANGES.TXT" ]; then
175
+	ln -s "${DOCSDIR}/CHANGES.TXT" .
176
+	FILES="${FILES} CHANGES.TXT"
177
+elif [ -e "${DOCSDIR}/CHANGELOG.TXT" ]; then
178
+	ln -s "${DOCSDIR}/CHANGELOG.TXT" .
179
+	FILES="${FILES} CHANGELOG.TXT"
180
+fi
181
+
182
+compress $FILES
183
+
184
+MD5BIN=`which md5sum`
185
+AWK=`which awk`
186
+getMD5() {
187
+	# Everything below the MD5SUM Line
188
+	MD5LINE=`grep -na "^MD5=\".*\"$" ${1}`
189
+	MD5LINE=$((${MD5LINE%%:*} + 1))
190
+
191
+	MD5SUM=`tail -n +${MD5LINE} "${1}" | ${MD5BIN} - | ${AWK} '{print $1}'`
192
+	return;
193
+}
194
+
195
+if [ "${MD5BIN}" != "" -a "${AWK}" != "" ]; then
196
+	echo "Adding MD5.."
197
+	
198
+	MD5SUM=""
199
+	getMD5 ${RUNNAME} ${MD5SUM}
200
+	
201
+	echo "SUM obtained is: ${MD5SUM}"
202
+	
203
+	LINENUM=`grep -na "^MD5=\"\"$" ${RUNNAME}`
204
+	LINENUM=${LINENUM%%:*}
205
+	
206
+	head -n $((${LINENUM} -1)) ${RUNNAME} > ${RUNNAME}.tmp
207
+	echo 'MD5="'${MD5SUM}'"' >> ${RUNNAME}.tmp
208
+	tail -n +$((${LINENUM} +1)) ${RUNNAME} >> ${RUNNAME}.tmp
209
+	mv ${RUNNAME}.tmp ${RUNNAME}
210
+else
211
+	echo "Not Adding MD5.."
212
+fi;
213
+
214
+echo "Chmodding"
215
+chmod a+x ${RUNNAME}
216
+
217
+if [ "${isRelease}" != "" ]; then
218
+	mv ${RUNNAME} ../output/DMDirc-${isRelease}-Setup.run
219
+else
220
+	mv ${RUNNAME} ../output/
221
+fi;
222
+mv setup.sh setup.sh.tmp
223
+rm -f ${FILES}
224
+mv setup.sh.tmp setup.sh
225
+
226
+echo "-----------"
227
+echo "Done."
228
+echo "-----------"
229
+
230
+# and Done \o
231
+exit 0;
232
+### Everything below here is part of the .run stub.
233
+###START INCLUDE###
234
+#!/bin/sh
235
+#
236
+# This script installs dmdirc
237
+#
238
+# DMDirc - Open Source IRC Client
239
+# Copyright (c) 2006-2007 Chris Smith, Shane Mc Cormack, Gregory Holmes
240
+#
241
+# Permission is hereby granted, free of charge, to any person obtaining a copy
242
+# of this software and associated documentation files (the "Software"), to deal
243
+# in the Software without restriction, including without limitation the rights
244
+# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
245
+# copies of the Software, and to permit persons to whom the Software is
246
+# furnished to do so, subject to the following conditions:
247
+#
248
+# The above copyright notice and this permission notice shall be included in
249
+# all copies or substantial portions of the Software.
250
+#
251
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
252
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
253
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
254
+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
255
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
256
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
257
+# SOFTWARE.
258
+
259
+MD5=""
260
+
261
+# Check the which command exists
262
+WHICH=`which`
263
+if [ "" != "${WHICH}" ]; then
264
+	echo "which command not found. Aborting.";
265
+	exit 0;
266
+fi
267
+
268
+
269
+###ADDITIONAL_STUFF###
270
+
271
+# Location of .run stub end
272
+ENDLINE=`grep -na "^###END INCLUDE###$" $0`
273
+ENDLINE=$((${ENDLINE%%:*} + 1))
274
+
275
+if [ "" = "${ENDLINE}" ]; then
276
+	echo "End of stub not found. Aborting.";
277
+	exit 0;
278
+fi
279
+
280
+# Attempt to get a name for a random dir in /tmp
281
+random() {
282
+	# First off, lets try mktemp.
283
+	MKTEMP=`which mktemp`
284
+	if [ "" != "${MKTEMP}" ]; then
285
+		# mktemp exists \o
286
+		DIR=`${MKTEMP} -d`
287
+		eval "$1=${DIR}"
288
+		return;
289
+	fi
290
+	
291
+	TMPDIR=${TMPDIR:=/tmp}
292
+	BASEDIR=${TMPDIR}dmdirc_`whoami`_
293
+	DIR=${PWD}
294
+	while [ -d "${DIR}" ]; do
295
+		if [ "" != "${RANDOM}" ]; then
296
+			# Bash has a psuedo random number generator that can be accessed
297
+			# using ${RANDOM}
298
+			RND=${RANDOM}${RANDOM}${RANDOM}
299
+		else
300
+			# Dash (the ubuntu default sh) however does not.
301
+			# od and awk however usually exist, and we can get a random number
302
+			# from /dev/urandom or /dev/random
303
+			OD=`which od`
304
+			AWK=`which awk`
305
+			RND=""
306
+			if [ "" != "$OD" -a "" != "$AWK" ]; then
307
+				# Try /dev/urandom first
308
+				RAND=/dev/urandom
309
+				# If it doesn't exist try /dev/random
310
+				if [ ! -e "${RAND}" ]; then
311
+					RAND=/dev/urandom;
312
+				fi
313
+				# This makes sure we only try to read if one exists
314
+				if [ ! -e "${RAND}" ]; then
315
+					RND=$(head -1 ${RAND} | od -N 3 -t u | awk '{ print $2 }')
316
+				fi;
317
+			fi;
318
+			
319
+			# No random number was generated, getting to here means that
320
+			# ${RANDOM} doesn't exist, /dev/random doesn't exist, /dev/urandom doesn't exist
321
+			# or that od/awk don't exist. Annoying.
322
+			# Try using this processes PID instead!
323
+			if [ "${RND}" = "" ]; then
324
+				RND=$$
325
+				DIR=${BASEDIR}${RND}
326
+				if [ -e "${DIR}" ]; then
327
+					# Lets hope this never happens.
328
+					echo "Unable to create random directory";
329
+					exit 0;
330
+				fi;
331
+			fi;
332
+		fi;
333
+		DIR=${BASEDIR}${RND}
334
+	done
335
+	mkdir ${DIR}
336
+	eval "$1=${DIR}"
337
+}
338
+
339
+uncompress() {
340
+	tail -n +${ENDLINE} "${OLDPWD}/$0" | gzip -cd | tar -xvf - 2>/dev/null || {
341
+		echo "Decompression failed."
342
+		kill -15 $$;
343
+	};
344
+}
345
+
346
+showHelp() {
347
+	echo "This will install DMDirc on a unix based system."
348
+	echo "The following command line arguments are known:"
349
+	echo "---------------------"
350
+	echo "-h, --help        Help information"
351
+	echo "-e, --extract     Extract .run file only, do not run setup.sh"
352
+	echo "-s, --script      Don't use installer.jar (not implemented yet)"
353
+	echo "---------------------"
354
+	exit 0;
355
+}
356
+
357
+# Defaults
358
+extractOnly="false"
359
+setupParams=""
360
+skipMD5="false"
361
+
362
+# Begin
363
+echo "---------------------"
364
+echo "DMDirc Unix Setup"
365
+if [ "${isRelease}" != "" ]; then
366
+	echo "Version: "${isRelease};
367
+	setupParams="${setupParams} --release "${isRelease}
368
+fi;
369
+echo "---------------------"
370
+# Check for cmdline args
371
+while test -n "$1"; do
372
+	case "$1" in
373
+		--help|-h)
374
+			showHelp
375
+			;;
376
+		--extract|-e)
377
+			extractOnly="true"
378
+			;;
379
+		--script|-s)
380
+			setupParams="${setupParams} --script"
381
+			;;
382
+		--nomd5)
383
+			skipMD5="true"
384
+			;;
385
+	esac
386
+	shift
387
+done
388
+
389
+MD5BIN=`which md5sum`
390
+AWK=`which awk`
391
+getMD5() {
392
+	# Everything below the MD5SUM Line
393
+	MD5LINE=`grep -na "^MD5=\".*\"$" ${1}`
394
+	MD5LINE=$((${MD5LINE%%:*} + 1))
395
+
396
+	MD5SUM=`tail -n +${MD5LINE} "${1}" | ${MD5BIN} - | ${AWK} '{print $1}'`
397
+	return;
398
+}
399
+
400
+if [ "${MD5BIN}" != "" ]; then
401
+	if [ ${skipMD5} != "true" ]; then
402
+		if [ -e "${0}.md5"  ]; then
403
+			echo "Checking MD5 using ${0}.md5.."
404
+			${MD5BIN} --check --status ${0}.md5
405
+			if [ $? = 0 ]; then
406
+				echo "MD5 Check Passed!"
407
+			else
408
+				echo ""
409
+				echo "MD5 Check Failed!"
410
+				echo "--------------------------"
411
+				echo "This copy of the DMDirc installer appears to be damaged and will now exit.";
412
+				echo "You may choose to skip this check and run it anyway by passing the --nomd5 parameter";
413
+				exit 1;
414
+			fi
415
+		elif [ "${MD5}" != ""  ]; then
416
+			echo "Checking MD5 using built in hash.."
417
+			if [ "${AWK}" != "" ]; then
418
+				MD5SUM=""
419
+				getMD5 ${0} ${MD5SUM}
420
+			
421
+				echo "SUM obtained is: ${MD5SUM}"
422
+				echo "SUM expected is: ${MD5}"
423
+				if [ "${MD5SUM}" = "${MD5}" ]; then
424
+					echo "MD5 Check Passed!"
425
+				else
426
+					echo ""
427
+					echo "MD5 Check Failed!"
428
+					echo "--------------------------"
429
+					echo "This copy of the DMDirc installer appears to be damaged and will now exit.";
430
+					echo "You may choose to skip this check and run it anyway by passing the --nomd5 parameter";
431
+					exit 1;
432
+				fi;
433
+			else
434
+				echo "MD5 Check skipped (awk not found).."
435
+			fi;
436
+		else
437
+			if [ "${MD5BIN}" = "" ]; then
438
+				echo "MD5 Check skipped (md5sum not found).."
439
+			else
440
+				echo "MD5 Check skipped (No MD5 hash found to compare against).."
441
+			fi
442
+		fi;
443
+	else
444
+		echo "MD5 Check skipped (Requested).."
445
+	fi
446
+fi;
447
+
448
+OLDPWD=${PWD}
449
+echo "Getting Temp Dir"
450
+random TEMPDIR
451
+echo "Got Temp Dir: ${TEMPDIR}"
452
+cd ${TEMPDIR}
453
+echo "Uncompressing to temp dir.."
454
+uncompress
455
+echo "Done."
456
+# Check if extract only was wanted.
457
+if [ "${extractOnly}" = "true" ]; then
458
+	echo "Extracted. (Files can be found in: ${TEMPDIR})"
459
+	exit 0;
460
+fi
461
+
462
+if [ -e "${TEMPDIR}/setup.sh" ]; then
463
+	echo "Running setup.."
464
+	chmod a+x ${TEMPDIR}/setup.sh
465
+	${TEMPDIR}/setup.sh ${setupParams}
466
+	echo ""
467
+	if [ $? -eq 0 ]; then
468
+		echo "Setup completed."
469
+	else
470
+		echo "Setup failed."
471
+	fi
472
+else
473
+	echo "No setup.sh found. This was pointless?"
474
+fi
475
+echo "Removing temp dir"
476
+cd ${OLDPWD}
477
+rm -Rf ${TEMPDIR}
478
+echo "Installation Completed."
479
+# Job Done!
480
+exit 0;
481
+###END INCLUDE###

+ 125
- 0
installer/linux/setup.sh View File

@@ -0,0 +1,125 @@
1
+#!/bin/sh
2
+#
3
+# This script launches the dmdirc java-based installer.
4
+#
5
+# DMDirc - Open Source IRC Client
6
+# Copyright (c) 2006-2007 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
+
26
+echo ""
27
+echo "---------------------"
28
+echo "Setup.sh"
29
+echo "---------------------"
30
+echo -n "Looking for java.. ";
31
+JAVA=`which java`
32
+
33
+if [ "" != "${JAVA}" ]; then
34
+	echo "Success!"
35
+else
36
+	echo "Failed!"
37
+	# This should in future offer to download and install the JVM automatically.
38
+	echo ""
39
+	echo "-----------------------------------------------------------------------"
40
+	echo "Unable to complete setup!"
41
+	echo "-----------------------------------------------------------------------"
42
+	echo "Sorry, java is not installed on this machine."
43
+	echo ""
44
+	echo "DMDirc requires a 1.6.0 compatible JVM, you can get one from:"
45
+	echo "http://jdl.sun.com/webapps/getjava/BrowserRedirect"
46
+	echo "-----------------------------------------------------------------------"
47
+	exit 1;
48
+fi
49
+
50
+echo "Success!"
51
+
52
+if [ "${UID}" = "" ]; then
53
+	UID=`id -u`;
54
+fi
55
+if [ "0" = "${UID}" ]; then
56
+	echo "Running as root.."
57
+	isRoot="--isroot";
58
+else
59
+	echo "Running as user.."
60
+	isRoot="";
61
+fi
62
+
63
+showHelp() {
64
+	echo "This will setup DMDirc on a unix based system."
65
+	echo "The following command line arguments are known:"
66
+	echo "---------------------"
67
+	echo "-h, --help                Help information"
68
+	echo "-r, --release [version]   This is a release"
69
+	echo "-s, --script              Don't use installer.jar (not implemented yet)"
70
+	echo "---------------------"
71
+	exit 0;
72
+}
73
+
74
+# Check for some CLI params
75
+scriptOnly="false"
76
+isRelease=""
77
+while test -n "$1"; do
78
+	case "$1" in
79
+		--script|-s)
80
+			scriptOnly="true"
81
+			shift
82
+			;;
83
+		--release|-r)
84
+			shift
85
+			isRelease=${1}
86
+			shift
87
+			;;
88
+		--help|-h)
89
+			showHelp;
90
+			;;
91
+	esac
92
+done
93
+
94
+if [ "${isRelease}" != "" ]; then
95
+	isRelease=" --release "${isRelease}
96
+fi
97
+
98
+if [ -e "installer.jar" ]; then
99
+	if [ "${scriptOnly}" = "true" ]; then
100
+		echo "Script-only install requested."
101
+	else
102
+		echo "Running installer.."
103
+		${JAVA} -cp DMDirc.jar -jar installer.jar ${isRoot}${isRelease}
104
+		if [ $? -ne 0 ]; then
105
+			echo ""
106
+			echo "-----------------------------------------------------------------------"
107
+			echo "Unable to complete setup!"
108
+			echo "-----------------------------------------------------------------------"
109
+			echo "Sorry, the currently installed version of java is not compatible with"
110
+			echo "DMDirc."
111
+			echo ""
112
+			echo "DMDirc requires a 1.6.0 compatible JVM, you can get one from:"
113
+			echo "http://jdl.sun.com/webapps/getjava/BrowserRedirect"
114
+			echo "-----------------------------------------------------------------------"
115
+			exit 1;
116
+		fi
117
+		exit 0;
118
+	fi
119
+else 
120
+	echo "No installer found!"
121
+fi
122
+
123
+## Script-Only install goes here.
124
+echo "Script-Only functionality not implemented."
125
+exit 1;

+ 149
- 0
installer/release.sh View File

@@ -0,0 +1,149 @@
1
+#!/bin/sh
2
+
3
+showHelp() {
4
+	echo "This will generate the different DMDirc installers."
5
+	echo "Usage: ${0} [params] <release>"
6
+	echo "Release can be either 'trunk', a valid tag, or a branch (if -b is passed)"
7
+	echo "The following params are known:"
8
+	echo "---------------------"
9
+	echo "-b, --branch              <release> is a branch"
10
+	echo "-h, --help                Help information"
11
+	echo "-o, --opt [options]       Additional options to pass to the make*Installer.sh files"
12
+	echo "---------------------"
13
+	exit 0;
14
+}
15
+
16
+# Check for some CLI params
17
+LAST=""
18
+OPT=""
19
+BRANCH=""
20
+while test -n "$1"; do
21
+	LAST=${1}
22
+	case "$1" in
23
+		--opt|-o)
24
+			shift
25
+			OPT="${1} "
26
+			;;
27
+		--help|-h)
28
+			showHelp;
29
+			;;
30
+		--branch|-b)
31
+			BRANCH="-b "
32
+			;;
33
+	esac
34
+	shift
35
+done
36
+
37
+if [ "${LAST}" != "" ]; then
38
+	if [ "${LAST}" = "trunk" ]; then
39
+		RELEASE=""
40
+	elif [ "${BRANCH}" != "" -a ! -e "../../branches/"${LAST} ]; then
41
+		echo "Branch '"${LAST}"' not found."
42
+		exit 1;
43
+	elif [ "${BRANCH}" = "" -a ! -e "../../tags/"${LAST} ]; then
44
+		echo "Tag '"${LAST}"' not found."
45
+		exit 1;
46
+	else
47
+		RELEASE="-r "${LAST}
48
+	fi
49
+else
50
+	echo "Usage: ${0} [params] <release>"
51
+	echo "Release can be either 'trunk' or a valid tag. (see ${0} --help for further information)"
52
+	exit 1;
53
+fi
54
+
55
+JAR=/usr/bin/jar
56
+JAVAC=/usr/bin/javac
57
+THISDIR=${PWD}
58
+
59
+echo "================================================================"
60
+echo "Removing existing releases from output directory"
61
+echo "================================================================"
62
+rm -Rf output/*.run output/*.exe
63
+echo "================================================================"
64
+echo "Building Installer JAR "
65
+echo "================================================================"
66
+mkdir -p installer_temp/build
67
+cd installer_temp
68
+ln -s ../../src/com
69
+ln -s ../../src/net
70
+# I don't know why, but -d doesn't nicely put ALL generated class files here,
71
+# just those that were in the dir of the java file that was requested for compile
72
+# So we specify each of the different ones we want built into the jar file here.
73
+${JAVAC} -d ./build com/dmdirc/installer/*.java
74
+${JAVAC} -d ./build com/dmdirc/installer/cliparser/*.java
75
+${JAVAC} -d ./build com/dmdirc/ui/swing/dialogs/wizard/*.java
76
+${JAVAC} -d ./build com/dmdirc/ui/interfaces/MainWindow.java
77
+${JAVAC} -d ./build com/dmdirc/ui/swing/MainFrame.java
78
+${JAVAC} -d ./build com/dmdirc/ui/swing/UIUtilities.java
79
+${JAVAC} -d ./build com/dmdirc/ui/swing/UIUtilities.java
80
+${JAVAC} -d ./build com/dmdirc/ui/swing/components/StandardDialog.java
81
+${JAVAC} -d ./build com/dmdirc/util/ListenerList.java
82
+${JAVAC} -d ./build com/dmdirc/util/WeakMapList.java
83
+${JAVAC} -d ./build com/dmdirc/util/WeakList.java
84
+#${JAVAC} -d ./build net/miginfocom/layout/*.java
85
+#${JAVAC} -d ./build net/miginfocom/swing/*.java
86
+if [ $? -ne 0 ]; then
87
+	echo "================================================================"
88
+	echo "Building installer failed."
89
+	echo "================================================================"
90
+	cd ${THISDIR}
91
+	rm -Rf installer_temp
92
+	exit 1;
93
+fi
94
+cd build
95
+echo "Manifest-Version: 1.0" > manifest.txt
96
+echo "Created-By: DMDirc Installer" >> manifest.txt
97
+echo "Main-Class: com.dmdirc.installer.Main" >> manifest.txt
98
+echo "Class-Path: " >> manifest.txt
99
+echo "" >> manifest.txt
100
+${JAR} cmf manifest.txt installer.jar com #net
101
+if [ $? -ne 0 ]; then
102
+	echo "================================================================"
103
+	echo "Building installer failed."
104
+	echo "================================================================"
105
+	cd ${THISDIR}
106
+	rm -Rf installer_temp	
107
+	exit 1;
108
+else
109
+	rm -Rf ${THISDIR}/common/installer.jar
110
+	mv installer.jar ${THISDIR}/common/installer.jar
111
+fi
112
+
113
+cd ${THISDIR}
114
+rm -Rf installer_temp
115
+echo "================================================================"
116
+echo "Building linux installer"
117
+echo "================================================================"
118
+cd linux
119
+./makeInstallerLinux.sh ${OPT}-c -k ${BRANCH}${RELEASE}
120
+cd ${THISDIR}
121
+
122
+echo "================================================================"
123
+echo "Building Windows installer"
124
+echo "================================================================"
125
+cd windows
126
+./makeInstallerWindows.sh ${OPT}-k -s ${BRANCH}${RELEASE}
127
+cd ${THISDIR}
128
+
129
+MD5BIN=`which md5sum`
130
+if [ "${MD5BIN}" != "" ]; then
131
+	echo "================================================================"
132
+	echo "Creating MD5SUM files"
133
+	echo "================================================================"
134
+	cd output
135
+	for outputFile in *; do
136
+		if [ "${outputFile##*.}" != "md5" ]; then
137
+			if [ -e "${outputFile}.md5" ]; then
138
+				rm -f "${outputFile}.md5"
139
+			fi
140
+			${MD5BIN} "${outputFile}" > "${outputFile}.md5"
141
+		fi
142
+	done
143
+	cd ${THISDIR}
144
+fi
145
+
146
+echo "================================================================"
147
+echo "Release ready - see output folder"
148
+echo "================================================================"
149
+exit 0;

+ 89
- 0
installer/windows/Launcher.dpr View File

@@ -0,0 +1,89 @@
1
+program Launcher;
2
+{$MODE Delphi}
3
+{$APPTYPE GUI}
4
+
5
+uses Windows, SysUtils, classes, MD5;
6
+
7
+//{$R files.res}
8
+//{$R version.res}
9
+//{$R icon.res}
10
+{$R all.res}
11
+
12
+{$I consts.inc}
13
+
14
+function GetTempDirectory(): String;
15
+var
16
+	buf: array[0..MAX_PATH] of Char;
17
+	wintemp, temp: String;
18
+begin
19
+	GetTempPath(SizeOf(buf)-1, buf);
20
+	wintemp := StrPas(buf);
21
+	Randomize;
22
+	temp := '\DMDirc-installer-'+inttostr(1000 + Random(1000));
23
+	while (DirectoryExists(wintemp+temp+'\')) do begin
24
+		temp := temp+'-'+inttostr(1+Random(1000));
25
+	end;
26
+	MkDir(wintemp+temp+'\');
27
+	result := wintemp+temp+'\';
28
+end;
29
+
30
+procedure ExtractResource(name: string; filename: string; dir: string = '');
31
+var
32
+	rStream: TResourceStream;
33
+	fStream: TFileStream;
34
+	fname: string;
35
+begin
36
+	if (dir = '') or (not DirectoryExists(dir)) then dir := IncludeTrailingPathDelimiter(ExtractFileDir(paramstr(0)));
37
+	fname := dir+filename;
38
+	if FileExists(fname) then DeleteFile(fname);
39
+	
40
+	rStream := TResourceStream.Create(hInstance, name, RT_RCDATA);
41
+	try
42
+		fStream := TFileStream.Create(fname, fmCreate);
43
+		try
44
+			fStream.CopyFrom(rStream, 0);
45
+		finally
46
+			fStream.Free;
47
+		end;
48
+	finally
49
+		rStream.Free;
50
+	end;
51
+end;
52
+
53
+procedure Launch(sProgramToRun: String);
54
+var
55
+	StartupInfo: TStartupInfo;
56
+	ProcessInfo: TProcessInformation;
57
+begin
58
+	FillChar(StartupInfo, SizeOf(TStartupInfo), 0);
59
+	with StartupInfo do begin
60
+		cb := SizeOf(TStartupInfo);
61
+		dwFlags := STARTF_USESHOWWINDOW;
62
+		wShowWindow := SW_SHOWNORMAL;
63
+	end;
64
+
65
+	CreateProcess(nil, PChar(sProgramToRun), nil, nil, False, NORMAL_PRIORITY_CLASS, nil, nil, StartupInfo, ProcessInfo);
66
+end;
67
+
68
+function checkMD5(filename: String): boolean;
69
+var
70
+	hash: String;
71
+begin
72
+	hash := MD5Print(MD5File(filename));
73
+	result := (hash = MD5SUM);
74
+//	if not result then begin
75
+//		MessageBox(0, PChar('MD5Hash Result:'+#10+'Got: '+hash+#10+'Exp: '+MD5SUM+#10+'Res:'+booltostr(hash = MD5SUM)), 'Test', MB_OK + MB_ICONSTOP);
76
+//	end;
77
+
78
+// Uncomment this to disable MD5 Check
79
+//	result := true;
80
+end;
81
+
82
+var
83
+	ErrorMessage: String;
84
+	TempDir: String;
85
+begin
86
+	TempDir := GetTempDirectory;
87
+	ErrorMessage := '';
88
+	{$I ExtractCode.inc}
89
+end.

+ 393
- 0
installer/windows/MD5.pas View File

@@ -0,0 +1,393 @@
1
+                                                                              // tabs = 2
2
+// -----------------------------------------------------------------------------------------------
3
+//
4
+//                                 MD5 Message-Digest for Delphi 4
5
+//
6
+//                                 Delphi 4 Unit implementing the
7
+//                      RSA Data Security, Inc. MD5 Message-Digest Algorithm
8
+//
9
+//                          Implementation of Ronald L. Rivest's RFC 1321
10
+//
11
+//                      Copyright � 1997-1999 Medienagentur Fichtner & Meyer
12
+//                                  Written by Matthias Fichtner
13
+//
14
+// -----------------------------------------------------------------------------------------------
15
+//               See RFC 1321 for RSA Data Security's copyright and license notice!
16
+// -----------------------------------------------------------------------------------------------
17
+//
18
+//     14-Jun-97  mf  Implemented MD5 according to RFC 1321                           RFC 1321
19
+//     16-Jun-97  mf  Initial release of the compiled unit (no source code)           RFC 1321
20
+//     28-Feb-99  mf  Added MD5Match function for comparing two digests               RFC 1321
21
+//     13-Sep-99  mf  Reworked the entire unit                                        RFC 1321
22
+//     17-Sep-99  mf  Reworked the "Test Driver" project                              RFC 1321
23
+//     19-Sep-99  mf  Release of sources for MD5 unit and "Test Driver" project       RFC 1321
24
+//
25
+// -----------------------------------------------------------------------------------------------
26
+//                   The latest release of md5.pas will always be available from
27
+//                  the distribution site at: http://www.fichtner.net/delphi/md5/
28
+// -----------------------------------------------------------------------------------------------
29
+//                       Please send questions, bug reports and suggestions
30
+//                      regarding this code to: mfichtner@fichtner-meyer.com
31
+// -----------------------------------------------------------------------------------------------
32
+//                        This code is provided "as is" without express or
33
+//                     implied warranty of any kind. Use it at your own risk.
34
+// -----------------------------------------------------------------------------------------------
35
+
36
+unit md5;
37
+{$MODE Delphi}
38
+// -----------------------------------------------------------------------------------------------
39
+INTERFACE
40
+// -----------------------------------------------------------------------------------------------
41
+
42
+uses
43
+	Windows;
44
+
45
+type
46
+	MD5Count = array[0..1] of DWORD;
47
+	MD5State = array[0..3] of DWORD;
48
+	MD5Block = array[0..15] of DWORD;
49
+	MD5CBits = array[0..7] of byte;
50
+	MD5Digest = array[0..15] of byte;
51
+	MD5Buffer = array[0..63] of byte;
52
+	MD5Context = record
53
+		State: MD5State;
54
+		Count: MD5Count;
55
+		Buffer: MD5Buffer;
56
+	end;
57
+
58
+procedure MD5Init(var Context: MD5Context);
59
+procedure MD5Update(var Context: MD5Context; Input: pChar; Length: longword);
60
+procedure MD5Final(var Context: MD5Context; var Digest: MD5Digest);
61
+
62
+function MD5String(M: string): MD5Digest;
63
+function MD5File(N: string): MD5Digest;
64
+function MD5Print(D: MD5Digest): string;
65
+
66
+function MD5Match(D1, D2: MD5Digest): boolean;
67
+
68
+// -----------------------------------------------------------------------------------------------
69
+IMPLEMENTATION
70
+// -----------------------------------------------------------------------------------------------
71
+
72
+var
73
+	PADDING: MD5Buffer = (
74
+		$80, $00, $00, $00, $00, $00, $00, $00,
75
+		$00, $00, $00, $00, $00, $00, $00, $00,
76
+		$00, $00, $00, $00, $00, $00, $00, $00,
77
+		$00, $00, $00, $00, $00, $00, $00, $00,
78
+		$00, $00, $00, $00, $00, $00, $00, $00,
79
+		$00, $00, $00, $00, $00, $00, $00, $00,
80
+		$00, $00, $00, $00, $00, $00, $00, $00,
81
+		$00, $00, $00, $00, $00, $00, $00, $00
82
+	);
83
+
84
+function F(x, y, z: DWORD): DWORD;
85
+begin
86
+	Result := (x and y) or ((not x) and z);
87
+end;
88
+
89
+function G(x, y, z: DWORD): DWORD;
90
+begin
91
+	Result := (x and z) or (y and (not z));
92
+end;
93
+
94
+
95
+function H(x, y, z: DWORD): DWORD;
96
+begin
97
+	Result := x xor y xor z;
98
+end;
99
+
100
+function I(x, y, z: DWORD): DWORD;
101
+begin
102
+	Result := y xor (x or (not z));
103
+end;
104
+
105
+procedure rot(var x: DWORD; n: BYTE);
106
+begin
107
+	x := (x shl n) or (x shr (32 - n));
108
+end;
109
+
110
+procedure FF(var a: DWORD; b, c, d, x: DWORD; s: BYTE; ac: DWORD);
111
+begin
112
+	inc(a, F(b, c, d) + x + ac);
113
+	rot(a, s);
114
+	inc(a, b);
115
+end;
116
+
117
+procedure GG(var a: DWORD; b, c, d, x: DWORD; s: BYTE; ac: DWORD);
118
+begin
119
+	inc(a, G(b, c, d) + x + ac);
120
+	rot(a, s);
121
+	inc(a, b);
122
+end;
123
+
124
+procedure HH(var a: DWORD; b, c, d, x: DWORD; s: BYTE; ac: DWORD);
125
+begin
126
+	inc(a, H(b, c, d) + x + ac);
127
+	rot(a, s);
128
+	inc(a, b);
129
+end;
130
+
131
+procedure II(var a: DWORD; b, c, d, x: DWORD; s: BYTE; ac: DWORD);
132
+begin
133
+	inc(a, I(b, c, d) + x + ac);
134
+	rot(a, s);
135
+	inc(a, b);
136
+end;
137
+
138
+// -----------------------------------------------------------------------------------------------
139
+
140
+// Encode Count bytes at Source into (Count / 4) DWORDs at Target
141
+procedure Encode(Source, Target: pointer; Count: longword);
142
+var
143
+	S: PByte;
144
+	T: PDWORD;
145
+	I: longword;
146
+begin
147
+	S := Source;
148
+	T := Target;
149
+	for I := 1 to Count div 4 do begin
150
+		T^ := S^;
151
+		inc(S);
152
+		T^ := T^ or (S^ shl 8);
153
+		inc(S);
154
+		T^ := T^ or (S^ shl 16);
155
+		inc(S);
156
+		T^ := T^ or (S^ shl 24);
157
+		inc(S);
158
+		inc(T);
159
+	end;
160
+end;
161
+
162
+// Decode Count DWORDs at Source into (Count * 4) Bytes at Target
163
+procedure Decode(Source, Target: pointer; Count: longword);
164
+var
165
+	S: PDWORD;
166
+	T: PByte;
167
+	I: longword;
168
+begin
169
+	S := Source;
170
+	T := Target;
171
+	for I := 1 to Count do begin
172
+		T^ := S^ and $ff;
173
+		inc(T);
174
+		T^ := (S^ shr 8) and $ff;
175
+		inc(T);
176
+		T^ := (S^ shr 16) and $ff;
177
+		inc(T);
178
+		T^ := (S^ shr 24) and $ff;
179
+		inc(T);
180
+		inc(S);
181
+	end;
182
+end;
183
+
184
+// Transform State according to first 64 bytes at Buffer
185
+procedure Transform(Buffer: pointer; var State: MD5State);
186
+var
187
+	a, b, c, d: DWORD;
188
+	Block: MD5Block;
189
+begin
190
+	Encode(Buffer, @Block, 64);
191
+	a := State[0];
192
+	b := State[1];
193
+	c := State[2];
194
+	d := State[3];
195
+	FF (a, b, c, d, Block[ 0],  7, $d76aa478);
196
+	FF (d, a, b, c, Block[ 1], 12, $e8c7b756);
197
+	FF (c, d, a, b, Block[ 2], 17, $242070db);
198
+	FF (b, c, d, a, Block[ 3], 22, $c1bdceee);
199
+	FF (a, b, c, d, Block[ 4],  7, $f57c0faf);
200
+	FF (d, a, b, c, Block[ 5], 12, $4787c62a);
201
+	FF (c, d, a, b, Block[ 6], 17, $a8304613);
202
+	FF (b, c, d, a, Block[ 7], 22, $fd469501);
203
+	FF (a, b, c, d, Block[ 8],  7, $698098d8);
204
+	FF (d, a, b, c, Block[ 9], 12, $8b44f7af);
205
+	FF (c, d, a, b, Block[10], 17, $ffff5bb1);
206
+	FF (b, c, d, a, Block[11], 22, $895cd7be);
207
+	FF (a, b, c, d, Block[12],  7, $6b901122);
208
+	FF (d, a, b, c, Block[13], 12, $fd987193);
209
+	FF (c, d, a, b, Block[14], 17, $a679438e);
210
+	FF (b, c, d, a, Block[15], 22, $49b40821);
211
+	GG (a, b, c, d, Block[ 1],  5, $f61e2562);
212
+	GG (d, a, b, c, Block[ 6],  9, $c040b340);
213
+	GG (c, d, a, b, Block[11], 14, $265e5a51);
214
+	GG (b, c, d, a, Block[ 0], 20, $e9b6c7aa);
215
+	GG (a, b, c, d, Block[ 5],  5, $d62f105d);
216
+	GG (d, a, b, c, Block[10],  9,  $2441453);
217
+	GG (c, d, a, b, Block[15], 14, $d8a1e681);
218
+	GG (b, c, d, a, Block[ 4], 20, $e7d3fbc8);
219
+	GG (a, b, c, d, Block[ 9],  5, $21e1cde6);
220
+	GG (d, a, b, c, Block[14],  9, $c33707d6);
221
+	GG (c, d, a, b, Block[ 3], 14, $f4d50d87);
222
+	GG (b, c, d, a, Block[ 8], 20, $455a14ed);
223
+	GG (a, b, c, d, Block[13],  5, $a9e3e905);
224
+	GG (d, a, b, c, Block[ 2],  9, $fcefa3f8);
225
+	GG (c, d, a, b, Block[ 7], 14, $676f02d9);
226
+	GG (b, c, d, a, Block[12], 20, $8d2a4c8a);
227
+	HH (a, b, c, d, Block[ 5],  4, $fffa3942);
228
+	HH (d, a, b, c, Block[ 8], 11, $8771f681);
229
+	HH (c, d, a, b, Block[11], 16, $6d9d6122);
230
+	HH (b, c, d, a, Block[14], 23, $fde5380c);
231
+	HH (a, b, c, d, Block[ 1],  4, $a4beea44);
232
+	HH (d, a, b, c, Block[ 4], 11, $4bdecfa9);
233
+	HH (c, d, a, b, Block[ 7], 16, $f6bb4b60);
234
+	HH (b, c, d, a, Block[10], 23, $bebfbc70);
235
+	HH (a, b, c, d, Block[13],  4, $289b7ec6);
236
+	HH (d, a, b, c, Block[ 0], 11, $eaa127fa);
237
+	HH (c, d, a, b, Block[ 3], 16, $d4ef3085);
238
+	HH (b, c, d, a, Block[ 6], 23,  $4881d05);
239
+	HH (a, b, c, d, Block[ 9],  4, $d9d4d039);
240
+	HH (d, a, b, c, Block[12], 11, $e6db99e5);
241
+	HH (c, d, a, b, Block[15], 16, $1fa27cf8);
242
+	HH (b, c, d, a, Block[ 2], 23, $c4ac5665);
243
+	II (a, b, c, d, Block[ 0],  6, $f4292244);
244
+	II (d, a, b, c, Block[ 7], 10, $432aff97);
245
+	II (c, d, a, b, Block[14], 15, $ab9423a7);
246
+	II (b, c, d, a, Block[ 5], 21, $fc93a039);
247
+	II (a, b, c, d, Block[12],  6, $655b59c3);
248
+	II (d, a, b, c, Block[ 3], 10, $8f0ccc92);
249
+	II (c, d, a, b, Block[10], 15, $ffeff47d);
250
+	II (b, c, d, a, Block[ 1], 21, $85845dd1);
251
+	II (a, b, c, d, Block[ 8],  6, $6fa87e4f);
252
+	II (d, a, b, c, Block[15], 10, $fe2ce6e0);
253
+	II (c, d, a, b, Block[ 6], 15, $a3014314);
254
+	II (b, c, d, a, Block[13], 21, $4e0811a1);
255
+	II (a, b, c, d, Block[ 4],  6, $f7537e82);
256
+	II (d, a, b, c, Block[11], 10, $bd3af235);
257
+	II (c, d, a, b, Block[ 2], 15, $2ad7d2bb);
258
+	II (b, c, d, a, Block[ 9], 21, $eb86d391);
259
+	inc(State[0], a);
260
+	inc(State[1], b);
261
+	inc(State[2], c);
262
+	inc(State[3], d);
263
+end;
264
+
265
+// -----------------------------------------------------------------------------------------------
266
+
267
+// Initialize given Context
268
+procedure MD5Init(var Context: MD5Context);
269
+begin
270
+	with Context do begin
271
+		State[0] := $67452301;
272
+		State[1] := $efcdab89;
273
+		State[2] := $98badcfe;
274
+		State[3] := $10325476;
275
+		Count[0] := 0;
276
+		Count[1] := 0;
277
+		ZeroMemory(@Buffer, SizeOf(MD5Buffer));
278
+	end;
279
+end;
280
+
281
+// Update given Context to include Length bytes of Input
282
+procedure MD5Update(var Context: MD5Context; Input: pChar; Length: longword);
283
+var
284
+	Index: longword;
285
+	PartLen: longword;
286
+	I: longword;
287
+begin
288
+	with Context do begin
289
+		Index := (Count[0] shr 3) and $3f;
290
+		inc(Count[0], Length shl 3);
291
+		if Count[0] < (Length shl 3) then inc(Count[1]);
292
+		inc(Count[1], Length shr 29);
293
+	end;
294
+	PartLen := 64 - Index;
295
+	if Length >= PartLen then begin
296
+		CopyMemory(@Context.Buffer[Index], Input, PartLen);
297
+		Transform(@Context.Buffer, Context.State);
298
+		I := PartLen;
299
+		while I + 63 < Length do begin
300
+			Transform(@Input[I], Context.State);
301
+			inc(I, 64);
302
+		end;
303
+		Index := 0;
304
+	end else I := 0;
305
+	CopyMemory(@Context.Buffer[Index], @Input[I], Length - I);
306
+end;
307
+
308
+// Finalize given Context, create Digest and zeroize Context
309
+procedure MD5Final(var Context: MD5Context; var Digest: MD5Digest);
310
+var
311
+	Bits: MD5CBits;
312
+	Index: longword;
313
+	PadLen: longword;
314
+begin
315
+	Decode(@Context.Count, @Bits, 2);
316
+	Index := (Context.Count[0] shr 3) and $3f;
317
+	if Index < 56 then PadLen := 56 - Index else PadLen := 120 - Index;
318
+	MD5Update(Context, @PADDING, PadLen);
319
+	MD5Update(Context, @Bits, 8);
320
+	Decode(@Context.State, @Digest, 4);
321
+	ZeroMemory(@Context, SizeOf(MD5Context));
322
+end;
323
+
324
+// -----------------------------------------------------------------------------------------------
325
+
326
+// Create digest of given Message
327
+function MD5String(M: string): MD5Digest;
328
+var
329
+	Context: MD5Context;
330
+begin
331
+	MD5Init(Context);
332
+	MD5Update(Context, pChar(M), length(M));
333
+	MD5Final(Context, Result);
334
+end;
335
+
336
+// Create digest of file with given Name
337
+function MD5File(N: string): MD5Digest;
338
+var
339
+	FileHandle: THandle;
340
+	MapHandle: THandle;
341
+	ViewPointer: pointer;
342
+	Context: MD5Context;
343
+begin
344
+	MD5Init(Context);
345
+	FileHandle := CreateFile(pChar(N), GENERIC_READ, FILE_SHARE_READ or FILE_SHARE_WRITE,
346
+		nil, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL or FILE_FLAG_SEQUENTIAL_SCAN, 0);
347
+	if FileHandle <> INVALID_HANDLE_VALUE then try
348
+		MapHandle := CreateFileMapping(FileHandle, nil, PAGE_READONLY, 0, 0, nil);
349
+		if MapHandle <> 0 then try
350
+			ViewPointer := MapViewOfFile(MapHandle, FILE_MAP_READ, 0, 0, 0);
351
+			if ViewPointer <> nil then try
352
+				MD5Update(Context, ViewPointer, GetFileSize(FileHandle, nil));
353
+			finally
354
+				UnmapViewOfFile(ViewPointer);
355
+			end;
356
+		finally
357
+			CloseHandle(MapHandle);
358
+		end;
359
+	finally
360
+		CloseHandle(FileHandle);
361
+	end;
362
+	MD5Final(Context, Result);
363
+end;
364
+
365
+// Create hex representation of given Digest
366
+function MD5Print(D: MD5Digest): string;
367
+var
368
+	I: byte;
369
+const
370
+	Digits: array[0..15] of char =
371
+		('0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f');
372
+begin
373
+	Result := '';
374
+	for I := 0 to 15 do Result := Result + Digits[(D[I] shr 4) and $0f] + Digits[D[I] and $0f];
375
+end;
376
+
377
+// -----------------------------------------------------------------------------------------------
378
+
379
+// Compare two Digests
380
+function MD5Match(D1, D2: MD5Digest): boolean;
381
+var
382
+	I: byte;
383
+begin
384
+	I := 0;
385
+	Result := TRUE;
386
+	while Result and (I < 16) do begin
387
+		Result := D1[I] = D2[I];
388
+		inc(I);
389
+	end;
390
+end;
391
+
392
+end.
393
+

+ 182
- 0
installer/windows/Setup.dpr View File

@@ -0,0 +1,182 @@
1
+{*
2
+ * This application launches the dmdirc java-based installer.
3
+ * 
4
+ * DMDirc - Open Source IRC Client
5
+ * Copyright (c) 2006-2007 Chris Smith, Shane Mc Cormack, Gregory Holmes
6
+ * 
7
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
8
+ * of this software and associated documentation files (the "Software"), to deal
9
+ * in the Software without restriction, including without limitation the rights
10
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11
+ * copies of the Software, and to permit persons to whom the Software is
12
+ * furnished to do so, subject to the following conditions:
13
+ * 
14
+ * The above copyright notice and this permission notice shall be included in
15
+ * all copies or substantial portions of the Software.
16
+ * 
17
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23
+ * SOFTWARE.
24
+ *}
25
+program Setup;
26
+{$MODE Delphi}
27
+// Use this instead of {$APPTYPE XXX}
28
+// APP_XXX is the same as {$APPTYPE XXX}
29
+// Defaults to console
30
+// This is a work-around for a bug in FPC Cross Compiling to windows in delphi
31
+// mode (IsConsole is always true)
32
+{$DEFINE APP_GUI}
33
+
34
+// This block actually does the work for the above work-around
35
+{$IFDEF APP_GUI}
36
+	{$APPTYPE GUI}
37
+{$ELSE}
38
+	{$IFDEF APP_FS}
39
+		{$APPTYPE FS}
40
+	{$ELSE}
41
+		{$IFDEF APP_TOOL}
42
+			{$DEFINE APP_CONSOLE}
43
+			{$APPTYPE TOOL}
44
+		{$ELSE}
45
+			{$DEFINE APP_CONSOLE}
46
+			{$APPTYPE CONSOLE}
47
+		{$ENDIF}
48
+	{$ENDIF}
49
+{$ENDIF}
50
+
51
+uses Windows, SysUtils, classes;
52
+
53
+// This is also part of the above work-around.
54
+{$IFDEF APP_CONSOLE}
55
+const
56
+	IsConsole: boolean = true;
57
+{$ELSE}
58
+const
59
+	IsConsole: boolean = false;
60
+{$ENDIF}
61
+
62
+// Run an application and wait for it to finish.
63
+function ExecAndWait(sProgramToRun: String): Longword;
64
+var
65
+	StartupInfo: TStartupInfo;
66
+	ProcessInfo: TProcessInformation;
67
+begin
68
+	FillChar(StartupInfo, SizeOf(TStartupInfo), 0);
69
+	with StartupInfo do begin
70
+		cb := SizeOf(TStartupInfo);
71
+		dwFlags := STARTF_USESHOWWINDOW;
72
+		wShowWindow := SW_SHOWNORMAL;
73
+	end;
74
+
75
+	CreateProcess(nil, PChar(sProgramToRun), nil, nil, False, NORMAL_PRIORITY_CLASS, nil, nil, StartupInfo, ProcessInfo);
76
+	getExitCodeProcess(ProcessInfo.hProcess, Result);
77
+
78
+	while Result=STILL_ACTIVE do begin
79
+		sleep(1000);
80
+		GetExitCodeProcess(ProcessInfo.hProcess, Result);
81
+	end;
82
+end;
83
+
84
+procedure dowriteln(line: String);
85
+begin
86
+	if IsConsole then writeln(line);
87
+end;
88
+
89
+procedure dowrite(line: String);
90
+begin
91
+	if IsConsole then write(line);
92
+end;
93
+
94
+procedure showError(ErrorMessage: String);
95
+begin
96
+	if IsConsole then begin
97
+		writeln('');
98
+		writeln('-----------------------------------------------------------------------');
99
+		writeln('Sorry, setup is unable to continue.!');
100
+		writeln('-----------------------------------------------------------------------');
101
+		writeln('Reason:');
102
+		writeln('----------');
103
+		writeln(ErrorMessage);
104
+		writeln('-----------------------------------------------------------------------');
105
+		writeln('If you feel this is incorrect, or you require some further assistance,');
106
+		writeln('please feel free to contact us.');
107
+		writeln('-----------------------------------------------------------------------');
108
+		readln();
109
+	end
110
+	else begin
111
+		ErrorMessage := ErrorMessage+#13#10;
112
+		ErrorMessage := ErrorMessage+#13#10+'If you feel this is incorrect, or you require some further assistance,';
113
+		ErrorMessage := ErrorMessage+#13#10+'please feel free to contact us.';
114
+		
115
+		MessageBox(0, PChar(ErrorMessage), 'Sorry, setup is unable to continue', MB_OK + MB_ICONSTOP);
116
+	end;
117
+end;
118
+
119
+var
120
+	errorMessage: String;
121
+	javaCommand: String = 'javaw.exe';
122
+begin
123
+	// Nice and simple
124
+		
125
+	if IsConsole then begin
126
+		writeln('-----------------------------------------------------------------------');
127
+		writeln('Welcome to the DMDirc installer.');
128
+		writeln('-----------------------------------------------------------------------');
129
+		writeln('This will install DMDirc on your computer.');
130
+		writeln('');
131
+		writeln('Please wait whilst the GUI part of the installer loads...');
132
+		writeln('-----------------------------------------------------------------------');
133
+//	end
134
+//	else begin
135
+//		errorMessage := 'This will install DMDirc on your computer, please click OK to continue, or Cancel to abort.';
136
+//		if (MessageBox(0, PChar(errorMessage), 'DMDirc Installer', MB_OKCANCEL + MB_ICONINFORMATION) <> IDOK) then begin
137
+//			exit;
138
+//		end;
139
+	end;
140
+	errorMessage := '';
141
+	dowrite('Checking for installer.jar.. ');
142
+	if FileExists('installer.jar') then begin
143
+		dowriteln('Success!');
144
+		dowrite('Checking for JVM.. ');
145
+		if (ExecAndWait(javaCommand+' -version') <> 0) then begin
146
+			dowriteln('Failed!');
147
+			errorMessage := errorMessage+'No JVM is currently installed.';
148
+			errorMessage := errorMessage+#13#10;
149
+			errorMessage := errorMessage+#13#10+'DMDirc requires a 1.6.0 compatible JVM, you can get one from:';
150
+			errorMessage := errorMessage+#13#10+'http://jdl.sun.com/webapps/getjava/BrowserRedirect';
151
+		end
152
+		else begin
153
+			if IsConsole then begin
154
+				writeln('Success!');
155
+				write('Starting installer.jar.. ');
156
+				javaCommand := 'java.exe';
157
+			end;
158
+			if (ExecAndWait(javaCommand+' -jar installer.jar') <> 0) then begin
159
+				dowriteln('Failed!');
160
+				errorMessage := errorMessage+'The currently installed version of java is not compatible with DMDirc.';
161
+				errorMessage := errorMessage+#13#10;
162
+				errorMessage := errorMessage+#13#10+'DMDirc requires a 1.6.0 compatible JVM, you can get one from:';
163
+				errorMessage := errorMessage+#13#10+'http://jdl.sun.com/webapps/getjava/BrowserRedirect';
164
+				showError(errorMessage);
165
+			end;
166
+		end;
167
+	end
168
+	else begin
169
+		dowriteln('Failed!');
170
+		errorMessage := errorMessage+'installer.jar was not found.';
171
+		errorMessage := errorMessage+#13#10;
172
+		errorMessage := errorMessage+#13#10+'This is likely because of a corrupt installer build.';
173
+		errorMessage := errorMessage+#13#10+'Please check http://www.dmdirc.com/ for an updated build.';
174
+		showError(errorMessage);
175
+	end;
176
+	if IsConsole then begin
177
+		writeln('');
178
+		writeln('-----------------------------------------------------------------------');
179
+		writeln('Installation Completed. Thank you for choosing DMDirc');
180
+		writeln('-----------------------------------------------------------------------');	
181
+	end;
182
+end.

BIN
installer/windows/Shortcut.exe View File


+ 364
- 0
installer/windows/makeInstallerWindows.sh View File

@@ -0,0 +1,364 @@
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-2007 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
+
26
+# Name of the extractor
27
+RUNNAME=extractor.exe
28
+# Name of the installer (without .exe)
29
+INSTALLNAME=DMDirc-Setup
30
+# Name of the internal file
31
+INTNAME=extractor.7z
32
+# full name of the files to output to
33
+RUNNAME="${PWD}/${RUNNAME}"
34
+INTNAME="${PWD}/${INTNAME}"
35
+# Get 7zip path
36
+ZIP=`which 7z`
37
+
38
+if [ "" = "${ZIP}" ]; then
39
+	echo "7Zip not found, failing."
40
+	exit 1;
41
+fi
42
+
43
+# Compress stuff!
44
+compress() {
45
+	${ZIP} a -yl ${INTNAME} $@ 2>/dev/null || {
46
+		echo "Compression failed."
47
+		kill -15 $$;
48
+	};
49
+}
50
+
51
+# Get signcode path
52
+SIGNCODE=`which signcode`
53
+
54
+if [ "" = "${SIGNCODE}" ]; then
55
+	echo "Signcode not found. EXE's will not be digitally signed."
56
+	exit 1;
57
+fi
58
+
59
+# Sign stuff!
60
+signexe() {
61
+return;
62
+	if [ "" != "${SIGNCODE}" ]; then
63
+		if [ -e "../signing/DMDirc.spc" -a -e "../signing/DMDirc.pvk" ]; then
64
+			echo "Digitally Signing EXE (${@})..."
65
+			${SIGNCODE} -spc "../signing/DMDirc.spc" -v "../signing/DMDirc.pvk" -i "http://www.dmdirc.com/" -n "DMDirc Installer" $@ 2>/dev/null || {
66
+				kill -15 $$;
67
+			};
68
+			rm ${@}.sig
69
+			rm ${@}.bak
70
+		fi
71
+	fi
72
+}
73
+
74
+# Go!
75
+echo "-----------"
76
+if [ -e "${RUNNAME}" ]; then
77
+	echo "Removing existing .exe file"
78
+	rm -Rf "${RUNNAME}"
79
+fi
80
+if [ -e "${INTNAME}" ]; then
81
+	echo "Removing existing .7z file"
82
+	rm -Rf "${INTNAME}"
83
+fi
84
+echo "Creating .7z file"
85
+
86
+# Check for some CLI params
87
+compileJar="false"
88
+updateSVN="true"
89
+compileSetup="false"
90
+useOldSetup="false"
91
+isRelease=""
92
+useUPX="false"
93
+finalTag=""
94
+signEXE="true"
95
+compilerFlags=""
96
+BRANCH="0"
97
+location="../../../"
98
+
99
+showHelp() {
100
+	echo "This will generate a DMDirc installer for a windows based system."
101
+	echo "The following command line arguments are known:"
102
+	echo "---------------------"
103
+	echo "-h, --help                Help information"
104
+	echo "-r, --release [version]   Generate a file based on an svn tag (or branch with -b aswell)"
105
+	echo "-b, --branch              Release in -r is a branch "
106
+	echo "-s, --setup               Recompile the .exe file"
107
+	echo "-e,                       If setup.exe compile fails, use old version"
108
+	echo "-c, --compile             Recompile the .jar file"
109
+	echo "-u, --unsigned            Don't sign the exe"
110
+	echo "-t, --tag [tag]           Tag to add to final exe name to distinguish this build from a standard build"
111
+	echo "-f, --flags [flags]       Extra flags to pass to the compiler"	
112
+# This is not in the help cos its crappy really, and makes little/no difference to the
113
+# exe size unless debugging information is added using --flags, in which case the person
114
+# probably is Dataforce and knows about this flag anyway
115
+#	echo "    --upx                 UPX binary if UPX is available on the path,"
116
+#	echo "                          (Compression Level: 4 for signed exe, 9 for unsigned)"
117
+	echo "-k, --keep                Keep the existing source tree when compiling"
118
+	echo "                          (don't svn update beforehand)"
119
+	echo "---------------------"
120
+	exit 0;
121
+}
122
+
123
+while test -n "$1"; do
124
+	case "$1" in
125
+		--compile|-c)
126
+			compileJar="true"
127
+			;;
128
+		--setup|-s)
129
+			compileSetup="true"
130
+			;;
131
+		-e)
132
+			useOldSetup="true"
133
+			;;
134
+		--release|-r)
135
+			shift
136
+			isRelease=${1}
137
+			;;
138
+		--tag|-t)
139
+			shift
140
+			finalTag="-${1}"
141
+			;;
142
+		--flags|-f)
143
+			shift
144
+			compilerFlags="${1} "
145
+			;;
146
+		--upx)
147
+			useUPX="true"
148
+			;;
149
+		--unsigned|-u)
150
+			signEXE="false"
151
+			;;			
152
+		--keep|-k)
153
+			updateSVN="false"
154
+			;;
155
+		--help|-h)
156
+			showHelp;
157
+			;;
158
+		--branch|-b)
159
+			BRANCH="1"
160
+			;;
161
+	esac
162
+	shift	
163
+done
164
+
165
+jarPath="${location}trunk"
166
+if [ "${isRelease}" != "" ]; then
167
+	if [ "${BRANCH}" != "0" ]; then
168
+		if [ -e "${location}branches/"${isRelease} ]; then
169
+			jarPath="${location}branches/"${isRelease}
170
+		else
171
+			echo "Branch "${isRelease}" not found."
172
+			exit 1;
173
+		fi
174
+	else
175
+		if [ -e "${location}tags/"${isRelease} ]; then
176
+			jarPath="${location}tags/"${isRelease}
177
+		else
178
+			echo "Tag "${isRelease}" not found."
179
+			exit 1;
180
+		fi
181
+	fi
182
+fi
183
+
184
+if [ ! -e ${jarPath}"/dist/DMDirc.jar" -o "${compileJar}" = "true" ]; then
185
+	echo "Creating jar.."
186
+	OLDPWD=${PWD}
187
+	cd ${jarPath}
188
+	if [ "${updateSVN}" = "true" ]; then
189
+		svn update
190
+	fi
191
+	rm -Rf build dist
192
+	ant jar
193
+	if [ ! -e "dist/DMDirc.jar" ]; then
194
+		echo "There was an error creating the .jar file. Aborting."
195
+		exit 0;
196
+	fi;
197
+	cd ${OLDPWD}
198
+fi;
199
+
200
+echo "Linking jar.."
201
+ln -s ${jarPath}"/dist/DMDirc.jar" "./DMDirc.jar"
202
+
203
+FILES="DMDirc.jar Setup.exe";
204
+if [ ! -e "Setup.exe"  -o "${compileSetup}" = "true" ]; then
205
+	echo "Setup.exe does not exist. Lets try and compile it."	
206
+	FPC=`which fpc`
207
+	if [ "${FPC}" = "" ]; then
208
+		echo "FPC Compiler not found, Setup.exe can not be built."
209
+		exit 1;
210
+	else
211
+		${FPC} -Sd -Twin32 ${compilerFlags}Setup.dpr
212
+		if [ $? -ne 0 ]; then
213
+			if [ -e "Setup.exe" -a "${useOldSetup}" = "true" ]; then
214
+				echo "Unable to compile Setup.exe, using existing version."
215
+			else
216
+				echo "Unable to compile Setup.exe, terminating."
217
+				exit 1;
218
+			fi
219
+		fi;
220
+	fi
221
+fi
222
+
223
+ls
224
+if [ ! -e "Setup.exe" ]; then
225
+	echo "Still can't find Setup.exe, terminating."
226
+	exit 1;
227
+fi
228
+
229
+echo "Compressing files.."
230
+
231
+if [ -e "../common/installer.jar" ]; then
232
+	ln -s ../common/installer.jar ./installer.jar
233
+	FILES="${FILES} installer.jar"
234
+else
235
+	echo "[WARNING] Creating installer-less archive - relying on Setup.exe"
236
+fi 
237
+
238
+if [ -e ${jarPath}"/src/com/dmdirc/res/icon.ico" ]; then
239
+	ln -s ${jarPath}"/src/com/dmdirc/res/icon.ico" ./icon.ico
240
+	FILES="${FILES} icon.ico"
241
+fi
242
+
243
+# Shortcut.exe is from http://www.optimumx.com/download/#Shortcut
244
+if [ ! -e Shortcut.exe ]; then
245
+	wget http://www.optimumx.com/download/Shortcut.zip
246
+	unzip -q Shortcut.zip Shortcut.exe
247
+	rm Shortcut.zip
248
+fi
249
+FILES="${FILES} Shortcut.exe"
250
+
251
+if [ "${isRelease}" != "" ]; then
252
+	DOCSDIR=${jarPath}
253
+else
254
+	DOCSDIR="../common"
255
+fi
256
+
257
+if [ -e "${DOCSDIR}/README.TXT" ]; then
258
+	ln -s "${DOCSDIR}/README.TXT" .
259
+	FILES="${FILES} README.TXT"
260
+fi
261
+
262
+if [ -e "${DOCSDIR}/CHANGES.TXT" ]; then
263
+	ln -s "${DOCSDIR}/CHANGES.TXT" .
264
+	FILES="${FILES} CHANGES.TXT"
265
+elif [ -e "${DOCSDIR}/CHANGELOG.TXT" ]; then
266
+	ln -s "${DOCSDIR}/CHANGELOG.TXT" .
267
+	FILES="${FILES} CHANGELOG.TXT"
268
+fi
269
+
270
+if [ -e "${jarPath}/launcher/windows" ]; then
271
+	# Try to compile all
272
+	olddir=${PWD}
273
+	cd "${jarPath}/launcher/windows/"
274
+	sh compile.sh
275
+	cd ${olddir}
276
+	# Now add to file list.
277
+	for thisfile in `ls -1 ${jarPath}/launcher/windows/*.exe`; do
278
+		ln -s "${jarPath}/launcher/windows/"${thisfile} .
279
+		FILES="${FILES} ${thisfile}"
280
+	done
281
+fi
282
+
283
+compress $FILES
284
+
285
+echo "Creating config.."
286
+echo ";!@Install@!UTF-8!" > 7zip.conf
287
+if [ "${isRelease}" != "" ]; then
288
+	echo "Title=\"DMDirc Installation "${isRelease}"\"" >> 7zip.conf
289
+#	echo "BeginPrompt=\"Do you want to install DMDirc "${isRelease}"?\"" >> 7zip.conf
290
+else
291
+	echo "Title=\"DMDirc Installation\"" > 7zip.conf
292
+#	echo "BeginPrompt=\"Do you want to install DMDirc?\"" >> 7zip.conf
293
+fi;
294
+echo "ExecuteFile=\"Setup.exe\"" >> 7zip.conf
295
+echo ";!@InstallEnd@!" >> 7zip.conf
296
+
297
+if [ ! -e "7zS.sfx" ]; then
298
+	echo "Obtaining sfx stub.."
299
+	wget http://kent.dl.sourceforge.net/sourceforge/sevenzip/7z447_extra.tar.bz2
300
+	tar -jxvf 7z447_extra.tar.bz2 7zS.sfx
301
+	rm 7z447_extra.tar.bz2
302
+fi
303
+
304
+echo "Creating .exe"
305
+cat 7zS.sfx 7zip.conf "${INTNAME}" > "${RUNNAME}"
306
+
307
+if [ "${isRelease}" != "" ]; then
308
+	ORIGNAME="DMDirc-${isRelease}-Setup${finalTag}.exe"
309
+else
310
+	ORIGNAME="${INSTALLNAME}${finalTag}.exe"
311
+fi;
312
+
313
+echo "Building launcher";
314
+sh makeLauncher.sh "${isRelease}" "${ORIGNAME}" "${compilerFlags}"
315
+if [ $? -ne 0 ]; then
316
+	exit 1;
317
+fi
318
+FULLINSTALLER="${PWD}/${INSTALLNAME}${finalTag}.exe"
319
+mv Launcher.exe ${FULLINSTALLER}
320
+
321
+if [ "${useUPX}" = "true" ]; then
322
+	UPX=`which upx`
323
+	if [ "${UPX}" != "" ]; then	
324
+		if [ "${signEXE}" = "true" ]; then
325
+			${UPX} -4 ${FULLINSTALLER}
326
+		else
327
+			${UPX} -9 ${FULLINSTALLER}
328
+		fi
329
+	fi
330
+fi
331
+
332
+echo "Chmodding.."
333
+chmod a+x ${FULLINSTALLER}
334
+if [ "${signEXE}" = "true" ]; then
335
+	echo "Signing.."
336
+	signexe ${FULLINSTALLER}
337
+else
338
+	echo "Not Signing.."
339
+fi;
340
+
341
+mv ${FULLINSTALLER} ../output/${ORIGNAME}
342
+
343
+# Quick hack to prevent deleting of 2 important files in ${FILES}
344
+mv Setup.exe Setup.exe.tmp
345
+mv Shortcut.exe Shortcut.exe.tmp
346
+
347
+rm -f ${FILES}
348
+rm -f ./7zip.conf
349
+rm -f ./*.o
350
+rm -f ./*.or
351
+rm -f ${RUNNAME}
352
+rm -f ${INTNAME}
353
+rm -f icon.ico
354
+
355
+# And un-hack
356
+mv Setup.exe.tmp Setup.exe
357
+mv Shortcut.exe.tmp Shortcut.exe
358
+
359
+echo "-----------"
360
+echo "Done."
361
+echo "-----------"
362
+
363
+# and Done \o
364
+exit 0;

+ 165
- 0
installer/windows/makeLauncher.sh View File

@@ -0,0 +1,165 @@
1
+#!/bin/sh
2
+#
3
+# This script generates a .exe file that will just launch a pre-defined exe
4
+# This exe exists solely to rebrand the installer as DMDirc not 7zip, and to
5
+# give the correct icon.
6
+#
7
+# DMDirc - Open Source IRC Client
8
+# Copyright (c) 2006-2007 Chris Smith, Shane Mc Cormack, Gregory Holmes
9
+#
10
+# Permission is hereby granted, free of charge, to any person obtaining a copy
11
+# of this software and associated documentation files (the "Software"), to deal
12
+# in the Software without restriction, including without limitation the rights
13
+# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14
+# copies of the Software, and to permit persons to whom the Software is
15
+# furnished to do so, subject to the following conditions:
16
+#
17
+# The above copyright notice and this permission notice shall be included in
18
+# all copies or substantial portions of the Software.
19
+#
20
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23
+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26
+# SOFTWARE.
27
+
28
+# Icon Res file
29
+echo "icon.ico ICON icon.ico" > icon.rc
30
+
31
+# Other resources
32
+echo "extractor RCDATA extractor.exe" > files.rc
33
+
34
+COMPILER_IS_BROKEN="0";
35
+
36
+# Version Numbers
37
+if [ "" = "${1}" ]; then
38
+	MAJORVER="0"
39
+	MINORVER="0"
40
+	RELEASE="0"
41
+	TEXTVER="Trunk"
42
+	PRIVATE="1"
43
+	USER=`whoami`
44
+	HOST=`hostname`
45
+	DATE=`date`
46
+else
47
+	MAJORVER=${1%%.*}
48
+	SUBVER=${1#*.}
49
+	DOT=`expr index "${SUBVER}" .`
50
+	if [ "${DOT}" = "0" ]; then
51
+		MINORVER=${SUBVER}
52
+		RELEASE="0"
53
+	else
54
+		MINORVER=${SUBVER%%.*}
55
+		RELEASE=${SUBVER##*.}
56
+	fi
57
+	TEXTVER=$1
58
+	PRIVATE="0"
59
+fi;
60
+
61
+# Information for the below section:
62
+#
63
+# http://support.microsoft.com/kb/139491
64
+# http://msdn2.microsoft.com/en-us/library/aa381049.aspx
65
+# http://courses.cs.vt.edu/~cs3304/FreePascal/doc/prog/node14.html#SECTION001440000000000000000
66
+# http://tortoisesvn.tigris.org/svn/tortoisesvn/trunk/src/Resources/TortoiseShell.rc2
67
+
68
+echo "1 VERSIONINFO" > version.rc
69
+echo "FILEVERSION 1, 0, 0, 0" >> version.rc
70
+echo "PRODUCTVERSION ${MAJORVER}, ${MINORVER}, ${RELEASE}, 0" >> version.rc
71
+if [ "${PRIVATE}" = "1" ]; then
72
+	if [ "${COMPILER_IS_BROKEN}" = "0" ]; then
73
+		echo "FILEFLAGSMASK 0x000A" >> version.rc
74
+		echo "FILEFLAGS 0x3f" >> version.rc
75
+	else
76
+		echo "FILEFLAGS 0x000A" >> version.rc
77
+	fi;
78
+else
79
+	echo "FILEFLAGSMASK 0" >> version.rc
80
+fi;
81
+echo "FILEOS 0x40004" >> version.rc
82
+echo "FILETYPE 1" >> version.rc
83
+echo "BEGIN" >> version.rc
84
+echo "	BLOCK \"StringFileInfo\"" >> version.rc
85
+echo "	BEGIN" >> version.rc
86
+echo "		BLOCK \"040004E4\"" >> version.rc
87
+echo "		BEGIN" >> version.rc
88
+echo "			VALUE \"Comments\", \"http://www.dmdirc.com/\"" >> version.rc
89
+echo "			VALUE \"CompanyName\", \"DMDirc\"" >> version.rc
90
+echo "			VALUE \"FileDescription\", \"Installer for DMDirc ${TEXTVER}\"" >> version.rc
91
+echo "			VALUE \"FileVersion\", \"1.0\"" >> version.rc
92
+echo "			VALUE \"InternalName\", \"DMDirc.jar\"" >> version.rc
93
+echo "			VALUE \"LegalCopyright\", \"Copyright (c) 2006-2007 Chris Smith, Shane Mc Cormack, Gregory Holmes\"" >> version.rc
94
+echo "			VALUE \"OriginalFilename\", \"$2\"" >> version.rc
95
+echo "			VALUE \"ProductName\", \"DMDirc\"" >> version.rc
96
+echo "			VALUE \"ProductVersion\", \"${TEXTVER}\"" >> version.rc
97
+if [ "${PRIVATE}" = "1" ]; then
98
+	echo "			VALUE \"PrivateBuild\", \"Build by ${USER}@${HOST} on ${DATE}\"" >> version.rc
99
+fi;
100
+echo "		END" >> version.rc
101
+echo "	END" >> version.rc
102
+echo "	BLOCK \"VarFileInfo\"" >> version.rc
103
+echo "	BEGIN" >> version.rc
104
+echo "		VALUE \"Translation\", 0x400, 1252" >> version.rc
105
+echo "	END" >> version.rc
106
+echo "END" >> version.rc
107
+
108
+echo "1 24 \"UAC.manifest\"" > UAC.rc
109
+
110
+MD5BIN=`which md5sum`
111
+AWK=`which awk`
112
+MD5SUM=""
113
+if [ "${MD5BIN}" != "" -a "${AWK}" != "" ]; then
114
+	MD5SUM=`${MD5BIN} extractor.exe | ${AWK} '{print $1}'`
115
+fi
116
+echo "const" > consts.inc
117
+echo "	MD5SUM: String = '${MD5SUM}';" >> consts.inc
118
+
119
+# Code to extract and launch resource
120
+echo "ExtractResource('extractor', 'dmdirc_extractor.exe', TempDir);" > ExtractCode.inc
121
+if [ "${MD5SUM}" != "" ]; then
122
+	echo "if FindCmdLineSwitch('-nomd5') or FindCmdLineSwitch('nomd5') or checkMD5(TempDir+'dmdirc_extractor.exe') then begin" >> ExtractCode.inc
123
+	echo -n "	"; # Oh so important for code formatting!
124
+fi;
125
+echo "Launch(TempDir+'dmdirc_extractor.exe');" >> ExtractCode.inc
126
+if [ "${MD5SUM}" != "" ]; then
127
+	echo "end" >> ExtractCode.inc
128
+	echo "else begin" >> ExtractCode.inc
129
+	echo "	ErrorMessage := 'This copy of the DMDirc installer appears to be damaged and will now exit';" >> ExtractCode.inc
130
+	echo "	ErrorMessage := ErrorMessage+#13#10+'You may choose to skip this check and run it anyway by passing the /nomd5 parameter';" >> ExtractCode.inc
131
+	echo "	ErrorMessage := ErrorMessage+#13#10+'';" >> ExtractCode.inc
132
+	echo "	ErrorMessage := ErrorMessage+#13#10;" >> ExtractCode.inc
133
+	echo "	ErrorMessage := ErrorMessage+#13#10+'If you feel this is incorrect, or you require some further assistance,';" >> ExtractCode.inc
134
+	echo "	ErrorMessage := ErrorMessage+#13#10+'please feel free to contact us.';" >> ExtractCode.inc
135
+	echo "	" >> ExtractCode.inc
136
+	echo "	MessageBox(0, PChar(ErrorMessage), 'Sorry, setup is unable to continue', MB_OK + MB_ICONSTOP);" >> ExtractCode.inc
137
+	echo "end;" >> ExtractCode.inc	
138
+fi
139
+
140
+# Build res files
141
+#windres -F pe-i386 -i version.rc -o version.res
142
+#windres -F pe-i386 -i files.rc -o files.res
143
+#windres -F pe-i386 -i icon.rc -o icon.res
144
+
145
+cat UAC.rc > all.rc
146
+cat version.rc >> all.rc
147
+cat files.rc >> all.rc
148
+cat icon.rc >> all.rc
149
+windres -F pe-i386 -i all.rc -o all.res
150
+
151
+FPC=`which fpc`
152
+${FPC} -Sd -Twin32 ${3}Launcher.dpr
153
+if [ $? -ne 0 ]; then
154
+	if [ -e "Launcher.exe" ]; then
155
+		echo "Unable to compile Launcher.exe, using existing version."
156
+	else
157
+		echo "Unable to compile Launcher.exe, terminating."
158
+		exit 1;
159
+	fi
160
+fi
161
+
162
+rm -f *.res
163
+rm -f *.rc
164
+rm -f *.inc
165
+rm -f *.ppu

+ 1
- 1
src/com/dmdirc/installer/Installer.java View File

@@ -36,7 +36,7 @@ import java.nio.channels.FileChannel;
36 36
  */
37 37
 public abstract class Installer extends Thread {
38 38
 	/** Types of shortcut */
39
-	public static enum ShortcutType { DESKTOP, MENU, QUICKLAUNCH; }
39
+	public static enum ShortcutType { DESKTOP, MENU, QUICKLAUNCH, UNINSTALLER; }
40 40
 	
41 41
 	/** Step where things happen. */
42 42
 	protected StepInstall step = null;

+ 5
- 0
src/com/dmdirc/installer/StepInstall.java View File

@@ -117,6 +117,11 @@ public final class StepInstall extends Step implements StepListener {
117 117
 			}
118 118
 		}
119 119
 		
120
+		if (Main.getInstaller().supportsShortcut(ShortcutType.UNINSTALLER)) {
121
+			addText("Creating uninstaller");
122
+			myInstaller.setupShortcut(location, ShortcutType.UNINSTALLER);
123
+		}
124
+		
120 125
 		addText("");
121 126
 		addText("Installation finished\n");
122 127
 		Main.getWizardDialog().enableNextStep(true);

+ 51
- 1
src/com/dmdirc/installer/WindowsInstaller.java View File

@@ -77,7 +77,8 @@ public class WindowsInstaller extends Installer {
77 77
 				return !(System.getProperty("os.name").indexOf("95") >= 0);
78 78
 			case DESKTOP:
79 79
 			case MENU:
80
-				// All versions of windows have desktop and menu
80
+			case UNINSTALLER:
81
+				// All versions of windows have desktop, menu and uninstaller
81 82
 				return true;
82 83
 			default:
83 84
 				// Anything else that gets added should be false until the relevent
@@ -130,6 +131,55 @@ public class WindowsInstaller extends Installer {
130 131
 					}
131 132
 					break;
132 133
 					
134
+				case UNINSTALLER:
135
+					// Registry hax!
136
+					
137
+					final String[] addKey = new String[] {
138
+					                      "reg.exe",
139
+					                      "add",
140
+					                      "HKLM\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\DMDirc"
141
+					                      };
142
+					final String[] displayName = new String[] {
143
+					                      "reg.exe",
144
+					                      "add",
145
+					                      "HKLM\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\DMDirc",
146
+					                      "/v",
147
+					                      "DisplayName",
148
+					                      "/t",
149
+					                      "REG_SZ",
150
+					                      "/d",
151
+					                      "DMDirc IRC Client"
152
+					                      };
153
+					final String[] uninstaller = new String[] {
154
+					                      "reg.exe",
155
+					                      "add",
156
+					                      "HKLM\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\DMDirc",
157
+					                      "/v",
158
+					                      "UninstallString",
159
+					                      "/t",
160
+					                      "REG_SZ",
161
+					                      "/d",
162
+					                      location+"\\Uninstall.exe"
163
+					                      };
164
+					try {
165
+						final Process keyProcess = Runtime.getRuntime().exec(addKey);
166
+						new StreamReader(keyProcess.getInputStream()).start();
167
+						new StreamReader(keyProcess.getErrorStream()).start();
168
+						keyProcess.waitFor();
169
+						
170
+						final Process displayNameProcess = Runtime.getRuntime().exec(displayName);
171
+						new StreamReader(displayNameProcess.getInputStream()).start();
172
+						new StreamReader(displayNameProcess.getErrorStream()).start();
173
+						displayNameProcess.waitFor();
174
+						
175
+						final Process uninstallerProcess = Runtime.getRuntime().exec(uninstaller);
176
+						new StreamReader(uninstallerProcess.getInputStream()).start();
177
+						new StreamReader(uninstallerProcess.getErrorStream()).start();
178
+						uninstallerProcess.waitFor();
179
+					} catch (Exception e) {
180
+						step.addText(" - Error adding registry entries: "+e.getMessage());
181
+					}
182
+					break;
133 183
 				default:
134 184
 					step.addText(" - Error creating shortcut. Not applicable to this Operating System");
135 185
 					return;

+ 6
- 1
src/com/dmdirc/ui/swing/JWrappingLabel.java View File

@@ -52,6 +52,11 @@ public class JWrappingLabel extends JLabel {
52 52
 	/** My prefered width. */
53 53
 	private int myPreferredWidth = 0;
54 54
 
55
+	/** Is this label in debugging mode? */
56
+	private boolean debug = false;
57
+	/** Enable debugging mode */
58
+	public void setDebug() { debug = true; }
59
+
55 60
 	/** {@inheritDoc} */
56 61
 	public JWrappingLabel() {
57 62
 		super();
@@ -83,7 +88,7 @@ public class JWrappingLabel extends JLabel {
83 88
 			return new Dimension(myPreferredWidth, myPreferredHeight);
84 89
 		}
85 90
 	}
86
-	
91
+
87 92
 	/** {@inheritDoc} */
88 93
 	@Override
89 94
 	public void paint(final Graphics g) {

+ 10
- 3
src/com/dmdirc/updater/components/ClientComponent.java View File

@@ -25,6 +25,8 @@ package com.dmdirc.updater.components;
25 25
 import com.dmdirc.Main;
26 26
 import com.dmdirc.updater.UpdateComponent;
27 27
 
28
+import java.io.File;
29
+
28 30
 /**
29 31
  * Represents the client component, which covers the core client resources.
30 32
  * 
@@ -39,15 +41,20 @@ public class ClientComponent implements UpdateComponent {
39 41
     }
40 42
 
41 43
     /** {@inheritDoc} */
42
-    @Override    
44
+    @Override
43 45
     public int getVersion() {
44 46
         return Main.RELEASE_DATE;
45 47
     }
46 48
 
47 49
     /** {@inheritDoc} */
48
-    @Override    
50
+    @Override
49 51
     public void doInstall(final String path) {
50
-        throw new UnsupportedOperationException("Not supported yet.");
52
+        final File tmpFile = new File(path);
53
+        final File targetFile = new File(tmpFile.getParent()+File.pathSeparator+".DMDirc.jar");
54
+        if (targetFile.exists()) {
55
+            targetFile.delete();
56
+        }
57
+        tmpFile.renameTo(targetFile);
51 58
     }
52 59
 
53 60
 }

Loading…
Cancel
Save