| clacker  
 
  
 
 
 Group: Members
 Posts: 570
 Joined: June 2004
 | 
|  | Posted: Jan. 13 2006,03:32 |  |  OK, I had to modify three files, but once that's done you can have spaces in path names and still be able to use the mydsl-load myapp.dsl games functionality.
 
 The first change was to the /usr/bin/mydsl-load script.  I changed the first area to slurp up all of the parameters and if this ends in an extension we want (dsl, uci, or tar.gz) I take that as the pasth and file name.  If it doesn't. then I assume that there is a $1 containing the file and a $2 containing the repository group.  I also added some quotes around $APP at the end of the script:
 
 
 | Code Sample |  | #!/bin/sh #(c) Robert Shingledecker 2004,2005
 #
 . /etc/init.d/dsl-functions
 #
 MYMENU="/var/tmp/mydsl.menu"
 MYICONS="/var/tmp/mydsl.icons"
 DESKTOP=`cat $HOME/.desktop`
 XTDESKTOP="$HOME/.xtdesktop"
 
 #
 desktop_setup(){
 if [ -f "$MYMENU/$APPNAME" ]; then
 #     if [ "$DESKTOP" == "fluxbox" ]; then
 /etc/init.d/mkmydslmenu.lua "$APPNAME"
 #     else
 /etc/init.d/mkmydsljwmmenu.lua "$APPNAME"
 jwm -restart
 #     fi
 fi
 iconsnap.sh
 }
 #
 # Main
 #
 if [ -n "$DISPLAY" ] && [ $UID != 1001 ]; then
 echo "Non DSL User error." > /tmp/noload
 echo "You must be logged in as user \"dsl\" to install a myDSL extension."
 exit 1
 else
 rm -f /tmp/noload
 fi
 
 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 if [ -n "$1" ]; then
 if (echo "$*" | grep -q "\.dsl$") || (echo "$*" | grep -q "\.uci$") || (echo "$*" | grep -q "\.tar\.gz$"); then
 APP="$*"
 else
 if [ -n "$2" ]; then
 APP="$1"
 mydsl-wget "$APP" "$2"
 if [ -f /tmp/noload ]; then
 cat /tmp/noload
 exit 1;
 fi
 fi
 fi
 else
 whiptail --title "Specify myDSL Extensions" --inputbox "Enter extension, e.g. /mnt/hda3/optional/myapp.dsl" 0 0 2>/tmp/mydsl.app
 APP=$(cat /tmp/mydsl.app)
 if [ ! -n "$APP" ]; then
 exit 1
 fi
 fi
 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 
 
 ######################################################################################################
 #if [ -n "$1" ]; then
 #   APP="$1"
 #else
 #   whiptail --title "Specify myDSL Extensions" --inputbox "Enter extension, e.g. /mnt/hda3/optional/myapp.dsl" 0 0 2>/tmp/mydsl.app
 #   APP=$(cat /tmp/mydsl.app)
 #   if [ ! -n "$APP" ]; then
 #      exit 1
 #   fi
 #fi
 #if [ -n "$2" ]; then
 #   mydsl-wget "$APP" "$2"
 #   if [ -f /tmp/noload ]; then
 #      cat /tmp/noload
 #      exit 1;
 #   fi
 #fi
 ######################################################################################################
 
 #
 case "$APP" in
 *.uci)
 APPNAME=$(getbasefile "$APP" 1)
 sudo /etc/init.d/mountci "$APP" "$APPNAME"
 if [ $? == 0 ] && [ -n "$DISPLAY" ]; then
 iconcheck
 desktop_setup
 fi
 ;;
 *.dsl)
 APPNAME=$(getbasefile "$APP" 1)
 sudo /etc/init.d/mydsl-install "$APP"
 if [ -n "$DISPLAY" ]; then
 iconcheck
 desktop_setup
 fi
 ;;
 *.tar.gz)
 APPNAME=$(getbasefile "$APP" 2)
 sudo /etc/init.d/mydsl-install "$APP"
 if [ -n "$DISPLAY" ]; then
 iconcheck
 desktop_setup
 fi
 ;;
 esac
 | 
 
 Next I edited the /etc/init.d/mydsl-install script.  Again I used a $* to get all of the parameter string, and also added some parenthesis around the $APP at the end:
 
 
 | Code Sample |  | #!/bin/sh #(c) Robert Shingledecker 2004,2005
 #
 MYICONS="/var/tmp/mydsl.icons"
 XTDESKTOP="$HOME"/.xtdesktop
 #
 if [ -n "$1" ]; then
 APP="$*"
 else
 exit 1
 fi
 UMOUNT=""
 if [ ! -e "$APP" ]; then
 APP_NAME=`basename "$APP"`
 MYDSL=`dirname "$APP"`
 if [ `basename "$MYDSL"` == "optional" ]; then
 MYDSL=`dirname "$MYDSL"`
 if [ "$MYDSL" == "/cdrom2" ]; then
 MYDSL="/mnt/auto/cdrom"
 APP="$MYDSL/optional/$APP_NAME"
 else
 mount "$MYDSL" 2>/dev/null
 fi
 fi
 if [ ! -e "$APP" ]; then
 if [ -n "$DISPLAY" ]; then
 popup.lua 'Please mount media containing optional dir and try again.'
 else
 echo -n 'Please mount media containing optional directory and try again.'
 read gagme
 fi
 exit 1
 else
 UMOUNT="yes"
 fi
 fi
 if [ -d "$XTDESKTOP" ]; then
 mount --bind "$MYICONS" "$XTDESKTOP"
 fi
 case "$APP" in
 *.dsl)
 /etc/init.d/mkwriteable
 busybox tar -C / -zxf "$APP"
 ;;
 *.tar.gz)
 busybox tar -C / -zxf "$APP"
 ;;
 *.deb)
 /usr/sbin/dpkg-restore >/dev/null 2>&1
 rxvt -rv -T "myDSL deb package terminal" -e sudo dpkg -i "$APP" &
 ;;
 esac
 if [ -d "$XTDESKTOP" ]; then
 umount "$XTDESKTOP"
 fi
 if [ "$UMOUNT" == "yes" ]; then
 umount "$MYDSL"
 fi
 | 
 
 The last change was to the file /etc/init.d/dsl-functions.  I changed the getbasefile function slightly by adding quotes around the $1.  I don't think it's really necessary, but I did it for completeness:
 
 
 | Code Sample |  | getbasefile(){ BASENAME=`basename "$1"`
 FIELDS=`echo $BASENAME|awk 'BEGIN{ FS="."} {print NF}'`
 ((FIELDS -= $2))
 INFO=`echo $BASENAME|cut -f1-$FIELDS -d.`
 echo $INFO
 return 0
 }
 | 
 
 Modifying those three script allowed me to load *.dsl, *.uci, and *.tar.gz files for a directory with spaces in it, as well as using the mydsl-load barrage.dsl games form correctly.
 
 I'm sure there is a cleaner way to do it, but this worked.  If you don't want to use it because spaces are a nono that's OK too.
 |