Bläddra i källkod

Lotsa changes to the linux installer to make it also run on OpenSolaris (and possibly normal solaris aswell, I don't have gui access to a normal solaris machine from here will try when I go back to uni)


git-svn-id: http://svn.dmdirc.com/trunk@4225 00569f92-eb28-0410-84fd-f71c24880f
tags/0.6
Shane Mc Cormack 16 år sedan
förälder
incheckning
3386666e1a

+ 52
- 10
installer/linux/getjre.sh Visa fil

3
 # This script downloads a JRE.
3
 # This script downloads a JRE.
4
 #
4
 #
5
 
5
 
6
+# Check the which command exists, and if so make sure it behaves how we want
7
+# it to...
8
+WHICH=`which which 2>/dev/null`
9
+if [ "" = "${WHICH}" ]; then
10
+	echo "which command not found. Aborting.";
11
+	exit 0;
12
+else
13
+	# Solaris sucks
14
+	BADWHICH=`which /`
15
+	if [ "${BADWHICH}" != "" ]; then
16
+		echo "Replacing bad which command.";
17
+		# "Which" on solaris gives non-empty results for commands that don't exist
18
+		which() {
19
+			OUT=`${WHICH} ${1}`
20
+			if [ $? -eq 0 ]; then
21
+				echo ${OUT}
22
+			else
23
+				echo ""
24
+			fi;
25
+		}
26
+	fi;
27
+fi
28
+
6
 PIDOF=`which pidof`
29
 PIDOF=`which pidof`
7
 if [ "${PIDOF}" = "" ]; then
30
 if [ "${PIDOF}" = "" ]; then
8
 	# For some reason some distros hide pidof...
31
 	# For some reason some distros hide pidof...
18
 	ISKDE=`${PIDOF} -x -s kdeinit`
41
 	ISKDE=`${PIDOF} -x -s kdeinit`
19
 	ISGNOME=`${PIDOF} -x -s gnome-panel`
42
 	ISGNOME=`${PIDOF} -x -s gnome-panel`
20
 else
43
 else
21
-	ISKDE=`ps ux | grep kdeinit | grep -v grep`
22
-	ISGNOME=`ps ux | grep gnome-panel | grep -v grep`
44
+	ISKDE=`ps -Af | grep kdeinit | grep -v grep`
45
+	ISGNOME=`ps -Af | grep gnome-panel | grep -v grep`
23
 fi;
46
 fi;
24
 KDIALOG=`which kdialog`
47
 KDIALOG=`which kdialog`
25
 ZENITY=`which zenity`
48
 ZENITY=`which zenity`
83
 	fi
106
 	fi
84
 }
107
 }
85
 
108
 
109
+# Get the JRE.
86
 ARCH=`uname -m`
110
 ARCH=`uname -m`
87
-# This page redirects us to the correct JRE
88
-URL="http://www.dmdirc.com/getjava/linux/`uname -m`"
111
+ISAINFO=`which isainfo`
112
+if [ "${ISAINFO}" != "" ]; then
113
+	# Solaris-ish
114
+	ARCH=`uname -p`
115
+fi;
116
+URL="http://www.dmdirc.com/getjava/`uname -s`/${ARCH}"
89
 
117
 
90
 length=`wget --spider ${URL} 2>&1 | grep "Length:"| awk '{print $2, $3}' | sed 's/,//g'`
118
 length=`wget --spider ${URL} 2>&1 | grep "Length:"| awk '{print $2, $3}' | sed 's/,//g'`
91
 actualLength=${length%% *}
119
 actualLength=${length%% *}
92
 niceLength=`echo ${length##* }  | sed 's/[()]//g'`
120
 niceLength=`echo ${length##* }  | sed 's/[()]//g'`
93
 
121
 
122
+if [ "${actualLength}" = "6" ]; then
123
+	# Unable to download.
124
+	errordialog "Download Failed" "Unable to find JRE for this platform (`uname -s`/${ARCH})."
125
+	exit 1;
126
+fi;
127
+
94
 PIPE=""
128
 PIPE=""
95
 wgetpid=""
129
 wgetpid=""
96
 # Make sure wget and the progressbar die if we do.
130
 # Make sure wget and the progressbar die if we do.
101
 	if [ "${PIPE}" != "" ]; then
135
 	if [ "${PIPE}" != "" ]; then
102
 		if [ -e ${PIPE} ]; then
136
 		if [ -e ${PIPE} ]; then
103
 			echo "quit" > ${PIPE}
137
 			echo "quit" > ${PIPE}
104
-			rm -Rf ${PIPE}
138
+			echo "Closing badly, pipe still exists."
105
 		fi
139
 		fi
106
 	fi
140
 	fi
107
 }
141
 }
116
 fi;
150
 fi;
117
 if [ $result -eq 0 ]; then
151
 if [ $result -eq 0 ]; then
118
 	PIPE=`mktemp -p ${PWD} progresspipe.XXXXXXXXXXXXXX`
152
 	PIPE=`mktemp -p ${PWD} progresspipe.XXXXXXXXXXXXXX`
119
-	/bin/sh ${PWD}/progressbar.sh "Downloading JRE.." ${actualLength} ${PIPE} &
120
 	wget -q ${URL} -O jre.bin &
153
 	wget -q ${URL} -O jre.bin &
121
 	wgetpid=${!}
154
 	wgetpid=${!}
