summaryrefslogtreecommitdiff
path: root/bin/meta-check
blob: 3eeb4c1daa9a7507e3af162b8af6f8dc184fcb8b (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
#!/bin/bash
# TODO: update to the split YAML files

######################################################################

. libremessages

file=$cfg_hackers
ret=0

norm=$(mktemp --tmpdir)
trap "rm -f -- $(printf '%q' "$norm")" EXIT
"$(dirname "$0")/meta-normalize-stdio" < "$file" > "$norm" || exit 1

usernames=($(<"$norm" sed -n 's/^[ -] username: //p' | sort))

dups=($(printf '%s\n' "${usernames[@]}" | uniq -d))
if (( ${#dups[@]} )); then
	error 'Duplicate usernames:'
	plain '%s' "${dups[@]}"
	ret=1
fi

illegal=($(printf '%s\n' "${usernames[@]}" | grep -v '^[a-z][a-z0-9]*$'))
if (( ${#illegal[@]} )); then
	error 'Illegal usernames:'
	plain '%s' "${illegal[@]}"
	ret=1
fi

if "$(dirname "$0")/list-pgp-keyids" | grep -Ev '^(trusted|secondary|revoked)/[a-z][a-z0-9]* [0-9A-F]{40}$'; then
	error 'Bad pgp keys ^^^'
	ret=1
fi

colordiff -u "$file" "$norm" || ret=$?

exit $ret