ids-update.pl revision 448004c340d41f1b7eb3c06cbd694b8862e6524d
b22d8a00f48f3c5fc4510b4acd3e1a43e731e592Tom Gundersen#!/usr/bin/perl
b22d8a00f48f3c5fc4510b4acd3e1a43e731e592Tom Gundersen
b22d8a00f48f3c5fc4510b4acd3e1a43e731e592Tom Gundersenuse strict;
b22d8a00f48f3c5fc4510b4acd3e1a43e731e592Tom Gundersenuse warnings;
b22d8a00f48f3c5fc4510b4acd3e1a43e731e592Tom Gundersen
b22d8a00f48f3c5fc4510b4acd3e1a43e731e592Tom Gundersenmy $vendor;
b22d8a00f48f3c5fc4510b4acd3e1a43e731e592Tom Gundersen
b22d8a00f48f3c5fc4510b4acd3e1a43e731e592Tom Gundersenopen(IN, "<", "usb.ids");
b22d8a00f48f3c5fc4510b4acd3e1a43e731e592Tom Gundersenopen(OUT, ">", "20-usb-vendor-product.hwdb");
b22d8a00f48f3c5fc4510b4acd3e1a43e731e592Tom Gundersenprint(OUT "# This file is part of systemd.\n" .
b22d8a00f48f3c5fc4510b4acd3e1a43e731e592Tom Gundersen "#\n" .
b22d8a00f48f3c5fc4510b4acd3e1a43e731e592Tom Gundersen "# Data imported and updated from: http://www.linux-usb.org/usb.ids\n");
b22d8a00f48f3c5fc4510b4acd3e1a43e731e592Tom Gundersen
b22d8a00f48f3c5fc4510b4acd3e1a43e731e592Tom Gundersenwhile (my $line = <IN>) {
b22d8a00f48f3c5fc4510b4acd3e1a43e731e592Tom Gundersen $line =~ s/\s+$//;
b22d8a00f48f3c5fc4510b4acd3e1a43e731e592Tom Gundersen $line =~ m/^([0-9a-f]{4})\s*(.*)$/;
b22d8a00f48f3c5fc4510b4acd3e1a43e731e592Tom Gundersen if (defined $1) {
b22d8a00f48f3c5fc4510b4acd3e1a43e731e592Tom Gundersen $vendor = uc $1;
b22d8a00f48f3c5fc4510b4acd3e1a43e731e592Tom Gundersen my $text = $2;
b22d8a00f48f3c5fc4510b4acd3e1a43e731e592Tom Gundersen print(OUT "\n");
b22d8a00f48f3c5fc4510b4acd3e1a43e731e592Tom Gundersen print(OUT "usb:v" . $vendor . "*\n");
b22d8a00f48f3c5fc4510b4acd3e1a43e731e592Tom Gundersen print(OUT " ID_VENDOR_FROM_DATABASE=" . $text . "\n");
b22d8a00f48f3c5fc4510b4acd3e1a43e731e592Tom Gundersen next;
b22d8a00f48f3c5fc4510b4acd3e1a43e731e592Tom Gundersen }
b22d8a00f48f3c5fc4510b4acd3e1a43e731e592Tom Gundersen
b22d8a00f48f3c5fc4510b4acd3e1a43e731e592Tom Gundersen $line =~ m/^\t([0-9a-f]{4})\s*(.*)$/;
b22d8a00f48f3c5fc4510b4acd3e1a43e731e592Tom Gundersen if (defined $1) {
b22d8a00f48f3c5fc4510b4acd3e1a43e731e592Tom Gundersen my $product = uc $1;
b22d8a00f48f3c5fc4510b4acd3e1a43e731e592Tom Gundersen my $text = $2;
b22d8a00f48f3c5fc4510b4acd3e1a43e731e592Tom Gundersen print(OUT "\n");
b22d8a00f48f3c5fc4510b4acd3e1a43e731e592Tom Gundersen print(OUT "usb:v" . $vendor . "p" . $product . "*\n");
b22d8a00f48f3c5fc4510b4acd3e1a43e731e592Tom Gundersen print(OUT " ID_PRODUCT_FROM_DATABASE=" . $text . "\n");
b22d8a00f48f3c5fc4510b4acd3e1a43e731e592Tom Gundersen }
b22d8a00f48f3c5fc4510b4acd3e1a43e731e592Tom Gundersen}
b22d8a00f48f3c5fc4510b4acd3e1a43e731e592Tom Gundersenclose(INP);
b22d8a00f48f3c5fc4510b4acd3e1a43e731e592Tom Gundersenclose(OUTP);
b22d8a00f48f3c5fc4510b4acd3e1a43e731e592Tom Gundersen
b22d8a00f48f3c5fc4510b4acd3e1a43e731e592Tom Gundersen
b22d8a00f48f3c5fc4510b4acd3e1a43e731e592Tom Gundersenmy $device;
b22d8a00f48f3c5fc4510b4acd3e1a43e731e592Tom Gundersen
b22d8a00f48f3c5fc4510b4acd3e1a43e731e592Tom Gundersenopen(IN, "<", "pci.ids");
b22d8a00f48f3c5fc4510b4acd3e1a43e731e592Tom Gundersenopen(OUT, ">", "20-pci-vendor-product.hwdb");
79008bddf679a5e0900369950eb346c9fa687107Lennart Poetteringprint(OUT "# This file is part of systemd.\n" .
b22d8a00f48f3c5fc4510b4acd3e1a43e731e592Tom Gundersen "#\n" .
b22d8a00f48f3c5fc4510b4acd3e1a43e731e592Tom Gundersen "# Data imported and updated from: http://pciids.sourceforge.net/v2.2/pci.ids\n");
b22d8a00f48f3c5fc4510b4acd3e1a43e731e592Tom Gundersen
79008bddf679a5e0900369950eb346c9fa687107Lennart Poetteringwhile (my $line = <IN>) {
b22d8a00f48f3c5fc4510b4acd3e1a43e731e592Tom Gundersen $line =~ s/\s+$//;
b22d8a00f48f3c5fc4510b4acd3e1a43e731e592Tom Gundersen $line =~ m/^([0-9a-f]{4})\s*(.*)$/;
b22d8a00f48f3c5fc4510b4acd3e1a43e731e592Tom Gundersen if (defined $1) {
b22d8a00f48f3c5fc4510b4acd3e1a43e731e592Tom Gundersen $vendor = uc $1;
b22d8a00f48f3c5fc4510b4acd3e1a43e731e592Tom Gundersen my $text = $2;
b22d8a00f48f3c5fc4510b4acd3e1a43e731e592Tom Gundersen print(OUT "\n");
b22d8a00f48f3c5fc4510b4acd3e1a43e731e592Tom Gundersen print(OUT "pci:v0000" . $vendor . "*\n");
b22d8a00f48f3c5fc4510b4acd3e1a43e731e592Tom Gundersen print(OUT " ID_VENDOR_FROM_DATABASE=" . $text . "\n");
b22d8a00f48f3c5fc4510b4acd3e1a43e731e592Tom Gundersen next;
b22d8a00f48f3c5fc4510b4acd3e1a43e731e592Tom Gundersen }
b22d8a00f48f3c5fc4510b4acd3e1a43e731e592Tom Gundersen
b22d8a00f48f3c5fc4510b4acd3e1a43e731e592Tom Gundersen $line =~ m/^\t([0-9a-f]{4})\s*(.*)$/;
79008bddf679a5e0900369950eb346c9fa687107Lennart Poettering if (defined $1) {
b22d8a00f48f3c5fc4510b4acd3e1a43e731e592Tom Gundersen $device = uc $1;
b22d8a00f48f3c5fc4510b4acd3e1a43e731e592Tom Gundersen my $text = $2;
b22d8a00f48f3c5fc4510b4acd3e1a43e731e592Tom Gundersen print(OUT "\n");
b22d8a00f48f3c5fc4510b4acd3e1a43e731e592Tom Gundersen print(OUT "pci:v0000" . $vendor . "d0000" . $device . "*\n");
b22d8a00f48f3c5fc4510b4acd3e1a43e731e592Tom Gundersen print(OUT " ID_PRODUCT_FROM_DATABASE=" . $text . "\n");
b22d8a00f48f3c5fc4510b4acd3e1a43e731e592Tom Gundersen next;
b22d8a00f48f3c5fc4510b4acd3e1a43e731e592Tom Gundersen }
b22d8a00f48f3c5fc4510b4acd3e1a43e731e592Tom Gundersen
b22d8a00f48f3c5fc4510b4acd3e1a43e731e592Tom Gundersen $line =~ m/^\t\t([0-9a-f]{4})\s*([0-9a-f]{4})\s*(.*)$/;
b22d8a00f48f3c5fc4510b4acd3e1a43e731e592Tom Gundersen if (defined $1) {
b22d8a00f48f3c5fc4510b4acd3e1a43e731e592Tom Gundersen my $sub_vendor = uc $1;
b22d8a00f48f3c5fc4510b4acd3e1a43e731e592Tom Gundersen my $sub_device = uc $2;
b22d8a00f48f3c5fc4510b4acd3e1a43e731e592Tom Gundersen my $text = $3;
b22d8a00f48f3c5fc4510b4acd3e1a43e731e592Tom Gundersen print(OUT "\n");
b22d8a00f48f3c5fc4510b4acd3e1a43e731e592Tom Gundersen print(OUT "pci:v0000" . $vendor . "d0000" . $device . "sv0000" . $sub_vendor . "sd0000" . $sub_device . "*\n");
b22d8a00f48f3c5fc4510b4acd3e1a43e731e592Tom Gundersen print(OUT " ID_PRODUCT_FROM_DATABASE=" . $text . "\n");
b22d8a00f48f3c5fc4510b4acd3e1a43e731e592Tom Gundersen }
b22d8a00f48f3c5fc4510b4acd3e1a43e731e592Tom Gundersen}
b22d8a00f48f3c5fc4510b4acd3e1a43e731e592Tom Gundersenclose(INP);
b22d8a00f48f3c5fc4510b4acd3e1a43e731e592Tom Gundersenclose(OUTP);
b22d8a00f48f3c5fc4510b4acd3e1a43e731e592Tom Gundersen
b22d8a00f48f3c5fc4510b4acd3e1a43e731e592Tom Gundersenopen(IN, "<", "oui.txt");
b22d8a00f48f3c5fc4510b4acd3e1a43e731e592Tom Gundersenopen(OUT, ">", "20-OUI-vendor.hwdb");
b22d8a00f48f3c5fc4510b4acd3e1a43e731e592Tom Gundersenprint(OUT "# This file is part of systemd.\n" .
79008bddf679a5e0900369950eb346c9fa687107Lennart Poettering "#\n" .
b22d8a00f48f3c5fc4510b4acd3e1a43e731e592Tom Gundersen "# Data imported and updated from: http://standards.ieee.org/develop/regauth/oui/oui.txt\n");
b22d8a00f48f3c5fc4510b4acd3e1a43e731e592Tom Gundersen
b22d8a00f48f3c5fc4510b4acd3e1a43e731e592Tom Gundersenwhile (my $line = <IN>) {
b22d8a00f48f3c5fc4510b4acd3e1a43e731e592Tom Gundersen $line =~ s/\s+$//;
b22d8a00f48f3c5fc4510b4acd3e1a43e731e592Tom Gundersen $line =~ m/^([0-9A-F]{6})\s*\(base 16\)\s*(.*)$/;
b22d8a00f48f3c5fc4510b4acd3e1a43e731e592Tom Gundersen if (defined $1) {
b22d8a00f48f3c5fc4510b4acd3e1a43e731e592Tom Gundersen my $vendor = uc $1;
b22d8a00f48f3c5fc4510b4acd3e1a43e731e592Tom Gundersen my $text = $2;
b22d8a00f48f3c5fc4510b4acd3e1a43e731e592Tom Gundersen print(OUT "\n");
b22d8a00f48f3c5fc4510b4acd3e1a43e731e592Tom Gundersen print(OUT "OUI:" . $vendor . "\n");
b22d8a00f48f3c5fc4510b4acd3e1a43e731e592Tom Gundersen print(OUT " ID_VENDOR_FROM_DATABASE=" . $text . "\n");
b22d8a00f48f3c5fc4510b4acd3e1a43e731e592Tom Gundersen }
b22d8a00f48f3c5fc4510b4acd3e1a43e731e592Tom Gundersen}
b22d8a00f48f3c5fc4510b4acd3e1a43e731e592Tom Gundersenclose(INP);
b22d8a00f48f3c5fc4510b4acd3e1a43e731e592Tom Gundersenclose(OUTP);
b22d8a00f48f3c5fc4510b4acd3e1a43e731e592Tom Gundersen