Tea23 / arch-gog

Arch Linux PKGBUILDs for various games from GOG.com
http://gogwiki.com/wiki/AUR
16 stars 0 forks source link

Initial thoughts on Wine #2

Open Tea23 opened 11 years ago

Tea23 commented 11 years ago

Wine came to mind and now I can't get it out; after some thinking a few things make sense:

However, there are a few issues that I'm having. First is how do we get the game data from /opt/gog and into unionfs? For DOSBox and AGS we create unionfs and cd into it before running the game. For Wine we're talking about installing a wineprefix and then running the game. Windows applications aren't sensitive to the directory they're being run in so we can't run it the same way as DOSBox and AGS.

Secondly, and more troubling are registry entries. Here actual effort may be involved on the part of the package creator. Registry entries that are created at install time can't be extracted with innoextract (unless this feature can be added) as they are usually hardcoded into the inno source. gogwrap regkeys are created here every time and some games require gogwrap arguments to work at all, so this poses a problem for those games. Secondly, some games will create their own regkeys at install time.

A way to workaround this would be to install each GOG in a live Windows environment, or Wine at a push, and export the regkeys and import them via the launcher script. Each wineprefix has its own registry and we should be able to check for keys before performing the import operation (although this may require a cat | grep on the flatfile).

Regkeys which are created at runtime by the game should be no issue.


Another possible, if somewhat crazy solution might be to, instead of extracting game data in build(), actually call wine and install the game to a wineprefix in $pkgdir/opt/gog/GAME/base. This would give us an entire wineprefix in /opt/gog which we then unionfs to ~/.gog. If GOGs have a -silent flag then we're in the money.

It would look something like:

cd $srcdir

if [ ! -f setup_${_gogname}.exe ]; then
    error "You must have setup_${_gogname}.exe present in the source dir: $PWD"
    error "Download the game from your GOG shelf and try again. Stopping."
    return 1
else
    WINEARCH=win32 WINEPREFIX=$pkgdir/opt/gog/${_gogname}/base
    wine setup_${_gogname}.exe  
fi

We would then unionfs the whole base folder, granting a user-specific wineprefix with the game already installed. The registry is contained within as a flat file as is the entire Windows structure.

Some drawbacks to this:

It might be crazy enough to work, or it might just be plain crazy. I'll play around with it in the morning when I'm not so tired.

Tea23 commented 11 years ago

After some experimentation I was able to 'install the game with: cd $srcdir

if [ ! -f setup_${_gogname}.exe ]; then
    error "You must have setup_${_gogname}.exe present in the source dir: $PWD"
    error "Download the game from your GOG shelf and try again. Stopping."
    return 1
else
    mkdir -p $pkgdir/opt/gog/${_gogname}/
    export WINEARCH='win32' 
    export WINEPREFIX=$pkgdir/opt/gog/${_gogname}/base
    wine $srcdir/setup_${_gogname}.exe  
fi

However, running the game doesn't work. I don't know why at all.

Here's the launcher I'm using:

#!/bin/sh

UNIONDIR=`mktemp -d`
RWDIR=$HOME/.gog/stronghold
RODIR=/opt/gog/stronghold/base

mkdir -p $RWDIR
unionfs -o cow ${RWDIR}=RW:${RODIR}=RO $UNIONDIR

cd $UNIONDIR/drive_c
export WINEARCH=win32
export WINEPREFIX=$UNIONDIR
wine "Program Files/GOG.com/Stronghold/stronghold.exe"
cd

sleep 1
fusermount -u $UNIONDIR
rmdir $UNIONDIR

The game just crashes with a generic page fault read whatever error that helps no one. But if I cd to the /tmp/ dir and run it from there, same wineprefix and all, it works.

I simply have no idea whatsoever what's causing this at all. It may just be my understanding of unionfs that's at fault and I'm doing something wrong in the launcher script. Hell, I didn't even know it was creating dirs in /tmp/ until today.

I've pushed the PKGBUILD as it stands so everyone else can study it.

Xyem commented 11 years ago

If we do it the other way around, i.e. only the gamedata in /opt/gog, in the launcher we can check if the directory in home exists and if not, 'wineboot -i' to create it, regedit the registry keys in (easy to extract due to being flatfiles in Wine) and then just unionfs the game data from /opt/gog into the right place

Tea23 commented 11 years ago

The thing is that unionfs might be causing this crash. I don't have enough data to go on. If it is because my tmpfs is too small then I need someone with more memory to give it a try.

I might also just be making wrong assumptions about how unionfs works; I still don't fully understand it but I figured taking the whole wineprefix as it stands in /opt/gog would have worked fine.

So two things need to be looked into:

I simply don't have the facilities to test either point unless we can actually run unionfs outside of tmpfs?

ceearrbee commented 11 years ago

Got the same crash.

Tea23 commented 11 years ago

I've just tried running it with a tmpdir outside of tmpfs. It's not my low RAM causing the issue.

I still have no idea why the crash is occurring, though.

Tea23 commented 11 years ago

Stronghold runs. It turns out it was crashing because we were running Stronghold.exe from the wrong directory, so I had to change the launcher script to:

export WINEARCH=win32
export WINEPREFIX=$UNIONDIR
cd $WINEPREFIX/drive_c/Program\ Files/GOG.com/Stronghold
wine Stronghold.exe

Buuuut of course there's a problem or two.

First of all it's simply not feasible for us to run all games in tmpfs. Some games will simply be too big for many configurations, so we simply must create our tmpdir in ~/.gog or some games will be problematic for some people.

Also, when I quit Stronghold, unionfs refused to unmount because it was still busy. No data was actually being written to ~/.gog/stronghold for some reason. Likely because wine is a weird process.

Anyway, I've pushed the sort of working script.