Pages

Monday, December 7, 2009

Howto Install latest wine with patched source and manage wine prefixes

If you dont need a patched wine, I strongly recommend you to use the package manager to install compiled sources.

To obtain the latest wine in this way, you first need to add the gpg key of winehq's repository:

wget -q http://wine.budgetdedicated.com/apt/387EE263.gpg -O- | sudo apt-key add -

Then add the repository:

sudo wget http://wine.budgetdedicated.com/apt/sources.list.d/$(lsb_release -sc).list \ -O /etc/apt/sources.list.d/winehq.list

And then wine can be installed with:

sudo apt-get update
sudo apt-get install wine

Introduction

Well, although there are repositories with the latest development version of wine 1.1.33 at the date of writing, many of the latest games require some patches to the source. So, this is what this tutorial is about!

Unlike other howtos ive seen elsewhere, I download and keep the sources up to date using git, and install wine with checkinstall. Almost all this with some slight modifications was written by the user Massimo from the Wine appDB.

1. Installing Wine

So lets begin by removing wine (only if you have installed it already through the package manager):
sudo apt-get remove wine

If you had previously added the winehq repository, delete it:

sudo rm /etc/apt/sources.list.d/winehq.list

Then, we install git:

sudo apt-get install git-core

And download wine sources from the git repository (this should take a while):

git clone git://source.winehq.org/git/wine.git ~/wine-git

This will download the sources at a folder called wine-git inside your home folder. You should keep this folder after the installation so it is easier (and less time consuming) to update and apply your patches later.

Next, we install the necessary packages to build wine:

sudo apt-get build-dep wine
sudo apt-get install fakeroot

You will also need checkinstall to install it later:

sudo apt-get install checkinstall

Build wine. This will quite some time (over 40 minutes to me with an AthlonX2 with 2gb ram):

cd ~/wine-git
./configure --prefix=/usr
make

Then, install wine (DONT CLOSE YOUR TERMINAL! or if you did, open it again and run cd ~/wine-git). I use checkinstall because it creates a deb package and installs it, and this makes it easier at the end to manage all of your compiled programs (NOTE, if you have installed the latest wine with the package manager, then you should delete the entry of the wine repository from /etc/apt/sources.list and then run sudo apt-get update before continuing). To install wine, I need to specify the version on checkinstall so it works. For example, with the 1.1.33 version, I did this:

sudo checkinstall --fstrans=no --pkgversion=1.1.33

Answer yes to everything, add a minor comment to the package if you like, and you'll have wine installed.

2. Patching Wine

This instructions can be followed any number of times you want, for all the patches you want, after going through the installation as explained above. Take care though, that it might be possible that patching one application will affect another one.

Almost all patches can be downloaded from internet. So, Ill suppose you have the URL of the patch (referred as ). First, we will create a folder to store your patches on your home folder:

mkdir ~/wine-patches

Then we download the patch:

wget -O ~/wine-patches/

Where is the name you want for the patch. If you have more than one patch, you need to download each one separetaly. Then, patch and compile wine (Compilation will take MUCH less time than before):

cd ~/wine-git
patch -p1 < ~/wine-patches/
make

If you have more than one patch, run the patch command for each patch before compiling. Finally, you must install it again with checkinstall:

sudo checkinstall --fstrans=no --pkgversion=1.1.33

and TADA! you have a patched wine installed.

3. Updating Wine

To update wine, first you need to update your sources:

cd ~/wine-git
git reset --hard origin
git fetch
git rebase origin

Then you should apply your patches as explained in the previous section, compile, and install (I suppose here the version changed form 1.1.33 to 1.1.34 so I change that on checkinstall):

cd ~/wine-git
patch -p1 < ~/wine-patches/
make
sudo checkinstall --fstrans=no --pkgversion=1.1.34

(REMEMBER TO RUN THE PATCH COMMAND FOR EACH OF YOUR PATCHES)

4. Undoing patches

To undo patches, you can try two different methods, number 1 is a sure way to go, but is time consuming cause you need to recompile everything, and number 2 should compile swiftly, but I havent personally tried it. I recommend trying number 2 first, and if it fails, trying number 1.

Method 1: Slow but sure...
If a particular patch ruined your installation, then you have to recover the original sources, apply the patches you want to use (obviously, omitting the one that left a mess), recompile and install:

