Sophie

Sophie

distrib > Mandriva > 9.1 > ppc > by-pkgid > 4d93b4709982476e9dbb8490886e8dec > files > 12

wine-20030115-4mdk.src.rpm

#!/bin/sh
# -*- 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 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/share/wine/wine-config
winedir=${HOME}/.wine/
export WINELOADER=${true_binary}
export WINEDLLPATH=/usr/lib/wine
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/lib/wine

usage()
{
echo ""
echo "Usage: wine.bin [options] [--] program_name [arguments]"
echo "The -- has to be used if you specify arguments OR options"
echo ""
echo "Options:"
echo "--debugmsg name  Turn debugging-messages on or off"
echo "--dll name       Enable or disable built-in DLLs"
echo "--help,-h        Show this help message"
echo "--version,-v     Display the Wine version"
echo ""
exit 1
}	    

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

if [ ! -d ${winedir} ];then
    mkdir -p ${winedir}
    cp ${default} ${winedir}/config
    if [ -x /usr/bin/perl ];then
	perl ${configurator} ${winedir}/config || :
    fi
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

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

for arg in "$@"
    do
        if [ $flag = 1 ] ; then
	    #set flag to 2: only the first argument after -- is the program
	    flag=2
	    dir=`dirname "$arg"`
	    if [ -d $dir ] ; then
		cd "$dir"
		arg=`basename "$arg"`
	    else
		usage
	    fi
	fi    
        
	if [ "$arg" = "--" ] && [ $flag = 0 ] ; then 
	    flag=1 
	fi

	allargs="$allargs $arg"
    done

if [ $flag = 0 ] ; then

# Left out because of 'wineconsole notepad'-like stuff:
#	if !([ $# -eq 1 ]) ; then
#	    echo "You need to use -- if you specify program arguments or wine options."
#	    usage
#	fi
	
    dir=`dirname "$*"`
    if [ -d "$dir" ] ; then
        cd "$dir"
        allargs=`basename "$*"`
    else
        usage
    fi
fi
																   
#Strip space from string and run wine through esd or arts. I'm not using
#soundwrapper because wine only works through arts when using single threaded mode.
if [ `/sbin/pidof -s artsd` ] ; then
		artsdsp -s ${true_binary} ${allargs#" "}
	else
		if [ `/sbin/pidof -s esd` ]; then
			esddsp ${true_binary} ${allargs#" "}
		else
			${true_binary} ${allargs#" "}
		fi
fi