diff options
author | Thierry Vignaud <tvignaud@mandriva.org> | 2002-07-04 11:26:39 +0000 |
---|---|---|
committer | Thierry Vignaud <tvignaud@mandriva.org> | 2002-07-04 11:26:39 +0000 |
commit | 24b1f7a5c218b5fc6d8253bac99e70811338cfa0 (patch) | |
tree | 292237413955cadf5f08bdfa545b6cbb3eaa726c /perl-install | |
parent | a4d8d6c87bd14c630159da1a029968b1434bd20f (diff) | |
download | drakx-24b1f7a5c218b5fc6d8253bac99e70811338cfa0.tar drakx-24b1f7a5c218b5fc6d8253bac99e70811338cfa0.tar.gz drakx-24b1f7a5c218b5fc6d8253bac99e70811338cfa0.tar.bz2 drakx-24b1f7a5c218b5fc6d8253bac99e70811338cfa0.tar.xz drakx-24b1f7a5c218b5fc6d8253bac99e70811338cfa0.zip |
harddrake2: "the return of the vengeance son"
- harddrake/data.pm: the data structure
- harddrake/ui.pm: the ui code
- standalone/service_harddrake: the init.d service (which need a few polishing (timeout, ...)
- standalone/harddrake2: the ui caller which need to be dadou/ln -fied
Diffstat (limited to 'perl-install')
-rw-r--r-- | perl-install/harddrake/data.pm | 77 | ||||
-rw-r--r-- | perl-install/harddrake/ui.pm | bin | 0 -> 8125 bytes | |||
-rwxr-xr-x | perl-install/standalone/harddrake2 | 6 | ||||
-rwxr-xr-x | perl-install/standalone/service_harddrake | 97 |
4 files changed, 180 insertions, 0 deletions
diff --git a/perl-install/harddrake/data.pm b/perl-install/harddrake/data.pm new file mode 100644 index 000000000..b4f87025d --- /dev/null +++ b/perl-install/harddrake/data.pm @@ -0,0 +1,77 @@ +#!/usr/bin/perl -w + +package data; + +use strict; +use lib qw(/usr/lib/libDrakX); +use vars qw(@ISA @EXPORT_OK); +use detect_devices; +use MDK::Common; + +@ISA = qw(Exporter); +@EXPORT_OK = (qw(version tree)); + +our ($version, $sbindir) = ("1.1.5", "/usr/sbin/"); + +sub wait_message {} #- needed to emulate $in required by printerdrake::auto_detect as argument + +# Update me each time you handle one more devices class (aka configurator) +sub unknown { + grep { $_->{media_type} !~ /tape|DISPLAY|MULTIMEDIA_VIDEO|BRIDGE|NETWORK|MULTIMEDIA_AUDIO/ } detect_devices::probeall(1); +} + + +# tree format ("CLASS_ID", "type", "type_icon", configurator, detect_sub) +# NEVER, NEVER alter CLASS_ID or you'll harddrake2 service to detect changes +# in hw configuration ... :-( + +our @tree = + ( + ["FLOPPY","Floppy", "floppy.png", "",\&detect_devices::floppies], + ["HARDDISK","Disk", "harddisk.png", "$sbindir/diskdrake", \&detect_devices::hds], + ["CDROM","Cdrom", "cd.png", "", \&detect_devices::cdroms], + ["TAPE","Tape", "tape.png", "", \&detect_devices::tapes], +# ["CDBURNER","Cd burners", "cd.png", "", \&detect_devices::burners], + + ["VIDEO","Videocard", "video.png", "$sbindir/XFdrake", + sub {grep { $_->{driver} =~ /^(Card|Server):/ || $_->{media_type} =~ 'DISPLAY_VGA' } detect_devices::probeall(1) }], + ["TV","Tvcard", "tv.png", "/usr/bin/XawTV", + sub {grep { $_->{media_type} =~ 'MULTIMEDIA_VIDEO' } detect_devices::probeall(1)}], + ["AUDIO","Soundcard", "sound.png", "", + sub {grep { $_->{media_type} =~ 'MULTIMEDIA_AUDIO' } detect_devices::probeall(1)}], +# "MULTIMEDIA_AUDIO" => "/usr/bin/X11/sounddrake"; + ["WEBCAM","Webcam", "webcam.png", "", sub {}], + ["ETHERNET","Ethernetcard", "hw_network.png", "$sbindir/draknet", sub { + #- generic NIC detection for USB seems broken (class, subclass, + #- protocol report are not accurate) so I'll need to verify against + #- known drivers :-( + my @usbnet = qw/CDCEther catc kaweth pegasus usbnet/; + # should be taken from detect_devices.pm or modules.pm. it's identical + + grep { $_->{media_type} =~ /^NETWORK/ || + member($_->{driver}, @usbnet) + } detect_devices::probeall(1)}], +# ["","Tokenring cards", "Ethernetcard.png", "", \&detect_devices::getNet], +# ["","FDDI cards", "Ethernetcard.png", "", \&detect_devices::getNet], +# ["","Modem", "Modem.png", "", \&detect_devices::getNet], +# ["","Isdn", "", "", \&detect_devices::getNet] + + ["BRIDGE","Bridge", "memory.png", "", sub {grep { $_->{media_type} =~ 'BRIDGE' } detect_devices::probeall(1)}], +# ["","Cpu", "cpu.png", "", sub {}], +# ["","Memory", "memory.png", "", sub {}], + ["UNKNOWN","Unknown/Others", "unknown.png", "" , \&unknown], + + ["PRINTER","Printer", "hw_printer.png", "$sbindir/printerdrake", + sub { require printerdrake; printerdrake::auto_detect(bless {}) } ], + ["SCANNER","Scanner", "scanner.png", "$sbindir/scannerdrake", + sub { require scanner; scanner::findScannerUsbport() }], + ["MOUSE","Mouse", "hw_mouse.png", "$sbindir/mousedrake", sub { use mouse; &mouse::detect()}], + ["JOYSTICK","Joystick", "joystick.png", "", sub {}] + +# ["","Ideinterface", "Ideinterface.png", "", "STORAGE_IDE"], +# ["","Scsiinterface", "Scsiinterface.png", "", \&detect_devices::getSCSI], +# ["","Usbinterface", "Usbinterface.png", "", \&detect_devices::usb_probe] + ); + + +1; diff --git a/perl-install/harddrake/ui.pm b/perl-install/harddrake/ui.pm Binary files differnew file mode 100644 index 000000000..ffd31e557 --- /dev/null +++ b/perl-install/harddrake/ui.pm diff --git a/perl-install/standalone/harddrake2 b/perl-install/standalone/harddrake2 new file mode 100755 index 000000000..b41cf2374 --- /dev/null +++ b/perl-install/standalone/harddrake2 @@ -0,0 +1,6 @@ +#!/usr/bin/perl -w + +use strict; +use harddrake::ui; + +ui->run; diff --git a/perl-install/standalone/service_harddrake b/perl-install/standalone/service_harddrake new file mode 100755 index 000000000..d0e8ae386 --- /dev/null +++ b/perl-install/standalone/service_harddrake @@ -0,0 +1,97 @@ +#!/usr/bin/perl -w +# harddrake2 This service runs the HardDrake hardware probe. +# +# chkconfig: 345 05 95 +# description: This runs the hardware probe, and optionally configures \ +# changed hardware. + + +# TODO: start/stop/status/ + +use lib qw(/usr/lib/libDrakX); + +use strict; +use standalone; #- warning, standalone must be loaded very first, for 'explanations' +use MDK::Common; +use POSIX; + +use interactive; + +use harddrake::data; +use Data::Dumper; + +my $hw_sysconfdir = "/etc/sysconfig/harddrake2"; +my $last_boot_config = "$hw_sysconfdir/previous_hw"; + +my $str = '#!/usr/bin/perl -w +# +# Special file generated by harddrake service (cvs revision $Revision$). +# Do not alter it; it\'ll be overwritten by harddrake2 service +# +# Format is : { Config_class_ID => { +# Device => { +# _Fields => values} ...} ...} +# +'; + +my $in = 'interactive'->vnew('su'); + +# first run ? if not read old hw config +my $previous_config = -f $last_boot_config ? do $last_boot_config : {}; + +my %config; + +# For each hw, class, detect device, compare and offer to reconfigure if +# needed +foreach (@data::tree) { + my ($Ident, $item, undef, $configurator, $detector) = @$_; + + # No detector ? (should never happen but who know ?) + ref($detector) eq 'CODE' or next; + + my %ID = map { + my $i = $_; + my $name = do { + if ($item eq "Mouse") { + $i->{media_type} = "MOUSE"; + $i->{device}; + } elsif (defined $i->{device}) { + $i->{media_type} = "MASS_STORAGE_MEDIA"; + $i->{device}; + } else { + join ':', map { $i->{$_} } qw(vendor id subvendor subid); + } + }; + $name => $i; + } &$detector; + $config{$Ident} = \%ID; + + my $oldconfig = $previous_config->{$Ident}; + + my $msg; + my @was_removed = difference2([ keys %$oldconfig ], [ keys %ID ]); + $msg .= _("Some devices in the \"%s\" hardware class were removed:\n", $item) if @was_removed; + $msg .= "- $_ was removed\n" foreach @was_removed; + + my @added = difference2([ keys %ID ], [ keys %$oldconfig ]); + $msg .= _("\nSome devices in the %s class were added:\n", $item) if @added; + $msg .= "- $_ was added\n" foreach @added; + + @added || @was_removed or next; + + if ($in->ask_okcancel("Hardware changes in $Ident class", + $msg . "\nDo you want to run the appropriate config tool ?", 1)) { + + if (my $pid = fork) { + POSIX::wait(); + } else { + exec($configurator) or die "$configurator missing\n"; + } + } +} + + +$Data::Dumper::Terse = 1; # don't output names where feasible +$Data::Dumper::Purity = 1; # fill in the holes for eval +# output new hw config +output("$last_boot_config", $str . Dumper(\%config) . ";\n"); |