Removed some trash
[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 Change to directory gnupg-$prev_ver (or however you renamed it)
37 and give this command:
38
39      zcat somepath/gnupg-$curr_ver.diff.gz | patch -p1
40
41 It is a good idea to rename your current directory to gnupg-$curr_ver now.
42
43
44
45 Prereq: $prev_ver
46
47 EOF
48
49 sed -ne '/^diff.*VERSION/,/^+[0-9][0-9]*/ p' $tmp_name >> $diff_name
50 echo  >> $diff_name
51 sed -e '/^diff.*VERSION/,/^+[0-9][0-9]*/ d'  $tmp_name >> $diff_name
52
53 rm $tmp_name
54
55 echo "Compressing patch file"
56 gzip -9 $diff_name
57
58 echo "Checking patch file"
59 cd gnupg-$prev_ver
60 zcat ../$diff_name.gz | patch -s -p1
61 rm $(find . -name "*.orig")
62 cd ..
63
64 if ! diff -urN "gnupg-$prev_ver/" "gnupg-$curr_ver/" >/dev/null ; then
65    echo "compare failed"
66    exit 1
67 fi
68
69
70 echo "cleaning up"
71
72 rm -rf "gnupg-$curr_ver"
73 rm -rf "gnupg-$prev_ver"
74
75 echo "Patch file $diff_name.gz is good."
76
77
78