/usr/bin/osinfo-pciids-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 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 | #!/usr/bin/perl -w
use strict;
use warnings;
my $vendor;
my $vendor_id;
my $device;
my $device_id;
my $subsystem;
my $subvendor_id;
my $subdevice_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);
} elsif (/^\t\t([0-9a-f]{4})\s+([0-9a-f]{4})\s+(.*?)\s*$/) {
$subsystem = $3;
$subvendor_id = $1;
$subdevice_id = $2;
&one_device($vendor, $vendor_id, $device, $device_id,
$subsystem, $subvendor_id, $subdevice_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;
my $subsystem = shift;
my $subvendor_id = shift;
my $subdevice_id = shift;
$vendor = &escape($vendor);
$device = &escape($device);
$subsystem = &escape($subsystem) if defined $subsystem;
my $id = "http://pciids.sourceforge.net/v2.2/pci.ids";
$id .= "/$vendor_id/$device_id";
$id .= "/$subvendor_id/$subdevice_id" if $subsystem;
print <<EOF;
<device id="$id">
<bus-type>pci</bus-type>
<vendor>$vendor</vendor>
<vendor-id>$vendor_id</vendor-id>
<device>$device</device>
<device-id>$device_id</device-id>
EOF
if ($subsystem) {
print <<EOF;
<subsystem>$subsystem</subsystem>
<subvendor-id>$subvendor_id</subvendor-id>
<subdevice-id>$subdevice_id</subdevice-id>
EOF
}
print <<EOF;
</device>
EOF
}
|