#!/bin/sh
# DocumentId:	$Id: dpsch-installpatch,v 1.6 2003/08/12 05:56:26 ola Exp $
# Author:	$Author: ola $
#		Ola Lundqvist <opal@debian.org>
# Arguments:	
# Summary:
#	Install system patches to a package name.

PATCHSRC=/usr/share/dpsyco/userpatch
. /etc/dpsyco/defaults.conf

if [ ! -d debian ] ; then
    echo "No debian directory, exiting."
    exit 0
fi

if [ ! -e debian/control ] ; then
    echo "No debian control file, exiting."
    exit 0
fi

dpsch-listbinpkgs | {
    while read PKG ; do
	if [ -e debian/$PKG.patch ] ; then
	    cat debian/$PKG.patch | {
		while read FILE ; do
		    mkdir -p debian/$PKG$PATCHSRC/$PKG
		    cp $FILE debian/$PKG$PATCHSRC/$PKG
		done
	    }
	fi
    done
}

dpsch-showfirstbinpkg | {
    while read PKG ; do
	if [ -e debian/patch ] ; then
	    cat debian/patch | {
		while read FILE ; do
		    mkdir -p debian/$PKG$PATCHSRC/$PKG
		    cp $FILE debian/$PKG$PATCHSRC/$PKG
		done
	    }
	fi
    done
}
