[dmdirc commit] r5814 - trunk/installer/linux

1 view
Skip to first unread message

com...@dmdirc.com

unread,
Jan 20, 2010, 10:21:15 AM1/20/10
to dmd...@googlegroups.com
Author: ShaneMcC
Date: 2010-01-20 15:21:13 +0000 (Wed, 20 Jan 2010)
New Revision: 5814

Modified:
trunk/installer/linux/getjre.sh
trunk/installer/linux/installjre.sh
trunk/installer/linux/progressbar.sh
Log:
Work without `bc` (fixes issue 3566 (http://bugs.dmdirc.com/view/3566)) When installing the JRE, show a pulsating progress bar if possible (gnome) else just show a "Please wait..." rather than showing nothing. (Fixes issue 1742 (http://bugs.dmdirc.com/view/1742))

Git-version: 0.6.3m2-341-g0f0afd9


Modified: trunk/installer/linux/getjre.sh
===================================================================
--- trunk/installer/linux/getjre.sh 2010-01-19 22:25:09 UTC (rev 5813)
+++ trunk/installer/linux/getjre.sh 2010-01-20 15:21:13 UTC (rev 5814)
@@ -69,13 +69,16 @@
length=`${CURL} -# -I ${URL} 2>&1 | grep "Content-Length:"| awk '{print $2}'`
fi;

-# Convert the length from Bytes to something user-friendly
-if [ ${actualLength} -ge 1048576 ]; then
+# Convert the length from Bytes to something user-friendly is possible.
+BC=`which bc`
+if [ "${BC}" = "" ]; then
+ niceLength=${actualLength}"B"
+elif [ ${actualLength} -ge 1048576 ]; then
niceLength=`echo "scale=2; ${actualLength}/1048576" | bc`"MB"
elif [ ${actualLength} -ge 1024 ]; then
niceLength=`echo "scale=2; ${actualLength}/1024" | bc`"KB"
else
- niceLength=`echo "scale=2; ${actualLength}/1024" | bc`"B"
+ niceLength=`echo "scale=2; ${actualLength}" | bc`"B"
fi;

if [ "${actualLength}" = "6" ]; then
@@ -132,6 +135,7 @@
exit 1;
fi;
done;
+ /bin/sh ${PWD}/progressbar.sh --watchdog ${progressbarpid}
wgetpid=""
if [ "${ISFREEBSD}" != "" -o "${ISAINFO}" != "" ]; then
echo "Killing progressbar"

Modified: trunk/installer/linux/installjre.sh
===================================================================
--- trunk/installer/linux/installjre.sh 2010-01-19 22:25:09 UTC (rev 5813)
+++ trunk/installer/linux/installjre.sh 2010-01-20 15:21:13 UTC (rev 5814)
@@ -161,7 +161,7 @@
STARTLINE=${STARTLINE%%:*}
# Location of license end
ENDLINE=`grep ${GREPOPTS} "Do you agree to the above license terms?" jre.bin`
- ENDLINE=$((${ENDLINE%%:*} - 4))
+ ENDLINE=$((${ENDLINE%%:*} - 2))
# Location of checksum start
CSSTARTLINE=`grep ${GREPOPTS} "^if \[ -x /usr/bin/sum \]; then$" jre.bin`
CSSTARTLINE=${CSSTARTLINE%%:*}
@@ -176,13 +176,20 @@
tail ${TAILOPTS}$((${ENDLINE})) jre.bin | head -n $((${CSSTARTLINE} -1 - ${ENDLINE})) >> jre.bin.tmp
echo "tail \${tail_args} +${SCENDLINE} \"\$0\" > \$outname" >> jre.bin.tmp
tail ${TAILOPTS}$((${CSENDLINE})) jre.bin >> jre.bin.tmp
-
- yes | sh jre.bin.tmp
- rm -Rf jre.bin.tmp
+
+ PIPE=`mktemp installprogresspipe.XXXXXXXXXXXXXX`
+ /bin/sh ${PWD}/progressbar.sh --pulsate "Installing JRE. Please wait.." 100 ${PIPE} &
+ sleep 1;
+ echo "-1" > ${PIPE}
+ # This is supposed to write to the pipe as it does stuff, but it appears
+ # not to work properly.
+ yes | sh jre.bin.tmp | egrep --line-buffered -i "(extracting|inflating):" > ${PIPE};
+ echo "quit" > ${PIPE}
+ # rm -Rf jre.bin.tmp
fi;

mv ${JREJAVAHOME} ${installdir}
-
+
if [ "0" = "${UID}" ]; then
# Add to global path.
if [ -e "/usr/bin/java" ]; then
@@ -229,4 +236,4 @@
else
errordialog "Java Install" "You must agree to the license before java can be installed"
fi;
-exit 1;
\ No newline at end of file
+exit 1;

Modified: trunk/installer/linux/progressbar.sh
===================================================================
--- trunk/installer/linux/progressbar.sh 2010-01-19 22:25:09 UTC (rev 5813)
+++ trunk/installer/linux/progressbar.sh 2010-01-20 15:21:13 UTC (rev 5814)
@@ -65,6 +65,7 @@
QDBUS=`which qdbus`
DBUSSEND=`which dbus-send`
DCOP=`which dcop`
+BC=`which bc`
KDETYPE=""
if [ "${ISKDE}" != "" -o "${ZENITY}" = "" ]; then
# Check to see if we have the dcop or dbus binaries needed..
@@ -99,9 +100,16 @@
exit 1;
fi;

+if [ "${1}" = "--pulsate" ]; then
+ shift;
+ PULSATE="1"
+else
+ PULSATE="0"
+fi;
+
CAPTION=${1}
FILESIZE=${2}
-WGETPID=${3}
+WGETPID=${4}
progresswindow=""
TYPE=""
PIPE="progresspipe_${$}"
@@ -125,16 +133,44 @@
break;
fi;
fi;
+
input=`cat "${PIPE}" | tail ${TAILOPTS}1`
if [ "${input}" = "quit" ]; then
break;
elif [ "${input}" != "" ]; then
data=${input}
input=""
- res=`echo "scale=4 ; (${data}/${FILESIZE})*100" | bc`
- val=${res%%.*}
- if [ "${val}" = "" ]; then
- val=0
+ if [ "${PULSATE}" = "1" ]; then
+ val=-1
+
+ if [ "${data}" != "-1" ]; then
+ if [ "${TYPE}" = "KDE" ]; then
+ if [ "${KDETYPE}" = "dcop" ]; then
+ ${DCOP} ${progresswindow} setLabelText "${data}"
+ elif [ "${KDETYPE}" = "qdbus" ]; then
+ ${QDBUS} ${progresswindow} org.kde.kdialog.ProgressDialog.setLabelText "${data}"
+ elif [ "${KDETYPE}" = "dbussend" ]; then
+ ${DBUSSEND} --print-reply --dest=${progresswindow} org.kde.kdialog.ProgressDialog.setLabelText "string:\'${data}\'" > /dev/null
+ fi;
+ elif [ "${TYPE}" = "GNOME" ]; then
+ echo "${data}" | sed 's/^/# /g'
+ else
+ echo "${data}"
+ fi;
+ fi;
+
+ else
+ if [ "${BC}" != "" ]; then
+ res=`echo "scale=4 ; (${data}/${FILESIZE})*100" | bc`;
+ else
+ # Note, this will return 0 or 100, nothing else, better than spamming
+ # errors and never closing tho.
+ res=`echo $(( (${data}/${FILESIZE})*100 ))`;
+ fi;
+ val=${res%%.*}
+ if [ "${val}" = "" ]; then
+ val=0
+ fi;
fi;
if [ "${TYPE}" = "KDE" ]; then
if [ "${KDETYPE}" = "dcop" ]; then
@@ -161,6 +197,7 @@
echo "-> "${val}"%"
fi;
fi;
+ echo "Val: ${val}";
if [ "${val}" = "100" ]; then
retval="0"
CONTINUE="0"
@@ -206,7 +243,7 @@
fi;
echo "Exiting with value: $retval"
if [ "${WGETPID}" != "" ]; then
- echo "Attempting to kill wget"
+ echo "Attempting to kill wget (${WGETPID})"
kill -9 ${WGETPID}
fi;

@@ -244,25 +281,34 @@
if [ "" != "${KDIALOG}" -a "" != "${DISPLAY}" -a "" = "${ISGNOME}" -a "${USEKDIALOG}" = "1" ]; then
echo "Progress dialog on Display: ${DISPLAY}"
progresswindow=`${KDIALOG} --title "DMDirc: ${CAPTION}" --progressbar "${CAPTION}" 100`
+ if [ "${PULSATE}" = "1" ]; then
+ SHOWCANCEL="false"
+ else
+ SHOWCANCEL="true"
+ fi;
if [ "${KDETYPE}" = "dcop" ]; then
${DCOP} ${progresswindow} setAutoClose true
- ${DCOP} ${progresswindow} showCancelButton true
+ ${DCOP} ${progresswindow} showCancelButton ${SHOWCANCEL}
elif [ "${KDETYPE}" = "qdbus" ]; then
${QDBUS} ${progresswindow} org.freedesktop.DBus.Properties.Set org.kde.kdialog.ProgressDialog autoClose true
- ${QDBUS} ${progresswindow} org.kde.kdialog.ProgressDialog.showCancelButton true
+ ${QDBUS} ${progresswindow} org.kde.kdialog.ProgressDialog.showCancelButton ${SHOWCANCEL}
elif [ "${KDETYPE}" = "dbussend" ]; then
- ${DBUSSEND} --print-reply --dest=${progresswindow} org.kde.kdialog.ProgressDialog.showCancelButton boolean:true >/dev/null
+ ${DBUSSEND} --print-reply --dest=${progresswindow} org.kde.kdialog.ProgressDialog.showCancelButton boolean:${SHOWCANCEL} >/dev/null
${DBUSSEND} --print-reply --dest=${progresswindow} org.freedesktop.DBus.Properties.Set string:'org.kde.kdialog.ProgressDialog' string:'autoClose' variant:boolean:true > /dev/null
fi;
TYPE="KDE"
readprogress
CONTINUE="0"
echo "Progress Bar Complete"
-elif [ "" != "${ZENITY}" -a "" != "${DISPLAY}" ]; then
+elif [ "" ! "${ZENITY}" -a "" != "${DISPLAY}" ]; then
# Else, if zenity exists and we have a display
echo "Progress dialog on Display: ${DISPLAY}"
TYPE="GNOME"
- readprogress | ${ZENITY} --progress --auto-close --auto-kill --title "DMDirc: ${CAPTION}" --text "${CAPTION}"
+ if [ "${PULSATE}" = "1" ]; then
+ readprogress | ${ZENITY} --progress --pulsate --auto-close --title "DMDirc: ${CAPTION}" --text "${CAPTION}"
+ else
+ readprogress | ${ZENITY} --progress --auto-close --auto-kill --title "DMDirc: ${CAPTION}" --text "${CAPTION}"
+ fi;
CONTINUE="0"
echo "Progress Bar Complete"
else

Reply all
Reply to author
Forward
0 new messages