summaryrefslogtreecommitdiffstats
path: root/perl-install/modules
diff options
context:
space:
mode:
Diffstat (limited to 'perl-install/modules')
-rw-r--r--perl-install/modules/any_conf.pm80
-rw-r--r--perl-install/modules/interactive.pm58
-rw-r--r--perl-install/modules/modprobe_conf.pm17
-rw-r--r--perl-install/modules/modules_conf.pm12
-rw-r--r--perl-install/modules/parameters.pm47
5 files changed, 106 insertions, 108 deletions
diff --git a/perl-install/modules/any_conf.pm b/perl-install/modules/any_conf.pm
index 0af11a461..c235e84f4 100644
--- a/perl-install/modules/any_conf.pm
+++ b/perl-install/modules/any_conf.pm
@@ -1,17 +1,12 @@
-package modules::any_conf; # $Id$
+package modules::any_conf;
use log;
use common;
sub vnew {
- if (c::kernel_version() =~ /^\Q2.6/) {
- require modules::modprobe_conf;
- modules::modprobe_conf->new;
- } else {
- require modules::modules_conf;
- modules::modules_conf->new;
- }
+ require modules::modprobe_conf;
+ modules::modprobe_conf->new;
}
@@ -37,7 +32,7 @@ sub get_options {
sub set_options {
my ($conf, $module, $new_option) = @_;
$module = $conf->mapping($module);
- log::l(qq(set option "$new_option" for module "$module"));
+ log::explanations(qq(set option "$new_option" for module "$module"));
$conf->{$module}{options} = $new_option;
}
sub get_parameters {
@@ -53,7 +48,7 @@ sub get_probeall {
sub _set_probeall {
my ($conf, $alias, $modules) = @_;
$conf->{$alias}{probeall} = $modules;
- log::l("setting probeall $alias to $modules");
+ log::explanations("setting probeall $alias to $modules");
}
sub add_probeall {
my ($conf, $alias, $module) = @_;
@@ -73,7 +68,7 @@ sub set_alias {
$module =~ /ignore/ and return;
$module = $conf->mapping($module);
/\Q$alias/ && $conf->{$_}{alias} && $conf->{$_}{alias} eq $module and return $_ foreach keys %$conf;
- log::l("adding alias $alias to $module");
+ log::explanations("adding alias $alias to $module");
$conf->{$alias}{alias} = $module;
$alias;
}
@@ -81,13 +76,13 @@ sub set_alias {
sub remove_alias {
my ($conf, $name) = @_;
- log::l(qq(removing alias "$name"));
+ log::explanations(qq(removing alias "$name"));
$conf->remove_alias_regexp("^$name\$");
}
sub remove_alias_regexp {
my ($conf, $aliased) = @_;
- log::l(qq(removing all aliases that match "$aliased"));
+ log::explanations(qq(removing all aliases that match "$aliased"));
foreach (keys %$conf) {
delete $conf->{$_}{alias} if /$aliased/;
}
@@ -95,7 +90,7 @@ sub remove_alias_regexp {
sub remove_alias_regexp_byname {
my ($conf, $name) = @_;
- log::l(qq(removing all aliases which names match "$name"));
+ log::explanations(qq(removing all aliases which names match "$name"));
foreach (keys %$conf) {
delete $conf->{$_} if /$name/;
}
@@ -103,9 +98,16 @@ sub remove_alias_regexp_byname {
sub remove_module {
my ($conf, $module) = @_;
+ return if !$module;
$module = $conf->mapping($module);
+ foreach my $file ("$::prefix/etc/modules", "$::prefix/etc/modprobe.preload") {
+ substInFile {
+ undef $_ if /^$module/;
+ } $file;
+ }
+
$conf->remove_alias($module);
- log::l("removing module $module");
+ log::explanations("removing module $module");
delete $conf->{$module};
0;
}
@@ -124,18 +126,8 @@ sub set_sound_slot {
sub read {
my (undef, $o_file) = @_;
- my $conf = modules::any_conf::vnew();
- my $raw_conf = modules::any_conf::read_raw($o_file || $::prefix . $conf->file);
-
- foreach my $module (keys %$raw_conf) {
- my $raw = $raw_conf->{$module};
- my $keep = $conf->{$module} = {};
- foreach ($conf->handled_fields) {
- $keep->{$_} = $raw->{$_} if $raw->{$_};
- }
- }
-
- $conf;
+ my $conf = vnew();
+ $conf->read($o_file);
}
sub write {
@@ -147,10 +139,7 @@ sub write {
#- Substitute new config (if config has changed)
substInFile {
my ($type, $module, $val) = split(' ', chomp_($_), 3);
- if ($type eq 'post-install' && $module eq 'supermount') {
- #- remove the post-install supermount stuff.
- $_ = '';
- } elsif (member($type, $conf->handled_fields)) {
+ if (member($type, $conf->handled_fields)) {
my $new_val = $conf->{$module}{$type};
if (!$new_val) {
$_ = '';
@@ -174,10 +163,34 @@ sub write {
modules::write_preload_conf($conf);
}
+sub merge_into {
+ my ($conf, $conf2) = @_;
-
+ if (ref($conf) eq ref($conf2)) {
+ log::l("merging " . ref($conf));
+ add2hash($conf, $conf2);
+ } else {
+ log::l("not merging modules_conf " . ref($conf2) . " into " . ref($conf));
+ }
+}
################################################################################
+sub read_handled {
+ my ($conf, $o_file) = @_;
+ my $file = $o_file || $::prefix . $conf->file;
+ my $raw_conf = read_raw($file);
+
+ foreach my $module (keys %$raw_conf) {
+ my $raw = $raw_conf->{$module};
+ my $keep = $conf->{$module} = {};
+ foreach ($conf->handled_fields) {
+ $keep->{$_} = $raw->{$_} if $raw->{$_};
+ }
+ }
+
+ $conf;
+}
+
sub read_raw {
my ($file) = @_;
my %c;
@@ -187,9 +200,6 @@ sub read_raw {
s/#.*$//;
s/\s+$//;
- s/\b(snd-card-)/snd-/g;
- s/\b(snd-via686|snd-via8233)\b/snd-via82xx/g;
-
my ($type, $module, $val) = split(' ', $_, 3) or next;
$c{$module}{$type} = $val;
diff --git a/perl-install/modules/interactive.pm b/perl-install/modules/interactive.pm
index a05f0a39e..dae135889 100644
--- a/perl-install/modules/interactive.pm
+++ b/perl-install/modules/interactive.pm
@@ -1,5 +1,5 @@
package modules::interactive;
-use interactive;
+
use modules;
use common;
@@ -11,17 +11,18 @@ sub config_window {
require modules::parameters;
my @l;
foreach (modules::parameters::parameters($data->{driver})) {
- my ($name, $format, $description) = @$_;
- push @l, { label => $name, help => join("\n", $description, if_(c::kernel_version() !~ /^\Q2.6/, "[$format]")),
- val => \$conf{$name}, allow_empty_list => 1 };
+ my ($name, $description) = @$_;
+ push @l, { label => $name, help => $description,
+ val => \$conf{$name}, allow_empty_list => 1 };
+ }
+ if (!@l) {
+ $in->ask_warn(N("Error"), N("This driver has no configuration parameter!"));
+ return;
}
- # BUG: once we've released mdk9.2 and unfreeze cooker, morph this
- # into a proper error dialog with a nice error message (but
- # for now we cannot due to string freeze :-()
- @l = { label => N("Parameters"), help => "", val => N("NONE"), allow_empty_list => 1 } if !@l;
if ($in->ask_from(N("Module configuration"), N("You can configure each parameter of the module here."), \@l)) {
- my $options = join(' ', map { if_($conf{$_}, "$_=$conf{$_}") } keys %conf);
- if ($options) {
+ my $options = join(' ', map { if_($conf{$_} =~ /^\S+$/, "$_=$conf{$_}") } keys %conf);
+ my $old_options = $modules_conf->get_options($data->{driver});
+ if ($options ne $old_options) {
$modules_conf->set_options($data->{driver}, $options);
$modules_conf->write;
}
@@ -66,7 +67,7 @@ sub load_category__prompt_for_more {
my $r = 'No';
$in->ask_from_({ messages => $msg,
- if_($category =~ m|disk/scsi|, interactive_help_id => 'setupSCSI'),
+ if_($category =~ m!disk/.*(ide|sata|scsi|hardware_raid|usb|firewire)!, interactive_help_id => 'setupSCSI'),
},
[ { list => [ N_("Yes"), N_("No"), N_("See hardware info") ], val => \$r, type => 'list', format => \&translate } ]);
if ($r eq "No") { return @l }
@@ -78,27 +79,39 @@ sub load_category__prompt_for_more {
}
}
+my %category2text = (
+ 'bus/usb' => N_("Installing driver for USB controller"),
+ 'bus/firewire' => N_("Installing driver for firewire controller \"%s\""),
+ 'disk/card_reader|ide|scsi|hardware_raid|sata|firewire|virtual' => N_("Installing driver for hard disk drive controller \"%s\""),
+ list_modules::ethernet_categories() => N_("Installing driver for ethernet controller \"%s\""),
+);
+
sub wait_load_module {
- my ($in, $category, $text, $module) = @_;
- $in->wait_message('',
- [
- #-PO: the first %s is the card type (scsi, network, sound,...)
- #-PO: the second is the vendor+model name
- N("Installing driver for %s card %s", $category, $text), if_($::expert, N("(module %s)", $module))
- ]);
+ my ($in, $category, $text, $_module) = @_;
+ my $msg = do {
+ if (my $t = $category2text{$category}) {
+ sprintf(translate($t), $text);
+ } else {
+ #-PO: the first %s is the card type (scsi, network, sound,...)
+ #-PO: the second is the vendor+model name
+ N("Installing driver for %s card %s", $category, $text);
+ }
+ };
+ $in->wait_message(N("Configuring Hardware"), $msg);
}
sub load_module__ask_options {
my ($in, $module_descr, $parameters) = @_;
- my @parameters = map { [ @$_[0, 1, 2] ] } @$parameters;
+ #- deep copying
+ my @parameters = map { [ @$_[0, 1] ] } @$parameters;
if (@parameters) {
$in->ask_from('',
N("You may now provide options to module %s.\nNote that any address should be entered with the prefix 0x like '0x123'", $module_descr),
- [ map { { label => $_->[0] . ($_->[1] ? " ($_->[1])" : ''), help => $_->[2], val => \$_->[3] } } @parameters ],
+ [ map { { label => $_->[0], help => $_->[1], val => \$_->[2] } } @parameters ],
) or return;
- join(' ', map { if_($_->[3], "$_->[0]=$_->[3]") } @parameters);
+ join(' ', map { if_($_->[2], "$_->[0]=$_->[2]") } @parameters);
} else {
my $s = $in->ask_from_entry('',
N("You may now provide options to module %s.
@@ -112,7 +125,8 @@ sub load_category__prompt {
my ($in, $modules_conf, $category) = @_;
(my $msg_type = $category) =~ s/\|.*//;
- my %available_modules = map_each { $::a => $::b ? "$::a ($::b)" : $::a } modules::category2modules_and_description($category);
+
+ my %available_modules = map_each { my $dsc = $::b; $dsc =~ s/\s+/ /g; $::a => $dsc ? "$::a ($dsc)" : $::a } modules::category2modules_and_description($category);
my $module = $in->ask_from_listf('',
#-PO: the %s is the driver type (scsi, network, sound,...)
N("Which %s driver should I try?", $msg_type),
diff --git a/perl-install/modules/modprobe_conf.pm b/perl-install/modules/modprobe_conf.pm
index 2db68122d..7989096f8 100644
--- a/perl-install/modules/modprobe_conf.pm
+++ b/perl-install/modules/modprobe_conf.pm
@@ -1,7 +1,8 @@
-package modules::modprobe_conf; # $Id$
+package modules::modprobe_conf;
use log;
use common;
+# perl_checker: require modules::any_conf
our @ISA = qw(modules::any_conf);
@@ -21,7 +22,7 @@ sub get_above {
my (undef, $after) = parse_non_virtual($module, $conf->{$module}{install}) or return;
my ($l, $_other_cmds) = partition_modprobes($after);
- join(' ', @$l);
+ @$l;
}
sub set_above {
my ($conf, $module, $o_modules) = @_;
@@ -42,19 +43,23 @@ sub set_above {
}
}
+sub create_from_old() {
+ #- use module-init-tools script
+ run_program::rooted($::prefix, "/sbin/generate-modprobe.conf", ">", file());
+}
+
sub read {
my ($type, $o_file) = @_;
my $file = $o_file || do {
my $f = $::prefix . file();
if (!-e $f && -e "$::prefix/etc/modules.conf") {
- #- use module-init-tools script
- run_program::rooted($::prefix, "/sbin/generate-modprobe.conf", ">", file());
+ create_from_old();
}
$f;
};
- my $conf = modules::any_conf::read($type, $file);
+ my $conf = modules::any_conf::read_handled($type, $file);
extract_probeall_field($conf);
@@ -98,7 +103,7 @@ sub parse_non_virtual {
sub unparse_non_virtual {
my ($module, $mode, $before, $after) = @_;
($before ? "$before; " : '')
- . "/sbin/modprobe --first-time $mode $module"
+ . (($before || $after) ? "/sbin/modprobe --first-time $mode $module" : '')
. ($after ? " && { $after; /bin/true; }" : '');
}
diff --git a/perl-install/modules/modules_conf.pm b/perl-install/modules/modules_conf.pm
index 476fd300f..be4b8fca4 100644
--- a/perl-install/modules/modules_conf.pm
+++ b/perl-install/modules/modules_conf.pm
@@ -1,7 +1,8 @@
-package modules::modules_conf; # $Id$
+package modules::modules_conf;
use log;
use common;
+# perl_checker: require modules::any_conf
our @ISA = qw(modules::any_conf);
@@ -19,7 +20,7 @@ sub get_above {
my ($conf, $module) = @_;
$module = $conf->mapping($module);
- $conf->{$module} && $conf->{$module}{above};
+ $conf->{$module} && split(' ', $conf->{$module}{above});
}
sub set_above {
my ($conf, $module, $o_modules) = @_;
@@ -36,7 +37,7 @@ sub set_above {
sub read {
my ($type, $o_file) = @_;
- my $conf = modules::any_conf::read($type, $o_file);
+ my $conf = modules::any_conf::read_handled($type, $o_file);
#- convert old aliases to new probeall
foreach my $name ('scsi_hostadapter', 'usb-interface') {
@@ -60,6 +61,11 @@ sub write {
};
modules::any_conf::write($conf, $file);
+
+ if ($::isInstall) {
+ require modules::modprobe_conf;
+ modules::modprobe_conf::create_from_old();
+ }
}
1;
diff --git a/perl-install/modules/parameters.pm b/perl-install/modules/parameters.pm
index 66590f7d8..36990b5d1 100644
--- a/perl-install/modules/parameters.pm
+++ b/perl-install/modules/parameters.pm
@@ -1,4 +1,4 @@
-package modules::parameters; # $Id$
+package modules::parameters;
use diagnostics;
use strict;
@@ -13,48 +13,11 @@ use modules;
sub parameters {
my ($module) = @_;
- if (!$::isStandalone && !$::testing) {
- ($module) = modules::extract_modules('/tmp', $module);
- }
-
- my @parameters;
- foreach (common::join_lines(run_program::get_stdout('modinfo', '-p', $module))) {
+ map {
chomp;
- next if /^warning:/;
- (my $name, $_) = /(\w+)(?::|\s+)(.*)/s or warn "modules::parameters::get_options_name($module): unknown line\n";
- if (c::kernel_version() =~ /^\Q2.6/) {
- push @parameters, [ $name, '', $_ ];
- next;
- }
-
- my $c_types = 'int|string|short|byte|char|long';
- my ($is_a_number, $description, $min, $max) = (0, '', 1, 1);
- if (/^($c_types) array \(min = (\d+), max = (\d+)\),?\s*(.*)/s) {
- $_ = $4;
- #- seems like "char" are buggy entries
- ($is_a_number, $min, $max) = ($1 ne 'string', $2, $3) if $1 ne 'char';
- } elsif (/^($c_types),?\s*(.*)/s) {
- $_ = $2;
- #- here "char" really are size-limited strings, modinfo doesn't display the size limit (but since we don't care about it, it doesn't matter :)
- $is_a_number = $1 ne 'string' if $1 ne 'char';
- } else {
- #- for things like "no format character" or "unknown format character"
- }
- if (/^description "(.*)",?\s*/s) {
- ($description, $_) = ($1, $2);
- }
- #- print "STILL HAVE ($_)\n" if $_;
-
- my $format = $min == 1 && $max == 1 ?
- ($is_a_number ? N("a number") : '') :
- $min == $max ?
- ($is_a_number ? N("%d comma separated numbers", $min) : N("%d comma separated strings", $min)) :
- $min == 1 ?
- ($is_a_number ? N("comma separated numbers") : N("comma separated strings")) :
- ''; #- too weird and buggy, do not display it
- push @parameters, [ $name, $format, $description ];
- }
- @parameters;
+ (my $name, $_) = /(\w+):(.*)/s or warn "modules::parameters::parameters($module): unknown line\n";
+ [ $name, $_ ];
+ } common::join_lines(run_program::get_stdout('modinfo', '-p', $module));
}
1;