summaryrefslogtreecommitdiffstats
path: root/rescue/drvinst
blob: be4fa6e94e4963202519c196b41271ad997e7a1e (plain)
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
#!/usr/bin/perl
#
# Guillaume Cottenceau
#
# Copyright 2000-2005 Mandriva
#
# This software may be freely redistributed under the terms of the GNU
# public license.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#

use lib qw(/usr/lib/libDrakX);
use common;
use detect_devices;

$ARGV[0] =~ /^--?h/ and die "usage: drivers_install [drivertype1 [drivertype2 ...]]\n";
my @types = @ARGV;

sub install_module_raw {
    my ($driver, $o_descr) = @_;
    print STDERR "Installing driver $driver", if_($o_descr, qq( (for "$o_descr"))), "\n";
    system("/sbin/modprobe", $driver) and print "\tfailed\n";
}

sub install_module {
    my ($driver, $descr) = @_;
    install_module_raw($driver, $descr);
}

#- start
foreach my $card (detect_devices::pci_probe()) {
    # ignoring "unknown", "Card:foobar" and the like as well as video cards:
    $card->{driver} eq 'unknown' || $card->{driver} =~ /:/ and next;
    $card->{media_type} eq "DISPLAY_VGA" and next;

    # load drivers for selected categories or for everything if no args:
    if (!@ARGV || find { $card->{media_type} =~ /$_/i } @types) {
	install_module($card->{driver}, $card->{description});
    }
}