Using pbuilder to build multiple distribution packages

If you have a technical writeup you would like to share, feel free to post it in the articles submission area within.
Locked
malcom2073
LQFP112 - Up with the play
Posts: 211
Joined: Tue May 01, 2012 4:17 pm
Location: Shrewsbury PA
Contact:

Using pbuilder to build multiple distribution packages

Post by malcom2073 »

So recently I've had the opportunity to learn how to use pbuilder, which is a really powerful tool. Basically it allows you to build for several distributions and architectures, from within a single environment. It uses chroot jails to perform this, and is just plain awesome.


To do this, you need several things. First, follow the instructions here to set up pbuilder:
http://www.snamellit.com/2011/07/buildi ... cleanroom/

Once you've done that, your application has to have a debian directory, which is outside the scope of this topic. The debian's control file will both allow a .dsc file to be generated, allowing pbuilder to build, and also define what packages are required for building.

The process itself is fairly simple:

Code: Select all

$ export ARCH=i386
$ export DIST=precise
$ debuild -S (-us -uc are optional arguments you canuse here, incase you don't want signing)
You will see some text scroll, including a line like this:

Code: Select all

dpkg-source: info: building emstudio in emstudio_0.0.1-1.dsc
This is your dsc file. Once debuild has finished, run pbuilder:

Code: Select all

$ sudo pbuilder build --buildresult outputdir emstudio_0.0.1-1.dsc
I: using fakeroot in build.
I: Current time: Sun May 26 12:25:39 EDT 2013
I: pbuilder-time-stamp: 1369585539
I: Building the build Environment
I: extracting base tarball [/var/cache/pbuilder/wheezy-i386-base.tgz]
I: creating local configuration
I: copying local configuration
I: mounting /proc filesystem
I: mounting /dev/pts filesystem
I: Mounting /var/cache/pbuilder/ccache
I: Mounting /var/cache/pbuilder/wheezy-i386/result
I: policy-rc.d already exists
W: hookdir /var/cache/pbuilder/wheezy-i386/hooks does not exist, skipping
I: Obtaining the cached apt archive contents
I: Setting up ccache
I: Installing the build-deps
W: no hooks of type D found -- ignoring
 -> Attempting to satisfy build-dependencies
 -> Creating pbuilder-satisfydepends-dummy package
Package: pbuilder-satisfydepends-dummy
Version: 0.invalid.0
Architecture: i386
<snip>
This will take a while. It activates the jailed environment from pbuilder's stored tar file, downloads the necessarily packages to build your application, then builds it. At the end, your files will all be built in outputdir.

So basically, if you build a pbuilder for every dist/arch you need, then run a script with something like this in it:

Code: Select all

$ git clone myrepohere/something.git
$ cd something
$ export ARCH=i386
$ export DIST=wheezy
$ debuild -S -uc -us
$ sudo pbuilder build --buildresult wheezy-i386 something.dsc

$ export ARCH=amd64
$ export DIST=wheezy
$ sudo pbuilder build --buildresult wheezy-amd64 something.dsc

$ export ARCH=i386
$ export DIST=precise
$ sudo pbuilder build --buildresult precise-i386 something.dsc

$ export ARCH=amd64
$ export DIST=precise
$ sudo pbuilder build --buildresult precise-amd64 something.dsc
You will now have 4 output folders, with the 4 built installers!
Locked