Browse Source

Be more intelligent when looking for functions.sh, and correctly build functions.sh into the launcher when building the installer.

Change-Id: I7d7b5dff75bcd4ed89e92b9add69cc9d398870c0
Reviewed-on: http://gerrit.dmdirc.com/946
Reviewed-by: Chris Smith <chris@dmdirc.com>
Automatic-Compile: DMDirc Local Commits <dmdirc@googlemail.com>
tags/0.6.3rc2
Shane Mc Cormack 14 years ago
parent
commit
1934770f6f

+ 11
- 1
installer/linux/getjre.sh View File

26
 	fi;
26
 	fi;
27
 fi
27
 fi
28
 
28
 
29
+# Find out where we are
30
+BASEDIR=${0%/*}
31
+if [ "${BASEDIR}" = "${0}" ]; then
32
+	BASEDIR=`which $0`
33
+	BASEDIR=${BASEDIR%/*}
34
+fi
35
+if [ "${BASEDIR:0:1}" != "/" ]; then
36
+	BASEDIR=${PWD}/${BASEDIR}
37
+fi;
38
+
29
 PIDOF=`which pidof`
39
 PIDOF=`which pidof`
30
 if [ "${PIDOF}" = "" ]; then
40
 if [ "${PIDOF}" = "" ]; then
31
 	# For some reason some distros hide pidof...
41
 	# For some reason some distros hide pidof...
37
 fi;
47
 fi;
38
 
48
 
39
 if [ -e "functions.sh" ]; then
49
 if [ -e "functions.sh" ]; then
40
-	. `dirname $0`/functions.sh
50
+	. ${BASEDIR}/functions.sh
41
 else
51
 else
42
 	echo "Unable to find functions.sh, unable to continue."
52
 	echo "Unable to find functions.sh, unable to continue."
43
 	exit 1;
53
 	exit 1;

+ 11
- 1
installer/linux/installjre.sh View File

41
 	fi;
41
 	fi;
42
 fi
42
 fi
43
 
43
 
44
+# Find out where we are
45
+BASEDIR=${0%/*}
46
+if [ "${BASEDIR}" = "${0}" ]; then
47
+	BASEDIR=`which $0`
48
+	BASEDIR=${BASEDIR%/*}
49
+fi
50
+if [ "${BASEDIR:0:1}" != "/" ]; then
51
+	BASEDIR=${PWD}/${BASEDIR}
52
+fi;
53
+
44
 PIDOF=`which pidof`
54
 PIDOF=`which pidof`
45
 if [ "${PIDOF}" = "" ]; then
55
 if [ "${PIDOF}" = "" ]; then
46
 	# For some reason some distros hide pidof...
56
 	# For some reason some distros hide pidof...
54
 ISFREEBSD=`uname -s | grep -i FreeBSD`
64
 ISFREEBSD=`uname -s | grep -i FreeBSD`
55
 
65
 
56
 if [ -e "functions.sh" ]; then
66
 if [ -e "functions.sh" ]; then
57
-	. `dirname $0`/functions.sh
67
+	. ${BASEDIR}/functions.sh
58
 else
68
 else
59
 	echo "Unable to find functions.sh, unable to continue."
69
 	echo "Unable to find functions.sh, unable to continue."
60
 	exit 1;
70
 	exit 1;

+ 23
- 1
installer/linux/makeInstallerLinux.sh View File

301
 fi
301
 fi
302
 
302
 
303
 if [ -e "${jarPath}/launcher/unix" ]; then
303
 if [ -e "${jarPath}/launcher/unix" ]; then
304
-	ln -sf ${jarPath}/launcher/unix/DMDirc.sh .
304
+	# Hax in functions.sh
305
+	FUNCTIONSFILE="functions.sh"
306
+	SRCFILE=${jarPath}/launcher/unix/DMDirc.sh
307
+	DESTFILE=./DMDirc.sh
308
+
309
+	if [ -e "${FUNCTIONSFILE}" ]; then
310
+		FUNCTIONSLINE=`grep ${GREPOPTS} "^###FUNCTIONS_FILE###$" ${SRCFILE}`
311
+		if [ "${FUNCTIONSLINE}" == "" ]; then
312
+			echo "    Functions already built into launcher."
313
+			cp ${SRCFILE} ${DESTFILE}
314
+		else
315
+			echo "    Including functions.sh into launcher."
316
+			FUNCTIONSLINE=$((${FUNCTIONSLINE%%:*} + 0))
317
+
318
+			head -n ${FUNCTIONSLINE} ${SRCFILE} > ${DESTFILE}
319
+			cat functions.sh >> ${DESTFILE}
320
+			echo "" >> ${DESTFILE}
321
+			tail ${TAILOPTS}$((${FUNCTIONSLINE%%:*} + 1)) ${SRCFILE} >> ${DESTFILE}
322
+		fi;
323
+	else
324
+		echo "    Unable to create unix launcher update, no functions.sh found."
325
+	fi;
326
+	
305
 	FILES="${FILES} DMDirc.sh"
327
 	FILES="${FILES} DMDirc.sh"
306
 fi
328
 fi
307
 
329
 

+ 11
- 1
installer/linux/setup.sh View File

46
 	fi;
46
 	fi;
47
 fi
47
 fi
48
 
48
 
49
+# Find out where we are
50
+BASEDIR=${0%/*}
51
+if [ "${BASEDIR}" = "${0}" ]; then
52
+	BASEDIR=`which $0`
53
+	BASEDIR=${BASEDIR%/*}
54
+fi
55
+if [ "${BASEDIR:0:1}" != "/" ]; then
56
+	BASEDIR=${PWD}/${BASEDIR}
57
+fi;
58
+
49
 PIDOF=`which pidof`
59
 PIDOF=`which pidof`
50
 if [ "${PIDOF}" = "" ]; then
60
 if [ "${PIDOF}" = "" ]; then
51
 	# For some reason some distros hide pidof...
61
 	# For some reason some distros hide pidof...
57
 fi;
67
 fi;
58
 
68
 
59
 if [ -e "functions.sh" ]; then
69
 if [ -e "functions.sh" ]; then
60
-	. `dirname $0`/functions.sh
70
+	. ${BASEDIR}/functions.sh
61
 else
71
 else
62
 	echo "Unable to find functions.sh, unable to continue."
72
 	echo "Unable to find functions.sh, unable to continue."
63
 	exit 1;
73
 	exit 1;

+ 36
- 3
installer/linux/uninstall.sh View File

1
 #!/bin/sh
1
 #!/bin/sh
2
 
2
 
3
-if [ ! -e `dirname $0`/.uninstall.conf ]; then
3
+# Check the which command exists, and if so make sure it behaves how we want
4
+# it to...
5
+WHICH=`which which 2>/dev/null`
6
+if [ "" = "${WHICH}" ]; then
7
+	echo "which command not found. Aborting.";
8
+	exit 0;
9
+else
10
+	# Solaris sucks
11
+	BADWHICH=`which /`
12
+	if [ "${BADWHICH}" != "" ]; then
13
+		echo "Replacing bad which command.";
14
+		# "Which" on solaris gives non-empty results for commands that don't exist
15
+		which() {
16
+			OUT=`${WHICH} ${1}`
17
+			if [ $? -eq 0 ]; then
18
+				echo ${OUT}
19
+			else
20
+				echo ""
21
+			fi;
22
+		}
23
+	fi;
24
+fi
25
+
26
+# Find out where we are
27
+BASEDIR=${0%/*}
28
+if [ "${BASEDIR}" = "${0}" ]; then
29
+	BASEDIR=`which $0`
30
+	BASEDIR=${BASEDIR%/*}
31
+fi
32
+if [ "${BASEDIR:0:1}" != "/" ]; then
33
+	BASEDIR=${PWD}/${BASEDIR}
34
+fi;
35
+
36
+if [ ! -e ${BASEDIR}/.uninstall.conf ]; then
4
 	echo "No .uninstall.conf found, unable to continue."
37
 	echo "No .uninstall.conf found, unable to continue."
5
 	exit 1;
38
 	exit 1;
6
 else
39
 else
7
 	INSTALLED_AS_ROOT=""
40
 	INSTALLED_AS_ROOT=""
8
 	INSTALL_LOCATION=""
41
 	INSTALL_LOCATION=""
9
 	
42
 	
10
-	. `dirname $0`/.uninstall.conf
43
+	. ${BASEDIR}/.uninstall.conf
11
 
44
 
12
 	if [ "${INSTALL_LOCATION}" = "" ]; then
45
 	if [ "${INSTALL_LOCATION}" = "" ]; then
13
 		echo "Unable to read .uninstall.conf, unable to continue."
46
 		echo "Unable to read .uninstall.conf, unable to continue."
28
 JAVA=`which java`
61
 JAVA=`which java`
29
 
62
 
30
 if [ -e "functions.sh" ]; then
63
 if [ -e "functions.sh" ]; then
31
-	. `dirname $0`/functions.sh
64
+	. ${BASEDIR}/functions.sh
32
 else
65
 else
33
 	echo "Unable to find functions.sh, unable to continue."
66
 	echo "Unable to find functions.sh, unable to continue."
34
 	exit 1;
67
 	exit 1;

+ 19
- 10
launcher/unix/DMDirc.sh View File

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
-LAUNCHERVERSION="14"
26
+LAUNCHERVERSION="15"
27
 LAUNCHERINFO="unix-${LAUNCHERVERSION}"
27
 LAUNCHERINFO="unix-${LAUNCHERVERSION}"
28
 
28
 
29
 params=""
29
 params=""
51
 	fi;
51
 	fi;
52
 fi
52
 fi
53
 
53
 
54
+# Find out where we are
55
+BASEDIR=${0%/*}
56
+if [ "${BASEDIR}" = "${0}" ]; then
57
+	BASEDIR=`which $0`
58
+	BASEDIR=${BASEDIR%/*}
59
+fi
60
+if [ "${BASEDIR:0:1}" != "/" ]; then
61
+	BASEDIR=${PWD}/${BASEDIR}
62
+fi;
63
+
54
 # Store params so that we can pass them back to the client
64
 # Store params so that we can pass them back to the client
55
 for param in "$@"; do
65
 for param in "$@"; do
56
 	if [ "${param}" = "--noprofile" -o "${param}" = "--updateonly" ]; then 
66
 	if [ "${param}" = "--noprofile" -o "${param}" = "--updateonly" ]; then 
69
 done;
79
 done;
70
 
80
 
71
 if [ -e "functions.sh" ]; then
81
 if [ -e "functions.sh" ]; then
72
-	. `dirname $0`/functions.sh
82
+	. ${BASEDIR}/functions.sh
73
 else
83
 else
74
-	# TODO: Remove this and depend on functions.sh...
75
 	echo "Unable to find functions.sh, using built in functions"
84
 	echo "Unable to find functions.sh, using built in functions"
76
-	
77
 	###FUNCTIONS_FILE###
85
 	###FUNCTIONS_FILE###
78
-	
79
 fi;
86
 fi;
80
 
87
 
81
 # Check to see if we can bspatch things
88
 # Check to see if we can bspatch things
153
 }
160
 }
154
 
161
 
155
 if [ "${ISOSX}" = "1" ]; then
162
 if [ "${ISOSX}" = "1" ]; then
156
-	jarDir=`dirname $0`/../Resources/Java/
163
+	jarDir=${BASEDIR}/../Resources/Java/
157
 	jar=${jarDir}DMDirc.jar
164
 	jar=${jarDir}DMDirc.jar
158
 else
165
 else
159
-	jar=`dirname $0`/DMDirc.jar
166
+	jar=${BASEDIR}/DMDirc.jar
160
 fi
167
 fi
161
 launcherUpdater=${profiledir}/updateLauncher.sh
168
 launcherUpdater=${profiledir}/updateLauncher.sh
162
 BSDJava1="/usr/local/jdk1.6.0/jre/bin/java"
169
 BSDJava1="/usr/local/jdk1.6.0/jre/bin/java"
191
 	echo "Found!";
198
 	echo "Found!";
192
 	echo "Attempting to update..";
199
 	echo "Attempting to update..";
193
 
200
 
201
+	# The code below intentionally doesn't use the FUNCTIONS_FILE include as it
202
+	# wouldn't correctly escape \${0} and \${2} where needed and thus stuff would
203
+	# break!
194
 	cat <<EOF> ${launcherUpdater}
204
 	cat <<EOF> ${launcherUpdater}
195
-		cd `dirname $0`
205
+		cd ${BASEDIR}
196
 		if [ -e "functions.sh" ]; then
206
 		if [ -e "functions.sh" ]; then
197
-			. `dirname $0`/functions.sh
207
+			. ${BASEDIR}/functions.sh
198
 		else
208
 		else
199
-			# TODO: Remove this and depend on functions.sh...
200
 			echo "Unable to find functions.sh, using old functions"
209
 			echo "Unable to find functions.sh, using old functions"
201
 			errordialog() {
210
 			errordialog() {
202
 				# Send message to console.
211
 				# Send message to console.

Loading…
Cancel
Save