genrules.awk revision 1.1 1 #!/usr/bin/awk -f
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
7 NR == 1 {
8 print "# Copyright (c) 2020 Yubico AB. All rights reserved."
9 print "# Use of this source code is governed by a BSD-style"
10 print "# license that can be found in the LICENSE file."
11 print ""
12 print "# This file is automatically generated, and should"
13 print "# be used with udev 188 or newer."
14 print ""
15 print "ACTION!=\"add|change\", GOTO=\"fido_end\""
16
17 next
18 }
19
20 $1 == "vendor" {
21 sub("0x", "", $3)
22 vendors[$2, "id"] = $3
23
24 f = 4
25 while (f <= NF) {
26 vendors[$2, "name"] = vendors[$2, "name"] " " $f
27 f++
28 }
29 }
30
31 $1 == "product" {
32 sub("0x", "", $3)
33 name = ""
34
35 f = 4
36 while (f <= NF) {
37 name = name " " $f
38 f++
39 }
40
41 line = "\n#" name " by" vendors[$2, "name"]"\n"
42 line = line"KERNEL==\"hidraw*\""
43 line = line", SUBSYSTEM==\"hidraw\""
44 line = line", ATTRS{idVendor}==\""vendors[$2, "id"]"\""
45 line = line", ATTRS{idProduct}==\""$3"\""
46 line = line", TAG+=\"uaccess\""
47 line = line", GROUP=\"plugdev\""
48 line = line", MODE=\"0660\""
49
50 print line
51 }
52
53 END {
54 print "\nLABEL=\"fido_end\""
55 }
56