Selaa lähdekoodia

Rather than just including an old version of the functions in the launcher, build in functions.sh from the installer.

This really negates the need to even include functions.sh when it exists but I'll leave that in for now.

Change-Id: I579dff3cae8930f43eea04780fa60cb55738a7d3
Reviewed-on: http://gerrit.dmdirc.com/434
Reviewed-by: Gregory Holmes <greboid@dmdirc.com>
Tested-by: Gregory Holmes <greboid@dmdirc.com>
tags/0.6.3b1
Shane Mc Cormack 14 vuotta sitten
vanhempi
commit
5390443ea0
2 muutettua tiedostoa jossa 41 lisäystä ja 81 poistoa
  1. 38
    1
      launcher/createUpdate.sh
  2. 3
    80
      launcher/unix/DMDirc.sh

+ 38
- 1
launcher/createUpdate.sh Näytä tiedosto

@@ -6,9 +6,46 @@ LAUNCHERUPDATEDIR="/home/dmdirc/www/updates/launchers/"
6 6
 UNIXVERSION=`cat ${LAUNCHERDIR}/unix/DMDirc.sh | grep LAUNCHERVERSION= | awk -F\" '{print $2}'`
7 7
 WINDOWSVERSION=`cat ${LAUNCHERDIR}/windows/DMDirc.dpr | grep "launcherVersion: String =" | awk -F\' '{print $2}'`
8 8
 
9
+# Find out what params we should pass to things.
10
+# Solaris has a nice and ancient version of grep in /usr/bin
11
+grep -na "" /dev/null >/dev/null 2>&1
12
+if [ $? -eq 2 ]; then
13
+	GREPOPTS="-n"
14
+else
15
+	GREPOPTS="-na"
16
+fi;
17
+# Solaris also has a crappy version of tail!
18
+tail -n +1 /dev/null >/dev/null 2>&1
19
+if [ $? -eq 2 ]; then
20
+	TAILOPTS="+"
21
+else
22
+	TAILOPTS="-n +"
23
+fi;
24
+
9 25
 if [ ! -e "${LAUNCHERUPDATEDIR}/unix-${UNIXVERSION}.sh" ]; then
10 26
 	echo "Creating Launcher Update: unix-${UNIXVERSION}";
11
-	cp -${LAUNCHERDIR}/unix/DMDirc.sh ${LAUNCHERUPDATEDIR}/unix-${UNIXVERSION}.sh
27
+	
28
+	FUNCTIONSFILE="${LAUNCHERDIR}/../installer/linux/functions.sh"
29
+	SRCFILE=${LAUNCHERDIR}/unix/DMDirc.sh
30
+	DESTFILE=${LAUNCHERUPDATEDIR}/unix-${UNIXVERSION}.sh
31
+	
32
+	if [ -e "${FUNCTIONSFILE}" ]; then
33
+		FUNCTIONSLINE=`grep ${GREPOPTS} "^###FUNCTIONS_FILE###$" ${SRCFILE}`
34
+		if [ "${FUNCTIONSLINE}" == "" ]; then
35
+			echo "    Functions already built into launcher."
36
+			cp ${SRCFILE} ${DESTFILE}
37
+		else
38
+			echo "    Including functions.sh into launcher."
39
+			FUNCTIONSLINE=$((${FUNCTIONSLINE%%:*} + 0))
40
+			
41
+			head -n ${FUNCTIONSLINE} ${SRCFILE} > ${DESTFILE}
42
+			cat functions.sh >> ${DESTFILE}
43
+			echo "" >> ${DESTFILE}
44
+			tail ${TAILOPTS}$((${FUNCTIONSLINE%%:*} + 1)) ${SRCFILE} >> ${DESTFILE}
45
+		fi;
46
+	else
47
+		echo "    Unable to create unix launcher update, no functions.sh found."
48
+	fi;
12 49
 fi;
13 50
 
14 51
 if [ ! -e "${LAUNCHERUPDATEDIR}/windows-${WINDOWSVERSION}.zip" ]; then

+ 3
- 80
launcher/unix/DMDirc.sh Näytä tiedosto

@@ -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="13"
26
+LAUNCHERVERSION="14"
27 27
 LAUNCHERINFO="unix-${LAUNCHERVERSION}"
28 28
 
29 29
 params=""
@@ -72,87 +72,10 @@ if [ -e "functions.sh" ]; then
72 72
 	. `dirname $0`/functions.sh
73 73
 else
74 74
 	# TODO: Remove this and depend on functions.sh...
