/usr/share/tools/discover-updater.pl is in discover-data 2.2013.01.11.
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
# Horrible hacky script in lead up to deadline. Please sort out!
# We don't use an XML parser as we want to minimize diffs. We rely on the
# textual structure of the discover.xml files. This is probably a bug, too,
# but not as big a bug as screwing with the entire file's format.
my %args;
my %mods;
my $name;
sub dev_attrs {
local $_=shift;
%args=();
while(s!(\w+)\=['"](.*?)["']!!) {
$args{$1}=$2;
}
}
sub make_name {
my $v=$args{'vendor'};
my $d=$args{'model'};
my $sv=$args{'subvendor'};
my $sd=$args{'subdevice'};
$sv='x' unless defined $sv;
$sd='x' unless defined $sd;
$name = "$v:$d:$sv:$sd";
}
sub short_tag {
my ($attrs)=@_;
dev_attrs($attrs);
make_name();
}
sub open_tag {
my ($attrs)=@_;
dev_attrs($attrs);
}
sub close_tag {
%args=();
}
# Read modules file
open(PCILST,"$ARGV[0]") || die "Cannot open $ARGV[0]";
while(<PCILST>) {
/^(\S+)\s+0x([0-9a-fA-F]+)\s+0x([0-9a-fA-F]+)\s+0x([0-9a-fA-F]+)\s+0x([0-9a-fA-F]+)/;
my ($name,$v,$d,$sv,$sd)=($1,$2,$3,$4,$5);
$v =~ s/^0000//;
$d =~ s/^0000//;
$sv =~ s/^0000//;
$sd =~ s/^0000//;
$sv='x' if($sv eq "ffffffff");
$sd='x' if($sd eq "ffffffff");
# Avoid some entries we do not want. 'generic' seem to be some
# hardware independent driver, and i810-tco make the machine reboot
# after a minute.
next if ($name =~ m/^generic$|^i810-tco$/);
$mods{"$v:$d:$sv:$sd"}=$name;
}
close PCILST;
# Read discover config file
while(<STDIN>) {
if(m!<device([^>]*?)/>!) {
short_tag($1);
make_name();
if($mods{$name}) {
print STDERR "Device $name has module $mods{$name}\n";
s!/>!>!;
$_.=<<"EOF";
<data class='linux'>
<data version='[2.6,inf)' class="module">
<data class='name'>$mods{$name}</data>
</data>
</data>
</device>
EOF
}
} elsif(m!<device(.*?)>!) {
open_tag($1);
} elsif(m!</device>!) {
close_tag();
}
print;
}
|