See ChangeLog: Mon Mar 8 21:53:47 CET 1999 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 gpg --clearsign --not-dash-escaped -u "(gnupg sig)" \
61     < $diff_name | gzip --best > $diff_name.gz
62 rm $diff_name
63
64 echo "Checking patch file"
65 cd gnupg-$prev_ver
66 zcat ../$diff_name.gz | patch -s -p1
67 rm $(find . -name "*.orig") 2>/dev/null || true
68 cd ..
69
70 if ! diff -urN "gnupg-$prev_ver/" "gnupg-$curr_ver/" >/dev/null ; then
71    echo "compare failed"
72    exit 1
73 fi
74
75 if ! zcat $diff_name.gz | gpg --batch --verify ; then
76     exit 1
77 fi
78
79
80 echo "cleaning up"
81
82 rm -rf "gnupg-$curr_ver"
83 rm -rf "gnupg-$prev_ver"
84
85 echo "Patch file $diff_name.gz is good."
86
87
88