#!/bin/sh -e [ -n "$1" ] [ -e debian/rules ] [ -d debian/patches ] [ ! -e debian/patches/$1 ] CWD=`pwd` D=`mktemp -d` trap "rm -rf $D" 0 1 2 3 4 5 6 7 8 10 11 12 13 14 15 debclean cp -r . $D/orig cd $D/orig debian/rules setup || debian/rules patch || debian/rules apply-patches || debian/rules apply-dpatches || debian/rules unpack || debian/rules patch-stamp [ -z "`find -name '*.rej'`" ] || { echo 'there are rejections from the current patches, aborting' >&2 exit 1 } find -name '*.orig' | xargs rm || true cd .. cp -a orig new cd new echo 'make your modifications in this shell and exit it successfully' bash find -name '*.orig' | xargs rm || true cd .. diff -Nurp orig new > "$CWD/debian/patches/$1"