diff options
author | Thierry Vignaud <tvignaud@mandriva.org> | 2002-11-18 13:42:04 +0000 |
---|---|---|
committer | Thierry Vignaud <tvignaud@mandriva.org> | 2002-11-18 13:42:04 +0000 |
commit | ca6e0a756bc83c1aa9927b99cc8e76f791202835 (patch) | |
tree | 10e7146ad475464e479cec3b71e0048802b57525 /perl-install/modules | |
parent | 4fbd711cae7b4e9f4b66c95725c960728b1f6166 (diff) | |
download | drakx-ca6e0a756bc83c1aa9927b99cc8e76f791202835.tar drakx-ca6e0a756bc83c1aa9927b99cc8e76f791202835.tar.gz drakx-ca6e0a756bc83c1aa9927b99cc8e76f791202835.tar.bz2 drakx-ca6e0a756bc83c1aa9927b99cc8e76f791202835.tar.xz drakx-ca6e0a756bc83c1aa9927b99cc8e76f791202835.zip |
rename modparm as modules::parameters
Diffstat (limited to 'perl-install/modules')
-rw-r--r-- | perl-install/modules/interactive.pm | 4 | ||||
-rw-r--r-- | perl-install/modules/parameters.pm | 61 |
2 files changed, 63 insertions, 2 deletions
diff --git a/perl-install/modules/interactive.pm b/perl-install/modules/interactive.pm index b4ce5280e..71b72a5b2 100644 --- a/perl-install/modules/interactive.pm +++ b/perl-install/modules/interactive.pm @@ -7,9 +7,9 @@ sub config_window { require modules; modules::mergein_conf('/etc/modules.conf'); my %conf = modules::get_parameters($data->{driver}); - require modparm; + require modules::parameters; my @l; - foreach (modparm::parameters($data->{driver})) { + foreach (modules::parameters::parameters($data->{driver})) { my ($name, $format, $description) = @$_; push @l, { label => $name, help => "$description\n[$format]", val => \$conf{$name} }; } diff --git a/perl-install/modules/parameters.pm b/perl-install/modules/parameters.pm new file mode 100644 index 000000000..59829389c --- /dev/null +++ b/perl-install/modules/parameters.pm @@ -0,0 +1,61 @@ +package modules::parameters; # $Id$ + +use diagnostics; +use strict; + +#-###################################################################################### +#- misc imports +#-###################################################################################### +use common; +use modules; + + +sub parameters { + my ($module) = @_; + + my $modinfo = '/sbin/modinfo'; + -x $modinfo or $modinfo = '/usr/bin/modinfo'; + -x $modinfo or die N("modinfo is not available"); + + if (!$::isStandalone && !$::testing) { + modules::extract_modules('/tmp', $module); + $module = "/tmp/$module.o"; + } + + my @parameters; + foreach (common::join_lines(`$modinfo -p $module`)) { + chomp; + next if /^warning:/; + (my $name, $_) = /(\S+)\s+(.*)/s or warn "modules::parameters::get_options_name($module): unknown line\n"; + + my $c_types = 'int|string|short|byte|char|long'; + my ($is_a_number, $description, $min, $max) = (0, '', 1, 1); + if (/^($c_types) array \(min = (\d+), max = (\d+)\),?\s*(.*)/s) { + $_ = $4; + #- seems like "char" are buggy entries + ($is_a_number, $min, $max) = ($1 ne 'string', $2, $3) if $1 ne 'char'; + } elsif (/^($c_types),?\s*(.*)/s) { + $_ = $2; + #- here "char" really are size-limited strings, modinfo doesn't display the size limit (but since we don't care about it, it doesn't matter :) + $is_a_number = $1 ne 'string' if $1 ne 'char'; + } else { + #- for things like "no format character" or "unknown format character" + } + if (/^description "(.*)",?\s*/s) { + ($description, $_) = ($1, $2); + } + #- print "STILL HAVE ($_)\n" if $_; + + my $format = $min == 1 && $max == 1 ? + ($is_a_number ? N("a number") : '') : + $min == $max ? + ($is_a_number ? N("%d comma separated numbers", $min) : N("%d comma separated strings", $min)) : + $min == 1 ? + ($is_a_number ? N("comma separated numbers") : N("comma separated strings")) : + ''; #- too weird and buggy, do not display it + push @parameters, [ $name, $format, $description ]; + } + @parameters; +} + +1; |