#!/bin/sh

# wander through a FreeSWAN linux directory, creating a patch file (to stdout)
# that will apply the code to a kernel source directory.
#
# $Id: kernelpatch,v 1.8 2002/08/30 01:44:07 mcr Exp $
#

KERN=$1
shift

case $KERN in
    2.0) patchname=fs2_0;;
    2.2) patchname=fs2_2;;
    2.4) patchname=fs2_4;;
    2.5) patchname=fs2_5;;
    *) echo "Invalid kernel patch target: $KERN"; exit 1;;
esac

# make sure that sort gets the right locale.
LANG=C export LANG
LC_ALL=C export LC_ALL


find linux -type f -print | grep -v CVS | egrep -v 'linux/Makefile' | sort | while read file 
do 
  base=`basename $file`
  case $base in 
    .cvsignore) ;;
    .*.o.flags) ;;
    *.o) ;;
    *~) ;;
    *.$patchname.patch) cat $file;;
    *.patch) ;;
    *) diff -u /dev/null $file;;
  esac
done

#
# finally, we have to produce a diff for linux/net/linux/Makefile.ver, 
# a file which is generated at runtime, so there is nothing in CVS.
#
echo '--- /dev/null   Fri May 10 13:59:54 2002'
echo '+++ linux/net/ipsec/Makefile.ver  Sun Jul 28 22:10:40 2002'
echo '@@ -0,0 +1 @@'
echo -n '+'
grep IPSECVERSION Makefile.ver

exit 0

	
