From 1ecdf66b38c42e7721bbdb08371de7ad6aa1faa2 Mon Sep 17 00:00:00 2001 From: Olivier Blin Date: Mon, 1 Sep 2008 16:47:01 +0000 Subject: service_harddrake: adapt kernel modaliases that are not valid anymore in modprobe.conf when booting a new kernel, this should fix migration from e1000 to e1000e and from iwl4965 to iwlagn (#41248) --- perl-install/harddrake/autoconf.pm | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'perl-install/harddrake/autoconf.pm') diff --git a/perl-install/harddrake/autoconf.pm b/perl-install/harddrake/autoconf.pm index 9b16f5d3c..4f234010d 100644 --- a/perl-install/harddrake/autoconf.pm +++ b/perl-install/harddrake/autoconf.pm @@ -83,4 +83,29 @@ sub cpufreq() { modules::set_preload_modules("cpufreq", cpufreq::get_modules()); } +sub fix_aliases { + my ($modules_conf) = @_; + require modalias; + my %new_aliases; + #- first pass: find module targets whose modalias is not valid anymore + foreach my $module ($modules_conf->modules) { + if (my $aliased_to = $modules_conf->get_alias($module)) { + my @valid_modaliases = modalias::get_modules($module, 'skip_config') or next; + my ($found, $others) = partition { $_ eq $aliased_to } @valid_modaliases; + $new_aliases{$aliased_to} = @{$others || []} == 1 && $others->[0] if is_empty_array_ref($found); + } + } + #- second pass: adapt module targets that are not valid anymore + foreach my $module ($modules_conf->modules) { + if (my $aliased_to = $modules_conf->get_alias($module)) { + if (my $new = exists $new_aliases{$aliased_to} && $new_aliases{$aliased_to}) { + $modules_conf->set_alias($module, $new); + } else { + $modules_conf->remove_alias($module); + } + } + } + $modules_conf->write; +} + 1; -- cgit v1.2.1