summaryrefslogtreecommitdiffstats
path: root/zarb-ml/mageia-dev/20100919/000740.html
diff options
context:
space:
mode:
Diffstat (limited to 'zarb-ml/mageia-dev/20100919/000740.html')
-rw-r--r--zarb-ml/mageia-dev/20100919/000740.html90
1 files changed, 90 insertions, 0 deletions
diff --git a/zarb-ml/mageia-dev/20100919/000740.html b/zarb-ml/mageia-dev/20100919/000740.html
new file mode 100644
index 000000000..ed41fe871
--- /dev/null
+++ b/zarb-ml/mageia-dev/20100919/000740.html
@@ -0,0 +1,90 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
+<HTML>
+ <HEAD>
+ <TITLE> [Mageia-dev] List on http://mageia.org/
+ </TITLE>
+ <LINK REL="Index" HREF="index.html" >
+ <LINK REL="made" HREF="mailto:mageia-dev%40mageia.org?Subject=Re%3A%20%5BMageia-dev%5D%20List%20on%20http%3A//mageia.org/&In-Reply-To=%3CAANLkTinos0FjsxeUkSp7a0tBh8sAAXe7hu5DuhthrMOd%40mail.gmail.com%3E">
+ <META NAME="robots" CONTENT="index,nofollow">
+ <META http-equiv="Content-Type" content="text/html; charset=us-ascii">
+ <LINK REL="Previous" HREF="000739.html">
+ <LINK REL="Next" HREF="000745.html">
+ </HEAD>
+ <BODY BGCOLOR="#ffffff">
+ <H1>[Mageia-dev] List on http://mageia.org/</H1>
+ <B>Ahmad Samir</B>
+ <A HREF="mailto:mageia-dev%40mageia.org?Subject=Re%3A%20%5BMageia-dev%5D%20List%20on%20http%3A//mageia.org/&In-Reply-To=%3CAANLkTinos0FjsxeUkSp7a0tBh8sAAXe7hu5DuhthrMOd%40mail.gmail.com%3E"
+ TITLE="[Mageia-dev] List on http://mageia.org/">ahmadsamir3891 at gmail.com
+ </A><BR>
+ <I>Sun Sep 19 01:46:33 CEST 2010</I>
+ <P><UL>
+ <LI>Previous message: <A HREF="000739.html">[Mageia-dev] List on http://mageia.org/
+</A></li>
+ <LI>Next message: <A HREF="000745.html">[Mageia-dev] List on http://mageia.org/
+</A></li>
+ <LI> <B>Messages sorted by:</B>
+ <a href="date.html#740">[ date ]</a>
+ <a href="thread.html#740">[ thread ]</a>
+ <a href="subject.html#740">[ subject ]</a>
+ <a href="author.html#740">[ author ]</a>
+ </LI>
+ </UL>
+ <HR>
+<!--beginarticle-->
+<PRE>On 19 September 2010 02:42, Jean Gabriel HAYS &lt;<A HREF="https://www.mageia.org/mailman/listinfo/mageia-dev">hays.jg at gmail.com</A>&gt; wrote:
+&gt;<i>
+</I>&gt;<i>
+</I>&gt;<i> 2010/9/19 Ahmad Samir &lt;<A HREF="https://www.mageia.org/mailman/listinfo/mageia-dev">ahmadsamir3891 at gmail.com</A>&gt;
+</I>&gt;&gt;<i>
+</I>&gt;&gt;<i> On 18 September 2010 22:42, Megastorage &lt;<A HREF="https://www.mageia.org/mailman/listinfo/mageia-dev">megastorage at hotmail.fr</A>&gt; wrote:
+</I>&gt;&gt;<i> &gt; &#160;Dear all,
+</I>&gt;&gt;<i> &gt;
+</I>&gt;&gt;<i> &gt; You can give my name on the list.
+</I>&gt;<i>
+</I>&gt;<i> And me too please. Thanks. ;)
+</I>&gt;<i> Jean-Gabriel HAYS (janot)
+</I>
+Could send the line that should be used? Please, format it like the
+ones in the list, (and please start a new thread so that your request
+doesn't get forgotten here).
+
+&gt;<i> --
+</I>&gt;<i> Jean-Gabriel HAYS - <A HREF="http://www.haysjg.fr/">http://www.haysjg.fr/</A>
+</I>&gt;<i> D&#233;buter sur Mandriva Linux : <A HREF="http://www.mandrivalinux-online.org/">http://www.mandrivalinux-online.org/</A>
+</I>&gt;<i> Mandriva Linux One 64 bits : <A HREF="http://www.community64.net">http://www.community64.net</A>
+</I>&gt;<i>
+</I>&gt;<i> _______________________________________________
+</I>&gt;<i> Mageia-dev mailing list
+</I>&gt;<i> <A HREF="https://www.mageia.org/mailman/listinfo/mageia-dev">Mageia-dev at mageia.org</A>
+</I>&gt;<i> <A HREF="https://www.mageia.org/mailman/listinfo/mageia-dev">https://www.mageia.org/mailman/listinfo/mageia-dev</A>
+</I>&gt;<i>
+</I>&gt;<i>
+</I>
+
+
+--
+Ahmad Samir
+</PRE>
+
+
+
+<!--endarticle-->
+ <HR>
+ <P><UL>
+ <!--threads-->
+ <LI>Previous message: <A HREF="000739.html">[Mageia-dev] List on http://mageia.org/
+</A></li>
+ <LI>Next message: <A HREF="000745.html">[Mageia-dev] List on http://mageia.org/
+</A></li>
+ <LI> <B>Messages sorted by:</B>
+ <a href="date.html#740">[ date ]</a>
+ <a href="thread.html#740">[ thread ]</a>
+ <a href="subject.html#740">[ subject ]</a>
+ <a href="author.html#740">[ author ]</a>
+ </LI>
+ </UL>
+
+<hr>
+<a href="https://www.mageia.org/mailman/listinfo/mageia-dev">More information about the Mageia-dev
+mailing list</a><br>
+</body></html>
>172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393
package modules; # $Id$

use strict;

use common;
use detect_devices;
use run_program;
use log;
use list_modules;

my %conf;

sub category2modules_and_description {
    my ($categories) = @_;
    my $f = '/lib/modules/' . c::kernel_version() . '/modules.description';
    -e $f or $f = '/lib/modules.description';
    my %modules_descriptions = map { /(\S+)\s+(.*)/ } cat_($f);
    map { $_ => $modules_descriptions{$_} } category2modules($categories);
}

#-###############################################################################
#- module loading
#-###############################################################################
# handles dependencies
# eg: load('vfat', 'reiserfs', [ ne2k => 'io=0xXXX', 'dma=5' ])
sub load {
    #- keeping the order of modules
    my %options;
    my @l = map {
	my ($name, @options) = ref $_ ? @$_ : $_;
	$options{$name} = \@options;
	dependencies_closure($name);
    } @_;

    @l = difference2([ uniq(@l) ], [ loaded_modules() ]) or return;

    my $network_module = do {
	my ($network_modules, $other) = partition { module2category($_) =~ m,network/(main|usb), } @l;
	if (@$network_modules > 1) {
	    # do it one by one
	    load($_) foreach @$network_modules;
	    load(@$other);
	    return;
	}
	$network_modules->[0];
    };
    my @network_devices = $network_module ? detect_devices::getNet() : ();

    if ($::testing) {
	log::l("i would load module $_ (@{$options{$_}})") foreach @l;
    } elsif ($::isStandalone || $::live) {
	run_program::run('/sbin/modprobe', $_, @{$options{$_}}) 
	  or die "insmod'ing module $_ failed" foreach @l;
    } else {
	load_raw(map { [ $_ => $options{$_} ] } @l);
    }
    sleep 2 if grep { /^(usb-storage|mousedev|printer)$/ } @l;

    if ($network_module) {
	add_alias($_, $network_module) foreach difference2([ detect_devices::getNet() ], \@network_devices);
    }
    when_load($_, @{$options{$_}}) foreach @l;
}

sub unload {
    if ($::testing) {
	log::l("rmmod $_") foreach @_;
    } else {
	run_program::run("rmmod", $_) foreach @_;
    }
}

sub load_category {
    my ($category, $wait_message, $probe_type) = @_;

    #- probe_category returns the PCMCIA cards. It doesn't know they are already
    #- loaded, so:
    read_already_loaded();

    my @try_modules = (
      if_($category =~ /scsi/,
	  if_(arch() !~ /ppc/, 'imm', 'ppa'),
	  if_(detect_devices::usbStorage(), 'usb-storage'),
      ),
      if_(arch() =~ /ppc/, 
	  if_($category =~ /scsi/, 'mesh', 'mac53c94'),
	  if_($category =~ /net/, 'bmac', 'gmac', 'mace'),
	  if_($category =~ /sound/, 'dmasound_awacs'),
      ),
    );
    grep {
	$wait_message->($_->{description}, $_->{driver}) if $wait_message;
	eval { load([ $_->{driver}, $_->{options} ]) };
	$_->{error} = $@;

	!($@ && $_->{try});
    } probe_category($category, $probe_type),
      map { { driver => $_, description => $_, try => 1 } } @try_modules;
}

sub probe_category {
    my ($category, $probe_type) = @_;

    my @modules = category2modules($category);

    grep {
	if ($category eq 'isdn') {
	    my $b = $_->{driver} =~ /ISDN:([^,]*),?([^,]*),?(.*)/;
	    if ($b) {
		$_->{driver} = $1;
		$_->{options} = $2;
		$_->{firmware} = $3;
		$_->{firmware} =~ s/firmware=//;
		$_->{driver} eq "hisax" and $_->{options} .= " id=HiSax";
	    }
	    $b;
	} else {
	    member($_->{driver}, @modules);
	}
    } detect_devices::probeall($probe_type);
}

sub load_ide {
    eval { load("ide-cd") }
}


#-###############################################################################
#- modules.conf functions
#-###############################################################################
sub get_alias {
    my ($alias) = @_;
    $conf{$alias}{alias};
}
sub get_probeall {
    my ($alias) = @_;
    $conf{$alias}{probeall};
}
sub get_options {
    my ($name) = @_;
    $conf{$name}{options};
}
sub set_options {
    my ($name, $new_option) = @_;
    $conf{$name}{options} = $new_option;
}
sub add_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 {
    my ($alias, $module) = @_;

    my $l = $conf{$alias}{probeall} ||= [];
    @$l = uniq(@$l, $module);
    log::l("setting probeall scsi_hostadapter to @$l");
}

sub remove_alias($) {
    my ($name) = @_;
    foreach (keys %conf) {
	$conf{$_}{alias} && $conf{$_}{alias} eq $name or next;
	delete $conf{$_}{alias};
	return 1;
    }
    0;
}

sub read_conf {
    my ($file) = @_;
    my %c;

    foreach (cat_($file)) {
	next if /^\s*#/;
	my ($type, $alias, $val) = split(/\s+/, chomp_($_), 3) or next;

	$val = [ split ' ', $val ] if $type eq 'probeall';

	$c{$alias}{$type} = $val;
    }
    #- cheating here: not handling aliases of aliases
    while (my ($k, $v) = each %c) {
	if (my $a = $v->{alias}) {
	    local $c{$a}{alias};
	    delete $v->{probeall};
	    add2hash($c{$a}, $v);
	}
    }
    #- convert old aliases to new probeall
    foreach my $name ('scsi_hostadapter', 'usb-interface') {
	my @old_aliases = 
	  map { $_->[0] } sort { $a->[1] <=> $b->[1] } 
	  map { if_(/^$name(\d*)/ && $c{$_}{alias}, [ $_, $1 || 0 ]) } keys %c;
	foreach my $alias (@old_aliases) {
	    push @{$c{$name}{probeall} ||= []}, delete $c{$alias}{alias};
	}
    }

    \%c;
}

sub mergein_conf {
    my ($file) = @_;
    my $modconfref = read_conf($file);
    while (my ($key, $value) = each %$modconfref) {
	$conf{$key}{alias} = $value->{alias} if !exists $conf{$key}{alias};
	push @{$conf{$key}{probeall} ||= []}, deref($value->{probeall});
    }
}

sub write_conf {
    my ($prefix) = @_;

    my $file = "$prefix/etc/modules.conf";
    rename "$prefix/etc/conf.modules", $file; #- make the switch to new name if needed

    #- Substitute new aliases in modules.conf (if config has changed)
    substInFile {
	my ($type,$alias,$module) = split(/\s+/, chomp_($_), 3);
	if ($type eq 'post-install' && $alias eq 'supermount') {	    
	    #- remove the post-install supermount stuff.
	    $_ = '';
	} elsif ($type eq 'alias' && $alias =~ /scsi_hostadapter|usb-interface/) {
	    #- remove old aliases which are replaced by probeall
	    $_ = '';
	} elsif (
	    $conf{$alias}{$type}  &&
	    $conf{$alias}{$type} ne $module)  {
	    my $v = join(' ', uniq(deref($conf{$alias}{$type})));
	    $_ = "$type $alias $v\n";
	}
    } $file;

    my $written = read_conf($file);

    local *F;
    open F, ">> $file" or die("cannot write module config file $file: $!\n");
    while (my ($mod, $h) = each %conf) {
	while (my ($type, $v) = each %$h) {
	    my $v2 = join(' ', uniq(deref($v)));
	    print F "$type $mod $v2\n" 
	      if $v2 && !$written->{$mod}{$type};
	}
    }
    my @l;
    push @l, 'scsi_hostadapter' if !is_empty_array_ref($conf{scsi_hostadapter}{probeall});
    push @l, 'bttv' if grep { $_->{driver} eq 'bttv' } detect_devices::probeall();
    append_to_etc_modules($prefix, @l);
}

sub append_to_etc_modules {
    my ($prefix, @l) = @_;
    my $l = join '|', map { '^\s*'.$_.'\s*$' } @l;
    log::l("to put in modules ", join(", ", @l));

    substInFile { 
	$_ = '' if $l && /$l/;
	$_ .= join '', map { "$_\n" } @l if eof;
    } "$prefix/etc/modules";
}

sub read_stage1_conf {
    mergein_conf($_[0]);
}

#-###############################################################################
#- pcmcia various
#-###############################################################################
sub configure_pcmcia {
    my ($pcic) = @_;

    #- try to setup pcmcia if cardmgr is not running.
    my $running if 0;
    return if $running;
    $running = 1;

    if (c::kernel_version() =~ /^2\.2/) {
	my $msg = _("PCMCIA support no longer exist for 2.2 kernels. Please use a 2.4 kernel.");
	log::l($msg);
	return $msg;
    }

    log::l("i try to configure pcmcia services");

    symlink "/tmp/stage2/$_", $_ foreach "/etc/pcmcia";

    eval {
	load("pcmcia_core");
	load($pcic);
	load("ds");
    };

    #- run cardmgr in foreground while it is configuring the card.
    run_program::run("cardmgr", "-f", "-m" ,"/modules");
    sleep(3);
    
    #- make sure to be aware of loaded module by cardmgr.
    read_already_loaded();
}

sub write_pcmcia {
    my ($prefix, $pcmcia) = @_;

    #- should be set after installing the package above otherwise the file will be renamed.
    setVarsInSh("$prefix/etc/sysconfig/pcmcia", {
	PCMCIA    => bool2yesno($pcmcia),
	PCIC      => $pcmcia,
	PCIC_OPTS => "",
        CORE_OPTS => "",
    });
}


#-###############################################################################
#- internal functions
#-###############################################################################
sub loaded_modules { 
    map { /(\S+)/ } cat_("/proc/modules");
}
sub read_already_loaded { 
    when_load($_) foreach reverse loaded_modules();
}

sub when_load {
    my ($name, @options) = @_;
    my $category = module2category($name);

    if ($category =~ m,disk/(scsi|hardware_raid|usb),) {
	add_probeall('scsi_hostadapter', $name);
	eval { load('sd_mod') };
    }
    add_alias('sound-slot-0', $name) if $category =~ /sound/;
    load('snd-pcm-oss') if $name =~ /^snd-/;
    add_probeall('usb-interface', $name) if $name =~ /usb-[uo]hci/ || $name eq 'ehci-hcd';
    $conf{$name}{options} = join " ", @options if @options;
}

sub cz_file { 
    "/lib/modules" . (arch() eq 'sparc64' && "64") . ".cz-" . c::kernel_version();
}

sub extract_modules {
    my ($dir, @modules) = @_;
    my $cz = cz_file();
    if (!-e $cz) {
	unlink $_ foreach glob_("/lib/modules*.cz*");
	require install_any;
        install_any::getAndSaveFile("Mandrake/mdkinst$cz", $cz) or die "failed to get modules $cz: $!";
    }
    eval {
	require packdrake;
	my $packer = new packdrake($cz, quiet => 1);
	$packer->extract_archive($dir, map { "$_.o" } @modules);
    };
}

sub load_raw {
    my @l = @_;

    extract_modules('/tmp', map { $_->[0] } @l);
    my @failed = grep {
	my $m = "/tmp/$_->[0].o";
	if (-e $m && run_program::run(["/usr/bin/insmod_", "insmod"], '2>', '/dev/tty5', $m, @{$_->[1]})) {
	    unlink $m;
	    '';
	} else {
	    log::l("missing module $_->[0]") if !-e $m;
	    -e $m;
	}
    } @l;

    die "insmod'ing module " . join(", ", map { $_->[0] } @failed) . " failed" if @failed;

    foreach (@l) {
	if ($_->[0] =~ /usb-[uo]hci/) {
	    eval {
		require fs; fs::mount('/proc/bus/usb', '/proc/bus/usb', 'usbdevfs');
		#- ensure keyboard is working, the kernel must do the job the BIOS was doing
		sleep 2;
		load("usbkbd", "keybdev") if detect_devices::usbKeyboards();
	    }
	}
    }
}



1;