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