From ff2191b0d6fe81de6447fe1d453f8640f1a19b42 Mon Sep 17 00:00:00 2001 From: Pascal Rigaux Date: Tue, 10 Aug 2004 02:00:45 +0000 Subject: internally keep module names according to what we configure (and our kernel, 2.4 or 2.6) --- perl-install/modules.pm | 17 +++++++++------ perl-install/modules/any_conf.pm | 40 ++++++++++++++++++++++------------- perl-install/modules/modprobe_conf.pm | 13 ++++++++++-- perl-install/modules/modules_conf.pm | 13 +++++++++++- 4 files changed, 58 insertions(+), 25 deletions(-) (limited to 'perl-install') diff --git a/perl-install/modules.pm b/perl-install/modules.pm index 8ea7ba431..31792b6e0 100644 --- a/perl-install/modules.pm +++ b/perl-install/modules.pm @@ -38,11 +38,16 @@ $mappings_26_24{'uhci-hcd'} = 'usb-uhci'; sub mapping_24_26 { my ($modname) = @_; - c::kernel_version() =~ /^\Q2.6/ && $mappings_24_26{$modname} || $modname; + $mappings_24_26{$modname} || $modname; } sub mapping_26_24 { my ($modname) = @_; - c::kernel_version() =~ /^\Q2.6/ && $mappings_26_24{$modname} || $modname; + $mappings_26_24{$modname} || $modname; +} + +sub cond_mapping_24_26 { + my ($modname) = @_; + c::kernel_version() =~ /^\Q2.6/ && $mappings_24_26{$modname} || $modname; } #-############################################################################### @@ -65,7 +70,7 @@ sub load_raw { sub load { my (@l) = @_; @l = map { - dependencies_closure(mapping_24_26($_)); + dependencies_closure(cond_mapping_24_26($_)); } @l; @l = remove_loaded_modules(@l) or return; @@ -80,7 +85,7 @@ sub load_and_configure { my $category = module2category($module) || ''; my $network_devices = $category =~ m!network/(main|gigabit|usb|wireless)! && [ detect_devices::getNet() ]; - my @l = remove_loaded_modules(dependencies_closure(mapping_24_26($module))) or return; + my @l = remove_loaded_modules(dependencies_closure(cond_mapping_24_26($module))) or return; load_raw(\@l, { $module => $o_options }); if ($network_devices) { @@ -211,8 +216,6 @@ sub name2file { sub when_load { my ($conf, $name) = @_; - $name = mapping_26_24($name); #- need to stay with 2.4 names, modutils will allow booting 2.4 and 2.6 - if (my $category = module2category($name)) { when_load_category($conf, $name, $category); } @@ -231,7 +234,7 @@ sub when_load_category { } elsif ($category eq 'bus/usb') { $conf->add_probeall('usb-interface', $name); -f '/proc/bus/usb/devices' or eval { - require fs; fs::mount('/proc/bus/usb', '/proc/bus/usb', 'usbdevfs'); + require fs; fs::mount('none', '/proc/bus/usb', 'usbdevfs'); #- ensure keyboard is working, the kernel must do the job the BIOS was doing sleep 4; load("usbkbd", "keybdev") if detect_devices::usbKeyboards(); diff --git a/perl-install/modules/any_conf.pm b/perl-install/modules/any_conf.pm index b2655dba0..0af11a461 100644 --- a/perl-install/modules/any_conf.pm +++ b/perl-install/modules/any_conf.pm @@ -30,42 +30,48 @@ sub get_alias { $conf->{$alias}{alias}; } sub get_options { - my ($conf, $name) = @_; - $conf->{$name}{options}; + my ($conf, $module) = @_; + $module = $conf->mapping($module); + $conf->{$module}{options}; } sub set_options { - my ($conf, $name, $new_option) = @_; - log::l(qq(set option "$new_option" for module "$name")); - $conf->{$name}{options} = $new_option; + my ($conf, $module, $new_option) = @_; + $module = $conf->mapping($module); + log::l(qq(set option "$new_option" for module "$module")); + $conf->{$module}{options} = $new_option; } sub get_parameters { - my ($conf, $name) = @_; - map { if_(/(.*)=(.*)/, $1 => $2) } split(' ', $conf->get_options($name)); + my ($conf, $module) = @_; + $module = $conf->mapping($module); + map { if_(/(.*)=(.*)/, $1 => $2) } split(' ', $conf->get_options($module)); } sub get_probeall { my ($conf, $alias) = @_; $conf->{$alias}{probeall}; } -sub set_probeall { +sub _set_probeall { my ($conf, $alias, $modules) = @_; $conf->{$alias}{probeall} = $modules; log::l("setting probeall $alias to $modules"); } sub add_probeall { my ($conf, $alias, $module) = @_; + $module = $conf->mapping($module); my $modules = join(' ', uniq(split(' ', $conf->{$alias}{probeall}), $module)); - set_probeall($conf, $alias, $modules); + _set_probeall($conf, $alias, $modules); } sub remove_probeall { my ($conf, $alias, $module) = @_; + $module = $conf->mapping($module); my $modules = join(' ', grep { $_ ne $module } split(' ', $conf->{$alias}{probeall})); - set_probeall($conf, $alias, $modules); + _set_probeall($conf, $alias, $modules); } sub set_alias { my ($conf, $alias, $module) = @_; $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"); $conf->{$alias}{alias} = $module; @@ -96,15 +102,17 @@ sub remove_alias_regexp_byname { } sub remove_module { - my ($conf, $name) = @_; - $conf->remove_alias($name); - log::l("removing module $name"); - delete $conf->{$name}; + my ($conf, $module) = @_; + $module = $conf->mapping($module); + $conf->remove_alias($module); + log::l("removing module $module"); + delete $conf->{$module}; 0; } sub set_sound_slot { my ($conf, $alias, $module) = @_; + $module = $conf->mapping($module); if (my $old = $conf->get_alias($alias)) { $conf->set_above($old, undef); } @@ -156,7 +164,9 @@ sub write { my $to_add; while (my ($module, $h) = each %$conf) { while (my ($type, $v) = each %$h) { - $to_add .= "$type $module $v\n" if $v && !$written{$module}{$type}; + if ($v && !$written{$module}{$type}) { + $to_add .= "$type $module $v\n"; + } } } append_to_file($file, $to_add); diff --git a/perl-install/modules/modprobe_conf.pm b/perl-install/modules/modprobe_conf.pm index c371c1e06..1bc5e478c 100644 --- a/perl-install/modules/modprobe_conf.pm +++ b/perl-install/modules/modprobe_conf.pm @@ -9,8 +9,15 @@ our @ISA = qw(modules::any_conf); sub file { '/etc/modprobe.conf' } sub handled_fields { qw(alias options install remove) } +sub mapping { + my ($_conf, @modules) = @_; + my @l = map { modules::mapping_24_26($_) } @modules; + wantarray ? @l : $l[0]; +} + sub get_above { my ($conf, $module) = @_; + $module = $conf->mapping($module); my (undef, $after) = parse_non_virtual($module, $conf->{$module}{install}) or return; my ($l, $_other_cmds) = partition_modprobes($after); @@ -18,17 +25,19 @@ sub get_above { } sub set_above { my ($conf, $module, $o_modules) = @_; + $module = $conf->mapping($module); + my @modules = $conf->mapping(split(' ', $o_modules || '')); { #- first add to "install" command my ($before, $after) = parse_non_virtual($module, $conf->{$module}{install}); my ($_previous_modules, $other_cmds) = partition_modprobes($after || ''); - $after = join('; ', @$other_cmds, map { "/sbin/modprobe $_" } split(' ', $o_modules || '')); + $after = join('; ', @$other_cmds, map { "/sbin/modprobe $_" } @modules); $conf->{$module}{install} = unparse_non_virtual($module, '--ignore-install', $before, $after); } { #- then to "remove" command my ($before, $after) = parse_non_virtual($module, $conf->{$module}{remove}); my ($_previous_modules, $other_cmds) = partition_modprobes($before || ''); - $before = join('; ', @$other_cmds, map { "/sbin/modprobe -r $_" } split(' ', $o_modules || '')); + $before = join('; ', @$other_cmds, map { "/sbin/modprobe -r $_" } @modules); $conf->{$module}{remove} = unparse_non_virtual($module, '-r --ignore-remove', $before, $after); } } diff --git a/perl-install/modules/modules_conf.pm b/perl-install/modules/modules_conf.pm index fc9f92179..c0944010d 100644 --- a/perl-install/modules/modules_conf.pm +++ b/perl-install/modules/modules_conf.pm @@ -9,14 +9,25 @@ our @ISA = qw(modules::any_conf); sub file { '/etc/modules.conf' } sub handled_fields { qw(alias above options probeall) } +sub mapping { + my ($_conf, @modules) = @_; + my @l = map { modules::mapping_26_24($_) } @modules; + wantarray ? @l : $l[0]; +} + sub get_above { my ($conf, $module) = @_; + $module = $conf->mapping($module); + $conf->{$module} && $conf->{$module}{above}; } sub set_above { my ($conf, $module, $o_modules) = @_; + $module = $conf->mapping($module); + if ($o_modules) { - $conf->{$module}{above} = $o_modules; + my $modules = join(' ', $conf->mapping(split(' ', $o_modules))); + $conf->{$module}{above} = $modules; } else { delete $conf->{$module}{above}; } -- cgit v1.2.1