chiark / gitweb /
Fix “make distcheck” run outside of the source directory.
[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) <(awk '{print $2}' ${KEYMAPS_DIR}/*|sort -u))
17 [ -z "$missing" ] || {
18     echo "ERROR: unknown key names in extras/keymap/keymaps/*:" >&2
19     echo "$missing" >&2
20     exit 1
21 }
22
23 # check that all maps referred to in $RULES exist
24 maps=$(sed -rn '/keymap \$name/ { s/^.*\$name ([^"[:space:]]+).*$/\1/; p }' $RULES)
25 for m in $maps; do
26     # ignore inline mappings
27     [ "$m" = "${m#0x}" ] || continue
28
29     [ -e ${KEYMAPS_DIR}/$m ] || {
30         echo "ERROR: unknown map name in $RULES: $m" >&2
31         exit 1
32     }
33     grep -q "extras/keymap/keymaps/$m\>" $SRCDIR/Makefile.am || {
34         echo "ERROR: map file $m is not added to Makefile.am" >&2
35         exit 1
36     }
37 done