chiark / gitweb /
udev: update file headers
[elogind.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);
81
82 open(IN, "<", "oui.txt");
83 open(OUT, ">", "20-OUI.hwdb");
84 print(OUT "# This file is part of systemd.\n" .
85           "#\n" .
86           "# Data imported and updated from: http://standards.ieee.org/develop/regauth/oui/oui.txt\n");
87
88 while (my $line = <IN>) {
89         $line =~ s/\s+$//;
90         $line =~ m/^([0-9A-F]{6})\s*\(base 16\)\s*(.*)$/;
91         if (defined $1) {
92                 my $vendor = uc $1;
93                 my $text = $2;
94                 print(OUT "\n");
95                 print(OUT "OUI:" . $vendor . "\n");
96                 print(OUT " ID_OUI_FROM_DATABASE=" . $text . "\n");
97         }
98 }
99 close(INP);
100 close(OUTP);