122
-	while [ `ps ${wgetpid} | wc -l` = 2 ]; do
155
+	/bin/sh ${PWD}/progressbar.sh "Downloading JRE.." ${actualLength} ${PIPE} ${wgetpid} &
156
+	progressbarpid=${!}
157
+	while [ `ps -p ${wgetpid} | wc -l` = 2 ]; do
123
 		SIZE=`ls -l jre.bin | awk '{print $5}'`
158
 		SIZE=`ls -l jre.bin | awk '{print $5}'`
124
 		if [ -e ${PIPE} ]; then
159
 		if [ -e ${PIPE} ]; then
125
 			echo "${SIZE}" > ${PIPE}
160
 			echo "${SIZE}" > ${PIPE}
130
 		fi;
165
 		fi;
131
 	done;
166
 	done;
132
 	wgetpid=""
167
 	wgetpid=""
133
-	echo "quit" > ${PIPE}
168
+#	echo "Killing progressbar"
169
+#	kill ${progressbarpid}
134
 	messagedialog "Download Completed" "Download Completed"
170
 	messagedialog "Download Completed" "Download Completed"
135
-	exit 1;
171
+	if [ -e ${PIPE} ]; then
172
+		echo "Deleting Pipe ${PIPE}"
173
+		rm -Rf "${PIPE}"
174
+	fi;
175
+	exit 0;
136
 else
176
 else
137
 	messagedialog "Download JRE" "JRE Download Canceled"
177
 	messagedialog "Download JRE" "JRE Download Canceled"
138
-fi;
178
+	exit 1;
179
+fi;
180
+exit 1;

+ 69
- 9
installer/linux/installerstub.sh Visa fil

25
 
25
 
26
 MD5=""
26
 MD5=""
27
 
27
 
28
-# Check the which command exists
28
+# Check the which command exists, and if so make sure it behaves how we want
29
+# it to...
29
 WHICH=`which which 2>/dev/null`
30
 WHICH=`which which 2>/dev/null`
30
 if [ "" = "${WHICH}" ]; then
31
 if [ "" = "${WHICH}" ]; then
31
 	echo "which command not found. Aborting.";
32
 	echo "which command not found. Aborting.";
32
 	exit 0;
33
 	exit 0;
34
+else
35
+	# Solaris sucks
36
+	BADWHICH=`which /`
37
+	if [ "${BADWHICH}" != "" ]; then
38
+		# "Which" on solaris gives non-empty results for commands that don't exist
39
+		which() {
40
+			OUT=`${WHICH} ${1}`
41
+			if [ $? -eq 0 ]; then
42
+				echo ${OUT}
43
+			else
44
+				echo ""
45
+			fi;
46
+		}
47
+	fi;
33
 fi
48
 fi
34
 
49
 
50
+# Find out what params we should pass to things.
51
+# Solaris has a nice and ancient version of grep in /usr/bin
52
+grep -na "" /dev/null >/dev/null 2>&1
53
+if [ $? -eq 2 ]; then
54
+	GREPOPTS="-n"
55
+else
56
+	GREPOPTS="-na"
57
+fi;
58
+# Solaris also has a crappy version of tail!
59
+tail -n +1 /dev/null >/dev/null 2>&1
60
+if [ $? -eq 2 ]; then
61
+	TAILOPTS="+"
62
+else
63
+	TAILOPTS="-n +"
64
+fi;
35
 
65
 
36
 ###ADDITIONAL_STUFF###
66
 ###ADDITIONAL_STUFF###
37
 
67
 
60
 		ISKDE=`${PIDOF} -x -s kdeinit`
90
 		ISKDE=`${PIDOF} -x -s kdeinit`
61
 		ISGNOME=`${PIDOF} -x -s gnome-panel`
91
 		ISGNOME=`${PIDOF} -x -s gnome-panel`
62
 	else
92
 	else
63
-		ISKDE=`ps ux | grep kdeinit | grep -v grep`
64
-		ISGNOME=`ps ux | grep gnome-panel | grep -v grep`
93
+		ISKDE=`ps -Af | grep kdeinit | grep -v grep`
94
+		ISGNOME=`ps -Af | grep gnome-panel | grep -v grep`
65
 	fi;
95
 	fi;
66
 	KDIALOG=`which kdialog`
96
 	KDIALOG=`which kdialog`
67
 	ZENITY=`which zenity`
97
 	ZENITY=`which zenity`
75
 }
105
 }
76
 
106
 
77
 # Location of .run stub end
107
 # Location of .run stub end
78
-ENDLINE=`grep -na "^###END STUB###$" $0`
108
+ENDLINE=`grep ${GREPOPTS} "^###END STUB###$" $0`
79
 ENDLINE=$((${ENDLINE%%:*} + 1))
109
 ENDLINE=$((${ENDLINE%%:*} + 1))
80
 
110
 
81
 if [ "" = "${ENDLINE}" ]; then
111
 if [ "" = "${ENDLINE}" ]; then
143
 }
173
 }
144
 
174
 
