Building Packages from the Git Repository

Using a separate build dir
Invoking external programs
Running lintian
Pushing into a remote repository
Running postexport hook
Running preexport hook

In order to build a Debian™ package from the Git repository, you use: gbp buildpackage. This builds the upstream tarball (as will be described below) and invokes Debuild to build the package. To use another build command, you can use the --git-builder option as described later in the manual, but Debuild is nice since it can invoke lintian. During the development phase (when you're either not on the debian-branch or when you have uncommitted changes in your repository), you'll usually use:

gbp buildpackage --git-ignore-new

If gbp buildpackage doesn't find a valid upstream tarball, it will create one by looking at the tag matching the upstream version. To change this behaviour, see the --git-upstream-tree option.

If you want to recreate the original tarball using the additional information from the pristine-tar branch, you have to specify the --git-pristine-tar option. This will make sure the upstream tarball matches exactly the one imported. Using this option is the recommended way of recreating the upstream tarball.

Once you're satisfied with the build and want to do a release, you commit all your changes and issue:

gbp buildpackage --git-tag

This will again build the Debian™ package and tag the final result after extracting the current version from the changelog. If you want GPG-signed tags, you can use the --git-sign and --git-keyid options. To save typing, these option can be specified via the configuration files. You can furthermore change the tag format used when creating tags with the debian-tag option; the default is debian/<version>.

Using a separate build dir

Tools like svn-buildpackage use a separate build-area. To achieve a similar behaviour with gbp buildpackage, use the --git-export-dir option:

gbp buildpackage --git-export-dir=../build-area/

This will export the head of the current branch to ../build-area/package-version and build the package. If you don't want to export the current branch head, you can use --git-export to export any treeish object. Here are some examples:

gbp buildpackage --git-export-dir=../build-area --git-export=debian/0.4.3
gbp buildpackage --git-export-dir=../build-area --git-export=etch
gbp buildpackage --git-export-dir=../build-area --git-export=8caed309653d69b7ab440e3d35abc090eb4c6697
gbp buildpackage --git-export-dir=../build-area --git-export=INDEX
gbp buildpackage --git-export-dir=../build-area --git-export=WC

The special argument INDEX exports the state of the current index, which can be used to include staged but uncommitted changes in the build. Whereas the special argument WC exports the current working copy as is.

If you want to default to build in a separate build area, you can specify the directory to use in the gbp.conf file.

[buildpackage]
# use a build area relative to the git repository
export-dir=../build-area
# to use the same build area for all packages use an absolute path:
#export-dir=/home/debian-packages/build-area

gbp buildpackage will cleanup the build-area after a successful build. If you want to keep the build tree, use --git-no-purge.