summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke Shumaker <lukeshu@sbcglobal.net>2014-12-19 23:18:02 -0500
committerLuke Shumaker <lukeshu@sbcglobal.net>2014-12-19 23:18:02 -0500
commita129362daeaafb0288e4d75f816973a46a7c9d16 (patch)
treeb86718f812b77c855c93c3531f71c9230bdb2f50
parent4d57d910a4cfeae6f1e5bfea646053b489324ce2 (diff)
bin/meta-check: update
-rwxr-xr-xbin/meta-check71
1 files changed, 37 insertions, 34 deletions
diff --git a/bin/meta-check b/bin/meta-check
index 3eeb4c1..eb4f8c7 100755
--- a/bin/meta-check
+++ b/bin/meta-check
@@ -1,38 +1,41 @@
#!/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
+PATH="$(dirname "$0"):$PATH"
+
+check-yaml() {
+ file=$1
+ msg 'Inspecting %q' "$file"
+ norm=$(mktemp --tmpdir)
+ trap "rm -f -- $(printf '%q' "$norm")" RETURN
+ meta-normalize-stdio < "$file" > "$norm" || return $?
+ colordiff -u "$file" "$norm" || return $?
+}
+
+main() {
+ declare -i ret=0
+
+ # Check the user YAML files
+ for file in users/*.yml; do
+ check-yaml "$file" || ret=$?
+ done
+
+ # Make sure there are no duplicate usernames
+ dups=($(sed -n 's/^username: //p' -- users/*.yml| sort | uniq -d))
+ if (( ${#dups[@]} )); then
+ error 'Duplicate usernames:'
+ plain '%s' "${dups[@]}"
+ ret=1
+ fi
+
+ # Check to make sure the pgp keys are OK
+ if pgp-list-keyids | grep -Ev '^(trusted|secondary|revoked)/[a-z][a-z0-9]* [0-9A-F]{40}$'; then
+ error 'Bad pgp keys ^^^'
+ ret=1
+ fi
+
+ return $ret
+}
+
+main "$@"