3
# Copyright (c) 2013 Gunnar Wolf <gwolf@debian.org>,
4
# Based on 2008 Jonathan McDowell <noodles@earth.li>
6
# Moves an existing key to another keyring directory
10
if [ -z "$1" ] || [ -z "$2" ]; then
11
echo "Usage: move-key keyid dir" >&2
16
destdir=$(readlink -f $2)
18
# avoid gnupg touching ~/.gnupg
19
GNUPGHOME=$(mktemp -d -t jetring.XXXXXXXX)
26
if [ $(echo -n $key|wc -c) -eq 16 ]; then
27
key='0x'$(echo $key|tr a-z A-Z)
28
elif [ $(echo -n $key|wc -c) -eq 40 ] ; then
29
key='0x'$(echo -n $key | cut -b 25-)
32
if [ ! -d "$destdir" ] || echo "$destdir"|grep -q -- '-gpg/?$'; then
33
echo "Error: $destdir is not a valid keyring directory" >& 2
38
if [ -f $dir/$key ]; then
39
keyfile=$(readlink -f "$dir/$key")
40
srcdir=$(readlink -f $dir)
45
if [ "$srcdir" = "$destdir" ]; then
46
echo "Source and destination directories are the same: $srcdir" >& 2
50
if [ -z "$keyfile" ]; then
51
echo "Requested key '$key' not found"
55
keyuser=$(gpg --with-colons --keyid long --options /dev/null --no-auto-check-trustdb < $keyfile| grep '^pub' | cut -d : -f 10)
58
echo "About to move key $key ($keyuser)"
61
echo "Are you sure you want to update this key? (y/n)"
64
if [ "x$n" = "xy" -o "x$n" = "xY" ]; then
66
echo -n "Enter full name of new key's owner: "
68
echo -n 'RT issue ID this change closes, if any: '
72
if ( echo $destdir | egrep -q 'debian-keyring-gpg/?$' ); then
73
log="Add new DD key $key ($name) $rtid"
75
elif ( echo $destdir | egrep -q 'debian-nonupload-gpg/?$' ); then
76
log="Add new nonuploading key $key ($name) $rtid"
78
elif ( echo $destdir | egrep -q 'debian-maintainer-gpg/?$' ); then
79
log="Add new DM key $key ($name) $rtid"
80
elif ( echo $destdir | egrep -q 'debian-emeritus-gpg/?$' ); then
81
log="Move $key to emeritus ($name) $rtid"
82
elif ( echo $destdir | egrep -q 'debian-removed-gpg/?$' ); then
83
log="Move $key ($name) to removed keyring $rtid"
86
bzr mv $keyfile $destdir
87
dch -D UNRELEASED -a "$log"
89
if [ ! -z "$add_to_keyid" ]; then
90
if oldkey=$(grep $key keyids); then
91
echo "Key already present in the keyids file:"
94
echo -n "Enter Debian login of new key: "
96
echo "$key $name <$login>" >> keyids
97
sort keyids > keyids.$$ && mv keyids.$$ keyids
101
echo "Not moving key."