#!/bin/sh

# script  : tools/mkcontents
# author  : willy tarreau
# function: creates the "patch-contents" file in the "pool" directory
# usage   : $0

# This script uses the variable BASEVER for the base kernel version, and the
# variable KERNVER for the new kernel version.

[ -z "$BASEVER" ] &&set -- $(grep -ih -m 1 "^++.*Based" CONTENTS)  &&BASEVER=$5
[ -z "$KERNVER" ] &&set -- $(grep -ih -m 1 "^++.*Kernel" CONTENTS) &&KERNVER=$4

set -- $(wc -l CONTENTS)
rm -f pool/patch-contents
cat >pool/patch-contents << EOF
--- linux-$BASEVER/CONTENTS	Thu Jan  1 01:00:00 1970
+++ linux-$KERNVER/CONTENTS	Thu Jan  1 01:00:00 1970
@@ -0,0 +1,$1 @@
EOF
sed -e 's/^/+/' < CONTENTS >>pool/patch-contents
