half-life 2 + gnu/linux + cedega on debian/amd64

copyright © 2005 sean finney <seanius@seanius.net>

this document is licensed under the Academic Free License, Version 2.1. That means you can do pretty much whatever you want with it, as long as you credit me and list the differences between your document and the original.

from start to finish

with transgaming's cedega (formerly known as winex) officially supporting both hl2 and steam, i thought i would take a stab at setting it up on my shiny, brand new amd64 3500+ system. i did have some requirements:

and i can happily say it works! below is a start to finish diary of what i had to do to get things up and running.

step 1, get cedega

pony up the cash, it's worth it. you can also try building from their cvs root, but i've never gotten it to succesfully build, and the quality of the packaging and the ease of installation (not to mention the access to support and a say in future development) is certainly imho worth the $30 i paid. i first tried to get things working with the point2play package, but never quite got that working. maybe that was my bad. but i'm not scared of cmdlines, so whatever--i downloaded the cedega deb, along with the microsoft core fonts deb and the mozilla active x control deb. copy these into /tmp, you'll see why in a bit.

step 2: bootstrap a chroot

unfortunately, cedega won't run in a native (or even mixed) 64-bit environment, and i won't sacrifice a pure 64-bit environment for a video game.

to work around this, you'll need to set up a chroot directory in which you have a pure 32-bit userland. you'll need to make sure you have enough space to accomodate a base chroot and cedega. with my current setup, all the games and data i install with cedega still get put into my home directory, so you don't need to account for all that in the chroot.

being a debian developer, i can't help but place things in the spirit of the FHS. so i will be using /srv/chroots/sid-i386 as the root of my chroot. you're encouraged to place the system wherever you feel is appropriate. i am also using a local mirror for all my debian packages, i encourage you to find your nearest mirror too.

so, to review:


bash# export CHROOTDIR DEBMIRROR
bash# CHROOTDIR="/srv/chroots/sid-i386"
bash# DEBMIRROR="ftp://esb/debian"
bash# debootstrap --arch i386 sid "$CHROOTDIR" "$DEBMIRROR"
bash# echo "sid-i386" > "$CHROOTDIR/etc/debian_chroot"
bash# echo "deb $DEBMIRROR sid main contrib non-free" > "$CHROOTDIR/etc/apt/sources.list"

the first of the two echo commands is a nice little trick that will change your default bash prompt to clearly indicate when you're chrooted in this particular directory (this is taken care of automatically in the global bash.bashrc file. if you have a customized .bashrc file, you'll want to put the following in it:


if [ -z "$debian_chroot" -a -r /etc/debian_chroot ]; then
    debian_chroot=$(cat /etc/debian_chroot)
    PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
fi

the second of the two echo commands sets up your apt configuration inside the chroot, which will come in handy later.

if debootstrap gives you errors about being unable to fetch certain unimportant packages when debootstrapping, just add them to the list of packages to ignore:


bash# debootstrap --arch i386 --exclude foo,bar sid "$CHROOTDIR" "$DEBMIRROR"

chances are that it's just some kind of turbulence in the available packages and you can install the packages later if you really need them (see step 4). if the packages are something important (like, say, dpkg or debconf), you may need to try a different mirror (Refer to The Fine Manpage of debootstrap).

step 3: set up access to/from your chroot

first, i recommend installing the dchroot package, which will make life easier for both administering and using the chroot. this will be explained with a few examples shortly.


bash# apt-get install dchroot 
bash# echo "sid-i386	$CHROOTDIR" >> /etc/dchroot.conf

in order to be able to run x apps from inside the chroot, you'll need access to a few unix sockets set up by your x server, devices (for hardware acceleration) as well as some other resources only available outside the chroot. i accomplished this by using "bind" mounts:


bash# mount --bind /tmp "$CHROOTDIR/tmp"
bash# mount --bind /proc "$CHROOTDIR/proc"
bash# mount --bind /etc/passwd "$CHROOTDIR/etc/passwd"
bash# mount --bind /etc/shadow "$CHROOTDIR/etc/shadow"
bash# mount --bind /etc/group "$CHROOTDIR/etc/group"
bash# mount --bind /etc/X11/xorg.conf "$CHROOTDIR/etc/X11/xorg.conf"
bash# mount --bind /home "$CHROOTDIR/home"
bash# mount --bind /dev "$CHROOTDIR/dev"

so now the chroot has the same view of processes, devices, users, groups, as well as shared home and temporary directories. to make the changes more permanent, you can put this in your /etc/fstab:


proc            $CHROOTDIR/proc      proc    defaults        0       0
/tmp            $CHROOTDIR/tmp       ext3    bind,defaults        0       0
/home           $CHROOTDIR/home      ext3    bind,defaults        0       0
/srv            $CHROOTDIR/srv       ext3    bind,defaults        0       0
/dev            $CHROOTDIR/dev       ext3    bind,defaults        0       0
/etc/passwd     $CHROOTDIR/etc/passwd        ext3    bind,defaults        0       0
/etc/shadow     $CHROOTDIR/etc/shadow        ext3    bind,defaults        0       0
/etc/group      $CHROOTDIR/etc/group         ext3    bind,defaults        0       0
/etc/X11/xorg.conf      $CHROOTDIR/etc/X11/xorg.conf         ext3    bind,defaults        0       0

replacing CHROOTDIR, naturally. you can test that this actually works by trying:


bash# dchroot apt-get update
bash# dchroot apt-get install xbase-clients
bash$ dchroot -d xclock

step 4: install cedega and dependencies

now that your chroot environment is bootstrapped, you're almost done. now, install the dependencies and you're ready to install cedega.


bash# dchroot apt-get install libjpeg62 xlibmesa3 xlibs zlib1g libpng3 mod-init-tools
bash# dchroot dpkg -i /tmp/cedega_4.2ForSteam-1_i386.deb /tmp/transgaming-fontinstaller_1.0_i386.deb /tmp/transgaming-mozctlinstaller_1.0-1_i386.deb

note that if you use nvidia's drivers, you'll also want to install the nvidia-glx package.

step 5: install hl2 and steam!

this part proved to be the most difficult. installing steam was easy enough. just mount the cd inside the chroot, and run "cedega steam.exe" from the directory that has the steam installer.


bash# dchroot bash
(sid-i386)bash# mount /cdrom
(sid-i386)bash# cd /cdrom
(sid-i386)bash# cedega steam.exe

installing half life 2 was a little tricker, as there was some wierd cd detection problems i couldn't seem to work out. the workaround is to copy the contents of every cd into somewhere in your home directory (all the exes should end up in the same directory), and then run the installer.