Tuesday, March 16, 2010

32 bit build environment on 64 bit Linux machines

Generally we come across many application which were designed only for 32 bit operation. Although any 32 bit program can be compiled in a 64 bit environment, sometimes the makefile design makes this a huge pain to do. So sooner than later, we end up with a program which just would not compile in a 64 bit environment.

For those extreme cases, you can create a 32 bit chroot environment on your 64 bit box. To do this, first decide on which environment you would like based on the .cfg files in /etc/mock/. Then create a softlink to the particular config to default.cfg . Then just run mock init.

ln -s /etc/mock/fedora-12-i386.cfg /etc/mock/default.cfg
mock init

mock init will use yum to download the required environment. After it completes, then you can run

mock shell

to enter the 32 bit environement. To install any additional packages use the command

mock --install package-name

Note, this can be used simulate build environments other than x86 too, and is used for testing packages on various environments without the cost of physical machines or the pain of virtual machines.