added option export
[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 read
22
23 echo "Diffing"
24 tmp_name="g10-$curr_ver.diff.tmp"
25 diff_name="g10-$curr_ver.diff"
26
27 diff -urN "g10-$prev_ver/" "g10-$curr_ver/"  > $tmp_name || true
28
29 echo "Making patch file"
30
31 cat <<EOF > $diff_name
32
33 This is a patch file against $prev_ver.
34
35 Change to directory g10-$prev_ver (or however you renamed it)
36 and give this command:
37
38      zcat somepath/g10-$curr_ver.diff.gz | patch -p1
39
40 It is a good idea to rename your current directory to g10-$curr_ver now.
41
42
43
44 Prereq: $prev_ver
45
46 EOF
47
48 sed -ne '/^diff.*VERSION/,/^+[0-9][0-9]*/ p' $tmp_name >> $diff_name
49 echo  >> $diff_name
50 sed -e '/^diff.*VERSION/,/^+[0-9][0-9]*/ d'  $tmp_name >> $diff_name
51
52 rm $tmp_name
53
54 echo "Compressing patch file"
55 gzip -9 $diff_name
56
57 echo "Checking patch file"
58 cd g10-$prev_ver
59 zcat ../$diff_name.gz | patch -s -p1
60 rm $(find . -name "*.orig")
61 cd ..
62
63 if ! diff -urN "g10-$prev_ver/" "g10-$curr_ver/" >/dev/null ; then
64    echo "compare failed"
65    exit 1
66 fi
67
68
69 echo "cleaning up"
70
71 rm -rf "g10-$curr_ver"
72 rm -rf "g10-$prev_ver"
73
74 echo "Patch file $diff_name.gz is good."
75
76
77