/!\ My thinking process sometimes following strange ways, you should directly jump to the end of my post to find a (probably) working script ;)
fettouhi: #!/usr/bin/bash
ID=baldurs-gate
WRITABLE='*.ini *.key *.tlk'
EXE=BGMain.exe
USERDIR=$HOME/.gog/$ID
export WINEPREFIX=$USERDIR/.wine
export WINEDEBUG=-all
This part is OK.
I can’t remember why I use bgmain2.exe instead of bgmain.exe… Maybe the latter is from the original game while the former is the one added by th expansion? Anyway, shouldn’t matter if the game can be launched from BGMain.exe on your system.
fettouhi: if ! [ -d $USERDIR ]
then
INSTALLDIR=/opt/gog/$ID
mkdir -p $(dirname $USERDIR)
cp -as $INSTALLDIR $USERDIR
WINEARCH=win32 wineboot -i
rm $WINEPREFIX/dosdevices/"z:"
ln -s $USERDIR $WINEPREFIX/drive_c
cd $USERDIR
for file in $WRITABLE
do
cp -a --remove-destination $INSTALLDIR/$file $file
done
fi
This part is OK
if the file BGMain.exe can be found under /opt/gog/baldurs-gate/BGMain.exe, is that the case? Otherwise, what is the absolute path to this file?
EDIT: I can see from the end of the script that $INSTALLDIR does not point directly to the directory containing BGMain.exe, see below for more comments on this.
fettouhi: cd $WINEPREFIX/drive_c/$ID/prefix/drive_c/GOG\ Games/Baldur's\ Gate/
wine $EXE
[/code]
I can see here you kept the files in the same file tree that GOG provides, which this script is not meant to use (it could, but it might need more tweaking to do so).
You should put everything found under whatever/prefix/drive_c/GOG\ Games/Baldur's\ Gate/ in a directory, and define $INSTALLDIR to its path. Everything else from the GOG archive can be trashed.
Here is how I do it (incomplete script, only relevant parts):
#!/bin/sh
ID=baldurs-gate
VERSION=1.3.5521
REVISION=gog1.0.0.8
ARCH=all
ARCHIVE=gog_baldurs_gate_1.0.0.8.tar.gz
PKGNAME="$ID"_"$VERSION"-"$REVISION"_"$ARCH"
mkdir -p $PKGNAME/usr/local/share/doc/$ID $PKGNAME/usr/local/share/games/$ID
TMPDIR=$ID.$(date +%s)
mkdir $TMPDIR
tar xvf "$ARCHIVE" -C $TMPDIR
mv $TMPDIR/*/docs/* $PKGNAME/usr/local/share/doc/$ID
mv $TMPDIR/*/prefix/drive_c/"GOG Games"/*/* $PKGNAME/usr/local/share/games/$ID
rm -r $TMPDIR
sed -i s/'HD0:=.\+'/'HD0:=C:\\baldurs-gate\\'/ $PKGNAME/usr/local/share/games/$ID/baldur.ini
sed -i s/'CD1:=.\+'/'CD1:=C:\\baldurs-gate\\'/ $PKGNAME/usr/local/share/games/$ID/baldur.ini
sed -i s/'CD2:=.\+'/'CD2:=C:\\baldurs-gate\\'/ $PKGNAME/usr/local/share/games/$ID/baldur.ini
sed -i s/'CD3:=.\+'/'CD3:=C:\\baldurs-gate\\'/ $PKGNAME/usr/local/share/games/$ID/baldur.ini
sed -i s/'CD4:=.\+'/'CD4:=C:\\baldurs-gate\\'/ $PKGNAME/usr/local/share/games/$ID/baldur.ini
sed -i s/'CD5:=.\+'/'CD5:=C:\\baldurs-gate\\'/ $PKGNAME/usr/local/share/games/$ID/baldur.ini
sed -i s/'CD6:=.\+'/'CD6:=C:\\baldurs-gate\\'/ $PKGNAME/usr/local/share/games/$ID/baldur.ini
$PKGNAME is the folder in which I create the Debian package, it probably can’t be used
as is with Archlinux system.
The command 'date +%s' is used to add an unique identifier to $TMPDIR, allowing parallel builds of the package. You can omit it if you don’t need to allow building several packages for the same game in parallel (you probably don’t).
The several sed commands are for editing the baldur.ini file, which you
have to do if you don’t keep the GOG files organization, or the game will complain about missing files and won’t launch.
-----
A maybe simpler alternative if you want to keep GOG files organization (this way you don’t need to change anything in baldur.ini), assuming BGMain.exe can be found at "/opt/gog/Baldurs Gate/prefix/drive_c/GOG Games/Baldur's Gate/BGMain.exe"
#!/usr/bin/bash
WRITABLE='*.ini *.key *.tlk'
EXE=BGMain.exe
USERDIR="$HOME/.gog/Baldurs Gate"
export WINEPREFIX="$USERDIR/prefix"
export WINEDEBUG=-all
if ! [ -d $USERDIR ]; then
INSTALLDIR="/opt/gog/Baldurs Gate"
mkdir -p $(dirname $USERDIR)
cp -as $INSTALLDIR $USERDIR
WINEARCH=win32 wineboot
cd "$USERDIR/prefix/drive_c/GOG Games/Baldur's Gate"
for file in $WRITABLE; do
cp -a --remove-destination "$INSTALLDIR/prefix/drive_c/GOG Games/Baldur's Gate"/$file $file
done
fi
cd "$WINEPREFIX/drive_c/GOG Games/Baldur's Gate"
wine $EXE
/!\ If it exists, you should remove directory "$HOME/.gog/Baldurs Gate"
before running the script to be sure it is initialized properly.
Run it from a console and give me any eventual error message if it still doesn’t work for you.
PS: Script written with no possibility to test it yet, double-check it for eventual typos ;)