Changed the directory structure a little and added a quit command.
[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     rsync -a --delete ../,cvsdir/ .
36     echo -e "\n----------- $xx ------------"
37     patch -p0 <$xx | tee ,patch.output
38     new=''
39     for nn in `sed -n 's/^patching file //p' ,patch.output`; do
40         [ -f ../,cvsdir/$nn ] || new="$new $nn"
41     done
42     while : ; do
43         echo -ne "\nFix rejections, Make proto.h, Edit diffs, Update, Next, Quit: [n] "
44         read ans
45         case "$ans" in
46         [Ee]*)
47             [ ! -z "$new" ] && cvs add $new
48             new=''
49             rm -f *.rej *.orig
50             cvs diff -N | grep -v '^Index: ' |
51                 grep -v '^=========' |
52                 grep -v '^diff -' |
53                 grep -v '^RCS file: ' |
54                 grep -v '^retrieving revision ' >,new.patch
55             vim -d $xx ,new.patch
56             ;;
57         [Ff]*)
58             vim *.rej
59             ;;
60         [Mm]*)
61             cat *.c lib/compat.c | awk -f mkproto.awk >proto.h
62             echo -e "\nRegenerated proto.h"
63             ;;
64         [Uu]*)
65             if [ -f ,new.patch ]; then
66                 cp -p ,new.patch $xx
67                 echo -e "\nCopied ,new.patch to $xx"
68             else
69                 echo -e "\n*** Edit the diffs first. ***"
70             fi
71             ;;
72         [Nn]*|'')
73             break
74             ;;
75         [Qq]*)
76             exit 0
77             ;;
78         esac
79     done
80 done