Parcourir la 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 il y a 14 ans
Parent
révision
1934770f6f

+ 11
- 1
installer/linux/getjre.sh Voir le fichier

@@ -26,6 +26,16 @@ else
26 26
 	fi;
27 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 39
 PIDOF=`which pidof`
30 40
 if [ "${PIDOF}" = "" ]; then
31 41
 	# For some reason some distros hide pidof...
@@ -37,7 +47,7 @@ if [ "${PIDOF}" = "" ]; then
37 47
 fi;
38 48
 
39 49
 if [ -e "functions.sh" ]; then
40
-	. `dirname $0`/functions.sh
50
+	. ${BASEDIR}/functions.sh
41 51
 else
42 52
 	echo "Unable to find functions.sh, unable to continue."
43 53
 	exit 1;

+ 11
- 1
installer/linux/installjre.sh Voir le fichier

@@ -41,6 +41,16 @@ else
41 41
 	fi;
42 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 54
 PIDOF=`which pidof`
45 55
 if [ "${PIDOF}" = "" ]; then
46 56
 	# For some reason some distros hide pidof...
@@ -54,7 +64,7 @@ fi;
54 64
 ISFREEBSD=`uname -s | grep -i FreeBSD`
55 65
 
56 66
 if [ -e "functions.sh" ]; then
57
-	. `dirname $0`/functions.sh
67
+	. ${BASEDIR}/functions.sh
58 68
 else
59 69
 	echo "Unable to find functions.sh, unable to continue."
60 70
 	exit 1;

+ 23
- 1
installer/linux/makeInstallerLinux.sh Voir le fichier

@@ -301,7 +301,29 @@ elif [ -e "${DOCSDIR}/CHANGELOG.TXT" ]; then
301 301
 fi
302 302
 
303 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 327
 	FILES="${FILES} DMDirc.sh"
306 328
 fi
307 329
 

+ 11
- 1
installer/linux/setup.sh Voir le fichier

@@ -46,6 +46,16 @@ else
46 46
 	fi;
47 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 59
 PIDOF=`which pidof`
50 60
 if [ "${PIDOF}" = "" ]; then
51 61
 	# For some reason some distros hide pidof...
@@ -57,7 +67,7 @@ if [ "${PIDOF}" = "" ]; then
57 67
 fi;
58 68
 
59 69
 if [ -e "functions.sh" ]; then
60
-	. `dirname $0`/functions.sh
70
+	. ${BASEDIR}/functions.sh
61 71
 else
62 72
 	echo "Unable to find functions.sh, unable to continue."
63 73
 	exit 1;

+ 36
- 3
installer/linux/uninstall.sh Voir le fichier

@@ -1,13 +1,46 @@
1 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 37
 	echo "No .uninstall.conf found, unable to continue."
5 38
 	exit 1;
6 39
 else
7 40
 	INSTALLED_AS_ROOT=""
8 41
 	INSTALL_LOCATION=""
9 42
 	
10
-	. `dirname $0`/.uninstall.conf
43
+	. ${BASEDIR}/.uninstall.conf
11 44
 
12 45
 	if [ "${INSTALL_LOCATION}" = "" ]; then
13 46
 		echo "Unable to read .uninstall.conf, unable to continue."
@@ -28,7 +61,7 @@ fi;
28 61
 JAVA=`which java`
29 62
 
30 63
 if [ -e "functions.sh" ]; then
31
-	. `dirname $0`/functions.sh
64
+	. ${BASEDIR}/functions.sh
32 65
 else
33 66
 	echo "Unable to find functions.sh, unable to continue."
34 67
 	exit 1;

+ 19
- 10
launcher/unix/DMDirc.sh Voir le fichier

@@ -23,7 +23,7 @@
23 23
 # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24 24
 # SOFTWARE.
25 25
 
26
-LAUNCHERVERSION="14"
26
+LAUNCHERVERSION="15"
27 27
 LAUNCHERINFO="unix-${LAUNCHERVERSION}"
28 28
 
29 29
 params=""
@@ -51,6 +51,16 @@ else
51 51
 	fi;
52 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 64
 # Store params so that we can pass them back to the client
55 65
 for param in "$@"; do
56 66
 	if [ "${param}" = "--noprofile" -o "${param}" = "--updateonly" ]; then 
@@ -69,13 +79,10 @@ for param in "$@"; do
69 79
 done;
70 80
 
71 81
 if [ -e "functions.sh" ]; then
72
-	. `dirname $0`/functions.sh
82
+	. ${BASEDIR}/functions.sh
73 83
 else
74
-	# TODO: Remove this and depend on functions.sh...
75 84
 	echo "Unable to find functions.sh, using built in functions"
76
-	
77 85
 	###FUNCTIONS_FILE###
78
-	
79 86
 fi;
80 87
 
81 88
 # Check to see if we can bspatch things
@@ -153,10 +160,10 @@ getConfigOption() {
153 160
 }
154 161
 
155 162
 if [ "${ISOSX}" = "1" ]; then
156
-	jarDir=`dirname $0`/../Resources/Java/
163
+	jarDir=${BASEDIR}/../Resources/Java/
157 164
 	jar=${jarDir}DMDirc.jar
158 165
 else
159
-	jar=`dirname $0`/DMDirc.jar
166
+	jar=${BASEDIR}/DMDirc.jar
160 167
 fi
161 168
 launcherUpdater=${profiledir}/updateLauncher.sh
162 169
 BSDJava1="/usr/local/jdk1.6.0/jre/bin/java"
@@ -191,12 +198,14 @@ elif [ -e "${profiledir}/.launcher.sh" ]; then
191 198
 	echo "Found!";
192 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 204
 	cat <<EOF> ${launcherUpdater}
195
-		cd `dirname $0`
205
+		cd ${BASEDIR}
196 206
 		if [ -e "functions.sh" ]; then
197
-			. `dirname $0`/functions.sh
207
+			. ${BASEDIR}/functions.sh
198 208
 		else
199
-			# TODO: Remove this and depend on functions.sh...
200 209
 			echo "Unable to find functions.sh, using old functions"
201 210
 			errordialog() {
202 211
 				# Send message to console.

Chargement…
Annuler
Enregistrer