75
-	echo "Unable to find functions.sh, using old functions"
75
+	echo "Unable to find functions.sh, using built in functions"
76 76
 	
77
-	# Check for OS X
78
-	OSASCRIPT=`which osascript`
79
-	KERNEL=`uname -s`
80
-	ISOSX="0"
81
-	# Kernel is darwin, and osascript exists, probably OS X!
82
-	if [ "${KERNEL}" = "Darwin" -a "" != "${OSASCRIPT}" ]; then
83
-		ISOSX="1"
84
-	fi;
85
-
86
-	if [ "${ISOSX}" != "1" ]; then
87
-		PIDOF=`which pidof`
88
-		if [ "${PIDOF}" = "" ]; then
89
-			# For some reason some distros hide pidof...
90
-			if [ -e /sbin/pidof ]; then
91
-				PIDOF=/sbin/pidof
92
-			elif [ -e /usr/sbin/pidof ]; then
93
-				PIDOF=/usr/sbin/pidof
94
-			fi;
95
-		fi;
96
-		
97
-		## Helper Functions
98
-		if [ "${PIDOF}" != "" ]; then
99
-			ISKDE=`${PIDOF} -x -s kdeinit`
100
-			ISGNOME=`${PIDOF} -x -s gnome-panel`
101
-		else
102
-			ISKDE=`ps -Af | grep kdeinit | grep -v grep`
103
-			ISGNOME=`ps -Af | grep gnome-panel | grep -v grep`
104
-		fi;
105
-		KDIALOG=`which kdialog`
106
-		ZENITY=`which zenity`
107
-		KSUDO=`which kdesudo`
108
-		GSUDO=`which gksudo`
109
-	fi;
110
-	
111
-	errordialog() {
112
-		# Send message to console.
113
-		echo ""
114
-		echo "-----------------------------------------------------------------------"
115
-		echo "Error: ${1}"
116
-		echo "-----------------------------------------------------------------------"
117
-		echo "${2}"
118
-		echo "-----------------------------------------------------------------------"
77
+	###FUNCTIONS_FILE###
119 78
 	
120
-		if [ "${ISOSX}" = "1" -a "" != "${OSASCRIPT}" ]; then
121
-			echo "Displaying dialog.."
122
-			${OSASCRIPT} -e 'tell application "System Events"' -e "activate" -e "display dialog \"${1}\n${2}\" buttons {\"Ok\"} with icon stop" -e 'end tell'
123
-		else
124
-			if [ "" != "${ISKDE}" -a "" != "${KDIALOG}" -a "" != "${DISPLAY}" ]; then
125
-				echo "Dialog on Display: ${DISPLAY}"
126
-				${KDIALOG} --title "DMDirc: ${1}" --error "${1}\n\n${2}"
127
-			elif [ "" != "${ISGNOME}" -a "" != "${ZENITY}" -a "" != "${DISPLAY}" ]; then
128
-				echo "Dialog on Display: ${DISPLAY}"
129
-				${ZENITY} --error --title "DMDirc: ${1}" --text "${1}\n\n${2}"
130
-			fi
131
-		fi;
132
-	}
133
-	
134
-	messagedialog() {
135
-		# Send message to console.
136
-		echo ""
137
-		echo "-----------------------------------------------------------------------"
138
-		echo "Info: ${1}"
139
-		echo "-----------------------------------------------------------------------"
140
-		echo "${2}"
141
-		echo "-----------------------------------------------------------------------"
142
-	
143
-		if [ "${ISOSX}" = "1" -a "" != "${OSASCRIPT}" ]; then
144
-			echo "Displaying dialog.."
145
-			${OSASCRIPT} -e 'tell application "System Events"' -e "activate" -e "display dialog \"${1}\n${2}\" buttons {\"Ok\"} giving up after 120 with icon note" -e 'end tell'
146
-		else
147
-			if [ "" != "${ISKDE}" -a "" != "${KDIALOG}" -a "" != "${DISPLAY}" ]; then
148
-				echo "Dialog on Display: ${DISPLAY}"
149
-				${KDIALOG} --title "DMDirc: ${1}" --msgbox "${1}\n\n${2}"
150
-			elif [ "" != "${ISGNOME}" -a "" != "${ZENITY}" -a "" != "${DISPLAY}" ]; then
151
-				echo "Dialog on Display: ${DISPLAY}"
152
-				${ZENITY} --info --title "DMDirc: ${1}" --text "${1}\n\n${2}"
153
-			fi
154
-		fi;
155
-	}
156 79
 fi;
157 80
 
158 81
 # Check to see if we can bspatch things

Loading…
Peruuta
Tallenna