A few more improvements.
[rsync/rsync-patches.git] / verify-patches
1 #!/bin/sh
2
3 [ -d patches ] && cd patches
4
5 if [ ! -f verify-patches ]; then
6     echo "Please run this script from the root of the rsync dir"
7     echo "or from inside the patches subdir."
8     exit 1
9 fi
10
11 root=`cat ../CVS/Root`
12 tmpdir=,tmp-for-patch-tests
13
14 [ -d $tmpdir ] || mkdir $tmpdir
15 cd $tmpdir || exit 1
16
17 [ -d ,workdir ] || mkdir ,workdir
18 echo "Using CVS to update the $tmpdir/,cvsdir copy of the source."
19 cvs -d "$root" co -d ,cvsdir rsync
20
21 cd ,workdir || exit 1
22
23 if [ -z "$1" ]; then
24     set -- ../../*.diff
25 fi
26
27 for xx in "${@}"; do
28     case "$xx" in
29     *gzip-rsyncable.diff) continue ;;
30     patches/*) xx=`echo $xx | sed 's:patches:../..:'` ;;
31     */*.diff) ;;
32     *.diff) xx=../../$xx ;;
33     *) continue ;;
34     esac
35     apply=y
36     while : ; do
37         echo -e "\n----------- $xx ------------"
38         if [ $apply = y ]; then
39             rsync -a --delete ../,cvsdir/ .
40             patch -p0 <$xx | tee ,patch.output
41             new=''
42             for nn in `sed -n 's/^patching file //p' ,patch.output`; do
43                 [ -f ../,cvsdir/$nn ] || new="$new $nn"
44             done
45             apply=n
46         fi
47         echo -e "\nFix rejects, Make proto, Edit both diffs, Update patch,"
48         echo -n "Apply patch again, Next, Quit: [n] "
49         read ans
50         case "$ans" in
51         [Ee]*)
52             [ ! -z "$new" ] && cvs add $new
53             new=''
54             rm -f *.rej *.orig
55             sed '/^--- /,$ d' $xx >,new.patch
56             cvs diff -N | grep -v '^Index: ' |
57                 grep -v '^=========' |
58                 grep -v '^diff -' |
59                 grep -v '^RCS file: ' |
60                 grep -v '^retrieving revision ' >>,new.patch
61             vim -d $xx ,new.patch
62             ;;
63         [Ff]*)
64             vim *.rej
65             ;;
66         [Mm]*)
67             cat *.c lib/compat.c | awk -f mkproto.awk >proto.h
68             echo -e "\nRegenerated proto.h"
69             ;;
70         [Uu]*)
71             if [ -f ,new.patch ]; then
72                 cp -p ,new.patch $xx
73                 echo -e "\nCopied ,new.patch to $xx"
74             else
75                 echo -e "\n*** Edit the diffs first. ***"
76             fi
77             ;;
78         [Aa]*)
79             apply=y
80             ;;
81         [Nn]*|'')
82             break
83             ;;
84         [Qq]*)
85             exit 0
86             ;;
87         esac
88     done
89 done