summaryrefslogtreecommitdiffstats
path: root/needs-checking/combine-applied
blob: 487b553c3534a9a0fe7ca185173314346153428d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/bin/sh

#
# Make superpatch from currently applied patches using combinediff.
#

. patchfns 2>/dev/null ||
. /usr/lib/patch-scripts/patchfns 2>/dev/null ||
. $PATCHSCRIPTS_LIBDIR/patchfns 2>/dev/null ||
{
	echo "Impossible to find my library 'patchfns'."
	echo "Check your install, or go to the right directory"
	exit 1
}

usage()
{
	echo "Usage: combine-applied output-file"
	exit 1
}

if [ $# -ne 1 ] 
then
	usage
fi

need_file_there applied-patches
CURRENT=$(mktemp /tmp/cmbd-XXXXXXXX)
for FILE in `cat applied-patches`
do
	NEXT=$(mktemp /tmp/cmbd-XXXXXXXX)
	if [ -f $P/patches/$FILE ] 
	then
		combinediff $CURRENT $P/patches/$FILE > $NEXT
	elif [ -f $P/patches/$FILE.patch ]
	then
		combinediff $CURRENT $P/patches/$FILE.patch > $NEXT
	elif [ -f $FILE ]
	then
		combinediff $CURRENT $FILE > $NEXT
	fi
	rm $CURRENT
	CURRENT=$NEXT
done

mv $NEXT "$1"