blob: 769a0805ef4da776d473e631fa69946f215e897d (
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
88
89
90
91
92
93
94
95
96
97
98
|
#!/bin/sh
# Copyright (c) 2008 Jonathan McDowell <noodles@earth.li>
# GNU GPL; v2 or later
# Updates an existing key in a keyring dir
set -e
if [ "x$1" = "x--no-clean" ]; then
NOCLEAN=1
shift
else
NOCLEAN=0
fi
if [ -z "$1" ] || [ -z "$2" ]; then
echo "Usage: update-key keyfile dir" >&2
exit 1
fi
# avoid gnupg touching ~/.gnupg
GNUPGHOME=$(mktemp -d -t jetring.XXXXXXXX)
export GNUPGHOME
cat > "$GNUPGHOME"/gpg.conf <<EOF
keyid-format 0xlong
no-auto-check-trustdb
no-autostart
EOF
if [ "$NOCLEAN" = "0" ]; then
echo "import-options import-clean" >> "$GNUPGHOME"/gpg.conf
echo "export-options export-clean,no-export-attributes" >> "$GNUPGHOME"/gpg.conf
cat output/keyrings/debian-keyring.gpg \
output/keyrings/debian-nonupload.gpg \
output/keyrings/debian-maintainers.gpg > $GNUPGHOME/pubring.gpg
fi
trap cleanup exit
cleanup () {
rm -rf "$GNUPGHOME"
}
keyfile=$(readlink -f "$1") # gpg works better with absolute keyring paths
keydir="$2"
basename=$(basename "$keyfile")
date=`date -R`
keyid=$(gpg --quiet --with-colons < $keyfile | grep '^pub' | head -n 1 | cut -d : -f 5)
name=$(gpg --quiet --with-colons < $keyfile | grep '^uid' | head -n 1 | cut -d : -f 10 | sed -e 's/ <.*//')
if [ ! -e $keydir/0x$keyid ]; then
echo "0x$keyid isn't already in $keydir - new key or error."
exit 1
fi
gpg --quiet --import $keydir/0x$keyid
summary=$(gpg --import $keyfile 2>&1 | \
scripts/parse-gpg-update 0x$keyid "$name")
gpg --export $keyid > $GNUPGHOME/0x$keyid
case "$summary" in
*:*)
# Something changed
;;
*)
# Nothing changed, exit
echo "No changes to $summary"
exit
esac
if cmp -s $GNUPGHOME/0x$keyid $keydir/0x$keyid; then
echo "No changes to 0x$keyid"
exit
fi
n='a'
while [ "x$n" = "xa" -o "x$n" = "xA" ]; do
echo "Running gpg-diff:"
(
echo $summary
echo
scripts/gpg-diff $keydir/0x$keyid $GNUPGHOME/0x$keyid
) | sensible-pager
echo "Are you sure you want to update this key? (y/n/a: Yes/No/Again)"
read n
done
if [ "x$n" = "xy" -o "x$n" = "xY" ]; then
mv $GNUPGHOME/0x$keyid $keydir/0x$keyid
git add $keydir/0x$keyid
echo "Updated key."
echo $summary >> update.log
else
echo "Not updating key."
fi
|