See ChangeLog: Fri Nov 27 15:30:24 CET 1998 Werner Koch
[gnupg.git] / scripts / mkdiff
1 #!/bin/sh
2
3 set -e
4
5 curr_ver=$(ls gnupg-*.tar.gz | sort -r -t '.' -n +0.4 -1 +1 -2 +2 \
6            | head -1 | sed -e 's/gnupg-\(.*\).tar.gz/\1/' )
7 prev_ver=$(ls gnupg-*.tar.gz | sort -r -t '.' -n +0.4 -1 +1 -2 +2 \
8            | head -2 | tail -1 | sed -e 's/gnupg-\(.*\).tar.gz/\1/' )
9
10 echo "Current  is: $curr_ver"
11 echo "Previous is: $prev_ver"
12
13 echo "Removing old directories"
14 [ -d "gnupg-$curr_ver" ] && rm -rf "gnupg-$curr_ver"
15 [ -d "gnupg-$prev_ver" ] && rm -rf "gnupg-$prev_ver"
16
17 echo "Unpacking previous and current tar"
18 tar xzf "gnupg-$curr_ver.tar.gz"
19 rm -f gnupg-${curr_ver}/po/*.gmo
20 tar xzf "gnupg-$prev_ver.tar.gz"
21 rm -f gnupg-${prev_ver}/po/*.gmo
22
23
24 echo "Diffing"
25 tmp_name="gnupg-$curr_ver.diff.tmp"
26 diff_name="gnupg-$curr_ver.diff"
27
28 diff -urN "gnupg-$prev_ver/" "gnupg-$curr_ver/"  > $tmp_name || true
29
30 echo "Making patch file"
31
32 cat <<EOF > $diff_name
33
34 This is a patch file against $prev_ver.
35
36 Please check the signature of this patch file:
37
38     zcat somepath/gnupg-$curr_ver.diff.gz | gpg --verify
39
40 Change to directory gnupg-$prev_ver (or however you renamed it)
41 and give this command:
42
43      zcat somepath/gnupg-$curr_ver.diff.gz | patch -p1
44
45 It is a good idea to rename your current directory to gnupg-$curr_ver now.
46
47
48
49 Prereq: $prev_ver
50
51 EOF
52
53 sed -ne '/^diff.*VERSION/,/^+[0-9][0-9]*/ p' $tmp_name >> $diff_name
54 echo  >> $diff_name
55 sed -e '/^diff.*VERSION/,/^+[0-9][0-9]*/ d'  $tmp_name >> $diff_name
56
57 rm $tmp_name
58
59 echo "Signing and compressing patch file"
60 ../gnupg/g10/gpg --clearsign --not-dash-escaped -u "(gnupg sig)" \
61     < $diff_name | gzip --best > $diff_name.gz
62
63 echo "Checking patch file"
64 cd gnupg-$prev_ver
65 zcat ../$diff_name.gz | patch -s -p1
66 rm $(find . -name "*.orig")
67 cd ..
68
69 if ! diff -urN "gnupg-$prev_ver/" "gnupg-$curr_ver/" >/dev/null ; then
70    echo "compare failed"
71    exit 1
72 fi
73
74 if ! zcat $diff_name.gz | ../gnupg/g10/gpg --batch --verify ; then
75     exit 1
76 fi
77
78
79 echo "cleaning up"
80
81 rm -rf "gnupg-$curr_ver"
82 rm -rf "gnupg-$prev_ver"
83
84 echo "Patch file $diff_name.gz is good."
85
86
87