1#!/bin/sh
2
3# This script creates a patch based on the current changes in the "src" directory that aren't already accounted for.
4
5SCRIPTDIR=$( dirname "$0" )
6pushd "$SCRIPTDIR" > /dev/null
7cd ..
8
9EXTDIR=/tmp/out.$$
10mkdir -p $EXTDIR
11
12VERSION=$( cat src/.version )
13
14rm -rf ${EXTDIR}/src
15bin/extract-source.sh $EXTDIR/
16
17# remove symlinks since we can't diff them
18
19ditto src /tmp/oldsrc.$$ || exit 1
20cd /tmp/oldsrc.$$ || exit 1
21find . ${EXTDIR}/src -type l -exec rm -f {} \;
22
23# generate the patch
24
25diff -Nur $EXTDIR/src/ . | sed "s|$EXTDIR|openssl-$VERSION|" > /tmp/$$.patch
26rm -rf /tmp/oldsrc.$$ $EXTDIR
27
28LINES=$( wc -l < /tmp/$$.patch )
29
30if [ $LINES == 0 ]; then
31   rm -f /tmp/$$.patch
32   echo "No local diffs"
33else
34   PATCHFILE="$1"
35   if [ "$PATCHFILE" != "" ]; then
36      popd > /dev/null
37      mv /tmp/$$.patch "$PATCHFILE"
38   else
39      PATCHFILE=/tmp/$$.patch
40   fi
41
42   echo "Patch in $PATCHFILE"
43fi
44