Wine package guidelines

From ArchWiki
Revision as of 19:06, 16 October 2007 by Ezzetabi (talk | contribs) (Wine programs packages guideline, informative.)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search


Many Windows programs may be still useful in Linux and so we may want having a package for them. The differences between the two operating systems make this task a little complex. In this guideline we'll talk about Win32 binaries, since projects where source is available usually are ported to Linux.

Things to check outright

  • Licence, does the licence allow to repackage the program?
  • Installer, it is possible installing the program silently? Even better, does exists and installerless version?
  • Portability, is the program portable? In Windows a program is portable if it never writes in the registry or outside its directory.


Usually licences are in a text file in the install directory. If you can't find it try follow the screens during installation. If nothing is said about repacking go on. The author does not care. Otherwise usually the licence does not allows removing files or does not allow repacking at all. In the former case just be careful that the makepkg process does not lose any file, in the latter case all the installing process must be done in the post_install() phase. The build() phase will be only copying the install file.


It is much easier to work with compressed files like .zip than with Windows installers. If you have no choice since the author insists to distribute its program with installers seek in the Internet if it is possible install silently the software. MSFN is usually a good place where seeking. If you can't find the way, try to open the installer with cabextract, unrar or other unpacking utilities, it may works.


A portable program does not need its own wine emulated filesystem, so check in Portable Freeware if the program you are packaging is portable. If it is not or you do not know do not worry, it just takes some more steps.

The guidelines in short

The idea behind packing a Windows program is to use the program's files as mere data that wine will interpret. Just like JVM and java bytecode.

So we will install the program in /usr/share/"$pkgname", we will use symbolics links to make believe to the application that it is actually installed in "$HOME"/."$pkgname" where it will write all what it needs. The fake installation folder will be made by a small script saved in /usr/bin/"$pkgname" that will create the folder and the symlinks if needed and finally start the program.

This way every user will have its settings and his decisions won't bother other users.


If the program is without installers the installation is a mere decompression of a file, unpack it in "$startdir"/pkg/usr/share/"$pkgname", just be sure the permissions are correct. This will commands will do:

find "$startdir"/pkg/usr/share -type -f -exec chmod 644 "{}" \;
find "$startdir"/pkg/usr/share -type -d -exec chmod 755 "{}" \;

If the program can't be installed the easy way you need to create a Wine environment:

mkdir -p "$startdir"/src/tmp
export WINEPREFIX="$startdir"/src/tmp
wine "$startdir"/src/installer.exe /silentoptions

We did not discussed about portability yet, but if your program does not need the registry keys it modified you can just copy the directory from the

"$startdir"/src/tmp/drive_c/Program\ Files/programname

otherwise you need to copy all the registry files too and eventually the files the program installed around. If does not exist a way to install the program silently... Maybe you can make a .tar.gz file and upload it somewhere? If nothing automated is possible force the user clicking in the installer and hope he will not mess the installation, write some checks before copying blindly a folder that may not exist (i.e., the user pressed 'Cancel'.)

The /usr/bin script

This script prepares the fake installation folder and starts the program, if your program is portable it will look like this:

if [ ! -d "$HOME"/.programname ] ; then
   mkdir -p "$HOME"/.programname
   #prepare the environment here
wine "$HOME"/.programname/programname $* &>/dev/null

if it is not it will look like this:

export WINEPREFIX="$HOME"/.programname/wine
if [ ! -d "$HOME"/.programname ] ; then
   mkdir -p "$HOME"/.programname/wine
   #copy the registry file if needed
   #prepare the environment here
wine "$HOME"/.programname/programname $* &>/dev/null

The task of preparing the environment may change much between applications, but follow this rules of thumb:

  • if the program...
    • ...just needs to read a file symlink it.
    • ...needs to write in a file copy it.
    • ...does not use a file ignore it.

Of course the minima is just symlinking the executable, or if the program does not writes settings at all do not create the directory and skip the if completly.

Usually the environment will be made symlinking beetween the "$HOME"/.programname directory and the /usr/share/programname files. But since some Windows programs are very fickle about theirs paths you may need to symlink directly in the "$HOME"/.programname/wine/drive_c/Program File/programname directory.

One example

We will make a package for eMule. According to Portable Freeware eMule is not totally portable since it writes some (useless) keys in the registry.

Luckily there is a installerless version available.

So we make our PKGBUILD, the only dependence is wine, the md5sums should be added.

# Contributor: You <youremail>
pkgdesc="One of the biggest and most reliable peer-to-peer file sharing clients around the world."

build() {
  cd "$startdir"
  rm -f src/eMule"$pkgver"/license* #It is GPL

  install -d -m755 pkg/usr/share/emule
  cp -ra src/eMule"$pkgver"/* pkg/usr/share/emule
  find pkg/usr/share/emule -type d -exec chmod 755 "{}" \;
  find pkg/usr/share/emule -type f -exec chmod 644 "{}" \;

  mkdir -p pkg/usr/bin
  install -m755 emule pkg/usr/bin }

And we make our emule file, that according to build() will be copied and made executable in /usr/bin.

export WINEPREFIX="$HOME/.emule/wine"

if [ ! -d "$HOME"/.emule ] ; then
  mkdir -p "$HOME"/.emule/wine || exit 1
  wineprefixcreate || exit 1
  #Each user will have its config...
  cp -r /usr/share/emule/config "$HOME"/.emule || exit 1
  ln -s /usr/share/emule/emule.exe "$HOME"/.emule/emule || exit 1
  ln -s -T /usr/share/emule/lang "$HOME"/.emule/lang || exit 1
  ln -s -T /usr/share/emule/webserver "$HOME"/.emule/webserver || exit 1

wine "$HOME"/.emule/emule $*

If you want being more precise you may add a message in .install file telling the user should disable search history since wine mess up that menu. And that's it... makepkg, check the pkg folder to be sure. Install.