summaryrefslogtreecommitdiffstats
path: root/scripts/mkdiff
blob: 914bb0a6ea7a3ab0fd09739893bd6f51c24f920a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
#!/bin/sh

set -e

curr_ver=$(ls gnupg-*.tar.gz | sort -r -t '.' -n +0.4 -1 +1 -2 +2 \
	   | head -1 | sed -e 's/gnupg-\(.*\).tar.gz/\1/' )
prev_ver=$(ls gnupg-*.tar.gz | sort -r -t '.' -n +0.4 -1 +1 -2 +2 \
	   | head -2 | tail -1 | sed -e 's/gnupg-\(.*\).tar.gz/\1/' )

echo "Current  is: $curr_ver"
echo "Previous is: $prev_ver"

echo "Removing old directories"
[ -d "gnupg-$curr_ver" ] && rm -rf "gnupg-$curr_ver"
[ -d "gnupg-$prev_ver" ] && rm -rf "gnupg-$prev_ver"

echo "Unpacking previous and current tar"
tar xzf "gnupg-$curr_ver.tar.gz"
rm -f gnupg-${curr_ver}/po/*.gmo
tar xzf "gnupg-$prev_ver.tar.gz"
rm -f gnupg-${prev_ver}/po/*.gmo


echo "Diffing"
tmp_name="gnupg-$curr_ver.diff.tmp"
diff_name="gnupg-$curr_ver.diff"

diff -urN "gnupg-$prev_ver/" "gnupg-$curr_ver/"  > $tmp_name || true

echo "Making patch file"

cat <<EOF > $diff_name

This is a patch file against $prev_ver.

Please check the signature of this patch file:

    zcat somepath/gnupg-$curr_ver.diff.gz | gpg --verify

Change to directory gnupg-$prev_ver (or however you renamed it)
and give this command:

     zcat somepath/gnupg-$curr_ver.diff.gz | patch -p1

It is a good idea to rename your current directory to gnupg-$curr_ver now.



Prereq: $prev_ver

EOF

sed -ne '/^diff.*VERSION/,/^+[0-9][0-9]*/ p' $tmp_name >> $diff_name
echo  >> $diff_name
sed -e '/^diff.*VERSION/,/^+[0-9][0-9]*/ d'  $tmp_name >> $diff_name

rm $tmp_name

echo "Signing and compressing patch file"
gpg --clearsign --not-dash-escaped -u "(gnupg sig)" \
    < $diff_name | gzip --best > $diff_name.gz

echo "Checking patch file"
cd gnupg-$prev_ver
zcat ../$diff_name.gz | patch -s -p1
rm $(find . -name "*.orig")
cd ..

if ! diff -urN "gnupg-$prev_ver/" "gnupg-$curr_ver/" >/dev/null ; then
   echo "compare failed"
   exit 1
fi

if ! zcat $diff_name.gz | gpg --batch --verify ; then
    exit 1
fi


echo "cleaning up"

rm -rf "gnupg-$curr_ver"
rm -rf "gnupg-$prev_ver"

echo "Patch file $diff_name.gz is good."