* parse-packet.c (dump_sig_subpkt, parse_signature), build-packet.c
[gnupg.git] / scripts / mkdiff
blobf17979383ee9869917dd862546951da0cd4d5570
1 #!/bin/sh
2 # Copyright (C) 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
4 # This file is free software; as a special exception the author gives
5 # unlimited permission to copy and/or distribute it, with or without
6 # modifications, as long as this notice is preserved.
8 # This program is distributed in the hope that it will be useful, but
9 # WITHOUT ANY WARRANTY, to the extent permitted by law; without even the
10 # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12 # Please note that this script is now maintained outside of GNUPG.
13 # To get the most up to date version use
14 # cvs -d :pserver:anoncvs@cvs.gnupg.org:/cvs/wk checkout misc-scripts/mkdiff
16 if [ $# != 1 ] ; then
17 echo "usage: mkdiff package-name" >&2
18 exit 1
21 pack="$1"
23 set -e
25 curr_ver=$(ls $pack-*.tar.gz 2>/dev/null | sed "s/^$pack-\(.*\)\.tar\.gz/\1/"\
26 | sort -r -t '.' -n +0 -1 +1 -2 +2 | head -1 )
27 if [ ! -f $pack-$curr_ver.tar.gz ]; then
28 echo "mkdiff: no current version of package $pack found" >&2
29 exit 1
31 prev_ver=$(ls $pack-*.tar.gz 2>/dev/null | sed "s/^$pack-\(.*\)\.tar\.gz/\1/"\
32 | sort -r -t '.' -n +0 -1 +1 -2 +2 | head -2 | tail -1 )
33 if [ "$prev_ver" = "$curr_ver" ]; then
34 echo "mkdiff: no previous version of package $pack found" >&2
35 exit 1
38 echo "Current is: $pack-$curr_ver"
39 echo "Previous is: $pack-$prev_ver"
42 echo "Removing old directories"
43 [ -d "$pack-$curr_ver" ] && rm -rf "$pack-$curr_ver"
44 [ -d "$pack-$prev_ver" ] && rm -rf "$pack-$prev_ver"
46 echo "Unpacking previous and current tar"
47 tar xzf "$pack-$curr_ver.tar.gz"
48 rm -f $pack-${curr_ver}/po/*.gmo
49 tar xzf "$pack-$prev_ver.tar.gz"
50 rm -f $pack-${prev_ver}/po/*.gmo
53 echo "Diffing"
54 tmp_name="$pack-$prev_ver-$curr_ver.diff.tmp"
55 diff_name="$pack-$prev_ver-$curr_ver.diff"
57 diff -urN "$pack-$prev_ver/" "$pack-$curr_ver/" > $tmp_name || true
59 echo "Making patch file"
61 cat <<EOF > $diff_name
63 This is a patch file to create version $curr_ver from $prev_ver.
65 Please check the signature of this patch file:
67 zcat somepath/$pack-$prev_ver-$curr_ver.diff.gz | gpg --verify
69 Change to directory $pack-$prev_ver (or however you renamed it)
70 and give this command:
72 zcat somepath/$pack-$prev_ver-$curr_ver.diff.gz | patch -p1
74 It is a good idea to rename your current directory to $pack-$curr_ver now.
78 Prereq: $prev_ver
80 EOF
82 sed -ne '/^diff.*VERSION/,/^+[0-9][0-9]*/ p' $tmp_name >> $diff_name
83 echo >> $diff_name
84 sed -e '/^diff.*VERSION/,/^+[0-9][0-9]*/ d' $tmp_name >> $diff_name
86 rm $tmp_name
88 echo "Signing and compressing patch file"
89 gpg --clearsign --not-dash-escaped -u 57548DCD \
90 < $diff_name | gzip --best > $diff_name.gz
91 rm $diff_name
93 echo "Checking patch file"
94 cd $pack-$prev_ver
95 zcat ../$diff_name.gz | patch -s -p1
96 rm $(find . -name "*.orig") 2>/dev/null || true
97 cd ..
99 if ! diff -urN "$pack-$prev_ver/" "$pack-$curr_ver/" >/dev/null ; then
100 echo "compare failed"
101 exit 1
104 if ! zcat $diff_name.gz | gpg --batch --verify ; then
105 exit 1
109 echo "cleaning up"
111 rm -rf "$pack-$curr_ver"
112 rm -rf "$pack-$prev_ver"
114 echo "Patch file $diff_name.gz is good."