diff options
author | Pascal Rigaux <pixel@mandriva.com> | 1999-09-03 09:43:22 +0000 |
---|---|---|
committer | Pascal Rigaux <pixel@mandriva.com> | 1999-09-03 09:43:22 +0000 |
commit | 3635161f628098787b71456e735c9ad87578930f (patch) | |
tree | 6e8df857210378709669328caaa249e95aad7355 /perl-install | |
parent | 2fe429a1283bb382c14b3657ab9f752a8b240233 (diff) | |
download | drakx-3635161f628098787b71456e735c9ad87578930f.tar drakx-3635161f628098787b71456e735c9ad87578930f.tar.gz drakx-3635161f628098787b71456e735c9ad87578930f.tar.bz2 drakx-3635161f628098787b71456e735c9ad87578930f.tar.xz drakx-3635161f628098787b71456e735c9ad87578930f.zip |
no_comment
Diffstat (limited to 'perl-install')
-rw-r--r-- | perl-install/common.pm | 2 | ||||
-rw-r--r-- | perl-install/detect_devices.pm | 33 | ||||
-rw-r--r-- | perl-install/install2.pm | 3 | ||||
-rw-r--r-- | perl-install/install_steps.pm | 2 | ||||
-rw-r--r-- | perl-install/install_steps_interactive.pm | 83 | ||||
-rw-r--r-- | perl-install/modules.pm | 263 | ||||
-rw-r--r-- | perl-install/network.pm | 6 | ||||
-rw-r--r-- | perl-install/pkgs.pm | 1 |
8 files changed, 221 insertions, 172 deletions
diff --git a/perl-install/common.pm b/perl-install/common.pm index fbaf4cd80..329dceaae 100644 --- a/perl-install/common.pm +++ b/perl-install/common.pm @@ -148,7 +148,7 @@ sub all { my $d = shift; local *F; - opendir F, $d or die "all: can't opendir $d: $!\n"; + opendir F, $d or die "all: can't open dir $d: $!\n"; grep { $_ ne '.' && $_ ne '..' } readdir F; } diff --git a/perl-install/detect_devices.pm b/perl-install/detect_devices.pm index 23c58ba7d..c0cdb221d 100644 --- a/perl-install/detect_devices.pm +++ b/perl-install/detect_devices.pm @@ -8,7 +8,7 @@ use common qw(:common :file); use devices; use c; - +my @netdevices = map { my $l = $_; map { "$l$_" } (0..3) } qw(eth tr plip fddi); my $scsiDeviceAvailable; my $CSADeviceAvailable; @@ -99,7 +99,6 @@ sub getIDE() { @idi; } - sub getCompaqSmartArray() { my @idi; my $f; @@ -117,15 +116,10 @@ sub getCompaqSmartArray() { sub getDAC960() { my @idi; - my $file = "/var/log/dmesg"; - -r $file or $file = "/tmp/syslog"; - - local *F; - open F, $file or die "Failed to open $file: $!"; # We are looking for lines of this format:DAC960#0: # /dev/rd/c0d0: RAID-7, Online, 17928192 blocks, Write Thru0123456790123456789012 - foreach (<F>) { + foreach (syslog()) { my ($devicename, $info) = m|/dev/rd/(.*?): (.*?),| or next; push @idi, { info => $info, type => 'hd', devicename => $devicename }; log::l("DAC960: $devicename: $info"); @@ -133,9 +127,23 @@ sub getDAC960() { @idi; } +sub net2module { + my @modules = map { quotemeta first(split) } cat_("/proc/modules"); + my $modules = join '|', @modules; + my $net = join '|', @netdevices; + my ($module, %l); + foreach (syslog()) { + if (/^($modules)\.c:/) { + $module = $1; + } elsif (/^($net):/) { + $l{$1} = $module if $module; + } + } + %l; +} sub getNet() { - grep { hasNetDevice($_) } qw(eth0 eth1 eth2 eth3 tr0 plip0 plip1 plip2 fddi0); + grep { hasNetDevice($_) } @netdevices; } sub getPlip() { foreach (0..2) { @@ -154,3 +162,10 @@ sub tryOpen($) { local *F; sysopen F, devices::make($_[0]), c::O_NONBLOCK(); } + +sub syslog { + my $file = "/var/log/dmesg"; + -r $file or $file = "/tmp/syslog"; + cat_($file); + `dmesg`; +} diff --git a/perl-install/install2.pm b/perl-install/install2.pm index bafaa515d..02c4dd38b 100644 --- a/perl-install/install2.pm +++ b/perl-install/install2.pm @@ -361,7 +361,6 @@ sub createBootdisk { } sub setupBootloader { - $o->{isUpgrade} or modules::read_conf("$o->{prefix}/etc/conf.modules"); $o->setupBootloader; } sub configureX { @@ -405,7 +404,7 @@ sub main { } modules::load_deps("/modules/modules.dep"); - modules::read_conf("/tmp/conf.modules"); + modules::get_stage1_conf("/tmp/conf.modules"); modules::read_already_loaded(); while (@_) { diff --git a/perl-install/install_steps.pm b/perl-install/install_steps.pm index 2377c6e4f..1fbeeff0f 100644 --- a/perl-install/install_steps.pm +++ b/perl-install/install_steps.pm @@ -101,7 +101,7 @@ sub doPartitionDisks($$) { sub rebootNeeded($) { my ($o) = @_; log::l("Rebooting..."); - exit(0); + exit "true"; } sub choosePartitionsToFormat($$) { diff --git a/perl-install/install_steps_interactive.pm b/perl-install/install_steps_interactive.pm index 9620d0be1..cb279d352 100644 --- a/perl-install/install_steps_interactive.pm +++ b/perl-install/install_steps_interactive.pm @@ -58,31 +58,7 @@ sub selectInstallClass($@) { [ @classes ], $o->default("installClass")); } -sub setupSCSI { - my ($o, $auto) = @_; - my $w; - my @l = modules::load_thiskind('scsi', sub { - $w = $o->wait_message('', - [ _("Installing driver for scsi card %s", $_->[0]), - $o->{installClass} ne "beginner" ? _("(module %s)", $_->[1]) : () - ]); - }); - undef $w; # kill wait_message - - return if $auto; - while (1) { - @l ? - $o->ask_yesorno('', - [ _("Found ") . join(", ", map { $_->[0] } @l) . _(" scsi interfaces"), - _("Do you have another one?") ], "No") : - $o->ask_yesorno('', _("Do you have an scsi interface?"), "No") or return; - - my $l = $o->ask_from_list('', _("What scsi card have you?"), [ modules::text_of_type('scsi') ]) or return; - my $m = modules::text2driver($l); - modules::load($m); - push @l, [ $l, $m ]; - } -} +sub setupSCSI { setup_thiskind($_[0], 'scsi', $_[1]) } sub rebootNeeded($) { my ($o) = @_; @@ -137,7 +113,8 @@ sub configureNetwork($) { if ($r =~ /^Don't/) { $o->{netc}{NETWORKING} = "false"; } elsif ($r !~ /^Keep/) { - my @l = network::getNet() or return die _("no network card found"); + $o->setup_thiskind('net', 1, 1); + my @l = detect_devices::getNet() or die _("no network card found"); my $last; foreach ($::expert ? @l : $l[0]) { my $intf = network::findIntf($o->{intf} ||= [], $_); @@ -215,4 +192,56 @@ Information on configuring your system is available in the post install chapter of the Official Linux Mandrake User's Guide.")); } -=cut +sub loadModule { + my ($o, $type) = @_; + my @options; + + my $l = $o->ask_from_list('', + _("What %s card have you?", $type), + [ modules::text_of_type($type) ]) or return; + my $m = modules::text2driver($l); + if ($o->ask_from_list('', +_("In some cases, the %s driver needs to have extra information to work +properly, although it normally works fine without. Would you like to specify +extra options for it or allow the driver to probe your machine for the +information it needs? Occasionally, probing will hang a computer, but it should +not cause any damage.", $l), + [ __("Autoprobe"), __("Specify options") ], "Autoprobe") ne "Autoprobe") { + @options = split ' ', + $o->ask_from_entry('', +_("Here must give the different options for the module %s. +Options are in format ``name=value name2=value2 ...''. +For example you can have ``io=0x300 irq=7''", $l), + _("Module options:"), + ); + } + modules::load($m, $type, @options); + $l, $m; +} + +sub load_thiskind { + my ($o, $type) = @_; + my $w; + modules::load_thiskind($type, sub { + $w = $o->wait_message('', + [ _("Installing driver for %s card %s", $type, $_->[0]), + $o->{installClass} ne "beginner" ? _("(module %s)", $_->[1]) : () + ]); + }); +} + +sub setup_thiskind { + my ($o, $type, $auto, $at_least_one) = @_; + my @l = $o->load_thiskind($type); + + return if $auto && (@l || !$at_least_one); + while (1) { + @l ? + $o->ask_yesorno('', + [ _("Found %s %s interfaces", join(", ", map { $_->[0] } @l), $type), + _("Do you have another one?") ], "No") : + $o->ask_yesorno('', _("Do you have an %s interface?", $type), "No") or return; + + push @l, [ $o->loadModule($type) ]; + } +} diff --git a/perl-install/modules.pm b/perl-install/modules.pm index 3bf19b943..59947da67 100644 --- a/perl-install/modules.pm +++ b/perl-install/modules.pm @@ -2,86 +2,91 @@ package modules; use diagnostics; use strict; -use vars qw(%loaded); use common qw(:common :file); use pci_probing::main; -use log; use detect_devices; use run_program; +use log; -%loaded = (); +my %conf; my %deps = (); - -my @neOptions = ( - [ "io=", "Base IO port:", "0x300:0x280:0x320:0x340:0x360" ], - [ "irq=", "IRQ level:", "" ], -); - -my @de4x5Options = ( - [ "io=", "Base IO port:", "0x0b" ], -); - -my @cdu31aOptions = ( - [ "cdu31a_port=", "Base IO port:", "" ], - [ "cdu31a_irq=", "IRQ level:", "" ], -); - -my @cm206Options = ( - [ "cm206=", "IO base, IRQ:", "" ], -); - -my @mcdOptions = ( - [ "mcd=", "Base IO port:", "" ], -); - -my @optcdOptions = ( - [ "optcd=", "Base IO port:", "" ], -); - -my @fdomainOptions = ( - [ "setup_called=", "Use other options", "1" ], - [ "port_base=", "Base IO port:", "0xd800" ], - [ "interrupt_level=", "Interrupt level (IRQ):", "10" ], -); - -my @sbpcdOptions = ( - [ "sbpcd=", "IO base, IRQ, label:", "" ], -); - -my @parportPcOptions = ( - [ "io=", "Base IO port:", "0x378" ], - [ "irq=", "IRQ level:", "7" ], -); - -my %modules = ( - "8390" => [ 1, undef, 0, '' ], - "cdu31a" => [ 0, \@cdu31aOptions, 0, '' ], - "cm206" => [ 0, \@cm206Options, 0, '' ], - "de4x5" => [ 1, \@de4x5Options, 'AUTOPROBE', "io=0" ], - "ds" => [ 1, undef, 0, '' ], - "fdomain" => [ 1, \@fdomainOptions, 0, '' ], - "i82365" => [ 1, undef, 0, '' ], - "isofs" => [ 1, undef, 0, '' ], - "loop" => [ 1, undef, 0, '' ], - "lp" => [ 1, undef, 0, '' ], - "parport" => [ 1, undef, 0, '' ], - "parport_pc" => [ 1, \@parportPcOptions, 0, "irq=7" ], - "mcd" => [ 0, \@mcdOptions, 0, '' ], - "ne" => [ 0, \@neOptions, 'FAKEAUTOPROBE', "io=0x300" ], - "nfs" => [ 1, undef, 0, '' ], - "optcd" => [ 0, \@optcdOptions, 0, '' ], - "pcmcia_core" => [ 1, undef, 0, '' ], - "sbpcd" => [ 1, \@sbpcdOptions, 0, '' ], - "smbfs" => [ 1, undef, 0, '' ], - "tcic" => [ 1, undef, 0, '' ], - "vfat" => [ 1, undef, 0, '' ], -); +# +#my %knownAliases = ( +# eth => { type => 'net', minor => 'ethernet' }, +# scsi_hostadapter => { type => 'scsi' }, +#); +# +#my @neOptions = ( +# [ "io=", __("Base IO port:"), "0x300", "0x280", "0x320", "0x340", "0x360" ], +# [ "irq=", __("IRQ level:"), "" ], +#); +# +#my @de4x5Options = ( +# [ "io=", __("Base IO port:"), "0x0b" ], +#); +# +#my @cdu31aOptions = ( +# [ "cdu31a_port=", __("Base IO port:"), "" ], +# [ "cdu31a_irq=", __("IRQ level:"), "" ], +#); +# +#my @cm206Options = ( +# [ "cm206=", __("IO base, IRQ:"), "" ], +#); +# +#my @mcdOptions = ( +# [ "mcd=", __("Base IO port:"), "" ], +#); +# +#my @optcdOptions = ( +# [ "optcd=", __("Base IO port:"), "" ], +#); +# +#my @fdomainOptions = ( +# [ "setup_called=", __("Use other options"), "1" ], +# [ "port_base=", __("Base IO port:"), "0xd800" ], +# [ "interrupt_level=", __("Interrupt level (IRQ):"), "10" ], +#); +# +#my @sbpcdOptions = ( +# [ "sbpcd=", __("IO base, IRQ, label:"), "" ], +#); +# +#my @parportPcOptions = ( +# [ "io=", __("Base IO port:"), "0x378" ], +# [ "irq=", __("IRQ level:"), "7" ], +#); +# +#my @modules_fields = qw(shouldAutoprobe options flags defaultOptions); +#my %modules = ( +# "8390" => [ 1 ], +# "cdu31a" => [ 0, \@cdu31aOptions ], +# "cm206" => [ 0, \@cm206Options ], +# "de4x5" => [ 1, \@de4x5Options, 'AUTOPROBE', "io=0" ], +# "ds" => [ 1, undef, 0, '' ], +# "fdomain" => [ 1, \@fdomainOptions, 0, '' ], +# "i82365" => [ 1, undef, 0, '' ], +# "isofs" => [ 1, undef, 0, '' ], +# "loop" => [ 1, undef, 0, '' ], +# "lp" => [ 1, undef, 0, '' ], +# "parport" => [ 1, undef, 0, '' ], +# "parport_pc" => [ 1, \@parportPcOptions, 0, "irq=7" ], +# "mcd" => [ 0, \@mcdOptions, 0, '' ], +# "ne" => [ 0, \@neOptions, 'FAKEAUTOPROBE', "io=0x300" ], +# "nfs" => [ 1, undef, 0, '' ], +# "optcd" => [ 0, \@optcdOptions, 0, '' ], +# "pcmcia_core" => [ 1, undef, 0, '' ], +# "sbpcd" => [ 1, \@sbpcdOptions, 0, '' ], +# "smbfs" => [ 1, undef, 0, '' ], +# "tcic" => [ 1, undef, 0, '' ], +# "vfat" => [ 1, undef, 0, '' ], +#); my @drivers_by_category = ( -[ 0, \&detect_devices::hasEthernet, 'net', 'ethernet', { +[ \&detect_devices::hasEthernet, 'net', 'ethernet', { "3c509" => "3com 3c509", "3c501" => "3com 3c501", "3c503" => "3com 3c503", @@ -129,7 +134,7 @@ my @drivers_by_category = ( "via-rhine" => "VIA Rhine", "wd" => "WD8003, WD8013 and compatible", }], -[ 0, \&detect_devices::hasSCSI, 'scsi', undef, { +[ \&detect_devices::hasSCSI, 'scsi', undef, { "aha152x" => "Adaptec 152x", "aha1542" => "Adaptec 1542", "aha1740" => "Adaptec 1740", @@ -161,7 +166,7 @@ my @drivers_by_category = ( "ultrastor" => "UltraStor 14F/24F/34F", "wd7000" => "Western Digital wd7000", }], -[ 0, undef, 'cdrom', 'none', { +[ undef, 'cdrom', 'none', { "sbpcd" => "SoundBlaster/Panasonic", "aztcd" => "Aztech CD", "bpcd" => "Backpack CDROM", @@ -176,25 +181,30 @@ my @drivers_by_category = ( }] ); +my @drivers_fields = qw(text detect type minor); my %drivers = ( - "plip" => [ "PLIP (parallel port)", 0, \&detect_devices::hasPlip, 'net', 'plip' ], - "ibmtr" => [ "Token Ring", 0, \&detect_devices::hasTokenRing, 'net', 'tr' ], - "DAC960" => [ "Mylex DAC960", 0, undef, 'scsi', undef ], - "pcmcia_core" => [ "PCMCIA core support", 0, undef, 'pcmcia', undef ], - "ds" => [ "PCMCIA card support", 0, undef, 'pcmcia', undef ], - "i82365" => [ "PCMCIA i82365 controller", 0, undef, 'pcmcia', undef ], - "tcic" => [ "PCMCIA tcic controller", 0, undef, 'pcmcia', undef ], - "isofs" => [ "iso9660", 0, undef, 'fs', undef ], - "nfs" => [ "Network File System (nfs)", 0, undef, 'fs', undef ], - "smbfs" => [ "Windows SMB", 0, undef, 'fs', undef ], - "loop" => [ "Loopback device", 0, undef, 'other', undef ], - "lp" => [ "Parallel Printer", 0, undef, 'other', undef ], + "plip" => [ "PLIP (parallel port)", \&detect_devices::hasPlip, 'net', 'plip' ], + "ibmtr" => [ "Token Ring", \&detect_devices::hasTokenRing, 'net', 'tr' ], + "DAC960" => [ "Mylex DAC960", undef, 'scsi', undef ], + "pcmcia_core" => [ "PCMCIA core support", undef, 'pcmcia', undef ], + "ds" => [ "PCMCIA card support", undef, 'pcmcia', undef ], + "i82365" => [ "PCMCIA i82365 controller", undef, 'pcmcia', undef ], + "tcic" => [ "PCMCIA tcic controller", undef, 'pcmcia', undef ], + "isofs" => [ "iso9660", undef, 'fs', undef ], + "nfs" => [ "Network File System (nfs)", undef, 'fs', undef ], + "smbfs" => [ "Windows SMB", undef, 'fs', undef ], + "loop" => [ "Loopback device", undef, 'other', undef ], + "lp" => [ "Parallel Printer", undef, 'other', undef ], ); foreach (@drivers_by_category) { my @l = @$_; my $l = pop @l; foreach (keys %$l) { $drivers{$_} = [ $l->{$_}, @l ]; } } +foreach (keys %drivers) { + my %l; @{$l{@drivers_fields}} = @{$drivers{$_}}; + $drivers{$_} = \%l; +} 1; @@ -203,35 +213,34 @@ foreach (@drivers_by_category) { sub text_of_type($) { my ($type) = @_; - map { $_->[0] } grep { $_->[3] eq $type } values %drivers; + map { $_->{text} } grep { $_->{type} eq $type } values %drivers; } sub text2driver($) { my ($text) = @_; while (my ($k, $v) = each %drivers) { - $v->[0] eq $text and return $k; + $v->{text} eq $text and return $k; } die "$text is not a valid module description"; } -sub load($;$$) { - my ($name, $type, $minor) = @_; +sub load($;$) { + my ($name, $type, @options) = @_; - $loaded{$name} and return; + $conf{$name}{loaded} and return; - $type or ($type, $minor) = @{$drivers{$name}}[3,4]; + $type ||= $drivers{$name}{type}; load($_, 'prereq', $minor) foreach @{$deps{$name}}; - load_raw($name, $type, $minor); + load_raw($name, @options); } sub unload($) { run_program::run("rmmod", $_[0]); } -sub load_raw($$$@) { - my ($name, $type, $minor, @options) = @_; +sub load_raw($@) { + my ($name, @options) = @_; -# @options or @options = guiGetModuleOptions($name); run_program::run("insmod", $name, @options) or die("insmod $name failed"); # this is a hack to make plip go @@ -244,13 +253,13 @@ sub load_raw($$$@) { print F $1; } } - $loaded{$name} = { type => $type, minor => $minor, options => \@options }; + $conf{$name}{loaded} = 1; } sub read_already_loaded() { foreach (cat_("/proc/modules", "die")) { my ($name) = split; - @{$loaded{$name}}{"type", "minor"} = @{$drivers{$name}}[3,4]; + $conf{$name}{loaded} = 1; } } @@ -267,52 +276,54 @@ sub load_deps($) { sub read_conf { my ($file) = @_; + my %c; - local *F; - open F, $file or log::l("failed to open $file for module information"), return 0; - - foreach (<F>) { - /^alias\s+eth0\s+(\S+)/ and $loaded{$1} = { type => 'net', minor => 'ethernet' }; - /^alias\s+scsi_hostadapter\s+(\S+)/ and $loaded{$1} = { type => 'scsi' }; - /^options\s+(\S+)\s+(.*)/ and add2hash($loaded{$1} || {}, { type => 'other', options => [ split ' ', $2 ] }); + foreach (cat_($file)) { + $c{$2}{$1} = $3 if /^\s*(\S+)\s+(\S+)\s+(.*?)\s*$/; + } + # cheating here: not handling aliases of aliases + while (my ($k, $v) = each %c) { + $c{scsi} ||= $v->{scsi_hostadapter}; + add2hash($c{$v->{alias}} ||= {}, $v) if $v->{alias}; } + %c; } sub write_conf { - my ($file, $append) = @_; - my ($tr, $eth, $scsi) = (0, 0, 0); - - $append or rename($file, "$file.orig"), log::l("backing up old $file"); + my ($file) = @_; + my %written = read_conf($file); + my $scsi = $written{scsi}; local *F; - open F, ($append ? ">" : "") . "> $file" or die("cannot write module config file $file: $!\n"); - - while (my ($k, $v) = each %loaded) { - if ($v->{type} eq 'net') { - $v->{minor} eq 'tr' and print F "alias tr", $tr++, " $k\n"; - $v->{minor} eq 'ethernet' and print F "alias eth", $eth++, " $k\n"; - } elsif ($v->{type} eq 'scsi') { - print F "alias scsi_hostadapter", $scsi++, " $k\n"; + open F, ">> $file" or die("cannot write module config file $file: $!\n"); + + while (my ($mod, $h) = each %conf) { + while (my ($type, $v2) = each %$h) { + unless ($written{$mod}{$type}) { + if ($mod eq 'scsi_hostadapter') { + print "#" if $scsi; + $scsi ||= 1; + } + print F "$type $mod $v2\n"; + } } - print F "options $k ", join(' ', @{$v->{options}}), "\n" unless is_empty_array_ref($v->{options}); } - print F "alias parport_lowlevel parport_pc\n"; - print F "pre-install pcmcia_core /etc/rc.d/init.d/pcmcia start\n"; } - +sub get_stage1_conf { + %conf = read_conf($_[0]); + $conf{alias}{parport_lowlevel} ||= "parport_pc"; + $conf{"pre-install"}{pcmcia_core} ||= "/etc/rc.d/init.d/pcmcia start"; + $conf{"pre-install"}{plip} ||= "modprobe parport_pc ; echo 7 > /proc/parport/0/irq"; +} sub load_thiskind($;&) { my ($type, $f) = @_; - my @devs; - my $found; - if ($type eq 'scsi' || $type eq 'net') { - @devs = pci_probing::main::probe($type); - log::l("pci probe found " . scalar @devs . " $type devices"); - } - my %devs; - foreach (@devs) { + my @devs = pci_probing::main::probe($type); + log::l("pci probe found " . scalar @devs . " $type devices"); + + my %devs; foreach (@devs) { my ($text, $mod) = @$_; $devs{$mod}++ and log::l("multiple $mod devices found"), next; $drivers{$mod} or log::l("module $mod not in install table"), next; diff --git a/perl-install/network.pm b/perl-install/network.pm index b3535301b..1234dcce2 100644 --- a/perl-install/network.pm +++ b/perl-install/network.pm @@ -7,7 +7,6 @@ use Socket; use common qw(:common :file :system :functional); use detect_devices; -use modules; use log; 1; @@ -133,11 +132,6 @@ sub dnsServers { grep { $_ } map { $netc->{$_} } qw(dnsServer dnsServer2 dnsServer3); } -sub getNet() { - modules::load_thiskind('net'); - detect_devices::getNet(); -} - sub findIntf { my ($intf, $device) = @_; my ($l) = grep { $_->{DEVICE} eq $device } @$intf; diff --git a/perl-install/pkgs.pm b/perl-install/pkgs.pm index d57ad837b..54091896e 100644 --- a/perl-install/pkgs.pm +++ b/perl-install/pkgs.pm @@ -11,6 +11,7 @@ use smp; use pkgs; use fs; use lang; +use c; 1; |