145
 uncompress() {
175
 uncompress() {
146
-	tail -n +${ENDLINE} "${OLDPWD}/$0" | gzip -cd | tar -xvf - 2>/dev/null || {
176
+#	DEBUGINFO="\n\nRunname: ${0}"
177
+#	DEBUGINFO="${DEBUGINFO}\nOldPwd: ${OLDPWD}"
178
+
179
+	# Try runname, in old dir.
180
+	FILE=${OLDPWD}/$0
181
+	if [ ! -e ${FILE} ]; then
182
+		# Else, try run filename in old dir
183
+		FILE=${OLDPWD}/`basename $0`
184
+		if [ ! -e ${FILE} ]; then
185
+			# Else try run name
186
+			FILE=$0
187
+			if [ ! -e ${FILE} ]; then
188
+				# Unable to find this file!
189
+				errordialog "DMDirc Setup" "Unable to find installer.\nThis shouldn't happen, please raise a bug report at http://bugs.dmdirc.com${DEBUGINFO}";
190
+				echo "Removing temp dir"
191
+				cd ${OLDPWD}
192
+				rm -Rf ${TEMPDIR}
193
+				exit 1;
194
+			fi;
195
+		fi;
196
+	fi;
197
+	echo "Decompressing: ${FILE}"
198
+#	DEBUGINFO="${DEBUGINFO}\nFile: ${FILE}"
199
+#	DEBUGINFO="${DEBUGINFO}\nCommand: tail ${TAILOPTS}${ENDLINE} "${FILE}" | gzip -cd | tar -xvf - 2>/dev/null"
200
+	OUTPUT=`tail ${TAILOPTS}${ENDLINE} "${FILE}" | gzip -cd | tar -xvf - 2>/dev/null`
201
+	if [ "${OUTPUT}" = "" ]; then
147
 		echo "Decompression failed."
202
 		echo "Decompression failed."
148
-		kill -15 $$;
149
-	};
203
+		errordialog "DMDirc Setup" "Decompression failed.\nThis shouldn't happen, please raise a bug report at http://bugs.dmdirc.com${DEBUGINFO}";
204
+		echo "Removing temp dir"
205
+		cd ${OLDPWD}
206
+		rm -Rf ${TEMPDIR}
207
+		exit 1;
208
+	fi;
209
+	echo "Decompression successful."
150
 }
210
 }
151
 
211
 
