Switching examples with Squeeze to Wheezy
adding gbp command example
|Deletions are marked like this.||Additions are marked like this.|
|Line 1:||Line 1:|
|This is a tutorial for `git-pbuilder`. See also [[cowbuilder]]. `git-pbuilder` is part of the package `git-buildpackage` and the usage is very similar to `cowbuilder`. `git-pbuilder` needs sudo rights!||This is a tutorial for `git-pbuilder`.
`git-pbuilder` is part of the package `git-buildpackage` and the usage is very similar to `cowbuilder` (see also [[cowbuilder]]).
`git-pbuilder` needs sudo rights!
|Line 6:||Line 10:|
First, an environment needs to be created, then it can be used by git-buildpackage, with, for instance, the `gbp buildpackage --git-pbuilder` option.
This is a tutorial for git-pbuilder.
git-pbuilder is part of the package git-buildpackage and the usage is very similar to cowbuilder (see also cowbuilder).
git-pbuilder needs sudo rights!
First, an environment needs to be created, then it can be used by git-buildpackage, with, for instance, the gbp buildpackage --git-pbuilder option.
Initialization and Variants
You can create base images for all architectures (mostly i386 or amd64) and distribution (mostly Squeeze, Wheezy or Testing/SID, Ubuntu xxx, ...) that your hardware can run on.
The easiest usage is to call no further options, that will create a Testing/SID build environment with the architecture you are currently running on (if you are using i386, the environment will also be created for i386):
The base build image is created in /var/cache/pbuilder/base.cow/
Creating other Architecture
If you want explicitly create a environment for i386 (but running on architecture amd64) you have to tell that git-pbuilder:
ARCH=i386 git-pbuilder create
The base build image is created in /var/cache/pbuilder/base-sid-i386.cow/
Creating Packages for other Distributions
Mainly package creating is done in the Testing distribution. But sometimes you want to create packages for the stable or old-stable release, so you have to tell this also while git-pbuilder is creating the environment. If you want to build for the Wheezy distribution then you have to call git-pbuilder like this:
DIST=wheezy git-pbuilder create
The base image is created in /var/cache/pbuilder/base-wheezy-[your-platform].cow/. The creating of a base image for the (old-old-stable) Squeeze Distribution is similar, just change the argument for DIST.
Using a Mirror
If you use git-pbuilder (or git-buildpackage) very offen it's better to use a local mirror to save downloadtime and reduce traffic. If you have set up a local Apt proxy the you can tell git-pbuilder to use it. Let's say you want to create a base image for Squeeze and architecture amd64 with a caching proxy with the IP 192.168.110.4 on port 3142 (like apt-cacher-ng), so it's a combination of all variants from above:
DIST=squeeze ARCH=amd64 git-pbuilder create --mirror=http://192.168.110.4:3142/ftp.de.debian.org/debian
The base build image is created in /var/cache/pbuilder/base-squeeze-amd64.cow/
If the date of creation of your build environment is quite older you have to update it before you can use it. To update the base image just run:
The update for the possible other distributions or architectures is similar like the creation of it. Update the Wheezy environmnt for the same architecture you are currently running on would be:
DIST=wheezy git-pbuilder update
or for Squeeze on i386
DIST=squeeze ARCH=i368 git-pbuilder update
If you have used a mirror while creating the base images it will be used! So remember that if you have various networks you working, the update will fail if the mirror isn't reachable.
Installing Extra Packages
Sometimes you have to install extra packages to the base image. This is helpful if you work offline in some cases or you want to speed up the packaging. The workflow for that is similar to cowbuilder.
git-pbuilder login --save-after-login # first step, update the package list root@host:/# apt-get update # then you can install any package root@host:/# apt-get install vim screen less
You have to repeat this steps for every base image you use if you needs the same behaviour in your various build environments.
DIST=wheezy ARCH=amd64 git-pbuilder login --save-after-login ...
Use of eatmydata
You can install the package eatmydata to improve the speed of your builds.
git-pbuilder login --save-after-login root@host:/# apt-get update root@host:/# apt-get install eatmydata
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.