A shell script that makes it easier to verify and fix the patches.
[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 cvsdir=,cvsdir-for-patch-tests
13 tmpdir=,tmpdir-for-patch-tests
14
15 [ -d $tmpdir ] || mkdir $tmpdir
16 cvs -d "$root" co -d $cvsdir rsync
17
18 cd $tmpdir || exit 1
19
20 if [ -z "$1" ]; then
21     set -- ../*.diff
22 fi
23
24 for xx in "${@}"; do
25     case "$xx" in
26     *gzip-rsyncable.diff) continue ;;
27     patches/*) xx=`echo $xx | sed 's:patches:..:'` ;;
28     */*.diff) ;;
29     *.diff) xx=../$xx ;;
30     *) continue ;;
31     esac
32     rsync -a --delete ../$cvsdir/ .
33     echo -e "\n----------- $xx ------------"
34     patch -p0 <$xx | tee ,patch.output
35     new=''
36     for nn in `sed -n 's/^patching file //p' ,patch.output`; do
37         [ -f ../$cvsdir/$nn ] || new="$new $nn"
38     done
39     while : ; do
40         echo -ne "\nFix rejections, Make proto.h, Edit diffs, Update, Next: [n] "
41         read ans
42         case "$ans" in
43         '') break ;;
44         [Ee]*)
45             [ ! -z "$new" ] && cvs add $new
46             new=''
47             rm -f *.rej *.orig
48             cvs diff -N | grep -v '^Index: ' |
49                 grep -v '^=========' |
50                 grep -v '^diff -' |
51                 grep -v '^RCS file: ' |
52                 grep -v '^retrieving revision ' >,new.patch
53             vim -d $xx ,new.patch
54             ;;
55         [Ff]*)
56             vim *.rej
57             ;;
58         [Mm]*)
59             cat *.c lib/compat.c | awk -f mkproto.awk >proto.h
60             echo -e "\nRegenerated proto.h"
61             ;;
62         [Uu]*)
63             if [ -f ,new.patch ]; then
64                 cp -p ,new.patch $xx
65                 echo -e "\nCopied ,new.patch to $xx"
66             else
67                 echo -e "\n*** Edit the diffs first. ***"
68             fi
69             ;;
70         esac
71     done
72 done