[commit] r2109 - separate plugin/audio kludges from interactive launcher

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[commit] r2109 - separate plugin/audio kludges from interactive launcher

commits-3
 
Author: piumarta
Date: 2009-08-27 02:16:19 -0700 (Thu, 27 Aug 2009)
New Revision: 2109

Added:
   trunk/platforms/unix/cmake/squeak.sh.in
Modified:
   trunk/platforms/unix/ChangeLog
   trunk/platforms/unix/cmake/squeak.in
   trunk/platforms/unix/vm/build.cmake
Log:
separate plugin/audio kludges from interactive launcher

Modified: trunk/platforms/unix/ChangeLog
===================================================================
--- trunk/platforms/unix/ChangeLog 2009-08-27 06:09:55 UTC (rev 2108)
+++ trunk/platforms/unix/ChangeLog 2009-08-27 09:16:19 UTC (rev 2109)
@@ -1,3 +1,11 @@
+2009-08-27    <[hidden email]>
+
+ * cmake/squeak.in: Deal with plugin path and pulseaudio; move menu
+ cruft elsewhere.
+
+ * cmake/squeak.sh.in: Added for launching from somewhere that
+ doesn't have a prompt.
+
 2009-08-26  Ian Piumarta  <com -dot- gmail -at- piumarta (backwards)>
 
  * plugins/Mpeg3Plugin/config.cmake: Added.

Modified: trunk/platforms/unix/cmake/squeak.in
===================================================================
--- trunk/platforms/unix/cmake/squeak.in 2009-08-27 06:09:55 UTC (rev 2108)
+++ trunk/platforms/unix/cmake/squeak.in 2009-08-27 09:16:19 UTC (rev 2109)
@@ -1,69 +1,68 @@
 #!/bin/sh
-#
-# Last edited: 2009-08-17 21:09:19 by piumarta on ubuntu.piumarta.com
+#
+# Launch squeakvm from the command line or a menu script, with a good
+# plugin path and pulseaudio kludge
+#
+# Last edited: 2009-08-27 02:00:45 by piumarta on ubuntu.piumarta.com
 
 PATH=/usr/bin:/bin
 
-myname=`basename $0`
+me=`basename $0`
 bindir=`dirname $0`
 bindir=`cd ${bindir}; pwd`
 prefix=`dirname ${bindir}`
 libdir="${prefix}/lib/squeak"
 plgdir="${libdir}/[version]"
-vm="${plgdir}/squeakvm"
-options="-plugins ${plgdir}"
+wrapper=""
+vm="squeakvm"
+plugins=""
+sound=""
 
-error () {
-    if test -n "$DISPLAY" -a -x "`which zenity 2>/dev/null`"; then
-        zenity --error --text "${myname}: $1"
-    else
- echo "${myname}: $1" >&2
-    fi
-}
+# find the vm and set the plugin path
 
-run () {
-    exec "${vm}" ${options} "$@"
-}
-
-if test ! -x "${vm}"; then
+if test -x "${plgdir}/${vm}"; then # bin/squeak -> lib/squeak/x.y-z/squeakvm
+    vm="${plgdir}/${vm}"
+    plugins="${plgdir}"
+elif test -x "${bindir}/${vm}"; then # bld/squeak -> bld/squeakvm
+    vm="${bindir}/${vm}"
+    plugins="${bindir}/%n"
+elif test -x "`which ${vm}`"; then
+    vm="`which ${vm}`"
+    plugins=""
+else    
     error "cannot find ${vm}"
     exit 1
 fi
 
-if test $# -gt 0 -o -f squeak.image; then
-    run "$@"
+# deal with pulseaudio if it is running
+
+if pulseaudio --check 2>/dev/null; then
+    sound="-vm-sound-oss"
+    if padsp true 2>/dev/null; then
+        wrapper=padsp
+    fi
 fi
 
-# deal with being launched from a menu
+# we should not interfere with the user's -plugins or -vm-sound options
 
-if test -z "$DISPLAY" -o ! -x "`which zenity 2>/dev/null`"; then
-    error "no image filename specified"
-    exit 1
-fi
+for opt in $*; do
+    case ${opt} in
+ -plugins) plugins="";;
+ -vm-sound*) sound=""; wrapper="";;
+ -vm) case "$2" in sound*) sound=""; wrapper=""; esac;;
+    esac
+done
 
-image=`zenity --title "Choose a saved image to resume or cancel to install a new one" --file-selection`
+# we should not interfere with the user's environment variables
 
