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 89 90 91
|
#!/usr/bin/perl
# Copyright (C) 2000 Zephaniah E. Hull.
# This code is under the GNU GPL, see /usr/share/common-licenses/GPL.
use strict;
use warnings;
use Debconf::Client::ConfModule ':all';
main();
my (%types);
BEGIN {
%types = (
"Voodoo Banshee" => "h3",
"Voodoo Banshee [Velocity 100]" => "h3",
"Voodoo 3" => "h3",
"Voodoo 4" => "h5",
"Voodoo 4 / Voodoo 5" => "h5",
"Voodoo 5" => "h5",
);
}
sub main {
version('2.0');
title('glide3 configuration');
my @cards = get_devices();
if ($#cards == -1) {
input('low', 'libglide3/no_card');
go();
my $choice = get('libglide3/no_card');
if ($choice eq "true") {
input('low', 'libglide3/driver');
go();
} else {
set('libglide3/driver', 'h5');
go();
}
} elsif ($#cards == 0) {
set('libglide3/driver', ${$cards[0]}{'Driver'});
go();
} else {
my %choices;
foreach my $card (@cards) {
my %card = %$card;
my $tmp;
if (defined($card{'SVendor'})) {
$tmp = sprintf("%s %s (%s)", $card{'SVendor'},
$card{'SDevice'}, $card{'Device'});
} else {
$tmp = sprintf("3Dfx %s", $card{'Device'});
}
$tmp =~ s/,//g;
$choices{$tmp} = $card{'Driver'};
}
my $choices = join ', ', keys %choices;
subst('libglide3/card', 'choices', $choices);
input('high', 'libglide3/card');
go();
my $choice = get('libglide3/card');
set('libglide3/driver', $choices{$choice});
}
# stop();
}
sub get_devices {
my @cards;
my $raw = qx(lspci -vm);
foreach my $dev (split(/\n\n/, $raw)) {
my (%info);
foreach my $line (split(/\n/, $dev)) {
if($line =~ /^(Class|Vendor|Device|SVendor|SDevice|Rev):\s+(.*)$/) {
$info{$1} = $2;
}
}
if (defined($types{$info{'Device'}})) {
$info{"Driver"} = $types{$info{"Device"}};
push(@cards, \%info);
}
}
return @cards;
}
|