cd ~/wine-git
git reset --hard origin
patch -p1 < ~/wine-patches/
make
sudo checkinstall --fstrans=no --pkgversion=1.1.34

Remember to run the patch command for all your patches but the one that caused conflicts!

Method 2: swift, but untested
However, the precious procedure will have to recompile everything and so, it will take quite long. The unsure way to do this while avoiding (I mean unsure cause I haven't test it) is to unpatch your sources:

cd ~/wine-git
patch -p1 -R < ~/wine-patches/
make
sudo checkinstall --fstrans=no --pkgversion=1.1.34

Where the patch command should be run for all patches you wish to undo. This should take much less time than compiling with the first method. If it works for you, please let me know...

5. Wine prefixes, or as I like to call them, BOTTLES!

Next, Ill explain an additional topic, BOTTLES!. Bottles (actually called wine prefixes, but I got accustomed to this term) let you encapsulate different applications, and apply particular tweaks only to the environment of a particular application. Here Ill explain how to install an application in a bottle, run the wine configuration utility winecfg, downloading windows dlls and setting as native, and uing winetricks, all these for an specific bottle so we dont mess with other applications configuration.

5.1 Keeping all your application on separate "bottles"

It is highly recommended to keep all your applications on separate "bottles" with they're own tweaks. This is because the tweaks for one application usually render other ones useless. To do this, lets create first a directory to keep all your bottles (You only need to do this once!):

mkdir ~/wine-bottles

Then, to install an application, do the following:

export WINEPREFIX=/home//wine-bottles/
wine

So, for example, if I want to install spore, Ill call the bottle spore, my username is pablo, and the installer is in /media/cdrom0/SPORESetup.exe and the previous commands would read:

export WINEPREFIX=/home/pablo/wine-bottles/spore
wine /media/cdrom0/SPORESetup.exe

And thats it!

5.2 Running winecfg to configure different bottles

There are some windows applications that I prefer to keep windowed, while others full-screened. Another advantage of bottles is that you can configure this and many other stuff with winecfg for each bottle independently. To run winecfg for a bottle, you must open a terminal, specify the bottle, and run winecfg:

export WINEPREFIX=/home//wine-bottles/
winecfg

And go ahead and configure all you want!

5.3 Set a dll as native on a bottle

To use a downloaded dll as native for an specific bottle, you must download your dll and put it at the appropriate place in the appropriate bottle. The folder where you must put the dlls is:
~/wine-bottles//drive_c/windows/system32
(In case you dont know, ~/ is equal to /home//)

Then, open the winecfg application for the bottle as mentioned in the previous section, select libraries, look for your dll, and set it as native.

5.4 Use winetricks with a bottle

winetricks is an useful app to install common packages needed for some applications. Usually, the versions required for different applications vary, for instance, some applications work with dotnet 1.1, and others with dotnet 2.0, so By keeping things on separate bottles, you can solve this.

First, lets download the winetricks script and make it executable (You only need to do this once). Ill keep winetricks on the wine-patches folder:

cd ~/wine-patches/
wget http://www.kegel.com/wine/winetricks
chmod +x winetricks

Then, you can run winetricks with the console, specifying first the bottle, and the running winetricks:

export WINEPREFIX=/home//wine-bottles/
~/wine-patches/winetricks

5.5 File association
To associate a specific file type in gnome with a wine application, first, create an executable for your application in /usr/bin (WARNING: BE SURE NOT TO OVERWRITE ANYTHING ON /usr/bin).First, create an open the file to edit it:

sudo gedit /usr/bin/

Here is the name of the file that will launch your application. REMEMBER NOT TO OVERWRITE ANYTHING UNDER /usr/bin. On the editor, add this content to the file and save it:

export WINEPREFIX=/home//wine-bottles/

wine "" "`winepath -w "$*"`"

Remember to change and accordingly, and where it says put the path of your program .exe file. If you are not using bottles, drop the line that starts with export. Then, make this executable:

sudo chmod +x /usr/bin/

Then, on a file you want to associate to this application, select "open with another application", then choose "use custom command", and put this:

/usr/bin/ %f

After that, your files should be correctly associated.

6. Conclusions

Well, I hope this helps someone. If something can be run with wine, then by following this instructions together with specific instructions for the installation of the application (such as patches, extra things needed, etc) you should get it done, as long as there are no hardware specific problems that affect you. Almost all the application-specific info you need can be found at the Wine appdb (http://appdb.winehq.org/).



No comments: