PbuilderHowto

Differences between revisions 45 and 46
Revision 45 as of 2007-05-13 22:04:00
Size: 7913
Editor: c-76-111-84-156
Comment: Changed BASETGZ. Example script uses a '-' instead of '/'.
Revision 46 as of 2007-05-23 00:38:37
Size: 8400
Editor: c-76-111-84-156
Comment: Adding section on signing source files.
Deletions are marked like this. Additions are marked like this.
Line 55: Line 55:
== Signing Source Files ==

If you intend to upload your packages to REVU, you must first sign your source files (.dsc and .changes files). The easiest way to do this is by using ''debsign''. Assuming your packages and source files were placed in /var/cache/pbuilder/result/, run;

{{{
sudo debsign /var/cache/pbuilder/result/*.changes
}}}

''debsign'' is a part of the package ''devscripts'' so you must first install ''devscripts''.
{{{
sudo apt-get install devscripts
}}}

Introduction

This document describes the steps to setup a chroot jail for building Ubuntu packages using pbuilder. It is recommended for Ubuntu maintainers or anyone interested in building packages using Ubuntu.

You can build packages without pbuilder but you must already have all the build dependencies of the package that you are building installed on your running system.

If you use LVM and want to take advantage of using LVM snapshots to speed up the chroot creation/destruction, please see ["SbuildLVMHowto"] for an alternate approach.

The following assume you want to install edgy. If you need a dapper or feisty chroot, then exchange edgy with the appropriate distribution.

Installing Pbuilder on edgy

The latest pbuilder package in Edgy (0.155ubuntu3) should work out of the box. You only need to install it and debootstrap. Then run:

sudo pbuilder create 

and then

sudo pbuilder build my-package_1.0.dsc

(i) Note: If you get the error "debootstrap does not exist", install debootstrap.

Rebuilding a package

If you reach this point you now have a Edgy chroot located at /var/cache/pbuilder ready to build a package. We will get a Debian source package from Ubuntu repository to test it.

To check if you can download source packages, you will need an uncommented deb-src line in /etc/apt/sources.list, containing:

    deb-src http://archive.ubuntu.com/ubuntu edgy main restricted 

If the line above is there but not uncommented, uncomment it. Make sure your package index files are synchronized so that apt-get knows where to find the sources:

    sudo apt-get update

We will build bc, a simple calculator, from source, let's download the debian source package from ubuntu repository:

    apt-get source bc

You can build the package using your Edgy chroot with the command:

    sudo pbuilder build *.dsc

In the end, the binary and source package will be at /var/cache/pbuilder/result/

Signing Source Files

If you intend to upload your packages to REVU, you must first sign your source files (.dsc and .changes files). The easiest way to do this is by using debsign. Assuming your packages and source files were placed in /var/cache/pbuilder/result/, run;

sudo debsign /var/cache/pbuilder/result/*.changes

debsign is a part of the package devscripts so you must first install devscripts.

sudo apt-get install devscripts

Updating a chroot

I recommend you update your chroot before each build, to this task use the command below:

    sudo pbuilder update

Speeding up build-dependency calculation

If you use feisty you can use a new build-dependency resolver based on gdebi that should be significantly faster. Change /etc/pbuilder/pbuilderrc likes:

    PBUILDERSATISFYDEPENDSCMD="/usr/lib/pbuilder/pbuilder-satisfydepends-gdebi"

Universe support

If you want to rebuild a package from universe or build a new one that needs a package out of main you will need to edit /etc/pbuilderrc again, uncommenting:

    COMPONENTS="main restricted universe multiverse"

Building an i386 pbuilder on AMD64

One of the things a pbuilder is useful for is building i386 packages on an AMD64 machine. You can create an i386 chroot with the command:

    sudo pbuilder create --debootstrapopts --arch --debootstrapopts i386

Upgrading to Latest Development Release

If you want to participate in the current release cycle, you will want to have a FeistyFawn chroot. Sometimes, the development version may not be installable directly. In this case, you have to install the latest release first, and upgrade then to development release

  • change all occurences of edgy in /etc/pbuilderrc and /etc/pbuilder/apt.config/ to feisty

  •  sudo pbuilder update --override-config 

  • use the --override-config option every time you run the update

Multiple pbuilders

When you work with packages, you often want to have multple pbuilders on your machine, if for example you want to backport to Dapper while developing on Edgy, or test packages on Sid to track bugs.

To do that, you can adapt the file in /usr/share/doc/pbuilder/examples/pbuilder-distribution.sh. That script assumes a common chroot directory for every distribution however, so it's recommended to change the script to the following :

# script from Jamin W. Collins  BTS: #255165
# name this script 'pbuilder-woody', 'pbuilder-sid', 'pbuilder-sarge' etc.


OPERATION=$1
DISTRIBUTION=`basename $0 | cut -f2 -d '-'`
PROCEED=false
BASE_DIR="/var/cache/pbuilder"
case $OPERATION in
   create|update|build|clean|login|execute )
      PROCEED=true
      ;;
esac
if [ "$PROCEED" = true ]
then
   shift
   sudo /usr/sbin/pbuilder $OPERATION \
      --basetgz $BASE_DIR/$DISTRIBUTION-base.tgz \
      --distribution $DISTRIBUTION \
      --configfile $BASE_DIR/$DISTRIBUTION/pbuilderrc \
      --aptconfdir $BASE_DIR/$DISTRIBUTION/apt.config \
      --buildresult $BASE_DIR/$DISTRIBUTION/result "$@"

else
   echo "Invalid command..."
   echo "Valid commands are:"
   echo "   create"
   echo "   update"
   echo "   build"
   echo "   clean"
   echo "   login"
   echo "   execute"
   exit 1
fi

Save this script in /usr/local/bin and name it according to the distribution you want, e.g. pbuilder-feisty. To make it executable, type (use whatever name you have given the script):

sudo chmod +x /usr/local/bin/pbuilder-feisty

Next, we'll prepare the staging area. Do this for every distribution you want to build packages for. Again, the examples assume that the distribution you want is feisty, change the name for other distributions.

sudo mkdir /var/cache/pbuilder/feisty
sudo cp /etc/pbuilderrc /var/cache/pbuilder/feisty

Then edit /var/cache/pbuilder/feisty/pbuilderrc and make sure that the following lines refer to the correct distribution:

DISTRIBUTION=feisty
BASETGZ=/var/cache/pbuilder/feisty-base.tgz
BUILDPLACE=/var/cache/pbuilder/feisty/build/
BUILDRESULT=/var/cache/pbuilder/feisty/result/

Now copy the apt configuration files to /var/cache/pbuilder/feisty/apt.config

sudo cp -R /etc/apt /var/cache/pbuilder/feisty/apt.config

Then edit /var/cache/pbuilder/feisty/apt.config/sources.list and make sure that every occurrence of edgy is changed to feisty.

Finally run pbuilder-feisty create to create the pbuilder chroot (base.tgz) in this location.

Follow the same steps to create pbuilder chroots for other distributions (e.g. pbuilder-edgy, pbuilder-sarge, pbuilder-sid, etc.).

Note that, to create a Debian pbuilder environment, you will need to make sure you have the Debian keys in the apt-keys used by the chroot. The easiest way to do this is probably to just add them with apt-key to your ubuntu system before copying your apt configuration files to apt.config.

Installing Pbuilder on Warty, Hoary or Breezy

Install pbuilder package and debootstrap.

Edit /etc/pbuilder/pbuilderrc changing the following directives:

    MIRRORSITE=http://archive.ubuntu.com/ubuntu
    DISTRIBUTION=edgy

Since pbuilder will complain about unauthenticated packages, you have to allow unauthenticated packages. You can make it like so:

Edit your /etc/pbuilder/pbuilderrc:

    APTCONFDIR="/etc/pbuilder/apt.config/"

Now you'll copy needed files of /etc/apt to it and

    sudo -s
    mkdir /etc/pbuilder/apt.config/
    cp -ar /etc/apt/* /etc/pbuilder/apt.config/
    echo "APT::Get::AllowUnauthenticated 1;" >> /etc/pbuilder/apt.config/apt.conf.d/allow-unauthenticated
    exit

NOTE: Make sure to remove 99update-notifier from /etc/pbuilder/apt.config/apt.conf.d/ if you have copied it in the last step. It can potentially break future updates to your pbuilder chroot, as update-notifier won't normally be installed.

Save the file and run the command below to build your Edgy chroot:

    sudo pbuilder create --distribution edgy

See also

pbuilder User's Manual: http://www.netfort.gr.jp/~dancer/software/pbuilder-doc/pbuilder-doc.html


["CategoryMOTU"]

PbuilderHowto (last edited 2020-01-28 13:36:36 by paelzer)