summaryrefslogtreecommitdiffstats
path: root/perl-install/modules/modprobe_conf.pm
diff options
context:
space:
mode:
Diffstat (limited to 'perl-install/modules/modprobe_conf.pm')
-rw-r--r--perl-install/modules/modprobe_conf.pm30
1 files changed, 22 insertions, 8 deletions
diff --git a/perl-install/modules/modprobe_conf.pm b/perl-install/modules/modprobe_conf.pm
index c371c1e06..7989096f8 100644
--- a/perl-install/modules/modprobe_conf.pm
+++ b/perl-install/modules/modprobe_conf.pm
@@ -1,7 +1,8 @@
-package modules::modprobe_conf; # $Id$
+package modules::modprobe_conf;
use log;
use common;
+# perl_checker: require modules::any_conf
our @ISA = qw(modules::any_conf);
@@ -9,43 +10,56 @@ 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);
- join(' ', @$l);
+ @$l;
}
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);
}
}
+sub create_from_old() {
+ #- use module-init-tools script
+ run_program::rooted($::prefix, "/sbin/generate-modprobe.conf", ">", file());
+}
+
sub read {
my ($type, $o_file) = @_;
my $file = $o_file || do {
my $f = $::prefix . file();
if (!-e $f && -e "$::prefix/etc/modules.conf") {
- #- use module-init-tools script
- run_program::rooted($::prefix, "/sbin/generate-modprobe.conf", ">", file());
+ create_from_old();
}
$f;
};
- my $conf = modules::any_conf::read($type, $file);
+ my $conf = modules::any_conf::read_handled($type, $file);
extract_probeall_field($conf);
@@ -89,7 +103,7 @@ sub parse_non_virtual {
sub unparse_non_virtual {
my ($module, $mode, $before, $after) = @_;
($before ? "$before; " : '')
- . "/sbin/modprobe --first-time $mode $module"
+ . (($before || $after) ? "/sbin/modprobe --first-time $mode $module" : '')
. ($after ? " && { $after; /bin/true; }" : '');
}