summaryrefslogtreecommitdiffstats
path: root/t/dm-vs-dd.t
blob: 6b1a99c9162002b4ea7f83c8ec6f700f06f53efa (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
#!/bin/sh
# Compares the DM keyring with the DD keyring. If the same name or email is
# in both keyrings, that's an error.
set -e

list_uids () {
	gpg --no-options --no-auto-check-trustdb --no-default-keyring \
		--keyring "$1" --list-keys | grep -a '^uid' | sed 's/^uid *//' |
		egrep -a -v '\[jpeg image of size .*\]'
}

list_names () {
	sed 's/ <.*>//'
}

list_emails () {
	sed 's/.* <\(.*\)>/\1/'
}

fail=0

dd_uids=$(list_uids ./output/keyrings/debian-keyring.gpg)
(
	echo "$dd_uids" | list_emails
	echo "$dd_uids" | list_names
	echo "$dd_uids"
) | sort | uniq > dd-list.tmp

IFS="
"
for uid in $(list_uids ./output/keyrings/debian-maintainers.gpg | sort | uniq); do
	name=$(echo "$uid" | list_names)
	email=$(echo "$uid" | list_emails)
	if grep -a -q "^$uid$" dd-list.tmp; then
		echo "$uid is in both the DD and DM keyrings"
		fail=1
	elif grep -a "^$name$" dd-list.tmp; then
		echo "warning: name $name is in both the DD and DM keyrings"
	elif grep -a "^$email$" dd-list.tmp; then
		echo "email $email is in both the DD and DM keyrings"
		fail=1
	fi
done

rm -f dd-list.tmp

exit $fail