summaryrefslogtreecommitdiffstats
path: root/perl-install/harddrake/autoconf.pm
diff options
context:
space:
mode:
authorOlivier Blin <oblin@mandriva.com>2008-09-01 16:47:01 +0000
committerOlivier Blin <oblin@mandriva.com>2008-09-01 16:47:01 +0000
commit1ecdf66b38c42e7721bbdb08371de7ad6aa1faa2 (patch)
tree9d229e9072e70c72613c7cf925304b5e46a06b2b /perl-install/harddrake/autoconf.pm
parent6cd47f9d37f9dd6c66351ecf477335a038481b62 (diff)
downloaddrakx-1ecdf66b38c42e7721bbdb08371de7ad6aa1faa2.tar
drakx-1ecdf66b38c42e7721bbdb08371de7ad6aa1faa2.tar.gz
drakx-1ecdf66b38c42e7721bbdb08371de7ad6aa1faa2.tar.bz2
drakx-1ecdf66b38c42e7721bbdb08371de7ad6aa1faa2.tar.xz
drakx-1ecdf66b38c42e7721bbdb08371de7ad6aa1faa2.zip
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)
Diffstat (limited to 'perl-install/harddrake/autoconf.pm')
-rw-r--r--perl-install/harddrake/autoconf.pm25
1 files changed, 25 insertions, 0 deletions
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;