#! /bin/sh -e
# Try compiling the diff between directory $1 and $2, patch name $3,
# actual patch $4, kernel version $5, arg $6.

echo "Attempting to $(echo $6 | cut -c3-) $3..." >&2

BASEDIR=$(dirname $1)
ONEDIR=$(basename $1)
TWODIR=$(basename $2)

cd $BASEDIR
ANSWER=RUN
if [ x"$6" = x"--compile" ]; then
    EXTRA="compile only"
    ANSWER=COMPILE
fi

if (echo Subject:compile for $3; echo ARCH=i386; echo KERNEL=$5; echo $EXTRA; echo "no tests"; kerndiff $ONEDIR $TWODIR) | ssh vanton@vanton ./vanton-live; then
    # Blank line in case there's any junk from above.
    echo; echo ${3}:${ANSWER}S:${4}
else
    # Blank line in case there's any junk from above.
    echo; echo ${3}:NO${ANSWER}:
fi