wiki:Linux/Ubuntu/Packages/CreatingPbuilderVariations

Version 7 (modified by tj, 9 years ago) (diff)

--

Creating Pbuilder Variations

Instead of using the various debootstrap options and other pbuilder options on the command line I use an amalgamation of the  Ubuntu Wiki Pbuilder Howto and my own modifications to ~/.pbuilderrc to ease the package build testing for different distributions and architectures before uploading to PPA.

pbuilderrc modification

My biggest modification is to look for the environment variable BASE and use it to set BASETGZ - the location and name of the pbuilder archive file. This allows the setting to over-ride the enforced value in /etc/pbuilderrc (BASETGZ=/var/cache/pbuilder/base.tgz).

Note: The value assigned to BASE is processed by dirname so the last segment beginning with a forward-slash is stripped off. This means that to specify the build location /home/all/pbuilder it needs BASE=/home/all/pbuilder/base. The final /base will be stripped off before the calculated name of the TGZ is added.

The file is attached to this article and can be directly downloaded.

Simple command launch

By setting the environment variables BASE, DIST and ARCH the options are calculated by ~/.pbuilderrc so, for example, all the following become possible:

# Create an environment for Ubuntu gutsy in the current directory
sudo BASE="$(pwd)/base" DIST=gutsy pbuilder create

# Create an environment for Debian sid
sudo DIST=sid pbuilder create

# Create an environment for Ubuntu gutsy with the i386 architecture in a defined directory
sudo BASE="/home/all/pbuilder/base" DIST=gutsy ARCH=i386 pbuilder create

# Update an environment for Ubuntu gutsy in the current directory
sudo BASE="$(pwd)/base" DIST=gutsy pbuilder update

# Build a package using Ubuntu gutsy (same architecture as is running)
cd ${PACKAGE}-${VERSION}
BASE="$(pwd)/base" DIST=gutsy pdebuild

# Build a package using Ubuntu gutsy with i386 architecture in a defined directory
cd ${PACKAGE}-${VERSION}
BASE="/home/all/pbuilder/base" DIST=gutsy ARCH=i386 linux32 pdebuild

# Build a package specified by a .dsc file using Ubuntu hardy with i386 architecture in a defined directory
BASE="/home/all/pbuilder/base" DIST=hardy ARCH=i386 linux32 pbuilder build /home/all/SourceCode/kvm-72+dfsg-0ubuntu1~ppa1h.dsc

Automated build tests for multiple distributions

I also modified my original PPA Publish Multiple Releases? script to be able to test-build the same package for multiple releases (e.g. gutsy hardy intrepid) in one automated process. The script is attached.

Cross-compiling architecture problems

If testing a package build in an i386 environment on an amd64 host it is possible that unexpected and hard-to-diagnose build errors will occur. I had issues with gnu/stubs-64.h missing trying to build the kvm package. The reason was qemu/configure does a big/little-endian test and the source-code it compiles causes the stubs-64.h file to be #include-ed (since the host architecture is 64-bit).

Another issue is missing gcc-multilib which, if the redirects of STDERR to /dev/null are removed, will reveal:

/usr/bin/ld: skipping incompatible /usr/lib/gcc/i486-linux-gnu/4.2.3/libgcc.a when searching for -lgcc
/usr/bin/ld: skipping incompatible /usr/lib/gcc/i486-linux-gnu/4.2.3/libgcc.a when searching for -lgcc
/usr/bin/ld: cannot find -lgcc
collect2: ld returned 1 exit status
big/little test failed

These problems are solved by causing pbuilder / pdebuild to run with a 32-bit kernel personality. Install the linux32 package on the 64-bit host:

$ sudo apt-get install linux32

And then start pdebuild from linux32:

BASE="/home/all/pbuilder/base" DIST=hardy ARCH=i386 linux32 pdebuild

This will build an i386 package using a 32-bit kernel personality. What this means is that if the configure scripts or Makefiles use "uname -m" they'll get a 32-bit result. E.g.:

$ uname -m
x86_64
$ linux32 uname -m
i686

Attachments