summaryrefslogtreecommitdiff
path: root/update-keys
blob: 25443a8fa2764d6a14c4c5f4ea3ed0e664981b9b (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
#!/bin/bash

export LANG=C

TMPDIR=$(mktemp -d)
trap "rm -rf '${TMPDIR}'" EXIT

KEYSERVER='hkp://keys.gnupg.net'
GPG_OPTIONS='--quiet --batch --no-tty --no-permission-warning'
GPG="gpg ${GPG_OPTIONS} --keyserver "${KEYSERVER}" --homedir ${TMPDIR}"

pushd "$(dirname "$0")" >/dev/null

$GPG --gen-key <<EOF
%echo Generating Arch Linux Ewe Keyring keychain master key...
Key-Type: RSA
Key-Length: 1024
Key-Usage: sign
Name-Real: Arch Linux Ewe Keyring Keychain Master Key
Name-Email: archlinuxewe-keyring@localhost
Expire-Date: 0
%no-protection
%no-ask-passphrase
%commit
%echo Done
EOF

rm -rf master master-revoked archlinuxewe-trusted archlinuxewe-revoked
mkdir master master-revoked

while read -ra data; do
	keyid="${data[0]}"
	username="${data[@]:1}"
	${GPG} --recv-keys ${keyid} &>/dev/null
	gpg ${GPG_OPTIONS} -a --export ${keyid} </dev/null | \
		${GPG} --import &>/dev/null
	curl -Ss "https://archlinux32.org/keys.php?k=${keyid}" | \
		${GPG} --import &>/dev/null
	printf 'minimize\nquit\ny\n' | \
		${GPG} --command-fd 0 --edit-key ${keyid}
	${GPG} --yes --lsign-key ${keyid} &>/dev/null
	${GPG} --armor --no-emit-version --export ${keyid} >> master/${username}.asc
	echo "${keyid}:4:" >> archlinuxewe-trusted
done < master-keyids
${GPG} --import-ownertrust < archlinuxewe-trusted 2>/dev/null

touch archlinuxewe-revoked

while read -ra data; do
	keyid="${data[0]}"
	username="${data[2]}"
	${GPG} --recv-keys ${keyid} &>/dev/null
	gpg ${GPG_OPTIONS} -a --export ${keyid} | \
		${GPG} --import &>/dev/null
	curl -Ss "https://archlinux32.org/keys.php?k=${keyid}" | \
		${GPG} --import &>/dev/null
	printf 'clean\nquit\ny\n' | \
		${GPG} --command-fd 0 --edit-key ${keyid}
	if ! ${GPG} --list-keys --with-colons ${keyid} 2>/dev/null | grep -q '^pub:f:'; then
		${GPG} --armor --no-emit-version --export ${keyid} >> master-revoked/${username}.asc
		echo "${keyid}" >> archlinuxewe-revoked
	else
		echo "key is still fully trusted: ${keyid} ${username}"
	fi
done < master-revoked-keyids

cat master/*.asc master-revoked/*.asc packager/*.asc packager-revoked/*.asc > archlinuxewe.gpg

popd >/dev/null