Here is a second revision based on our IRC discussion.  It looks for a file
debian/git-patches, which it expects to have pairs of refs (well, things
that git-format-patch understands). It will interoplate %DEB_VERSION%.

I also attach an example recipe file.  I tried some malicious things
like

`halt` $(rm *)

and was fine (i.e. ignored), but I'm not really an expert on shell
shenanigans.  Speaking of which I suppose IFS should be set before the
loop reading the file.

#!/bin/sh
# export patches according to a recipe in debian/git-patches
# To use as a hook in gitpkg, 
#   git config gitpkg.deb-export-hook debian/export-patches.sh

# make this configable?
recipe=debian/git-patches

export GIT_DIR
if [ -n "$REPO_DIR" ]; then
    GIT_DIR=$REPO_DIR/.git
else
    # support running as a free-standing script, without gitpkg
    DEB_VERSION=$(dpkg-parsechangelog | sed -n 's/^Version: \(.*:\|\)\(.*\)/\2/p')
fi;

tmpdir=$(mktemp -d patches.XXXXXXX)
echo "# Patches exported from git by gitpkg-export-patches" > $tmpdir/series

sed s/%DEB_VERSION%/${DEB_VERSION}/g  < $recipe |
while read -r base tip
do
    case $base in
	\#*)
	    ;;
	*)
	    count=$(wc -l $tmpdir/series | cut -f1 -d' ')
	    PATCHES=$(git format-patch --start-number $count -N -o $tmpdir $base...$tip)
	    echo $PATCHES | sed -e "s%$tmpdir/%%g" -e 's% %\n%g'>> $tmpdir/series
    esac
done

count=$(wc -l $tmpdir/series | cut -f1 -d' ')

if [ $count -gt 1 ]; then
    rm -rf debian/patches
    mv $tmpdir debian/patches
else
    echo "No patches found: debian/patches left untouched"
    rm -rf $tmpdir
fi

Attachment: git-patches
Description: recipe file

>From my point of view this is just as usable as the last version.

Reply via email to