9 open(IN, "<", "usb.ids");
10 open(OUT, ">", "20-usb-vendor-model.hwdb");
11 print(OUT "# This file is part of systemd.\n" .
13 "# Data imported from: http://www.linux-usb.org/usb.ids\n");
15 while (my $line = <IN>) {
17 $line =~ m/^([0-9a-f]{4})\s*(.+)$/;
22 print(OUT "usb:v" . $vendor . "*\n");
23 print(OUT " ID_VENDOR_FROM_DATABASE=" . $text . "\n");
27 $line =~ m/^\t([0-9a-f]{4})\s*(.+)$/;
32 print(OUT "usb:v" . $vendor . "p" . $model . "*\n");
33 print(OUT " ID_MODEL_FROM_DATABASE=" . $text . "\n");
46 open(IN, "<", "usb.ids");
47 open(OUT, ">", "20-usb-classes.hwdb");
48 print(OUT "# This file is part of systemd.\n" .
50 "# Data imported from: http://www.linux-usb.org/usb.ids\n");
52 while (my $line = <IN>) {
55 $line =~ m/^C\ ([0-9a-f]{2})\s*(.+)$/;
58 if ($class =~ m/^00$/) {
63 print(OUT "usb:v*p*d*dc" . $class . "*\n");
64 print(OUT " ID_USB_CLASS_FROM_DATABASE=" . $text . "\n");
68 if (not defined $class) {
70 } elsif ($line =~ m/^$/) {
74 $line =~ m/^\t([0-9a-f]{2})\s*(.+)$/;
77 if ($subclass =~ m/^00$/) {
81 if ($text =~ m/^(\?|None|Unused)$/) {
85 print(OUT "usb:v*p*d*dc" . $class . "dsc" . $subclass . "*\n");
86 print(OUT " ID_USB_SUBCLASS_FROM_DATABASE=" . $text . "\n");
90 $line =~ m/^\t\t([0-9a-f]{2})\s*(.+)$/;
94 if ($text =~ m/^(\?|None|Unused)$/) {
98 print(OUT "usb:v*p*d*dc" . $class . "dsc" . $subclass . "dp" . $protocol . "*\n");
99 print(OUT " ID_USB_PROTOCOL_FROM_DATABASE=" . $text . "\n");
112 open(IN, "<", "pci.ids");
113 open(OUT, ">", "20-pci-vendor-model.hwdb");
114 print(OUT "# This file is part of systemd.\n" .
116 "# Data imported from: http://pci-ids.ucw.cz/v2.2/pci.ids\n");
118 while (my $line = <IN>) {
120 $line =~ m/^([0-9a-f]{4})\s*(.+)$/;
126 print(OUT "pci:v0000" . $vendor . "*\n");
127 print(OUT " ID_VENDOR_FROM_DATABASE=" . $text . "\n");
131 $line =~ m/^\t([0-9a-f]{4})\s*(.+)$/;
136 print(OUT "pci:v0000" . $vendor . "d0000" . $device . "*\n");
137 print(OUT " ID_MODEL_FROM_DATABASE=" . $device_text . "\n");
141 $line =~ m/^\t\t([0-9a-f]{4})\s*([0-9a-f]{4})\s*(.*)$/;
143 my $sub_vendor = uc $1;
144 my $sub_device = uc $2;
146 $sub_text =~ s/^\Q$device_text\E\s*//;
147 $sub_text =~ s/(.+)/\ ($1)/;
149 print(OUT "pci:v0000" . $vendor . "d0000" . $device . "sv0000" . $sub_vendor . "sd0000" . $sub_device . "*\n");
150 print(OUT " ID_MODEL_FROM_DATABASE=" . $device_text . $sub_text . "\n");
163 open(IN, "<", "pci.ids");
164 open(OUT, ">", "20-pci-classes.hwdb");
165 print(OUT "# This file is part of systemd.\n" .
167 "# Data imported from: http://pci-ids.ucw.cz/v2.2/pci.ids\n");
169 while (my $line = <IN>) {
172 $line =~ m/^C\ ([0-9a-f]{2})\s*(.+)$/;
177 print(OUT "pci:v*d*sv*sd*bc" . $class . "*\n");
178 print(OUT " ID_PCI_CLASS_FROM_DATABASE=" . $text . "\n");
182 if (not defined $class) {
184 } elsif ($line =~ m/^$/) {
188 $line =~ m/^\t([0-9a-f]{2})\s*(.+)$/;
193 print(OUT "pci:v*d*sv*sd*bc" . $class . "sc" . $subclass . "*\n");
194 print(OUT " ID_PCI_SUBCLASS_FROM_DATABASE=" . $text . "\n");
198 $line =~ m/^\t\t([0-9a-f]{2})\s*(.+)$/;
203 print(OUT "pci:v*d*sv*sd*bc" . $class . "sc" . $subclass . "i" . $interface . "*\n");
204 print(OUT " ID_PCI_INTERFACE_FROM_DATABASE=" . $text . "\n");
216 open(IN, "<", "sdio.ids");
217 open(OUT, ">", "20-sdio-vendor-model.hwdb");
218 print(OUT "# This file is part of systemd.\n" .
220 "# Data imported from: hwdb/sdio.ids\n");
222 while (my $line = <IN>) {
224 $line =~ m/^([0-9a-f]{4})\s*(.+)$/;
230 print(OUT "sdio:c*v" . $vendor . "*\n");
231 print(OUT " ID_VENDOR_FROM_DATABASE=" . $text . "\n");
235 $line =~ m/^\t([0-9a-f]{4})\s*(.+)$/;
240 print(OUT "sdio:c*v" . $vendor . "d" . $device . "*\n");
241 print(OUT " ID_MODEL_FROM_DATABASE=" . $text . "\n");
255 open(IN, "<", "sdio.ids");
256 open(OUT, ">", "20-sdio-classes.hwdb");
257 print(OUT "# This file is part of systemd.\n" .
259 "# Data imported from: hwdb/sdio.ids\n");
261 while (my $line = <IN>) {
264 $line =~ m/^C\ ([0-9a-f]{2})\s*(.+)$/;
269 print(OUT "sdio:c" . $class . "v*d*\n");
270 print(OUT " ID_SDIO_CLASS_FROM_DATABASE=" . $text . "\n");
281 my %iab_prefixes = ();
283 open(OUT, ">", "20-OUI.hwdb");
284 print(OUT "# This file is part of systemd.\n" .
286 "# Data imported from:\n" .
287 "# http://standards.ieee.org/develop/regauth/oui/oui.txt\n" .
288 "# http://standards.ieee.org/develop/regauth/iab/iab.txt\n");
290 open(IN, "<", "iab.txt");
291 while (my $line = <IN>) {
294 $line =~ m/^([0-9A-F]{2})-([0-9A-F]{2})-([0-9A-F]{2})\s*\(hex\)\s*.+$/;
296 $iab_prefix = $1 . $2 . $3;
297 $iab_prefixes{ $iab_prefix } = 1;
301 $line =~ m/^([0-9A-F]{3})000-\g1FFF\s*\(base 16\)\s*(.+)$/;
307 print(OUT "OUI:" . $iab_prefix . $vendor . "*\n");
308 print(OUT " ID_OUI_FROM_DATABASE=" . $text . "\n");
313 open(IN, "<", "oui.txt");
314 while (my $line = <IN>) {
317 $line =~ m/^([0-9A-F]{6})\s*\(base 16\)\s*(.+)$/;
322 # skip the IAB prefixes
323 if (! exists $iab_prefixes{ $vendor }) {
325 print(OUT "OUI:" . $vendor . "*\n");
326 print(OUT " ID_OUI_FROM_DATABASE=" . $text . "\n");