#!/bin/sh
#
# Copyright 2001 Wichert Akkerman

set -e

thispatch=ipmi-kcs
stamp=debian/APPLIED_i386_$thispatch
patchdir=/usr/src/kernel-patches/i386/$thispatch

if [ ! -d kernel -a -d Documentation ] ; then
	echo "This does not seem to be a kernel source directory." >&2
	exit 1
fi

if [ ! -f $stamp ] ; then
	echo "The $thispatch patch is not applied"
	exit 0
fi

patch=$(cat $stamp)

if [ ! -r "$patch" ] ; then
	echo "Can not find patch $patch which was used to patch the kernel"
	exit 1
fi

patch -p1 -s -l -N -R < "$patch"
rm -f $stamp
[ -d debian ] && rmdir -p debian || true
exit 0

