Filewatcher File Search
FTP Search
  
Directory (beta)
  
Content Search (beta)
   
pkg://wine-20050211-2mdk.src.rpm:9086164/wine-launcher.sh  info  downloads

#!/bin/bash
# -*- Mode: sh -*-
# Copyright (C) 2000 by Chmouel Boudjnah <chmouel@mandrakesoft.com>,
# MandrakeSoft
# Redistribution of this file is permitted under the terms of the GNU 
# Public License (GPL)
#
# Modified by Per Øyvind Karlsen <peroyvind@linux-mandrake.com>
# Aug 25 2004
# - update script according to upstream changes
#
# Modified by Per Øyvind Karlsen <peroyvind@linux-mandrake.com>
# Jul 22 2004
# - don't use soundwrappers anymore as we also have esd support in wine now
#
# Modified by Per Øyvind Karlsen <peroyvind@linux-mandrake.com>
# Jun 18 2004
# - update configurator to use wineprefixcreate
#
# Modified by Frank <fwallingford@hotmail.com>
# May 03 2004
# - Allow WINEPREFIX to work again
#
# Modified by Danny <obiwan@mailmij.org>
# Apr 01 2004
# - add -native option for using a native windows installation
#
# Modified by Per Øyvind <peroyvind@linux-mandrake.com>
# Mar 21 2004
# - fix problems with arguments when none is specified
#
# Modified by Mark <rickscafe.casablanca@gmx.net>
# Apr 27 2003
# - make winstyle paths work (ie C:\\xxx xxx\\yyy)
# - changed argument handling
# - changed interpreter to bash because we're using bash extensions
#
# Modified by Per Øyvind Karlsen <peroyvind@sintrax.net>
# Apr 16 2003
# - make it work with spaces again
# 
# Modified by Danny <obiwan@mailmij.org>
# Aug 11 2002
# - check and create winetmp-${USER}
# - make sure all options get pass to wine, while still
#    cd-ing to correct directory (I had to require -- even when giving options, 
#    in contrast with normal wine.bin commandline)
# - check for number of arguments
#
# Dec 16 2002
# - run through artsd or esd
#
# Jan 21 2002
# - add /usr/lib/wine to dll patch

true_binary=/usr/bin/wine.bin
default=/etc/wine/config
configurator=/usr/bin/wineprefixcreate
winedir=${WINEPREFIX:-${HOME}/.wine/}
export WINELOADER=${true_binary}
export WINEDLLPATH=/usr/lib/wine
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/lib/wine

usage()
{
cat <<EOF
Usage: wine PROGRAM [ARGUMENTS...]   Run the specified program
       wine --help                   Display this help and exit
       wine --version                Output version information and exit
       wine --native                 Use DLLs from a native MS-Windows (TM) installation

EOF
exit 1
}	    

if [ ! -d /tmp/winetmp-${USER} ]; then
   mkdir -p /tmp/winetmp-${USER}
fi

if [ $# -eq 0 ] || [ $# -eq 1 -a "$1" = "" ] || [ $# -eq 1 -a "$1" = "--" ] ; then
    echo "Wine called with no arguments. Wine requires at least one argument - the name of the Windows application you would like to run."
    usage
fi

# Danny: if called with native, use ~/.wine-native/config
native=""
for arg in "$@"
    do
        if [ "$arg" = "--native" ]; then
           winedir=${WINEPREFIX:-$HOME/.wine-native/}
           native="-n"
       fi
    done

#if needed, create config:
if [ ! -d ${winedir} ];then
    mkdir -p ${winedir}
    cp ${default} ${winedir}/config
        ${configurator}
fi

# Figure out if wine was called with arguments, if so, we need to determine
# the programname that should be executed:

# initialize some stuff
opts=""
dash=""
allargs=""
winstyle="nope"
abs_path="nope"
have_exe=0
argnum=$#

# here we go, check the command line arguments
for arg in "$@"
    do
    #get rid of native:
    if [ "$arg" != "--native" ]; then
	    
        # This block deals with the translation of winstyle paths
	# assume winstyle path includes a character followed by a colon
	# this will zero a winstyle path for testing it
        winstyle=${arg##?:*}
	if [ -z "$winstyle" ]; then
	    # split drive letter and path
	    drive_letter=`echo $arg | sed -e "s/:.*$//" | tr a-z A-Z`
	    winpath=`echo $arg | sed -e "s/^.://"`
	    # lookup drive letter in user's config
	    drive=`cat ${HOME}/.wine/config | sed -e "/Drive $drive_letter/!d" -e "N" -e "s/^.*=//" -e "s/.*\"\\(.*\\)\".*/\\1/"`
	    drive=`cat ${winedir}/config | sed -e "/Drive $drive_letter/!d" -e "N" -e "s/^.*=//" -e "s/.*\"\\(.*\\)\".*/\\1/"`	    
	    # translate backslashes to slashes
	    ### linpath=`echo "$winpath" | sed -e 's/\\\\/\//g' -e 's/ /\\\\ /g'`
	    linpath=`echo "$winpath" | sed -e 's/\\\\/\//g'`
	    # merge to full linux path
	    arg=`eval echo "${drive}${linpath}"`
	fi
   fi
	
	# This block determines the dir and the file to be executed
	if [ $argnum -eq 1 ] || [ ! -z $dash ]; then	
	    if [ -z "$exe" ]; then
		# do we have absolute path, ie starting with a slash	
		abs_path=${arg##/*}
		if [ -z "$abs_path" ]; then
		    dir=`dirname "$arg"`
		    if [ -d "$dir" ]; then
    			cd "$dir"
		    else
			echo "Error: nosuchdir '$dir'"
			echo
    			usage
		    fi
    		    exe=`basename "$arg"`
		else
		    exe="$arg"
		fi

		if [ ! -z "$exe" ]; then
		    have_exe=1
		fi
	    fi
	fi
        
	# check for presence of a dash, ie whether we have options
	if [ "$arg" = "--" ]; then
	    dash="$arg"
	    opts="$allargs"
	    allargs=""
	else
	    # this looks weird but it only keeps the exe from being added to allargs 
	    if [ $have_exe -eq 0 ]; then
		allargs="$allargs $arg"
		allargs="${allargs#" "}"
	    else
		have_exe=0
	    fi
	fi
	
	# hum, this was for debugging, but it won't hurt
	argnum=$(($argnum-1))
    done

# Should be set after any changes to ${winedir}
export WINEPREFIX=${winedir}

# more debugging stuff
# pwd
# echo "opts:  '$opts'"
# echo "dash:  '$dash'"
# echo "exe:   '$exe'"
# echo "allargs: '$allargs'"

if [ -z "$allargs" ]; then 
		${true_binary} $opts $dash "$exe"
	else
		${true_binary} $opts $dash "$exe" "$allargs";
fi
# end
Results 1 - 1
Help - FTP Sites List - Software Dir.
Searching half a billion files worldwide
© 1997-2008 IT MARUHN