How To: Comfortably Make your own WINE Bottles

If you're installing a few programs in WINE, you may notice that they tend to influence each other negatively. The fix is to install them in completely different operating system environments, also known as WINE bottles. This way it's easy to completely remove applications by just deleting their "bottle". Let me show you how to make this effortless with standard WINE and a simple shell script.

The script is the key part. You tell it a directory where you want your bottles installed and then it will create a new folder each time you install a program. Of course you may also install several programs into one bottle. Let's call the script wine-bottle, which I suggest to put into your $PATH:

!/bin/bash
# wine-bottle v. 0.2
# (c) 2009 Linux-Tipps.blogspot.com, (c) 2009 Joost @ http://home.student.utwente.nl/j.vanderhof
# newest version at http://linux-tipps.blogspot.com/2009/03/how-to-make-your-own-wine-bottles.html
# published under the GPL v. 3.0 http://gplv3.fsf.org/
INSTALLDIR="$HOME/.wine/bottles"; #Set this to where you want to put your Wine bottles
[ $# -lt 1 ] && #if you gave no parameters
echo "Please give me parameters! Usage:" &&
echo "Execute a program : $0 \"BottleName\" \"Program\"" &&
echo "Configure a bottle : $0 --conf \"BottleName\"" &&
echo "List bottles : $0 --list" &&
exit 1;
[ $# -lt 2 -a $1 != "--list" ] && #if you didn't give the right parameters
echo "Please give me at least two parameters or a --list parameter! Usage:" &&
echo "Execute a program : $0 \"BottleName\" \"Program\"" &&
echo "Configure a bottle : $0 --conf \"BottleName\"" &&
echo "List bottles : $0 --list" &&
exit 1;
[ $1 == "--list" ] && #if you want to list the bottles
echo "Wine bottles in $INSTALLDIR:" &&
ls -1 $INSTALLDIR &&
exit 1;
[ -d "$INSTALLDIR" ] || ( #if installdir is not existing
echo "Root of Wine bottles not existing: $INSTALLDIR" &&
mkdir "$INSTALLDIR"
) || ( #if installdir creation failed
echo "Could not create installation Directory: \"$INSTALLDIR\"." &&
exit 1);
which wine || ( #if wine is not found
echo "Wine not found, please install it first" &&
exit 1);
[ $1 == "--conf" ] && #if you wish to configure a bottle
WINEPREFIX="$INSTALLDIR/$2/" winecfg &&
exit 1;
#finally, the only remaining possibility is you want to run an application
PREF="$1";
shift; #drop first parameter to leave the command with its parameters
WINEPREFIX="$INSTALLDIR/$PREF/" wine "${@}";

You can now use this script almost like wine. The only difference is that you first need to tell it the bottle's name. E.g. wine-bottle lingopad setup.exe installs the program inside setup.exe into the bottle lingopad. I suggest using the "create Desktop short cut" option of installers, as it lets you easily start them later, without the need to use this script.

If you want to create a backup of your bottle, simpy put the bottle directory inside $INSTALLDIR together with the related .desktop file into an archive. If you want to manually start a program, you can of course still use wine-bottle from the shell: e.g. wine-bottle lingopad "$HOME/Wine/lingopad/drive_c/Program Files/Lingopad/Lingopad.exe".

You may also want to install a current wine via the wine ubuntu repository.

Let me know if you liked this howto!

Update: Updated to Joost's version, thanks!

Update2: It seems my script has inspired "Joost". He's created a version including a simple GUI. Check out his website.

9 comments:

  1. Thanks for the tip! I often use WINEPREFIX and like it a lot, but it would perhaps be easier to do it your way.

    A question: Do you have any idea how to organize installed Wine programs correctly in the (KDE) menu?
    I find the icons related to the menu entries in /home/"usr"/.local/share/applications/Wine
    but only some of them are correclty put under the "wine" menu in the KDE "start menu", whereas others are put in generic "Programs" menu.
    A small annoyance but one I would like to figure out... cheers!

    ReplyDelete
  2. Hi Jens,
    I'm sorry I don't have an idea. It probably depends on the content of the desktop files. Have you ever opened two diffently behaving .desktop files with an editor and checked what's in there? I guess that would be the difference.
    I usually let them make a desktop icon and then put the icons in a folder myself.
    Let me know if you found a fix! :)

    ReplyDelete
  3. thanks for the script!

    but if I may, you forgot to add a little something or else it exits before running wine.

    which wine || echo Please install wine first && exit 1;
    to
    which wine || (echo Please install wine first && exit 1);

    thanks again! :)

    ReplyDelete
  4. Nice tip, but a little limited in functionality. I have made a modified version of your script with the ability to list your bottles and the ability to configure a bottle using winecfg. Here is my source code:

    #!/bin/bash
    # wine-bottle v. 0.1
    # (c) 2009 Linux-Tipps.blogspot.com
    # GPL v. 3.0
    INSTALLDIR="$HOME/.wine/bottles"; #Set this to where you want to put your Wine bottles
    [ $# -lt 1 ] && #if you gave no parameters
    echo "Please give me parameters! Usage:" &&
    echo "Execute a program : $0 \"BottleName\" \"Program\"" &&
    echo "Configure a bottle : $0 --conf \"BottleName\"" &&
    echo "List bottles : $0 --list" &&
    exit 1;
    [ $# -lt 2 -a $1 != "--list" ] && #if you didn't give the right parameters
    echo "Please give me at least two parameters or a --list parameter! Usage:" &&
    echo "Execute a program : $0 \"BottleName\" \"Program\"" &&
    echo "Configure a bottle : $0 --conf \"BottleName\"" &&
    echo "List bottles : $0 --list" &&
    exit 1;
    [ $1 == "--list" ] && #if you want to list the bottles
    echo "Wine bottles in $INSTALLDIR:" &&
    ls -1 $INSTALLDIR &&
    exit 1;
    [ -d "$INSTALLDIR" ] || ( #if installdir is not existing
    echo "Root of Wine bottles not existing: $INSTALLDIR" &&
    mkdir "$INSTALLDIR"
    ) || ( #if installdir creation failed
    echo "Could not create installation Directory: \"$INSTALLDIR\"." &&
    exit 1);
    which wine || ( #if wine is not found
    echo "Wine not found, please install it first" &&
    exit 1);
    [ $1 == "--conf" ] && #if you wish to configure a bottle
    WINEPREFIX="$INSTALLDIR/$2/" winecfg &&
    exit 1;
    #finally, the only remaining possibility is you want to run an application
    PREF="$1";
    shift; #drop first parameter to leave the command with its parameters
    WINEPREFIX="$INSTALLDIR/$PREF/" wine "${@}";

    ReplyDelete
  5. Thanks, Joost! I've updated it.

    ReplyDelete
  6. I have made a yet newer version of the script. Even more functions have been added, the comments have been placed in a way that makes the code easier to view, and the list function now only displays the names of the bottles and not a "wine bottles in dirname" message. The latter is in favor of a GUI frontend I have also written. You can find the most recent version of the script and the GUI frontend on my webspace.
    By the way, I am the same person as Joost.

    ReplyDelete
  7. Great! I'm proud to have inspired you. :)

    Keep it up. It was my idea, too, to make a GUI for it at first. But then I was so satisfied with the script already. I think at some point when it's working well we should try to get this into the wine distribution. ;)

    ReplyDelete
  8. Can someone educate me on how to use Joost's GUI. I wanted to send a message to him, but don't know how. I tried putting his GUI script in an empty file and tried executing the file in terminal. That did nothing.

    ReplyDelete

I appreciate comments. Feel free to write anything you wish. Selected comments and questions will be published.