Debian-Pakete bauen mit git-buildpackage

Einfache Dinge sind in manpages manchmal gut versteckt.

Ich wollte einfach nur ein paar bash-skripte und text-dateien, die ich mit git verwalte, als .deb verpacken.
Beim Doku suchen war ich kurz davor war das Paket mittels

rsync --cvs-ignore /pfad/zum/paket /zielordner
tar cfz paket.tar.gz /zielordner
alien paket.tar.gz --description "Mein Paket"

zu bauen. Aber wozu hat man schließlich git-buildpackage?

Die nötigen Vorarbeiten erledigt dieses kleine Skript:

#!/bin/bash -
#===============================================================
#         FILE: newproj.sh
#        USAGE: ./newproj.sh <projectname>
#
#  DESCRIPTION: Prepare a git-repo to create basic .deb-packages
#               like a .deb full of bash-scripts
#
#      OPTIONS: The name of your project
# REQUIREMENTS: git-buildpackage
#         BUGS: likely...
#        NOTES: no warranty...
#       AUTHOR: Marco.Markgraf@gmx.de
#      CREATED: 14.02.2012 11:38:48 CET
#===============================================================
set -o nounset # Treat unset variables as an error

## parameters needed by dh_make
export DEBFULLNAME='your name' # you may want to set these
export EMAIL='you@example.com' # in .bashrc and comment these lines out here...

project="$1"
version="0.1" # dh_make needs version in dirname
# But as i want my versioning done by git,
dir="${project}-${version}" # this will be renamed later.

mkdir $dir
cd $dir

## set up repo
git init
git commit --allow-empty -m "Empty repo"
git branch upstream # apparently git buildpackage needs this.

## generate /debian and files therein
dh_make --packagename $dir --native --email $EMAIL --indep
rm debian/*.{ex,EX} # unless you want to read the examples...
rm debian/README.* # unless you need debian-specific README

## extra files i want
mkdir --parents etc/$project
mkdir --parents usr/bin
mkdir --parents usr/share/doc/$project
touch etc/$project/README
touch usr/share/doc/$project/README

## this one is important!
## without it, git buildpackage will build a package,
## properly versioned, but with no content.
touch debian/install
echo 'etc/*
usr/*' > debian/install # or whatever dirs you need...

## get repo up to date
git add .
git commit --all --message 'Initial blank Debian package template'

cd ..
mv $dir $project # rename to get rid of version in dirname

## start coding :-)

# NOTE: do not use git commit -a in $project!
# you'll end up having generated files in /debian/$project
# under version control which you don't need!
# They'll be generated from your sources with every
# git buildpackage --pristine-tar

# NOTE: dh_??? will fetch version from
# debian/changelog, not $dir as dh_make does.
# You need to set versions with
# dch -i # increment
# or dch -v version # set version manually
#===============================================================

Zugegeben, das ist keine hohe Programmierkunst, aber es erfüllt den Zweck.