summaryrefslogtreecommitdiffstats
path: root/perl-install/modules.pm
diff options
context:
space:
mode:
Diffstat (limited to 'perl-install/modules.pm')
-rw-r--r--perl-install/modules.pm122
1 files changed, 46 insertions, 76 deletions
diff --git a/perl-install/modules.pm b/perl-install/modules.pm
index 2439c758b..abeb0b366 100644
--- a/perl-install/modules.pm
+++ b/perl-install/modules.pm
@@ -1,4 +1,4 @@
-package modules; # $Id$
+package modules;
use strict;
@@ -33,7 +33,7 @@ my %mappings_24_26 = (
"dc395x_trm" => "dc395x",
);
my %mappings_26_24 = reverse %mappings_24_26;
-$mappings_26_24{'uhci_hcd'} = 'usb_uhci';
+$mappings_26_24{uhci_hcd} = 'usb_uhci';
my @parallel_zip_modules = qw(imm ppa);
@@ -59,13 +59,45 @@ sub module_is_available {
#-###############################################################################
#- module loading
#-###############################################################################
+
+sub filter_loaded_modules {
+ my ($lm) = @_;
+
+ my $l;
+
+ # try to detect built-in modules by looking at /sys/module
+ # unfortunately it does not work for all modules eg :
+ # - networks protocols like af_packet
+ # - filesystems
+ foreach my $mod (@$lm) {
+ $mod =~ s/-/_/g;
+ if (-d "/sys/module/$mod") {
+ log::l("$mod already loaded");
+ } elsif ($mod =~ /af_packet/) {
+ if (-f "/proc/net/packet") {
+ log::l("$mod already loaded");
+ } else {
+ push @$l, $mod;
+ }
+ } elsif (cat_("/proc/filesystems") =~ /$mod/) {
+ log::l("$mod already loaded");
+ } elsif ($mod =~ /serial/) {
+ # hack ... must find who tries to load the module serial
+ } else {
+ push @$l, $mod;
+ }
+ }
+ $l;
+}
+
# handles dependencies
sub load_raw {
- my ($l, $h_options) = @_;
+ my ($lm, $h_options) = @_;
+
+ my $l = filter_loaded_modules($lm);
+
if ($::testing || $::local_install) {
log::l("i would load module $_ ($h_options->{$_})") foreach @$l;
- } elsif ($::isInstall) {
- load_raw_install($l, $h_options);
} else {
run_program::run('/sbin/modprobe', $_, split(' ', $h_options->{$_}))
or !run_program::run('/sbin/modprobe', '-n', $_) #- ignore missing modules
@@ -76,16 +108,7 @@ sub load_raw {
} elsif (member('usb_storage', @$l)) {
#- usb_storage is only modprobed when we know there is some scsi devices
#- so trying hard to wait for devices to be detected
-
- #- first sleep the minimum time usb-stor-scan takes
- sleep 5; #- 5 == /sys/module/usb_storage/parameters/delay_use
- # then wait for usb-stor-scan to complete
- my $retry = 0;
- while ($retry++ < 10) {
- fuzzy_pidofs('usb-stor-scan') or last;
- sleep 1;
- log::l("waiting for usb_storage devices to appear (retry = $retry)");
- }
+ run_program::run('udevadm', 'settle');
}
}
sub load_with_options {
@@ -94,10 +117,11 @@ sub load_with_options {
my @l = map {
if_(member($_, 'plip', @parallel_zip_modules), 'parport_pc'),
if_($_ eq 'vfat', 'nls_cp437', 'nls_iso8859_1'),
- dependencies_closure(cond_mapping_24_26($_));
+ if_(member($_, qw(btrfs xfs)), 'crc32c', 'crc32c-intel'),
+ cond_mapping_24_26($_);
} @$l;
- @l = remove_loaded_modules(@l) or return;
+ @l = filter_out_loaded_modules(@l) or return;
my %options = map { cond_mapping_24_26($_) => $h_options->{$_} } keys %$h_options;
load_raw(\@l, \%options);
@@ -111,7 +135,7 @@ sub load {
sub load_and_configure {
my ($conf, $module, $o_options) = @_;
- my @l = remove_loaded_modules(dependencies_closure(cond_mapping_24_26($module)));
+ my @l = filter_out_loaded_modules(cond_mapping_24_26($module));
load_raw(\@l, { cond_mapping_24_26($module) => $o_options });
if (member($module, @parallel_zip_modules)
@@ -141,13 +165,6 @@ sub load_category {
if_($category =~ /scsi/,
if_(detect_devices::usbStorage(), 'usb_storage'),
),
- arch() =~ /ppc/ ? (
- if_($category =~ /scsi/,
- if_(detect_devices::has_mesh(), 'mesh'),
- if_(detect_devices::has_53c94(), 'mac53c94'),
- ),
- if_($category =~ /net/, 'bmac', 'gmac', 'mace', 'airport'),
- ) : (),
);
my @l = (
(map {
@@ -172,8 +189,6 @@ sub load_category {
sub load_parallel_zip {
my ($conf) = @_;
- arch() !~ /ppc/ or return;
-
grep {
eval { load_and_configure($conf, $_); 1 };
} @parallel_zip_modules;
@@ -231,7 +246,7 @@ sub set_preload_modules {
sub loaded_modules() {
map { /(\S+)/ } cat_("/proc/modules");
}
-sub remove_loaded_modules {
+sub filter_out_loaded_modules {
my (@l) = @_;
difference2([ uniq(@l) ], [ map { my $s = $_; $s =~ s/_/-/g; $s, $_ } loaded_modules() ]);
}
@@ -259,13 +274,13 @@ sub when_load_category {
if ($category =~ m,disk/ide,) {
$conf->add_probeall('ide-controller', $name);
eval { load('ide_gd_mod') };
- } elsif ($category =~ m,disk/(scsi|hardware_raid|sata|firewire),) {
+ } elsif ($category =~ m,disk/(scsi|hardware_raid|sata|firewire|virtual),) {
$conf->add_probeall('scsi_hostadapter', $name);
eval { load('sd_mod') };
} elsif ($category eq 'bus/usb') {
$conf->add_probeall('usb-interface', $name);
- -f '/proc/bus/usb/devices' or eval {
- require fs::mount; fs::mount::usbfs('');
+ -f '/sys/kernel/debug/usb/devices' or eval {
+ require fs::mount; fs::mount::sys_kernel_debug('');
#- ensure keyboard is working, the kernel must do the job the BIOS was doing
sleep 4;
load("usbhid") if detect_devices::usbKeyboards();
@@ -282,49 +297,4 @@ sub when_load_category {
}
}
-#-###############################################################################
-#- isInstall functions
-#-###############################################################################
-sub module_extension() { ".ko" }
-
-sub extract_modules {
- my ($dir, @modules) = @_;
- map {
- my $modname = $_;
- my $path = list_modules::modname2path($modname);
- my $f = $modname . module_extension();
- if (-e $path) {
- system("gzip -dc $path > $dir/$f") == 0
- or unlink "$dir/$f";
- } else {
- log::l("warning: unable to get module filename for $modname (path: $path)");
- }
- "$dir/$f";
- } @modules;
-}
-
-sub load_raw_install {
- my ($l, $options) = @_;
-
- extract_modules('/tmp', @$l);
- my @failed = grep {
- my $m = '/tmp/' . $_ . module_extension();
- if (-e $m) {
- my $stdout;
- my $rc = run_program::run('/sbin/insmod', '2>', \$stdout, $m, split(' ', $options->{$_}));
- log::l(chomp_($stdout)) if $stdout;
- if ($rc) {
- unlink $m;
- '';
- }
- } else {
- log::l("missing module $_");
- 'error';
- }
- } @$l;
-
- die "insmod'ing module " . join(", ", @failed) . " failed" if @failed;
-
-}
-
1;