From 149bb85110e0f6de5f16d8acbb636644c4fb114d Mon Sep 17 00:00:00 2001 From: Pascal Rigaux Date: Thu, 8 Jul 2004 01:21:42 +0000 Subject: - rename add_alias() into set_alias() - create set_sound_slot() and use it --- perl-install/detect_devices.pm | 2 +- perl-install/harddrake/sound.pm | 6 +++--- perl-install/modules.pm | 18 +++++++++++++----- perl-install/network/adsl.pm | 2 +- perl-install/network/ethernet.pm | 4 ++-- 5 files changed, 20 insertions(+), 12 deletions(-) (limited to 'perl-install') diff --git a/perl-install/detect_devices.pm b/perl-install/detect_devices.pm index be21dac4b..5e573574d 100644 --- a/perl-install/detect_devices.pm +++ b/perl-install/detect_devices.pm @@ -441,7 +441,7 @@ sub getSerialModem { my @devs = pcmcia_probe(); foreach my $modem (@modems) { #- add an alias for macserial on PPC - modules::add_alias('serial', $serdev) if arch() =~ /ppc/ && $modem->{device}; + modules::set_alias('serial', $serdev) if arch() =~ /ppc/ && $modem->{device}; foreach (@devs) { $_->{type} =~ /serial/ and $modem->{device} = $_->{device} } } @modems; diff --git a/perl-install/harddrake/sound.pm b/perl-install/harddrake/sound.pm index 9796e7e7f..94f3ac5f9 100644 --- a/perl-install/harddrake/sound.pm +++ b/perl-install/harddrake/sound.pm @@ -154,8 +154,8 @@ sub do_switch { rooted("service alsa stop") if $old_driver =~ /^snd-/ && !$blacklisted; unload($old_driver); # run_program("/sbin/modprobe -r $driver"); # just in case ... } - modules::remove_module($old_driver); # completed by the next add_alias() - modules::add_alias("sound-slot-$index", $new_driver); + modules::remove_module($old_driver); + modules::set_sound_slot("sound-slot-$index", $new_driver); modules::write_conf(); if ($new_driver =~ /^snd-/) { # new driver is an alsa one $in->do_pkgs->ensure_is_installed('alsa-utils', '/usr/sbin/alsactl'); @@ -307,7 +307,7 @@ sub configure_sound_slots() { my $default_driver = modules::get_alias("sound-slot-$::i"); if (!member($default_driver, @{get_alternative($_->{driver})}, $_->{driver})) { $altered ||= $default_driver; - modules::add_alias("sound-slot-$::i", $_->{driver}); + modules::set_sound_slot("sound-slot-$::i", $_->{driver}); } } detect_devices::getSoundDevices(); modules::write_conf() if $altered && $::isStandalone; diff --git a/perl-install/modules.pm b/perl-install/modules.pm index dc71ad5e1..085abf894 100644 --- a/perl-install/modules.pm +++ b/perl-install/modules.pm @@ -87,7 +87,7 @@ sub load { sleep 2 if any { /^(usb-storage|mousedev|printer)$/ } @l; if ($network_module) { - add_alias($_, $network_module) foreach difference2([ detect_devices::getNet() ], \@network_devices); + set_alias($_, $network_module) foreach difference2([ detect_devices::getNet() ], \@network_devices); } when_load($_, @{$options{$_}}) foreach @l; } @@ -173,13 +173,12 @@ sub set_options { log::l(qq(set option "$new_option" for module "$name")); $conf{$name}{options} = $new_option; } -sub add_alias { +sub set_alias { my ($alias, $module) = @_; $module =~ /ignore/ and return; /\Q$alias/ && $conf{$_}{alias} && $conf{$_}{alias} eq $module and return $_ foreach keys %conf; log::l("adding alias $alias to $module"); $conf{$alias}{alias} = $module; - $conf{$module}{above} = 'snd-pcm-oss' if $module =~ /^snd-/; $alias; } sub add_probeall { @@ -227,6 +226,15 @@ sub remove_module { 0; } +sub set_sound_slot { + my ($alias, $module) = @_; + if (my $old = $conf{$alias}{alias}) { + $conf{$old} and delete $conf{$old}{above}; + } + set_alias($alias, $module); + $conf{$module}{above} = 'snd-pcm-oss' if $module =~ /^snd-/; +} + sub read_conf { my ($file) = @_; my %c; @@ -396,11 +404,11 @@ sub when_load { } elsif ($category eq 'bus/usb') { add_probeall('usb-interface', $name); } elsif ($category eq 'bus/firewire') { - add_alias('ieee1394-controller', $name); + set_alias('ieee1394-controller', $name); } elsif ($category =~ /sound/) { my $sound_alias = find { /^sound-slot-[0-9]+$/ && $conf{$_}{alias} eq $name } keys %conf; $sound_alias ||= 'sound-slot-0'; - add_alias($sound_alias, $name); + set_sound_slot($sound_alias, $name); } } } diff --git a/perl-install/network/adsl.pm b/perl-install/network/adsl.pm index bc3c170e9..2089dd229 100644 --- a/perl-install/network/adsl.pm +++ b/perl-install/network/adsl.pm @@ -307,7 +307,7 @@ TYPE=$kind # set aliases: if (exists $modems{$adsl_device}{aliases}) { - modules::add_alias($_->[0], $_->[1]) foreach @{$modems{$adsl_device}{aliases}}; + modules::set_alias($_->[0], $_->[1]) foreach @{$modems{$adsl_device}{aliases}}; $::isStandalone and modules::write_conf(); } diff --git a/perl-install/network/ethernet.pm b/perl-install/network/ethernet.pm index ea322a7f2..6f9cc8c85 100644 --- a/perl-install/network/ethernet.pm +++ b/perl-install/network/ethernet.pm @@ -87,7 +87,7 @@ sub get_eth_cards_names { foreach my $card (@all_cards) { modules::remove_alias($card->[1]); - modules::add_alias($card->[0], $card->[1]); + modules::set_alias($card->[0], $card->[1]); } { map { $_->[0] => join(': ', $_->[0], $_->[2]) } @all_cards }; @@ -134,7 +134,7 @@ sub conf_network_card_backend { sub configure_eth_aliases() { foreach (detect_devices::getNet()) { my $driver = c::getNetDriver($_) or next; - modules::add_alias($_, $driver); + modules::set_alias($_, $driver); } } -- cgit v1.2.1