File: explode-keyring

package info (click to toggle)
debian-keyring 2013.04.21
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 63,116 kB
  • sloc: sh: 510; perl: 256; makefile: 108
file content (37 lines) | stat: -rwxr-xr-x 984 bytes parent folder | download | duplicates (4)
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
#!/bin/sh

# Copyright (c) 2008 Jonathan McDowell <noodles@earth.li>
# GNU GPL; v2 or later
# Converts a keyring into individual keys.
# Taken from jetring-explode, Copyright 2007 Joey Hess <joeyh@debian.org>

set -e

if [ -z "$1" ] || [ -z "$2" ]; then
	echo "Usage: explode-keyring keyring dir" >&2
	exit 1
fi

# avoid gnupg touching ~/.gnupg
GNUPGHOME=$(mktemp -d -t jetring.XXXXXXXX)
export GNUPGHOME
trap cleanup exit
cleanup () {
	rm -rf "$GNUPGHOME"
}

keyring=$(readlink -f "$1") # gpg works better with absolute keyring paths
changesetdir="$2"

basename=$(basename "$keyring")
date=`date -R`

mkdir -p "$changesetdir"

for key in $(gpg --no-auto-check-trustdb --options /dev/null --no-default-keyring --keyring "$keyring" --list-keys --keyid-format long | grep '^pub' | sed -e 's!.*/!!' -e 's/ .*//'); do
	out="$changesetdir/0x$key"
	echo "$out"
	gpg --no-auto-check-trustdb --options /dev/null \
		--no-default-keyring --keyring "$keyring" \
		--export "$key" > "$out"
done