wiki:Linux/Ubuntu/BuildWinePackages

Build Wine Packages

I found several forum postings by novice users who were failing to manually build wine on amd64 (x86_64) platforms. The problems are mostly caused by 32-bit compatibility library packages not installing all the symbolic links the wine configure script expects, and thus failing to detect many vitial system libraries wine depends on.

I answered one forums posting explaining the reason, and then decided to write up a step-by-step guide on how to combine the latest source from the winehq git repository with the debian packaging, and use the standard Debian/Ubuntu? build system. It turned into quite a long article so I decided to post it here to ensure I can easily update it in future.

The most reliable way to build the latest wine source on Ubuntu is by merging the current debian packaging with the latest source. This is relatively easy to do. This same method can be used to test new patches, your own code, or simply the latest development branch. Once the preparations are completed, building a proper Ubuntu package requires just one command.

Create a source-code working directory

(In the user directory or elsewhere that has user write/execute permissions - I put all my source packages in /home/all/SourceCode/)

mkdir ~/SourceCode
cd ~/SourceCode

Get the Ubuntu wine source package  from the winehq repository

Add the winehq package signing key

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

Add the winehq sources list

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

Update the local package list

sudo apt-get update

Get the latest debian package source from winehq

apt-get source wine

Get the latest development source from winehq using git

Install git

sudo apt-get install git-core

Clone the  winehq development git repository

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

There should now be two sub-directories containing wine source

One directory containing the (older) debian packaged version, the other containing the (latest) development version. On Ubuntu Hardy that might look like this:

ls -dl  wine*
drwxr-xr-x 12 tj tj     4096 2009-01-06 22:33 wine
drwxr-xr-x 12 tj tj     4096 2009-01-06 21:59 wine-1.1.12~winehq0~ubuntu~8.04
-rw-r--r--  1 tj tj   109121 2009-01-03 10:55 wine_1.1.12~winehq0~ubuntu~8.04-0ubuntu1.diff.gz
-rw-r--r--  1 tj tj     2337 2009-01-03 10:55 wine_1.1.12~winehq0~ubuntu~8.04-0ubuntu1.dsc
-rw-r--r--  1 tj tj 19163897 2009-01-03 10:55 wine_1.1.12~winehq0~ubuntu~8.04.orig.tar.gz

Create a convenience environment variable (makes instructions more portable)

export WINE_DEB="$(pwd)/$(ls -ld wine* | sed -n 's/^d.*\(wine-.*winehq.*\)/\1/p')"
echo $WINE_DEB
/home/all/SourceCode/wine-1.1.12~winehq0~ubuntu~8.04

Change to the local winehq git repository and check status

cd wine
git status
# On branch master
nothing to commit (working directory clean)

Create a debian packaging branch

Copy the packaging files to the git working tree

git checkout -b debian
cp -a ${WINE_DEB}/debian .

Add changes to staging index, then commit the changes

git add debian
git commit -m "Debian packaging"
git-log -3

Create a work-in-progress branch (can have any valid git branch-name)

