debian git packaging with git upstream

Update

There is an easier method to do all this using gbp-clone as described here. Ah !

Then to build the package, you just need to suggest git-buildpackage where to find the pristin-tar :

git-buildpackage --git-upstream-branch=upstream/master

or you could simply describe (as suggested) the layout in debian/gbp.conf.

Easy !!!


I’ve found a lot of different recipes and howtos about git debian packaging, but I failed to find one simple recipe to create a debian package from scratch when upstream is using git. Of course the following is a big patchwork from many different sources.

First we need to do a bit of administrative work to setup the repository :

mkdir yourpackage
cd yourpackage
git init --shared

Then, since I’m interested in tracking upstream development branch I’m going to add a remote branch to my repo:

git remote add upstream git://the.url/here.git

at this point I need to fetch upstream and create a branch for it.

git fetch upstream
git checkout -b upstream upstream/master

Now in my repo I have a master branch and an upstream branch. So far, so good. Let’s add the debian branch based on master:

git checkout master
git checkout -b debian master

It’s in the debian branch where I’m going to keep the debian related files. I’m finally read for hacking git add / git commit / git remove ...

When I’m done, I can switch to master, merge the debian branch into it and use git-buildpackage to build the package.

git checkout master
git branch 
  debian
* master
  upstream

git merge debian
git-buildpackage

Suppose I want to put everything on gitourious for example. I’ll create an acocunt, set up my ssh pub key and then I’ve to add an origin ref in my .git/config . Something like :

[remote "origin"]
       url = git@gitorious.org:debian-stuff/yourpackage.git
       fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
       remote = origin
       merge = refs/heads/master

The only thing left to do is to push everything on gitourious. the —all is important.

git push --all

People willing to pull your work from girourious have to follow the following script :

$git clone git@gitorious.org:debian-stuff/yourpackage.git
$cd yourpackage
$git branch -a
* master
  remotes/origin/HEAD -> origin/master
  remotes/origin/debian
  remotes/origin/master
  remotes/origin/upstream
$git checkout -t origin/debian
$git checkout -t origin/upstream
$git branch -a
  debian
  master
* upstream
  remotes/origin/HEAD -> origin/master
  remotes/origin/debian
  remotes/origin/master
  remotes/origin/upstream
$git checkout master
$git-buildpackage

Maybe there is an easier way to pull all remote branches at once, but I’m not aware of it. Any better way ?


latexdiff, git-buildpackage and topgit

I’ve packaged latexdiff for debian, that is a small utility to generate latex files with revision markers from multiple versions of the same file. While packaging this utility I’ve learned about two very nice tools to help the debian maintainers: git-buildpackage and topgit.

Regarding git-buildpackage there is an extensive manual that should get you started : http://honk.sigxcpu.org/projects/git-buildpackage/manual-html/gbp.html

Topgit documentation is a bit sparse. tg help <command> should guide you for syntax. The README file in the tg distribution is full of examples.

Zack’s work on debcheckout to make it topgit aware is also very interesting ( http://upsilon.cc/~zack/blog/posts/2008/10/debcheckout_hacking/ )

I’ve put everything on alioth.debian.org in my personal git space following these instructions : http://wiki.debian.org/Alioth/Git

the git repo is here : http://git.debian.org/?p=users/munga-guest/latexdiff.git;a=summary

to build the package :

debcheckout git://git.debian.org/git/users/munga-guest/latexdiff.git
debian/rules tg-export
git-buildpackage --git-pristine-tar --git-ignore-new

the second command debian/rules tg-export exports the patch from the git branch that is managed by topgit and transform it to a quilt patch that will be applied to the master branch to generate the package.

You can also get the package in the usual way with dget : dget -u http://alioth.debian.org/~munga-guest/latexdiff_0.5-1.dsc

This package is nice and easy, with only on patch, so it should be nice to see what topgit, git-buildpackage is all about.