#! /bin/sh
#
# (C) 1998 Manoj Srivastava & Eric Delaunay.

set -e

ARCHITECTURE=all
PATCHNAME=freeswan
PATCHDIR=/usr/src/kernel-patches/$ARCHITECTURE/freeswan
#PATCHDIR=`dirname $0`/../$PATCHNAME

if ! test -d kernel -a -d Documentation ; then
    echo "Not in kernel top level directory. Exiting" >&2
    exit 1
fi

if test -f debian/APPLIED_${ARCHITECTURE}_$PATCHNAME ; then
   exit 0               # patch already applied
fi

rm -rf net/ipsec
KERNELDIR=`pwd`

make -C "$PATCHDIR" -f Makefile insert \
	KERNELSRC="$KERNELDIR"\
	PATCHER="./patcher" \
        KLIPSLINK="cp -a"

mkdir -p debian && touch debian/APPLIED_${ARCHITECTURE}_$PATCHNAME
