How can I build i386 and amd64 packages on my amd64 laptop using debuild

How can I build i386 and amd64 packages on my amd64 laptop using debuild

I would like to be able to build multiple versions (i386 and amd64) of my package that has non trivial dependencies (gtk, etc).

My build script uses cmake.

At the moment, the command debuild -i -us -uc -b only builds amd64 on my ubuntu 64bits distribution and I havent installed any cross compiling toolchain.

How can I build binaries for both platforms?

答案1

The packaging (ie debuild) is not the hard part here: building the application is.

There are many ways to build i386 binaries on a 64bits system

Using a 32bits virtual machine

Installing one via virtualbox is straightforward.

This is by far the easiest but it will take a significant amount of disk space and you will need to setup the entire system from scratch.

Setting up a chroot

The idea is to create a minimal i386 sandbox in your 64bits setup.

You will install all the build toolchain and i386 dependencies of your application in the chroot and perform the build from there.

This approach is lighter than the vm one and offers a good deal of isolation.

Kaizou tutorial explains clearly how to do it

A chroot ready to build a gtk vala application will eats about 700M on your harddrive.

Using cross compilation

cmake is able to build your application easily provided you have the multilib toolchain installed.

The multilib toolchain can be installed via

sudo apt-get install g++-multilib 

Then you have to specify the m32 parameters to cmake so it can build i386 binaries which is easy.

Of course, you will need to install on your computer all the i386 variants of your application dependencies.

Provided the apt gods are with you, this can be done with:

dpkg --add-architecture i386 
apt-get update
apt-get install libgtk-3-dev:i386 libgee-0.8-dev:i386 ...

Once this is done you can package your shiny i386 binaries with

debuild -ai386 -i -us -uc -b
debuild clean   

相关内容