chiark / gitweb /
extras/keymap/check-keymaps.sh: Ignore comment-only lines
[elogind.git] / extras / keymap / check-keymaps.sh
1 #!/bin/bash
2
3 # check that all key names in keymaps/* are known in <linux/input.h>
4 # and that all key maps listed in the rules are valid and present in
5 # Makefile.am
6 SRCDIR=$1
7 KEYLIST=$2
8 KEYMAPS_DIR=$SRCDIR/extras/keymap/keymaps #extras/keymap/keymaps
9 RULES=$SRCDIR/extras/keymap/95-keymap.rules
10
11 [ -e "$KEYLIST" ] || {
12     echo "need $KEYLIST please build first" >&2
13     exit 1
14 }
15
16 missing=$(join -v 2 <(awk '{print tolower(substr($1,5))}' $KEYLIST | sort -u) \
17                     <(grep -hv '^#' ${KEYMAPS_DIR}/*| awk '{print $2}' | sort -u))
18 [ -z "$missing" ] || {
19     echo "ERROR: unknown key names in extras/keymap/keymaps/*:" >&2
20     echo "$missing" >&2
21     exit 1
22 }
23
24 # check that all maps referred to in $RULES exist
25 maps=$(sed -rn '/keymap \$name/ { s/^.*\$name ([^"[:space:]]+).*$/\1/; p }' $RULES)
26 for m in $maps; do
27     # ignore inline mappings
28     [ "$m" = "${m#0x}" ] || continue
29
30     [ -e ${KEYMAPS_DIR}/$m ] || {
31         echo "ERROR: unknown map name in $RULES: $m" >&2
32         exit 1
33     }
34     grep -q "extras/keymap/keymaps/$m\>" $SRCDIR/Makefile.am || {
35         echo "ERROR: map file $m is not added to Makefile.am" >&2
36         exit 1
37     }
38 done