]> git.ipfire.org Git - thirdparty/systemd.git/blob - hwdb/ids-update.pl
udev: add hardware database support
[thirdparty/systemd.git] / hwdb / ids-update.pl
1 #!/usr/bin/perl
2
3 use strict;
4 use warnings;
5
6 my $vendor;
7
8 open(IN, "<", "usb.ids");
9 open(OUT, ">", "20-usb-vendor-product.hwdb");
10 print(OUT "# This file is part of systemd.\n" .
11 "#\n" .
12 "# Data imported and updated from: http://www.linux-usb.org/usb.ids\n");
13
14 while (my $line = <IN>) {
15 $line =~ s/\s+$//;
16 $line =~ m/^([0-9a-f]{4})\s*(.*)$/;
17 if (defined $1) {
18 $vendor = uc $1;
19 my $text = $2;
20 print(OUT "\n");
21 print(OUT "usb:v" . $vendor . "*\n");
22 print(OUT " ID_VENDOR_FROM_DATABASE=" . $text . "\n");
23 next;
24 }
25
26 $line =~ m/^\t([0-9a-f]{4})\s*(.*)$/;
27 if (defined $1) {
28 my $product = uc $1;
29 my $text = $2;
30 print(OUT "\n");
31 print(OUT "usb:v" . $vendor . "p" . $product . "*\n");
32 print(OUT " ID_PRODUCT_FROM_DATABASE=" . $text . "\n");
33 }
34 }
35 close(INP);
36 close(OUTP);
37
38
39 my $device;
40
41 open(IN, "<", "pci.ids");
42 open(OUT, ">", "20-pci-vendor-product.hwdb");
43 print(OUT "# This file is part of systemd.\n" .
44 "#\n" .
45 "# Data imported and updated from: http://pciids.sourceforge.net/v2.2/pci.ids\n");
46
47 while (my $line = <IN>) {
48 $line =~ s/\s+$//;
49 $line =~ m/^([0-9a-f]{4})\s*(.*)$/;
50 if (defined $1) {
51 $vendor = uc $1;
52 my $text = $2;
53 print(OUT "\n");
54 print(OUT "pci:v0000" . $vendor . "*\n");
55 print(OUT " ID_VENDOR_FROM_DATABASE=" . $text . "\n");
56 next;
57 }
58
59 $line =~ m/^\t([0-9a-f]{4})\s*(.*)$/;
60 if (defined $1) {
61 $device = uc $1;
62 my $text = $2;
63 print(OUT "\n");
64 print(OUT "pci:v0000" . $vendor . "d0000" . $device . "*\n");
65 print(OUT " ID_PRODUCT_FROM_DATABASE=" . $text . "\n");
66 next;
67 }
68
69 $line =~ m/^\t\t([0-9a-f]{4})\s*([0-9a-f]{4})\s*(.*)$/;
70 if (defined $1) {
71 my $sub_vendor = uc $1;
72 my $sub_device = uc $2;
73 my $text = $3;
74 print(OUT "\n");
75 print(OUT "pci:v0000" . $vendor . "d0000" . $device . "sv0000" . $sub_vendor . "sd0000" . $sub_device . "*\n");
76 print(OUT " ID_PRODUCT_FROM_DATABASE=" . $text . "\n");
77 }
78 }
79 close(INP);
80 close(OUTP);