diff options
author | Pascal Rigaux <pixel@mandriva.com> | 2004-07-21 00:16:04 +0000 |
---|---|---|
committer | Pascal Rigaux <pixel@mandriva.com> | 2004-07-21 00:16:04 +0000 |
commit | 7e8fa9773839843c9d8def81ec2ef1315115825a (patch) | |
tree | b20f63ae9f67b2d9c7e8aa6a2b86d56e0d953743 /perl-install/modules/any_conf.pm | |
parent | 54b71cdf438434e4693aa6064596f4fdb4aac59e (diff) | |
download | drakx-7e8fa9773839843c9d8def81ec2ef1315115825a.tar drakx-7e8fa9773839843c9d8def81ec2ef1315115825a.tar.gz drakx-7e8fa9773839843c9d8def81ec2ef1315115825a.tar.bz2 drakx-7e8fa9773839843c9d8def81ec2ef1315115825a.tar.xz drakx-7e8fa9773839843c9d8def81ec2ef1315115825a.zip |
- %modules::conf is no more a global, so many functions need passing $modules_conf
- $modules_conf is a class choosing modules.conf or modprobe.conf
(esp. useful after install) (but not working yet!)
- modules::load() doesn't use $modules_conf, use modules::load_and_configure()
- modules::load() doesn't allow options, use either modules::load_raw() or modules::load_and_configure()
- some functions used to want an array ref for modules options and some a string, now every functions use a string
- many functions (like modules::get_alias()) are now methods on $modules_conf
- some functions in mouse.pm needed a $in where a $do_pkgs is enough
- some perl_checker compliance
- small fixes
Diffstat (limited to 'perl-install/modules/any_conf.pm')
-rw-r--r-- | perl-install/modules/any_conf.pm | 117 |
1 files changed, 117 insertions, 0 deletions
diff --git a/perl-install/modules/any_conf.pm b/perl-install/modules/any_conf.pm new file mode 100644 index 000000000..10d21e712 --- /dev/null +++ b/perl-install/modules/any_conf.pm @@ -0,0 +1,117 @@ +package modules::any_conf; + +use log; +use common; + + +sub vnew { + if (0 && c::kernel_version() =~ /^\Q2.6/) { + require modules::modprobe_conf; + modules::modprobe_conf->new; + } else { + require modules::modules_conf; + modules::modules_conf->new; + } +} + + +sub new { + my ($type) = @_; + bless {}, ref($type) || $type; +} + +sub read { + my ($_type, $o_file) = @_; + + my $conf = vnew(); + my $raw_conf = modules::read_conf($o_file || "$::prefix/etc/modules.conf"); + foreach my $key (keys %$raw_conf) { + my $raw = $raw_conf->{$key}; + my $keep = $conf->{$key} = {}; + $keep->{alias} ||= $raw->{alias}; + $keep->{above} ||= $raw->{above}; + $keep->{options} = $raw->{options} if $raw->{options}; + push @{$keep->{probeall} ||= []}, deref($raw->{probeall}) if $raw->{probeall}; + } + $conf; +} + +sub write { + my ($conf) = @_; + modules::write_conf($conf); +} + +sub modules { + my ($conf) = @_; + keys %$conf; +} + +sub get_alias { + my ($conf, $alias) = @_; + $conf->{$alias}{alias}; +} +sub get_options { + my ($conf, $name) = @_; + $conf->{$name}{options}; +} +sub set_options { + my ($conf, $name, $new_option) = @_; + log::l(qq(set option "$new_option" for module "$name")); + $conf->{$name}{options} = $new_option; +} +sub get_parameters { + my ($conf, $name) = @_; + map { if_(/(.*)=(.*)/, $1 => $2) } split(' ', $conf->get_options($name)); +} + + +sub set_alias { + my ($conf, $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; + $alias; +} + + +sub remove_alias { + my ($conf, $name) = @_; + log::l(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")); + foreach (keys %$conf) { + delete $conf->{$_}{alias} if /$aliased/; + } +} + +sub remove_alias_regexp_byname { + my ($conf, $name) = @_; + log::l(qq(removing all aliases which names match "$name")); + foreach (keys %$conf) { + delete $conf->{$_} if /$name/; + } +} + +sub remove_module { + my ($conf, $name) = @_; + $conf->remove_alias($name); + log::l("removing module $name"); + delete $conf->{$name}; + 0; +} + +sub set_sound_slot { + my ($conf, $alias, $module) = @_; + if (my $old = $conf->get_alias($alias)) { + $conf->remove_above($old); + } + $conf->set_alias($alias, $module); + $conf->set_above($module, 'snd-pcm-oss') if $module =~ /^snd-/; +} + +1; |