chiark / gitweb /
c4572745e031b532f21be3444c4d4696387475c1
[elogind.git] / src / udev / 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:-src/udev/keymap/keys.txt}
8 KEYMAPS_DIR=$SRCDIR/keymaps
9 RULES=$SRCDIR/src/udev/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 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 "keymaps/$m\>" $SRCDIR/Makefile.am || {
35                 echo "ERROR: map file $m is not added to Makefile.am" >&2
36                 exit 1
37         }
38 done