/usr/bin/osinfo-usbids-convert is in libosinfo-bin 0.1.0-0ubuntu1.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 | #!/usr/bin/perl -w
use strict;
use warnings;
my $vendor;
my $vendor_id;
my $device;
my $device_id;
use encoding 'utf8', STDIN => 'iso88591';
print "<libosinfo version='1.0'>\n";
while (<>) {
next if /^#/;
next if /^\s*$/;
if (/^([0-9a-f]{4})\s+(.*?)\s*$/) {
$vendor = $2;
$vendor_id = $1;
} elsif (/^\t([0-9a-f]{4})\s+(.*?)\s*$/) {
$device = $2;
$device_id = $1;
&one_device($vendor, $vendor_id, $device, $device_id);
} else {
#warn $_;
}
}
print "</libosinfo>\n";
sub escape {
my $data = shift;
$data =~ s/&/&/g;
$data =~ s/</</g;
$data =~ s/>/>/g;
return $data;
}
sub one_device {
my $vendor = shift;
my $vendor_id = shift;
my $device = shift;
my $device_id = shift;
$vendor = &escape($vendor);
$device = &escape($device);
my $id = "http://www.linux-usb.org/usb.ids";
$id .= "/$vendor_id/$device_id";
print <<EOF;
<device id="$id">
<bus-type>usb</bus-type>
<vendor>$vendor</vendor>
<vendor-id>$vendor_id</vendor-id>
<device>$device</device>
<device-id>$device_id</device-id>
</device>
EOF
}
|