summaryrefslogtreecommitdiff
path: root/udev/check.sh
diff options
context:
space:
mode:
Diffstat (limited to 'udev/check.sh')
-rwxr-xr-xudev/check.sh31
1 files changed, 31 insertions, 0 deletions
diff --git a/udev/check.sh b/udev/check.sh
new file mode 100755
index 0000000..97bbb97
--- /dev/null
+++ b/udev/check.sh
@@ -0,0 +1,31 @@
1#!/bin/sh -u
2
3# Copyright (c) 2020 Yubico AB. All rights reserved.
4# Use of this source code is governed by a BSD-style
5# license that can be found in the LICENSE file.
6
7sort_by_id() {
8 awk '{ printf "%d\n", $3 }' | sort -Cnu
9}
10
11if ! grep '^vendor' "$1" | sort_by_id; then
12 echo unsorted vendor section 1>&2
13 exit 1
14fi
15
16VENDORS=$(grep '^vendor' "$1" | awk '{ print $2 }')
17PRODUCTS=$(grep '^product' "$1" | awk '{ print $2 }' | uniq)
18
19if [ "${VENDORS}" != "${PRODUCTS}" ]; then
20 echo vendors: "$(echo "${VENDORS}" | tr '\n' ',')" 1>&2
21 echo products: "$(echo "${PRODUCTS}" | tr '\n' ',')" 1>&2
22 echo vendors and products in different order 1>&2
23 exit 2
24fi
25
26for v in ${VENDORS}; do
27 if ! grep "^product ${v}" "$1" | sort_by_id; then
28 echo "${v}": unsorted product section 1>&2
29 exit 3
30 fi
31done