Whamcloud - gitweb
b=17671
[fs/lustre-release.git] / lustre / kernel_patches / scripts / touched-by-patch
1 #!/bin/sh
2 # Extract names of new files from a patch, print them out
3
4 PATCHFILE=$1
5 case "$PATCHFILE" in
6 *.gz) CMD="gzip -d < $PATCHFILE";;
7 *)    CMD="cat $PATCHFILE";;
8 esac
9
10 TMP=$(mktemp /tmp/tbp-XXXXXX) || exit 1
11 TMP2=$(mktemp /tmp/tbp2-XXXXXX) || exit 1
12
13 eval $CMD | egrep '^\+\+\+ |^\-\-\- ' > $TMP
14
15 cat $TMP | sed -e 's@[^/]*/\([^         ]*\).*@\1@' \
16          | grep -v '^dev\/null$' \
17          | sort \
18          | uniq \
19          > $TMP2
20
21 rm -f $TMP
22 grep < $TMP2 '^[+][+][+]' > /dev/null
23 if [ "$?" = "0" ]
24 then
25         echo "WARNING: $PATCHFILE appears to be -p0 form rather than -p1." 1>&2
26         echo "         Use "\'"p0-2-p1 . . < $PATCHFILE"\'" to fix" 1>&2
27         awk '{ print $2 }' < $TMP2
28 else
29         cat $TMP2
30 fi | grep -v '~'
31
32 rm -f $TMP2