Sunday, September 30, 2007

dpatch and svn-buildpackage

dpatch is a simple but reasonably powerful patching system for debian packages. One of the comforts I appreciate greatly with dpatch is the ease with which one can edit patches. The following command lauches a new shell in a copy of the package, and every difference is recorded as patch 56-new-patch.
dpatch-edit-patch 56-new-patch
For those like me who like automatic completion, here is a snippet of my .zshrc to enable automatic completion for dpatch:
dpatch-comp() {
    f=(debian/patches/*);
    f=(${f%.dpatch});
    f=(${f#debian/patches/});
    f=(${f#00list});
    if [[ -n $f ]]; then
        _values 'patches' $f;
    fi;
}
compdef dpatch-comp dpatch-edit-patch svn-edit-patch bzr-edit-patch;
However, the problem with dpatch is that is doesn't play really well with tools like svn-buildpackage, in the case where only the debian diff is handled by the SCM. The following snippets of my .zshrc permits the use of dpatch even in these cases:
svn-edit-patch () {
    patch="$1"
    shift;
    target=`pwd`;
    svn-buildpackage \
        --svn-ignore-new --svn-builder="dpatch-edit-patch $patch $@" \
        --svn-postbuild="cp debian/patches/$patch* $target/debian/patches"
}

bzr-edit-patch () {
    patch="$1"
    target=`pwd`;
    bzr builddeb -w \
        --builder="dpatch-edit-patch $patch && cp debian/patches/$patch* $target/debian/patches" 
}
Just run svn-edit-patch as you would run dpatch-edit-patch. In the hope that someone will find that useful...

No comments: