[yast-commit] r40477 - in /trunk/network: ./ agents/ package/ src/lan/ src/modules/ src/routines/
Author: mzugec Date: Fri Aug 24 16:37:45 2007 New Revision: 40477 URL: http://svn.opensuse.org/viewcvs/yast?rev=40477&view=rev Log: write extra drivers into 79-yast2-drivers.rules (#300892) handle renamed udev rule for network devices (#302544) Modified: trunk/network/VERSION trunk/network/agents/ag_udev_persistent trunk/network/package/yast2-network.changes trunk/network/src/lan/hardware.ycp trunk/network/src/modules/Lan.ycp trunk/network/src/modules/LanItems.ycp trunk/network/src/routines/complex.ycp trunk/network/src/routines/routines.ycp Modified: trunk/network/VERSION URL: http://svn.opensuse.org/viewcvs/yast/trunk/network/VERSION?rev=40477&r1=40476&r2=40477&view=diff ============================================================================== --- trunk/network/VERSION (original) +++ trunk/network/VERSION Fri Aug 24 16:37:45 2007 @@ -1 +1 @@ -2.15.65 +2.15.66 Modified: trunk/network/agents/ag_udev_persistent URL: http://svn.opensuse.org/viewcvs/yast/trunk/network/agents/ag_udev_persistent?rev=40477&r1=40476&r2=40477&view=diff ============================================================================== --- trunk/network/agents/ag_udev_persistent (original) +++ trunk/network/agents/ag_udev_persistent Fri Aug 24 16:37:45 2007 @@ -9,28 +9,28 @@ use strict; -my $filename = "/etc/udev/rules.d/70-persistent-net.rules"; -my @comment = (); +my $net_file = "/etc/udev/rules.d/70-persistent-net.rules"; +my $drivers_file = "/etc/udev/rules.d/79-yast2-drivers.rules"; +my @net_comment = (); +my @drivers_comment = (); -sub parse_rules { +sub parse_net_rules { my $class = shift; my %hash_table = (); - # you don't need it read twice -# return 1 if (keys(%hash_table)); - if( open( FILE, "< $filename" ) ) { + if( open( FILE, "< $net_file" ) ) { while( my $line = <FILE> ) { # remove '\n' and space before delimiter ',' chomp($line); $line =~ s/, /,/g; - if ( $line =~ /^#/ ) { push(@comment, $line); } + if ( $line =~ /^#/ ) { push(@net_comment, $line); } else { if ($line =~ /,/ ) { my @cols = split(",", $line); - my (undef, $device) = split("=", $cols[3]); + my (undef, $device) = split("=", $cols[$#cols]); $device =~ s/\"//g; $hash_table{ $device } = \@cols; } @@ -38,13 +38,70 @@ } close(FILE); } else { - return $class->SetError(summary => sprintf( _("opening %s failed: %s"),$filename, $!), + return $class->SetError(summary => sprintf( _("opening %s failed: %s"),$net_file, $!), code => "OPEN_FAILED"); } return \%hash_table; } +sub parse_drivers_rules { + my $class = shift; + my %hash_table = (); + + if( open( FILE, "< $drivers_file" ) ) { + while( my $line = <FILE> ) { + + # remove '\n' and space before delimiter ',' + chomp($line); + $line =~ s/, /,/g; + + if ( $line =~ /^#/ ) { push(@drivers_comment, $line); } + else { + if ($line =~ /,/ ) + { + my @cols = split(",", $line); + my (undef, $device) = split("==", $cols[0]); + $device =~ s/\"//g; + $hash_table{ $device } = \@cols; + } + } + } + close(FILE); + } else { + return $class->SetError(summary => sprintf( _("opening %s failed: %s"),$drivers_file, $!), + code => "OPEN_FAILED"); + } + + return \%hash_table; +} + +sub write_drivers_rules(){ + my $class = shift; + my $param = \@_; + my %hash = %{$$param[0]}; + + my @output = (); + foreach my $row (@drivers_comment){ + push (@output, $row."\n"); + } + foreach my $key (keys %hash){ + my $row = join(', ', @{$hash{$key}}); + push(@output, $row."\n"); + + } + + + if( open( FILE, "> $drivers_file" ) ) { + print FILE @output; + } else { + return $class->SetError(summary => sprintf( _("saving %s failed: %s"),$drivers_file, $!), + code => "OPEN_FAILED"); + } +} + + + sub Execute { my $class = shift; my ($path, @args) = @_; @@ -56,11 +113,21 @@ sub Read { my $class = shift; my ($path, @args) = @_; - - return $class->parse_rules(); + if ($path eq '.net'){ + return $class->parse_net_rules(); + } + elsif ($path eq '.drivers'){ + return $class->parse_drivers_rules(); + } } sub Write { + my $class = shift; + my ($path, @args) = @_; + if ($path eq '.drivers'){ + my $hash_pointer = $args[0]; + return $class->write_drivers_rules($hash_pointer); + } } sub Dir { Modified: trunk/network/package/yast2-network.changes URL: http://svn.opensuse.org/viewcvs/yast/trunk/network/package/yast2-network.changes?rev=40477&r1=40476&r2=40477&view=diff ============================================================================== --- trunk/network/package/yast2-network.changes (original) +++ trunk/network/package/yast2-network.changes Fri Aug 24 16:37:45 2007 @@ -1,4 +1,11 @@ ------------------------------------------------------------------- +Fri Aug 24 16:42:17 CEST 2007 - mzugec@suse.cz + +- write extra drivers into 79-yast2-drivers.rules (#300892) +- handle renamed udev rule for network devices (#302544) +- 2.15.66 + +------------------------------------------------------------------- Fri Aug 24 14:40:53 CEST 2007 - kmachalkova@suse.cz - Adjusted layout of several dialogs to fit 80x25 screen Modified: trunk/network/src/lan/hardware.ycp URL: http://svn.opensuse.org/viewcvs/yast/trunk/network/src/lan/hardware.ycp?rev=40477&r1=40476&r2=40477&view=diff ============================================================================== --- trunk/network/src/lan/hardware.ycp (original) +++ trunk/network/src/lan/hardware.ycp Fri Aug 24 16:37:45 2007 @@ -81,7 +81,11 @@ hardware["realtype"] = NetworkDevices::RealType(hardware["type"]:"", hardware["hotplug"]:""); if (hasAnyValue(NetworkDevices::Name)) hardware["device"] = NetworkDevices::device_num(NetworkDevices::Name); else hardware["device"] = LanItems::device; - hardware["default_device"] = LanItems::device; + string driver = LanItems::getCurrentItem()["udev", "driver"]:""; + + + hardware["default_device"] = hasAnyValue(driver) ? driver : LanItems::getCurrentItem()["hwinfo", "module"]:"" ; + // #38213, remember device id when we switch back from pcmcia/usb hardware["non_hotplug_device_id"] = hardware["device"]:""; /* @@ -225,7 +229,7 @@ ); UI::ReplaceWidget(`hw_content, contents); - + UI::ChangeWidget(`modul, `Value, hardware["default_device"]:""); UI::ChangeWidget(`id(`modul), `Enabled, hardware["no_hotplug_dummy"]:false); // UI::ChangeWidget(`id(`options), `Enabled, hardware["no_hotplug_dummy"]:false); ChangeWidgetIfExists(`id(`list), `Enabled, hardware["no_hotplug_dummy"]:false); @@ -386,8 +390,8 @@ } if(hardware["hotplug"]:"" == "usb") hardware["device"] = "bus-usb"; - else if(hardware["hotplug"]:"" == "pcmcia") hardware["device"] = "bus-pcmcia"; - else hardware["device"] = hardware["non_hotplug_device_id"]:""; + else if(hardware["hotplug"]:"" == "pcmcia") hardware["device"] = "bus-pcmcia"; + else hardware["device"] = hardware["non_hotplug_device_id"]:""; UI::ChangeWidget(`id(`num), `Value, hardware["device"]:""); @@ -445,6 +449,10 @@ NetworkDevices::Name = name; LanItems::Items[LanItems::current]= $["ifcfg":name]; } + + LanItems::setDriver((string) UI::QueryWidget(`modul, `Value)); + + /* if(!(boolean)UI::QueryWidget(`enable_hwcfg, `Value)) { Modified: trunk/network/src/modules/Lan.ycp URL: http://svn.opensuse.org/viewcvs/yast/trunk/network/src/modules/Lan.ycp?rev=40477&r1=40476&r2=40477&view=diff ============================================================================== --- trunk/network/src/modules/Lan.ycp (original) +++ trunk/network/src/modules/Lan.ycp Fri Aug 24 16:37:45 2007 @@ -366,6 +366,7 @@ if(Abort()) return false; /* Progress step 3 - multiple devices may be present, really plural*/ ProgressNextStage(_("Writing device configuration...")); + LanItems::WriteUdevRules(); NetworkDevices::Write("netcard"); // WriteDevices(); sleep(sl); Modified: trunk/network/src/modules/LanItems.ycp URL: http://svn.opensuse.org/viewcvs/yast/trunk/network/src/modules/LanItems.ycp?rev=40477&r1=40476&r2=40477&view=diff ============================================================================== --- trunk/network/src/modules/LanItems.ycp (original) +++ trunk/network/src/modules/LanItems.ycp Fri Aug 24 16:37:45 2007 @@ -16,7 +16,7 @@ */ global map<integer, any> Items = $[]; global list<map> Hardware = []; -global map <string, any> udev_rules = $[]; +global map <string, any> udev_net_rules = $[]; global string interfacename=""; @@ -134,14 +134,21 @@ include "network/hardware.ycp"; -map <string, any> ReadUdevRules(){ - udev_rules = (map<string, any>)SCR::Read(.udev_persistent); -y2internal("read udev : %1", udev_rules); - return udev_rules; +boolean ReadUdevRules(){ + y2milestone ("Reading udev rules ..."); + udev_net_rules = (map<string, any>)SCR::Read(.udev_persistent.net); + return true; } -void WriteUdevRules(){ - SCR::Write(.udev_persistent, udev_rules); +global void WriteUdevRules(){ +// SCR::Write(.udev_persistent.net, udev_net_rules); + map<string, any> udev_drivers_rules = $[]; + foreach(integer key, (list<integer>)Map::Keys(Items), { + if (hasAnyValue(Items[key, "udev", "driver"]:"")) + udev_drivers_rules[Items[key, "udev", "driver"]:""] = [ sformat("ENV{MODALIAS}==\"%1\"", Items[key, "hwinfo", "modalias"]:""), sformat("ENV{MODALIAS}=\"%1\"", Items[key, "udev", "driver"]:"") ]; + }); +y2internal("%1", udev_drivers_rules); + SCR::Write(.udev_persistent.drivers, udev_drivers_rules); } /** @@ -199,9 +206,12 @@ global void ReadHw(){ Hardware = ReadHardware("netcard"); ReadUdevRules(); + + map<string, any> udev_drivers_rules = (map<string, any>)SCR::Read(.udev_persistent.drivers); foreach(map hwitem, Hardware, { - list udev = (hwitem["dev_name"]:"" != "") ? udev_rules[hwitem["dev_name"]:""]:[] : []; - Items[size(Items)] = $["hwinfo":hwitem, "udev":udev]; + list udev_net = (hwitem["dev_name"]:"" != "") ? udev_net_rules[hwitem["dev_name"]:""]:[] : []; + string mod = deletechars(splitstring((udev_drivers_rules[hwitem["modalias"]:""]:[])[1]:"", "=")[1]:"", "\""); + Items[size(Items)] = $["hwinfo":hwitem, "udev":$["net":udev_net, "driver":mod]]; }); } @@ -711,18 +721,13 @@ ]; global list<string> GetItemUdev(){ -// column: 0 mens rule, 1 means device +// column: 0 mens rule, 1 means NAME list<string> udevs=["", ""]; - if (size(Items[current, "udev"]:[])>3) + if (size(Items[current, "udev", "net"]:[])>3) { - udevs[0]=Items[current, "udev", 2]:""; -/* - if (regexpmatch (Items[current, "udev", 3]:"", ".* [^ ]*\"$")) { - udevs[1]=regexpsub (Items[current, "udev", 3]:"", ".* ([^ ]*)\"$", "\\1"); - } -*/ - if (regexpmatch (Items[current, "udev", 3]:"", ".*=[^ ]*\"$")) - udevs[1]=regexpsub (Items[current, "udev", 3]:"", ".*=[\"]*([^ ]*)\"$", "\\1"); + udevs[0]=Items[current, "udev", "net", 2]:""; + if (regexpmatch (Items[current, "udev", "net", 3]:"", ".*=[^ ]*\"$")) + udevs[1]=regexpsub (Items[current, "udev", "net", 3]:"", ".*=[\"]*([^ ]*)\"$", "\\1"); } return udevs; } @@ -1341,4 +1346,11 @@ return true; } +global void setDriver(string driver){ +y2internal("driver %1, %2", driver, getCurrentItem()["hwinfo", "module"]:""); + if (getCurrentItem()["hwinfo", "module"]:""==driver && !hasAnyValue(getCurrentItem()["udev", "driver"]:"")) return; + Items[current, "udev", "driver"] = driver; +} + + } Modified: trunk/network/src/routines/complex.ycp URL: http://svn.opensuse.org/viewcvs/yast/trunk/network/src/routines/complex.ycp?rev=40477&r1=40476&r2=40477&view=diff ============================================================================== --- trunk/network/src/routines/complex.ycp (original) +++ trunk/network/src/routines/complex.ycp Fri Aug 24 16:37:45 2007 @@ -36,7 +36,6 @@ */ define string BuildDescription (string devtype, string devnum, map devmap, list<map> Hardware) { -y2internal("devmap %1", devmap); string descr = devmap["NAME"]:""; if (descr != "") return descr; descr = HardwareName (Hardware, devnum); Modified: trunk/network/src/routines/routines.ycp URL: http://svn.opensuse.org/viewcvs/yast/trunk/network/src/routines/routines.ycp?rev=40477&r1=40476&r2=40477&view=diff ============================================================================== --- trunk/network/src/routines/routines.ycp (original) +++ trunk/network/src/routines/routines.ycp Fri Aug 24 16:37:45 2007 @@ -626,6 +626,7 @@ one["sysfs_id"] = card["sysfs_id"]:""; one["dev_name"] = card["dev_name"]:""; one["requires"] = card["requires"]:[]; + one["modalias"] = card["modalias"]:""; // Each card remembers its position in the list of _all_ cards. // It is used when selecting the card from the list of _unconfigured_ // ones (which may be smaller). #102945. @@ -696,7 +697,7 @@ y2milestone ("No good drivers found"); // #153235 // fail, unless we are in xen (it has the driver built in) - card_ok = Arch::is_xenU (); +// card_ok = Arch::is_xenU (); } else { -- To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org For additional commands, e-mail: yast-commit+help@opensuse.org
participants (1)
-
mzugec@svn.opensuse.org