There are a number of ways you could use. Many Debian developers use pbuilder
which operates out of a chroot you can create with speficic tools -- a quick google search lead me to this Ubuntu wiki page but there are also Debian wiki pages on it.
An alternative is to just use a virtual environment, either libkvm, or virtualbox, or vagrant, ... I recently needed a 'backport' of a current package for Ubuntu 12.04 LTS and set up vagrant in no time for it.
Edit: Here are my recent notes from when I needed a 64-bit Ubuntu 12.04 environment to (reb-)build / backport a current package in order to use it from Travis CI / GitHub. My host machine for this exercise was my 32-bit Ubuntu laptop which at the time ran Ubuntu 13.10:
- Install vagrant 1.5.1 deb from Vagrant
- Run
vagrant init hashicorp/precise64
to set up a 64-bit Ubuntu 12.04 instance
(cf the guide at http://docs.vagrantup.com/v2/getting-started/ and
http://docs.vagrantup.com/v2/getting-started/boxes.html)
- Run
vagrant up
which takes a moment
- Run
vagrant ssh
and we are now at the prompt.
- [outside] copy a triplet dsc/orig.tar.gz/changes.gz into
~/vagrant/tmp
which is shared with the Vagrant instance
- [inside again] Run
sudo apt-get update; sudo apt-get install dpkg-dev
followed by
dpkg-source -x *.dsc
- [outside: edit debian/changelog as needed]
- run
sudo apt-get install ....build-depends listed....
to install the listed Build-Depenbds
- run
dpkg-buildpackage -us -uc -rfakeroot
to build the package.
I have since deployed that binary package I created in a number of Travis builds. So there: creating a 64-bit package on a 32-bit system.
Vagrant is one rather popular tool, and used by a large number of virtual providers.
If you are on 64-bit Linux as a host, you can do even better via docker.io which likely the lighest, fastest, and highest performing method (and hence likely to outperform the Qemu approach -- eg this recent post