Differences between revisions 21 and 22
Revision 21 as of 2011-05-11 18:23:51
Size: 3449
Comment:
Revision 22 as of 2011-05-11 18:36:41
Size: 3814
Comment:
Deletions are marked like this. Additions are marked like this.
Line 37: Line 37:

You can use an `apt` cache to reduce the downloads on mirrors, so my mirror is always `http://apt:9999/debian` or `http://apt:9999/ubuntu`.
( you shoud then add {{{--mirror http://apt:9999/debian }}}
Line 48: Line 44:
sudo cowbuilder --create --basepath /var/cache/pbuilder/squeeze-i386/base.cow --distribution squeeze --debootstrapopts --arch --debootstrapopts i386 sudo cowbuilder \
--create \
--basepath /var/cache/pbuilder/squeeze-i386/base.cow\
--distribution squeeze\
--debootstrapopts --arch --debootstrapopts i386
Line 56: Line 56:
<!> Some steps left to describe here.
Line 61: Line 61:
Building `i386` base paths may be achieved by appending those options to the `cowbuilder --create` command line.
Line 65: Line 63:
  * Then you can build up a package. For instance a backport of nano for squeeze:
{{{
Line 66: Line 66:
Once everything is set up, I use this script in a debian source package directory to build it for every distribution. dget http://ftp.de.debian.org/debian/pool/main/n/nano/nano_2.2.6-1.dsc
cd nano-2.2.6
sudo DIST=squeeze ARCH=i386 pdebuild
ls -l /var/cache/pbuilder/squeeze-i386/result/nano_2.2.6-1_i386.deb
-rw-r--r-- 1 root root 569906 11 mai 20:33 /var/cache/pbuilder/squeeze-i386/result/nano_2.2.6-1_i386.deb
}}}

The result will be available in:
/var/cache/pbuilder/squeeze-i386/result

===== Optionnal ======
  * Once everything is set up, you can use a script in a debian source package directory to build it for every distribution.
Line 87: Line 98:
  * You can use an `apt` cache to reduce the downloads on mirrors, so if the mirror is `http://apt:9999/debian` or `http://apt:9999/ubuntu`.
( you shoud then add {{{--mirror http://apt:9999/debian }}}

cowbuilder

This is the tutorial for cowbuilder. See also qemubuilder.

Usage

Initialization

Create the base image:

sudo cowbuilder --create

And a new and shiny build image is created in /var/cache/pbuilder/base.cow/

Every day usage

Update the base image

sudo cowbuilder --update

Build a package:

sudo cowbuilder --build somepackage.dsc

Tips

Bash and SVN tips

Setup your .bashrc according to: http://upsilon.cc/~zack/blog/posts/2007/09/svn-cowbuilder/

Building your package for many distributions at once

cowbuilder is really handy to build your pet project for many distributions at once. If you have got an amd64 system, you can easily build a package for i386 and amd64 architectures and for say stable, sid and lucid.

  • The first step involves creating as many basepaths as you need. I chose to put them in /var/cache/pbuilder/$DIST-$ARCH/base.cow.

sudo mkdir  /var/cache/pbuilder/squeeze-i386/
  • Then creating them base image :

sudo cowbuilder \
--create \
--basepath /var/cache/pbuilder/squeeze-i386/base.cow\
 --distribution squeeze\
 --debootstrapopts --arch --debootstrapopts i386

Creating an ubuntu base path which is trickier because one must :

  • import ubuntu signing keys
  • use a backport of the latest cdebootstrap if you use etch and install pbuilder > 0.174

  • exclude packages of priority important in /usr/share/cdebootstrap/generic-ubuntu/packages

  • add universe to complete creation of chroot because the cowdancer package is in universe.

$ DIST=gutsy sudo cowbuilder --create --distribution gutsy --components "main universe" --basepath /var/cache/pbuilder/gutsy-amd64.cow --mirror http://apt:9999/ubuntu --debootstrapopts --exclude=udev,pcmciautils,initramfs-tools
  • Then create a ~/.pbuilderrc file to this purpose. You can use the example of the Ubuntu pbuilder howto.

  • Then you can build up a package. For instance a backport of nano for squeeze:

dget http://ftp.de.debian.org/debian/pool/main/n/nano/nano_2.2.6-1.dsc
cd nano-2.2.6
sudo DIST=squeeze ARCH=i386 pdebuild
ls -l /var/cache/pbuilder/squeeze-i386/result/nano_2.2.6-1_i386.deb
-rw-r--r-- 1 root root 569906 11 mai   20:33 /var/cache/pbuilder/squeeze-i386/result/nano_2.2.6-1_i386.deb

The result will be available in: /var/cache/pbuilder/squeeze-i386/result

===== Optionnal ======

  • Once everything is set up, you can use a script in a debian source package directory to build it for every distribution.

set -e

RESULTDIR=$1
[ -d $RESULTDIR ] || mkdir $RESULTDIR

DISTLIST=$(ls -d /var/cache/pbuilder/*.cow)

for chrootdir in $DISTLIST
do
    sudo cowbuilder --update --basepath $chrootdir
    DIST=$(basename $chrootdir | cut -d'-' -f1)
    [ -d $RESULTDIR/$DIST ] || mkdir $RESULTDIR/$DIST
    DIST=$DIST pdebuild --pbuilder cowbuilder\
                        --buildresult $RESULTDIR/$DIST\
                        -- --basepath $chrootdir
done
  • You can use an apt cache to reduce the downloads on mirrors, so if the mirror is http://apt:9999/debian or http://apt:9999/ubuntu.

( you shoud then add --mirror http://apt:9999/debian 

Troubleshooting

Slow copying and removing of the COW directory

What cowbuilder does is:

cp -al /var/cache/pbuilder/base.cow /tmp/new
rm -rf /tmp/new

Of course cowbuilder uses a different location than /tmp/new. You need to optimize those 2 commands on your computer. They should take around 0.2s each. If not, try to use the ext3 filesystem, for more details, see our benchmarks.