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