For this example I will apply a patch that attempts to a fix an SSL/TLS protocol failure (winehq  bug #16831 - patch comes from  bug #15482). The branch name reflects the issue I've created it for

git checkout -b 16831_SSL

This branch is based on the committed state of the debian branch, so it inherits the debian packaging files.

-Optional- Apply a patch (or make custom changes of your own)

Get the patch

wget http://bugs.winehq.org/attachment.cgi?id=17403 \
 -O ../15482_negotiate_TLSv1_instead_of_SSL.patch

Apply the patch

patch -p1 <../15482_negotiate_TLSv1_instead_of_SSL.patch
patching file dlls/wininet/netconnection.c
Hunk #1 succeeded at 109 (offset 4 lines).
Hunk #2 succeeded at 172 (offset 4 lines).
Hunk #3 succeeded at 206 (offset 4 lines).

Add changes to working index then commit changes locally

git add dlls/wininet/netconnection.c
git commit -m "Test for bug #16831 NETCON_secure_connect SSL_connect failed"
Created commit 04787c5: Test for bug #16831 NETCON_secure_connect SSL_connect failed
 1 files changed, 3 insertions(+), 3 deletions(-)

Update debian package version

Install and configure debian developer scripts

Use your own name and email address (the ones used in your  Ubuntu Launchpad account and associated PGP key) in these variables

sudo apt-get install devscripts
export DEBFULLNAME="Your Name"
export DEBEMAIL="Your Email Address"

Increment version and add a local version suffix (also useful for PPA packages)

The package version number needs to be changed to show the package was built from git. The most consistent way is to use git-describe to get a reference to the last upstream commit in your local repository. Assuming you haven't made any commits to the master branch this command will give the reference

git describe master
wine-1.1.12-198-g83fc733

A modified git describe command result can be embedded in the debchange command along with a local version suffix.

debchange --newversion $(git describe master | sed 's/wine-\(.*\)/\1/')~${USER}~ppa1 --distribution $(lsb_release -sc)

This will load the preferred system text-editor where the change can be detailed. E.g.

wine (1.1.12-198-g83fc733~tj~ppa1) hardy; urgency=low

  *

 -- TJ <ubuntu@tjworld.net>  Tue, 06 Jan 2009 23:59:05 +0100

Now detail the changes after the asterix (*). So, for example

  * Fix NETCON_secure_connect SSL_connect failed (bug #16831)

If using the nano text-editor, Ctrl+X will save the changes.

Increment local version only

Unless the local git repository is updated from the winehq repository (using pull) the upstream version part will remain the same. In that case all that needs incrementing for subsequent package versions is the local version number:

debchange --local ~${USER}~ppa --distribution $(lsb_release -sc)

which will do something similar to this

wine (1.1.12-198-g83fc733~tj~ppa2) hardy; urgency=low

Commit the package changes to the local repository

git add debian/changelog
git commit -m "Update package version"
git-log -3
commit a5a54cc24c625f505a9528a0b55940ef0db01f08
Author: TJ <linux@tjworld.net>
Date:   Wed Jan 7 01:06:51 2009 +0000

    Update package version

commit 149ac24d1e3abfe89773048ce8be5962c5987bef
Author: TJ <linux@tjworld.net>
Date:   Tue Jan 6 23:32:27 2009 +0000

    Test for bug #16831 NETCON_secure_connect SSL_connect failed

commit d9d7b45d9c59b107cd389b6f10f8513d6a96cc4c
Author: TJ <linux@tjworld.net>
Date:   Tue Jan 6 23:25:11 2009 +0000

    Debian packaging

Build new Ubuntu package

Install build tools

sudo apt-get install build-essential dpkg-dev fakeroot autoconf automake autotools-dev

Install development headers and libraries

sudo apt-get build-dep wine

Any problems at this stage could be due to you having previously enabled other package repositories (maybe some PPAs?) and subsequently disabled them again. Check current package versions and figure out where they came from (using apt-cache show <package>, apt-cache showsrc <package>, and dpkg-query -l '<package>*').

Build the binary debian package

dpkg-buildpackage -b 2>&1 | tee build.log

If there are problems examine the build.log file that all output from stderr and stdout was copied to. Errors might include:

  1. missing build dependencies (newer development source might have build-depends not in the existing debian packaging - in which case an addition to debian/control build-depends statement will be required.
  2. compiler error caused by an incorrect statement or preprocessor definition - identify the cause and correct it.

Build including source package

When building, if you omit the -b (binary) option then source package files will also be created that are suitable for uploading to an  Ubuntu PPA (Personal Package Archive). Additionally, to sign the source files with your PGP key (as required by the PPA) use the -k<KEYID> option, e.g.

dpkg-buildpackage -k29CD6080

Successful Build Result

You'll see something similar to this:

dpkg-deb: building package `wine' in `../wine_1.1.12-198-g83fc733~tj~ppa1_amd64.deb'.
	dpkg-deb -Z lzma --build debian/wine-dev ..
warning, `debian/wine-dev/DEBIAN/control' contains user-defined field `Original-Maintainer'
dpkg-deb: ignoring 1 warnings about the control file(s)
dpkg-deb: building package `wine-dev' in `../wine-dev_1.1.12-198-g83fc733~tj~ppa1_amd64.deb'.
 signfile wine_1.1.12-198-g83fc733~tj~ppa1.dsc
gpg: skipped "TJ <ubuntu@tjworld.net>": secret key not available
gpg: [stdin]: clearsign failed: secret key not available
 dpkg-genchanges  >../wine_1.1.12-198-g83fc733~tj~ppa1_amd64.changes

dpkg-genchanges: including full source code in upload
dpkg-buildpackage: warning: Failed to sign .dsc and .changes file
dpkg-buildpackage: full upload; Debian-native package (full source is included)

The build script puts the .deb package(s) in the parent directory. They can be listed using:

ls -ld ../*wine*
drwxr-xr-x 13 tj tj      4096 2009-01-07 03:14 ../wine
drwxr-xr-x 13 tj tj      4096 2009-01-07 02:11 ../wine-1.1.12~winehq0~ubuntu~8.04
-rw-r--r--  1 tj tj    109121 2009-01-03 10:55 ../wine_1.1.12~winehq0~ubuntu~8.04-0ubuntu1.diff.gz
-rw-r--r--  1 tj tj      2337 2009-01-03 10:55 ../wine_1.1.12~winehq0~ubuntu~8.04-0ubuntu1.dsc
-rw-r--r--  1 tj tj  19163897 2009-01-03 10:55 ../wine_1.1.12~winehq0~ubuntu~8.04.orig.tar.gz
-rw-r--r--  1 tj tj  28346804 2009-01-07 03:15 ../wine-dbgsym_1.1.12-198-g83fc733~tj~ppa1_amd64.ddeb
-rw-r--r--  1 tj tj   1348780 2009-01-07 03:16 ../wine-dev_1.1.12-198-g83fc733~tj~ppa1_amd64.deb
-rw-r--r--  1 tj tj      1089 2009-01-07 03:16 ../wine_1.1.12-198-g83fc733~tj~ppa1_amd64.changes
-rw-r--r--  1 tj tj   7977626 2009-01-07 03:16 ../wine_1.1.12-198-g83fc733~tj~ppa1_amd64.deb
-rw-r--r--  1 tj tj      1531 2009-01-07 02:43 ../wine_1.1.12-198-g83fc733~tj~ppa1.dsc
-rw-r--r--  1 tj tj 132315281 2009-01-07 02:43 ../wine_1.1.12-198-g83fc733~tj~ppa1.tar.gz

Clean up

Using the packaging script

To remove all the files creating during the build process, and therefore return the working directory to the the state it was before the build

fakeroot debian/rules clean
rm build.log

Check with git for any files not cleaned up

git status

Forcefully using git (deleting all uncommitted changes)

git reset --hard HEAD
git-status

Installation of the new packages

sudo dpkg -i ../wine*.deb

Upload to PPA

If you have an  Ubuntu Launchpad PPA (Personal Package Archive) and have correctly configured a GPG digital certificate key, at the build stage the changes should have been signed using the key (if "${DEBFULLNAME} <${DEBEMAIL}>" [i]exactlyi matches the gpg key user ID). That allows you to use dput to upload the source to the Ubuntu PPA for building and making the binaries available to other users.

dput my-ppa wine_1.1.12-198-g83fc733~tj~ppa1_amd64.changes

Signing source files

If the files weren't signed at the build stage it can be done manually if you have the key id. E.g.

gpg --list-secret-keys
sec   1024D/29CD6080 2007-01-12
uid                  XXXX TJ (Ubuntu Launchpad) <ubuntu@tjworld.net>
uid                  TJ (Ubuntu contributions) <ubuntu@tjworld.net>

debsign -k29CD6080 ../wine_1.1.12-198-g83fc733~tj~ppa1.dsc

Notes

There will likely be some mistakes in this guide since towards the end I was shuffling parts around to enhance clarity. I tested all commands as I was writing and pasted them in so they should be reliable. I'll update this posting with any corrections noticed by readers.