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 ?