-if test -z "${image}"; then
-    images=`cd ${libdir}; ls *.image 2>/dev/null`
-    if test -z "${images}"; then
- error "no installable images in ${libdir}"
- exit 1
-    fi
-    image=`zenity --title "Choose an image to install" --list --column Images $images`
-    if test -z "${image}"; then
- exit 0
-    fi
-    changes=`basename ${image} .image`.changes
-    location=`zenity --title "Choose a destination directory" --file-selection --directory`
-    if test -z "${location}"; then
- exit 0
-    fi
-    cp -p ${libdir}/${image}   ${location}/.
-    cp -p ${libdir}/${changes} ${location}/.
-    ln -s ${libdir}/*.sources  ${location}/.
-    options="${options}"
-    image="${location}/${image}"
+if test -n "${SQUEAK_PLUGINS}"; then
+    plugins=""
 fi
 
-cd `dirname ${image}`
-run `basename ${image}` "$@"
+if test -z "${plugins}"; then
+    set -x
+    exec ${wrapper} "${vm}" ${sound} "$@"
+else
+    set -x
+    exec ${wrapper} "${vm}" -plugins "${plugins}" ${sound} "$@"
+fi

Added: trunk/platforms/unix/cmake/squeak.sh.in
===================================================================
--- trunk/platforms/unix/cmake/squeak.sh.in                        (rev 0)
+++ trunk/platforms/unix/cmake/squeak.sh.in 2009-08-27 09:16:19 UTC (rev 2109)
@@ -0,0 +1,99 @@
+#!/bin/sh
+#
+# Launch squeak from a menu, prompting for and/or installing an image
+#
+# Last edited: 2009-08-27 02:06:21 by piumarta on ubuntu.piumarta.com
+
+PATH=/usr/bin:/bin
+
+me=`basename $0`
+bindir=`dirname $0`
+bindir=`cd ${bindir}; pwd`
+prefix=`dirname ${bindir}`
+libdir="${prefix}/lib/squeak"
+vm="squeak"
+
+# find a way to display dialogues
+
+if test -n "$DISPLAY" -a -x "`which xkdialog 2>/dev/null`"; then
+    error () { kdialog --error "${me}: $*"; exit 1; }
+    confirm () { if kdialog --yesno "${1} ${2}?"; then result="${2}"; else result=""; fi; }
+    chooseItem () { title="$1"; shift; result=`kdialog --combobox "${title}" $*`; }
+    findFile () { result=`kdialog --title "$1" --getopenfilename . '*.image'`; }
+    findDirectory () { result=`kdialog --title "$1" --getexistingdirectory .`; }
+elif [ -n "$DISPLAY" -a -x "`which zenity 2>/dev/null`" ]; then
+    error () { zenity --error --text "${me}: $*"; exit 1; }
+    confirm () { if zenity --question --text="${1} ${2}?"; then result="${2}"; else result=""; fi; }
+    chooseItem () { title="$1"; shift; result=`zenity --title "${title}" --list --column Images $*`; }
+    findFile () { result=`zenity --title "$1" --file-selection --file-filter='*.image'`; }
+    findDirectory () { result=`zenity --title "$1" --file-selection --directory`; }
+else
+    error () { echo "${me}: $*" >&2; exit 1; }
+    confirm () { error "this cannot happen"; }
+    chooseItem () { error "this cannot happen"; }
+    findFile () { error "no image name specified"; }
+    findDirectory () { error "this cannot happen"; }
+fi
+
+# succeed if there are two or more arguments
+
+plural () { test -n "$2"; }
+
+# find the VM
+
+if test -x "${bindir}/${vm}"; then
+    vm="${bindir}/${vm}"
+elif test -x "`which ${vm} 2>/dev/null`"; then
+    vm="`which ${vm} 2>/dev/null`"
+else
+    error "Cannot find ${vm}"
+fi
+
+# if we have arguments then assume an image name was given or we came
+# from a command line
+
+if test $# -gt 0; then
+    exec "${vm}" "$@"
+fi
+
+findFile "Choose a saved image to resume or cancel to install a new one"
+
+if test -z "${result}"; then
+    images=""
+    if test -d "${libdir}"; then
+ images=`cd "${libdir}"; ls *.image 2>/dev/null`
+    fi
+    if test -z "${images}"; then
+ error "no image name specified and no images found in ${libdir}"
+ exit 1
+    fi
+    if plural ${images}; then
+ chooseItem "Choose an image to install" ${images}
+    else
+ confirm "Install image" ${images}
+    fi
+    if test -z "${result}"; then
+ exit 0
+    fi
+    image=${result}
+    changes=`basename ${image} .image`.changes
+    findDirectory "Choose a destination directory for the image"
+    if test -z "${result}"; then
+ exit 0
+    fi
+    if test -e "${result}/${image}"; then
+ confirm "Overwrite existing ${image} in" "${result}"
+ if test -z "${result}"; then
+    exit 0;
+ fi
+    fi
+    cp -p "${libdir}/${image}"   "${result}/."
+    cp -p "${libdir}/${changes}" "${result}/."
+    ln -s "${libdir}"/*.sources  "${result}/."
+    image="${result}/${image}"
+else
+    image="${result}"
+fi
+
+cd "`dirname ${image}`"
+exec "${vm}" "`basename ${image}`"


Property changes on: trunk/platforms/unix/cmake/squeak.sh.in
___________________________________________________________________
Added: svn:executable
   + *

Modified: trunk/platforms/unix/vm/build.cmake
===================================================================
--- trunk/platforms/unix/vm/build.cmake 2009-08-27 06:09:55 UTC (rev 2108)
+++ trunk/platforms/unix/vm/build.cmake 2009-08-27 09:16:19 UTC (rev 2109)
@@ -39,13 +39,17 @@
 
 CONFIGURE_FILE (${config}/config.in ${bld}/config @ONLY)
 
-# launcher script
+# launcher scripts
 
 ADD_CUSTOM_TARGET (squeak
   DEPENDS ${config}/squeak.in
   COMMAND sh ${bld}/config ${config}/squeak.in ${bld}/squeak
 )
-ADD_DEPENDENCIES (squeakvm squeak)
+ADD_CUSTOM_TARGET (squeak.sh
+  DEPENDS ${config}/squeak.sh.in
+  COMMAND sh ${bld}/config ${config}/squeak.sh.in ${bld}/squeak.sh
+)
+ADD_DEPENDENCIES (squeakvm squeak squeak.sh)
 INSTALL (PROGRAMS ${bld}/squeak DESTINATION bin)
 
 # manual page