152
 showHelp() {
212
 showHelp() {
196
 AWK=`which awk`
256
 AWK=`which awk`
197
 getMD5() {
257
 getMD5() {
198
 	# Everything below the MD5SUM Line
258
 	# Everything below the MD5SUM Line
199
-	MD5LINE=`grep -na "^MD5=\".*\"$" ${1}`
259
+	MD5LINE=`grep ${GREPOPTS} "^MD5=\".*\"$" ${1}`
200
 	MD5LINE=$((${MD5LINE%%:*} + 1))
260
 	MD5LINE=$((${MD5LINE%%:*} + 1))
201
 
261
 
202
-	MD5SUM=`tail -n +${MD5LINE} "${1}" | ${MD5BIN} - | ${AWK} '{print $1}'`
262
+	MD5SUM=`tail ${TAILOPTS}${MD5LINE} "${1}" | ${MD5BIN} - | ${AWK} '{print $1}'`
203
 	return;
263
 	return;
204
 }
264
 }
205
 
265
 

+ 62
- 17
installer/linux/installjre.sh Visa fil

3
 # Install the JRE.
3
 # Install the JRE.
4
 #
4
 #
5
 
5
 
6
+# Find out what params we should pass to things.
7
+# Solaris has a nice and ancient version of grep in /usr/bin
8
+grep -na "" /dev/null >/dev/null 2>&1
9
+if [ $? -eq 2 ]; then
10
+	GREPOPTS="-n"
11
+else
12
+	GREPOPTS="-na"
13
+fi;
14
+# Solaris also has a crappy version of tail!
15
+tail -n +1 /dev/null >/dev/null 2>&1
16
+if [ $? -eq 2 ]; then
17
+	TAILOPTS="+"
18
+else
19
+	TAILOPTS="-n +"
20
+fi;
21
+# Check the which command exists, and if so make sure it behaves how we want
22
+# it to...
23
+WHICH=`which which 2>/dev/null`
24
+if [ "" = "${WHICH}" ]; then
25
+	echo "which command not found. Aborting.";
26
+	exit 0;
27
+else
28
+	# Solaris sucks
29
+	BADWHICH=`which /`
30
+	if [ "${BADWHICH}" != "" ]; then
31
+		echo "Replacing bad which command.";
32
+		# "Which" on solaris gives non-empty results for commands that don't exist
33
+		which() {
34
+			OUT=`${WHICH} ${1}`
35
+			if [ $? -eq 0 ]; then
36
+				echo ${OUT}
37
+			else
38
+				echo ""
39
+			fi;
40
+		}
41
+	fi;
42
+fi
43
+
6
 PIDOF=`which pidof`
44
 PIDOF=`which pidof`
7
 if [ "${PIDOF}" = "" ]; then
45
 if [ "${PIDOF}" = "" ]; then
8
 	# For some reason some distros hide pidof...
46
 	# For some reason some distros hide pidof...
18
 	ISKDE=`${PIDOF} -x -s kdeinit`
56
 	ISKDE=`${PIDOF} -x -s kdeinit`
19
 	ISGNOME=`${PIDOF} -x -s gnome-panel`
57
 	ISGNOME=`${PIDOF} -x -s gnome-panel`
20
 else
58
 else
21
-	ISKDE=`ps ux | grep kdeinit | grep -v grep`
22
-	ISGNOME=`ps ux | grep gnome-panel | grep -v grep`
59
+	ISKDE=`ps -Af | grep kdeinit | grep -v grep`
60
+	ISGNOME=`ps -Af | grep gnome-panel | grep -v grep`
23
 fi;
61
 fi;
24
 KDIALOG=`which kdialog`
62
 KDIALOG=`which kdialog`
25
 ZENITY=`which zenity`
63
 ZENITY=`which zenity`
89
 	FILE=`mktemp -p ${PWD} license.XXXXXXXXXXXXXX`
127
 	FILE=`mktemp -p ${PWD} license.XXXXXXXXXXXXXX`
90
 	
128
 	
91
 	# Location of license start
129
 	# Location of license start
92
-	STARTLINE=`grep -na "^more <<\"EOF\"$" jre.bin`
130
+	STARTLINE=`grep ${GREPOPTS} "^more <<\"EOF\"$" jre.bin`
93
 	STARTLINE=$((${STARTLINE%%:*} + 1))
131
 	STARTLINE=$((${STARTLINE%%:*} + 1))
94
 	# Location of license end
132
 	# Location of license end
95
-	ENDLINE=`grep -na "Do you agree to the above license terms?" jre.bin`
133
+	ENDLINE=`grep ${GREPOPTS} "Do you agree to the above license terms?" jre.bin`
96
 	ENDLINE=$((${ENDLINE%%:*} - 2))
134
 	ENDLINE=$((${ENDLINE%%:*} - 2))
97
 	
135
 	
98
-	head -n ${ENDLINE} jre.bin | tail -n +${STARTLINE} > ${FILE}
136
+	head -n ${ENDLINE} jre.bin | tail ${TAILOPTS}${STARTLINE} > ${FILE}
99
 	
137
 	
100
 	# Send text to console.
138
 	# Send text to console.
101
 	echo ""
139
 	echo ""
132
 questiondialog "Java Install" "Do you agree to the Java License?"
170
 questiondialog "Java Install" "Do you agree to the Java License?"
133
 if [ $? -eq 0 ]; then
171
 if [ $? -eq 0 ]; then
134
 	# Look to see where the JRE wants to install to
172
 	# Look to see where the JRE wants to install to
135
-	JREJAVAHOME=`grep -na "^javahome=" jre.bin`
173
+	JREJAVAHOME=`grep ${GREPOPTS} "^javahome=" jre.bin`
136
  	JREJAVAHOME=${JREJAVAHOME##*=}
174
  	JREJAVAHOME=${JREJAVAHOME##*=}
137
 	
175
 	
176
+	echo "JREJAVAHOME: ${JREJAVAHOME}"
177
+	
138
 	if [ "${UID}" = "" ]; then
178
 	if [ "${UID}" = "" ]; then
139
 		UID=`id -u`;
179
 		UID=`id -u`;
140
 	fi
180
 	fi
144
 		installdir=${HOME}/${JREJAVAHOME}
184
 		installdir=${HOME}/${JREJAVAHOME}
145
 	fi;
185
 	fi;
146
 	
186
 	
147
-	if [ -e ${installdir} ]; then
187
+	echo "installdir: ${installdir}"
188
+	
189
+	if [ ! -e ${installdir} ]; then
148
 		# Hack jre.bin to allow us to install without asking for a license, or failing
190
 		# Hack jre.bin to allow us to install without asking for a license, or failing
149
 		# the checksum.
191
 		# the checksum.
150
 		
192
 		
151
 		# Location of license start
193
 		# Location of license start
152
-		STARTLINE=`grep -na "^more <<\"EOF\"$" jre.bin`
194
+		STARTLINE=`grep ${GREPOPTS} "^more <<\"EOF\"$" jre.bin`
153
 		STARTLINE=${STARTLINE%%:*}
195
 		STARTLINE=${STARTLINE%%:*}
154
 		# Location of license end
196
 		# Location of license end
155
-		ENDLINE=`grep -na "If you don't agree to the license you can't install this software" jre.bin`
197
+		ENDLINE=`grep ${GREPOPTS} "If you don't agree to the license you can't install this software" jre.bin`
156
 		ENDLINE=$((${ENDLINE%%:*} + 3))
198
 		ENDLINE=$((${ENDLINE%%:*} + 3))
157
 		# Location of checksum start
199
 		# Location of checksum start
158
-		CSSTARTLINE=`grep -na "^if \[ -x /usr/bin/sum \]; then$" jre.bin`
200
+		CSSTARTLINE=`grep ${GREPOPTS} "^if \[ -x /usr/bin/sum \]; then$" jre.bin`
159
 		CSSTARTLINE=${CSSTARTLINE%%:*}
201
 		CSSTARTLINE=${CSSTARTLINE%%:*}
160
 		# Location of checksum end
202
 		# Location of checksum end
161
-		CSENDLINE=`grep -na "Can't find /usr/bin/sum to do checksum" jre.bin`
203
+		CSENDLINE=`grep ${GREPOPTS} "Can't find /usr/bin/sum to do checksum" jre.bin`
162
 		CSENDLINE=$((${CSENDLINE%%:*} + 2))
204
 		CSENDLINE=$((${CSENDLINE%%:*} + 2))
163
 		# Location of script end
205
 		# Location of script end
164
-		SCENDLINE=`grep -na "^echo \"Done.\"$" jre.bin`
206
+		SCENDLINE=`grep ${GREPOPTS} "^echo \"Done.\"$" jre.bin`
165
 		SCENDLINE=$((${SCENDLINE%%:*} + 2 - (${ENDLINE} - ${STARTLINE}) - (${CSENDLINE} - ${CSSTARTLINE})))
207
 		SCENDLINE=$((${SCENDLINE%%:*} + 2 - (${ENDLINE} - ${STARTLINE}) - (${CSENDLINE} - ${CSSTARTLINE})))
166
 		# Remove the license and checksum stuff!
208
 		# Remove the license and checksum stuff!
167
 		head -n $((${STARTLINE} -1)) jre.bin > jre.bin.tmp
209
 		head -n $((${STARTLINE} -1)) jre.bin > jre.bin.tmp
168
-		tail -n +$((${ENDLINE})) jre.bin | head -n $((${CSSTARTLINE} -1 - ${ENDLINE})) >> jre.bin.tmp
210
+		tail ${TAILOPTS}$((${ENDLINE})) jre.bin | head -n $((${CSSTARTLINE} -1 - ${ENDLINE})) >> jre.bin.tmp
169
 		echo "tail \${tail_args} +${SCENDLINE} \"\$0\" > \$outname" >> jre.bin.tmp
211
 		echo "tail \${tail_args} +${SCENDLINE} \"\$0\" > \$outname" >> jre.bin.tmp
170
-		tail -n +$((${CSENDLINE})) jre.bin >> jre.bin.tmp
212
+		tail ${TAILOPTS}$((${CSENDLINE})) jre.bin >> jre.bin.tmp
171
 		
213
 		
172
 		messagedialog "Java Install" "Java install will begin when you press OK.\nThis may take some time, so please wait.\n\nYou will be informed when the installation is completed."
214
 		messagedialog "Java Install" "Java install will begin when you press OK.\nThis may take some time, so please wait.\n\nYou will be informed when the installation is completed."
173
 		yes | sh jre.bin.tmp
215
 		yes | sh jre.bin.tmp
199
 				echo "endfi" >> ${HOME}/.cshrc
241
 				echo "endfi" >> ${HOME}/.cshrc
200
 			fi
242
 			fi
201
 			
243
 			
244
+			echo "Adding JREPath: ${PWD}/jrepath"
202
 			# This allows the main installer to continue with the new java version.
245
 			# This allows the main installer to continue with the new java version.
203
-			echo "export PATH=~/${JREJAVAHOME}/bin:\"\${PATH}\"" > .jrepath
246
+			echo "export PATH=~/${JREJAVAHOME}/bin:\"\${PATH}\"" > ${PWD}/jrepath
204
 			
247
 			
205
 			# This allows dmdirc launcher to find the jre if the path is not set.
248
 			# This allows dmdirc launcher to find the jre if the path is not set.
206
 			ln -sf ${installdir} ${HOME}/jre
249
 			ln -sf ${installdir} ${HOME}/jre
209
 		messagedialog "Java Install" "Java installation complete"
252
 		messagedialog "Java Install" "Java installation complete"
210
 		exit 0;
253
 		exit 0;
211
 	else
254
 	else
212
-		messagedialog "Java Install" "An existing install was found at ${installdir}, but this directory is not in the current path."
213
-		echo "export PATH=~/${JREJAVAHOME}/bin:\"\${PATH}\"" > .jrepath
255
+		messagedialog "Java Install" "An existing install was found at ${installdir}, but this directory is not in the current path, DMDirc setup will try to use this version of java for the install."
256
+		echo "Adding JREPath: ${PWD}/jrepath"
257
+		# This allows the main installer to continue with the new java version.
258
+		echo "export PATH=~/${JREJAVAHOME}/bin:\"\${PATH}\"" > ${PWD}/jrepath
214
 		exit 0;
259
 		exit 0;
215
 	fi;
260
 	fi;
216
 else
261
 else

+ 44
- 6
installer/linux/makeInstallerLinux.sh Visa fil

28
 # full name of the file to output to
28
 # full name of the file to output to
29
 RUNNAME="${PWD}/${INSTALLERNAME}.run"
29
 RUNNAME="${PWD}/${INSTALLERNAME}.run"
30
 
30
 
31
+# Find out what params we should pass to things.
32
+# Solaris has a nice and ancient version of grep in /usr/bin
33
+grep -na "" /dev/null >/dev/null 2>&1
34
+if [ $? -eq 2 ]; then
35
+	GREPOPTS="-n"
36
+else
37
+	GREPOPTS="-na"
38
+fi;
39
+# Solaris also has a crappy version of tail!
40
+tail -n +1 /dev/null >/dev/null 2>&1
41
+if [ $? -eq 2 ]; then
42
+	TAILOPTS="+"
43
+else
44
+	TAILOPTS="-n +"
45
+fi;
46
+# Check the which command exists, and if so make sure it behaves how we want
47
+# it to...
48
+WHICH=`which which 2>/dev/null`
49
+if [ "" = "${WHICH}" ]; then
50
+	echo "which command not found. Aborting.";
51
+	exit 0;
52
+else
53
+	# Solaris sucks
54
+	BADWHICH=`which /`
55
+	if [ "${BADWHICH}" != "" ]; then
56
+		echo "Replacing bad which command.";
57
+		# "Which" on solaris gives non-empty results for commands that don't exist
58
+		which() {
59
+			OUT=`${WHICH} ${1}`
60
+			if [ $? -eq 0 ]; then
61
+				echo ${OUT}
62
+			else
63
+				echo ""
64
+			fi;
65
+		}
66
+	fi;
67
+fi
68
+
31
 # Compress stuff!
69
 # Compress stuff!
32
 compress() {
70
 compress() {
33
 	tar cvfh - $@ | gzip - 2>/dev/null >>${RUNNAME} || {
71
 	tar cvfh - $@ | gzip - 2>/dev/null >>${RUNNAME} || {
264
 
302
 
265
 getMD5Linux() {
303
 getMD5Linux() {
266
 	# Everything below the MD5SUM Line
304
 	# Everything below the MD5SUM Line
267
-	MD5LINE=`grep -na "^MD5=\".*\"$" ${1}`
305
+	MD5LINE=`grep ${GREPOPTS} "^MD5=\".*\"$" ${1}`
268
 	MD5LINE=$((${MD5LINE%%:*} + 1))
306
 	MD5LINE=$((${MD5LINE%%:*} + 1))
269
 
307
 
270
-	MD5SUM=`tail -n +${MD5LINE} "${1}" | ${MD5BIN} - | ${AWK} '{print $1}'`
308
+	MD5SUM=`tail ${TAILOPTS}${MD5LINE} "${1}" | ${MD5BIN} - | ${AWK} '{print $1}'`
271
 	return;
309
 	return;
272
 }
310
 }
273
 
311
 
274
 getMD5OSX() {
312
 getMD5OSX() {
275
 	# Everything below the MD5SUM Line
313
 	# Everything below the MD5SUM Line
276
-	MD5LINE=`grep -na "^MD5=\".*\"$" ${1}`
314
+	MD5LINE=`grep ${GREPOPTS} "^MD5=\".*\"$" ${1}`
277
 	MD5LINE=$((${MD5LINE%%:*} + 1))
315
 	MD5LINE=$((${MD5LINE%%:*} + 1))
278
 
316
 
279
-	MD5SUM=`tail -n +${MD5LINE} "${1}" | ${MD5BIN} | ${AWK} '{print $1}'`
317
+	MD5SUM=`tail ${TAILOPTS}${MD5LINE} "${1}" | ${MD5BIN} | ${AWK} '{print $1}'`
280
 	return;
318
 	return;
281
 }
319
 }
282
 
320
 
288
 
326
 
289
 	echo "SUM obtained is: ${MD5SUM}"
327
 	echo "SUM obtained is: ${MD5SUM}"
290
 
328
 
291
-	LINENUM=`grep -na "^MD5=\"\"$" ${RUNNAME}`
329
+	LINENUM=`grep ${GREPOPTS} "^MD5=\"\"$" ${RUNNAME}`
292
 	LINENUM=${LINENUM%%:*}
330
 	LINENUM=${LINENUM%%:*}
293
 
331
 
294
 	head -n $((${LINENUM} -1)) ${RUNNAME} > ${RUNNAME}.tmp
332
 	head -n $((${LINENUM} -1)) ${RUNNAME} > ${RUNNAME}.tmp
295
 	echo 'MD5="'${MD5SUM}'"' >> ${RUNNAME}.tmp
333
 	echo 'MD5="'${MD5SUM}'"' >> ${RUNNAME}.tmp
296
-	tail -n +$((${LINENUM} +1)) ${RUNNAME} >> ${RUNNAME}.tmp
334
+	tail ${TAILOPTS}$((${LINENUM} +1)) ${RUNNAME} >> ${RUNNAME}.tmp
297
 	mv ${RUNNAME}.tmp ${RUNNAME}
335
 	mv ${RUNNAME}.tmp ${RUNNAME}
298
 else
336
 else
299
 	echo "Not Adding MD5.."
337
 	echo "Not Adding MD5.."

+ 56
- 9
installer/linux/progressbar.sh Visa fil

10
 # only terminate when the next line of data is read from the pipe.
10
 # only terminate when the next line of data is read from the pipe.
11
 #
11
 #
12
 
12
 
13
+# Check the which command exists, and if so make sure it behaves how we want
14
+# it to...
15
+WHICH=`which which 2>/dev/null`
16
+if [ "" = "${WHICH}" ]; then
17
+	echo "which command not found. Aborting.";
18
+	exit 0;
19
+else
20
+	# Solaris sucks
21
+	BADWHICH=`which /`
22
+	if [ "${BADWHICH}" != "" ]; then
23
+		echo "Replacing bad which command.";
24
+		# "Which" on solaris gives non-empty results for commands that don't exist
25
+		which() {
26
+			OUT=`${WHICH} ${1}`
27
+			if [ $? -eq 0 ]; then
28
+				echo ${OUT}
29
+			else
30
+				echo ""
31
+			fi;
32
+		}
33
+	fi;
34
+fi
35
+# Solaris also has a crappy version of tail!
36
+tail -n +1 /dev/null >/dev/null 2>&1
37
+if [ $? -eq 2 ]; then
38
+	TAILOPTS="-"
39
+else
40
+	TAILOPTS="-n"
41
+fi;
42
+
13
 PIDOF=`which pidof`
43
 PIDOF=`which pidof`
14
 if [ "${PIDOF}" = "" ]; then
44
 if [ "${PIDOF}" = "" ]; then
15
 	# For some reason some distros hide pidof...
45
 	# For some reason some distros hide pidof...
25
 	ISKDE=`${PIDOF} -x -s kdeinit`
55
 	ISKDE=`${PIDOF} -x -s kdeinit`
26
 	ISGNOME=`${PIDOF} -x -s gnome-panel`
56
 	ISGNOME=`${PIDOF} -x -s gnome-panel`
27
 else
57
 else
28
-	ISKDE=`ps ux | grep kdeinit | grep -v grep`
29
-	ISGNOME=`ps ux | grep gnome-panel | grep -v grep`
58
+	ISKDE=`ps -Af | grep kdeinit | grep -v grep`
59
+	ISGNOME=`ps -Af | grep gnome-panel | grep -v grep`
30
 fi;
60
 fi;
31
 KDIALOG=`which kdialog`
61
 KDIALOG=`which kdialog`
32
 ZENITY=`which zenity`
62
 ZENITY=`which zenity`
33
 CAPTION=${1}
63
 CAPTION=${1}
34
 FILESIZE=${2}
64
 FILESIZE=${2}
65
+WGETPID=${3}
35
 progresswindow=""
66
 progresswindow=""
36
 TYPE=""
67
 TYPE=""
37
 PIPE="progresspipe_${$}"
68
 PIPE="progresspipe_${$}"
38
 retval="1"
69
 retval="1"
70
+CONTINUE="1"
39
 
71
 
40
 readprogress() {
72
 readprogress() {
41
 	data=""
73
 	data=""
42
 	input=""
74
 	input=""
43
-	while [ -e ${PIPE} ]; do
75
+	while [ ${CONTINUE} -eq "1" -a -e ${PIPE} ]; do
44
 		if [ "${TYPE}" = "KDE" ]; then
76
 		if [ "${TYPE}" = "KDE" ]; then
45
 			if [ `dcop ${progresswindow} wasCancelled` = "true" ]; then
77
 			if [ `dcop ${progresswindow} wasCancelled` = "true" ]; then
46
 				break;
78
 				break;
47
 			fi
79
 			fi
48
 		fi;
80
 		fi;
49
-		input=`cat "${PIPE}"`
50
-		if [ "${input}" == "quit" ]; then
81
+		input=`cat "${PIPE}" | tail ${TAILOPTS}1`
82
+		if [ "${input}" = "quit" ]; then
51
 			break;
83
 			break;
52
 		elif [ "${input}" != "" ]; then
84
 		elif [ "${input}" != "" ]; then
53
 			data=${input}
85
 			data=${input}
74
 			fi;
106
 			fi;
75
 			if [ "${val}" = "100" ]; then
107
 			if [ "${val}" = "100" ]; then
76
 				retval="0"
108
 				retval="0"
109
+				CONTINUE="0"
77
 				break;
110
 				break;
78
 			fi;
111
 			fi;
79
 		fi;
112
 		fi;
99
 fi;
132
 fi;
100
 
133
 
101
 echo "Using pipe: "${PIPE}
134
 echo "Using pipe: "${PIPE}
102
-
103
 mkfifo "${PIPE}"
135
 mkfifo "${PIPE}"
104
 closeProgress() {
136
 closeProgress() {
137
+	CONTINUE="0"
105
 	if [ "${TYPE}" = "KDE" -a ${retval} != "0" ]; then
138
 	if [ "${TYPE}" = "KDE" -a ${retval} != "0" ]; then
106
 		dcop ${progresswindow} close
139
 		dcop ${progresswindow} close
107
 	fi;
140
 	fi;
108
-	echo "Deleting ${PIPE}"
109
-	rm -Rf "${PIPE}"
141
+	echo "Exiting with value: $retval"
142
+	if [ -e ${PIPE} ]; then
143
+		echo "Attempting to kill wget"
144
+		kill -9 ${WGETPID}
145
+		echo "Emptying pipe"
146
+		cat ${PIPE};
147
+		echo "Deleting Pipe ${PIPE}"
148
+		rm -Rf "${PIPE}"
149
+	fi;
110
 	exit $retval;
150
 	exit $retval;
111
 }
151
 }
112
 trap 'closeProgress' INT TERM EXIT
152
 trap 'closeProgress' INT TERM EXIT
118
 	dcop ${progresswindow} showCancelButton true
158
 	dcop ${progresswindow} showCancelButton true
119
 	TYPE="KDE"
159
 	TYPE="KDE"
120
 	readprogress
160
 	readprogress
161
+	CONTINUE="0"
162
+	echo "Progress Bar Complete"
121
 elif [ "" != "${ISGNOME}" -a "" != "${ZENITY}" -a "" != "${DISPLAY}" ]; then
163
 elif [ "" != "${ISGNOME}" -a "" != "${ZENITY}" -a "" != "${DISPLAY}" ]; then
122
 	echo "Progress dialog on Display: ${DISPLAY}"
164
 	echo "Progress dialog on Display: ${DISPLAY}"
123
 	TYPE="GNOME"
165
 	TYPE="GNOME"
124
 	readprogress | ${ZENITY} --progress --auto-close --auto-kill --title "DMDirc: ${CAPTION}" --text "${CAPTION}"
166
 	readprogress | ${ZENITY} --progress --auto-close --auto-kill --title "DMDirc: ${CAPTION}" --text "${CAPTION}"
167
+	CONTINUE="0"
168
+	echo "Progress Bar Complete"
125
 else
169
 else
126
 	echo "Progress For: ${CAPTION}"
170
 	echo "Progress For: ${CAPTION}"
127
 	echo "-> 0%"
171
 	echo "-> 0%"
128
 	readprogress
172
 	readprogress
173
+	CONTINUE="0"
129
 	echo ""
174
 	echo ""
130
 	echo "Finished!"
175
 	echo "Finished!"
131
-fi
176
+fi
177
+echo "Exiting progressbar"
178
+exit 0;

+ 30
- 15
installer/linux/setup.sh Visa fil

23
 # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23
 # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24
 # SOFTWARE.
24
 # SOFTWARE.
25
 
25
 
26
+# Check the which command exists, and if so make sure it behaves how we want
27
+# it to...
28
+WHICH=`which which 2>/dev/null`
29
+if [ "" = "${WHICH}" ]; then
30
+	echo "which command not found. Aborting.";
31
+	exit 0;
32
+else
33
+	# Solaris sucks
34
+	BADWHICH=`which /`
35
+	if [ "${BADWHICH}" != "" ]; then
36
+		echo "Replacing bad which command.";
37
+		# "Which" on solaris gives non-empty results for commands that don't exist
38
+		which() {
39
+			OUT=`${WHICH} ${1}`
40
+			if [ $? -eq 0 ]; then
41
+				echo ${OUT}
42
+			else
43
+				echo ""
44
+			fi;
45
+		}
46
+	fi;
47
+fi
48
+
26
 PIDOF=`which pidof`
49
 PIDOF=`which pidof`
27
 if [ "${PIDOF}" = "" ]; then
50
 if [ "${PIDOF}" = "" ]; then
28
 	# For some reason some distros hide pidof...
51
 	# For some reason some distros hide pidof...
38
 	ISKDE=`${PIDOF} -x -s kdeinit`
61
 	ISKDE=`${PIDOF} -x -s kdeinit`
39
 	ISGNOME=`${PIDOF} -x -s gnome-panel`
62
 	ISGNOME=`${PIDOF} -x -s gnome-panel`
40
 else
63
 else
41
-	ISKDE=`ps ux | grep kdeinit | grep -v grep`
42
-	ISGNOME=`ps ux | grep gnome-panel | grep -v grep`
64
+	ISKDE=`ps -Af | grep kdeinit | grep -v grep`
65
+	ISGNOME=`ps -Af | grep gnome-panel | grep -v grep`
43
 fi;
66
 fi;
44
 KDIALOG=`which kdialog`
67
 KDIALOG=`which kdialog`
45
 ZENITY=`which zenity`
68
 ZENITY=`which zenity`
64
 }
87
 }
65
 
88
 
66
 UNAME=`uname -a`
89
 UNAME=`uname -a`
67
-isLinux=`echo ${UNAME} | grep -i linux`
68
 
90
 
69
 echo ""
91
 echo ""
70
 echo "---------------------"
92
 echo "---------------------"
103
 		result=$?
125
 		result=$?
104
 	fi;
126
 	fi;
105
 	if [ ${result} -ne 0 ]; then
127
 	if [ ${result} -ne 0 ]; then
106
-		if [ "upgrade" != "${1}" ]; then
128
+		if [ "upgrade" = "${1}" ]; then
107
 			errordialog "DMDirc Setup" "Sorry, DMDirc setup can not continue without an updated version of java."
129
 			errordialog "DMDirc Setup" "Sorry, DMDirc setup can not continue without an updated version of java."
108
 		else
130
 		else
109
 			errordialog "DMDirc Setup" "Sorry, DMDirc setup can not continue without java."
131
 			errordialog "DMDirc Setup" "Sorry, DMDirc setup can not continue without java."
110
 		fi;
132
 		fi;
111
 		exit 1;
133
 		exit 1;
112
 	else
134
 	else
113
-		if [ -e ".jrepath" ]; then
114
-			. .jrepath
115
-			JAVA=`which java`
135
+		if [ -e "${PWD}/jrepath" ]; then
136
+			echo "Found JREPath: ${PWD}/jrepath"
137
+			. ${PWD}/jrepath
116
 		fi;
138
 		fi;
139
+		JAVA=`which java`
117
 	fi;
140
 	fi;
118
 }
141
 }
119
 
142
 
121
 	echo "Success!"
144
 	echo "Success!"
122
 else
145
 else
123
 	echo "Failed!"
146
 	echo "Failed!"
124
-	if [ "" == "${isLinux}" ]; then
125
-		errordialog "DMDirc Setup" "Sorry, DMDirc setup can not continue without java 6."
126
-		exit 1
127
-	fi;
128
 	installjre "install"
147
 	installjre "install"
129
 fi
148
 fi
130
 
149
 
183
 		echo "Running installer.."
202
 		echo "Running installer.."
184
 		${JAVA} -cp DMDirc.jar com.dmdirc.installer.Main ${isRoot}${isRelease}
203
 		${JAVA} -cp DMDirc.jar com.dmdirc.installer.Main ${isRoot}${isRelease}
185
 		if [ $? -ne 0 ]; then
204
 		if [ $? -ne 0 ]; then
186
-			if [ "" == "${isLinux}" ]; then
187
-				errordialog "DMDirc Setup" "Sorry, DMDirc setup can not continue without java 6."
188
-				exit 1
189
-			fi;
190
 			installjre "upgrade"
205
 			installjre "upgrade"
191
 			echo "Trying to run installer again.."
206
 			echo "Trying to run installer again.."
192
 			${JAVA} -cp DMDirc.jar com.dmdirc.installer.Main ${isRoot}${isRelease}
207
 			${JAVA} -cp DMDirc.jar com.dmdirc.installer.Main ${isRoot}${isRelease}

Binär
launcher/windows/DMDirc.exe Visa fil


Binär
launcher/windows/DMDircUpdater.exe Visa fil


Laddar…
Avbryt
Spara