[[!meta title="Keyringer: development guidelines and workflow"]]

Development environment
-----------------------

The following steps needs to be run just once.

### Create the `debian/` structure

    if [ ! -d "debian" ]; then
      dh_make -p keyringer_0.1 --createorig
    fi

### Setup a sid pbuilder chroot

    DIST=sid sudo pbuilder create --debootstrapopts --variant=buildd

### Setup a sid cowbuilder chroot

    DIST=sid sudo cowbuilder --create

Environment maintenance
-----------------------

These steps should be run once in a while to ensure we have an up to date packaging environment.

### Pbuilder

    DIST=sid sudo pbuilder update

### Cowbuilder

    DIST=sid sudo cowbuilder --update

Release workflow
----------------

Go to master branch

    git checkout master

Prepare the source code:

    $EDITOR ChangeLog
    make build_man

Update debian changelog:

    cd debian
    dch -i
    cd -

Commit and tag a release:

    git commit -a -m "Keyringer $VERSION"
    git tag -s $VERSION -m "Keyringer $VERSION"
    git checkout upstream
    git merge    master
    git checkout debian
    git merge    upstream

Create a release file:

    make tarball

Generate a `keyringer_VERSION.orig.tar.bz2` file:

    make dh

Sign the release ([see backupninja development guidelines](https://labs.riseup.net/code/projects/backupninja/wiki/Release)):

    cd ../tarballs
    gpg --armor --detach-sign keyringer-$VERSION.tar.bz2

Upload the release:

    scp keyringer-$VERSION.tar.bz2* server:/var/sites/keyringer/releases/
    cd -

Add the release into the `pristine-tar` branch:

    pristine-tar commit ../tarballs/keyringer_$VERSION.orig.tar.bz2 $VERSION

Push everything:

    git push --tags

Build the package from the git three using the upstream branch:

    git-buildpackage

Run lintian (or [add it to your pbuilder hooks](http://askubuntu.com/questions/140697/how-do-i-run-lintian-from-pbuilder-dist)):

    lintian --info --display-info --pedantic --color auto \
     ../build-area/keyringer_$VERSION*.changes

Adding a subcommand
-------------------

When adding a new subcommand, ensure:

* Manpage is updated.
* Shell completions are updated.

References
----------

* [Using Git for Debian Packaging](http://www.eyrie.org/~eagle/notes/debian/git.html).
* [Building packages from the Git repository](http://honk.sigxcpu.org/projects/git-buildpackage/manual-html/gbp.building.html).
* [Cowbuilder](https://wiki.debian.org/cowbuilder).
* [git-pbuilder](https://wiki.debian.org/git-pbuilder).
* [PackagingWithGit - Debian Wiki](https://wiki.debian.org/PackagingWithGit).
* [Generating pristine tarballs from git repositories](http://joeyh.name/blog/entry/generating_pristine_tarballs_from_git_repositories/).