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 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116
|
#!/usr/bin/perl -w
# Copyright (C) 2000 Zephaniah E. Hull.
# This code is under the GNU GPL, see /usr/share/common-licenses/GPL.
use strict;
use Debconf::Client::ConfModule ':all';
main();
my (%types, %type_map);
BEGIN {
%types = (
"Voodoo 2" => "cvg",
"Voodoo Banshee" => "h3",
"Voodoo Banshee [Velocity 100]" => "h3",
"Voodoo 3" => "h3",
);
%type_map = (
"cvg" => "/usr/lib/glide2/libglide_cvg.so.2.53",
"h3" => "/usr/lib/glide2/libglide_h3.so.2.60",
);
}
sub main {
my (@cards, $driver);
version('2.0');
title('glide2 configuration');
@cards = get_devices();
if ($#cards == -1) {
my ($choice);
input('low', 'libglide2/no_card');
go();
$choice = get('libglide2/no_card');
if ($choice eq "true") {
input('low', 'libglide2/driver');
go();
} else {
set('libglide2/driver', 'h3');
go();
}
} elsif ($#cards == 0) {
set('libglide2/driver', ${$cards[0]}{'Driver'});
go();
} else {
my (%card, $card, $choices, %choices, $choice, $tmp);
for $card (@cards) {
%card = %$card;
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'};
}
$choices = join(', ', keys(%choices));
subst('libglide2/card', 'choices', $choices);
input('high', 'libglide2/card');
go();
$choice = get('libglide2/card');
$tmp = $choices{$choice};
set('libglide2/driver', $tmp);
}
# stop();
}
sub select_device {
my ($type, $file, $target);
$target = '/usr/lib/libglide.so.2';
$type = shift;
if (!defined($type_map{$type})) {
die("No mapping for type " . $type);
}
$file = $type_map{$type};
if (!-f $file) {
die($file . " does not exist.");
}
if (-e $target) {
if (-l $target) {
unlink($target);
} else {
die($target . " exists but is NOT a symlink!")
}
}
symlink($file, "/usr/lib/libglide.so.2");
}
sub get_devices {
my ($raw, $dev, $line, $tmp, @cards);
$raw = `lspci -vm`;
foreach $dev (split(/\n\n/, $raw)) {
my (%info);
foreach $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;
}
|