diff options
author | Anssi Hannula <anssi@mandriva.org> | 2011-04-17 11:08:12 +0000 |
---|---|---|
committer | Anssi Hannula <anssi@mandriva.org> | 2011-04-17 11:08:12 +0000 |
commit | efa657fde1008c47b12df6b6464463e7d6699943 (patch) | |
tree | 355929e5d8c561cac585f20a532bfde9dd428c30 | |
parent | 8d292ef16e45810732b28c37bc2d77aff110670b (diff) | |
download | drakx-backup-do-not-use-efa657fde1008c47b12df6b6464463e7d6699943.tar drakx-backup-do-not-use-efa657fde1008c47b12df6b6464463e7d6699943.tar.gz drakx-backup-do-not-use-efa657fde1008c47b12df6b6464463e7d6699943.tar.bz2 drakx-backup-do-not-use-efa657fde1008c47b12df6b6464463e7d6699943.tar.xz drakx-backup-do-not-use-efa657fde1008c47b12df6b6464463e7d6699943.zip |
service_harddrake: ask for a reboot after a driver switch if needed, and load the new driver if no reboot is needed
-rw-r--r-- | perl-install/NEWS | 2 | ||||
-rwxr-xr-x | perl-install/standalone/service_harddrake | 25 |
2 files changed, 25 insertions, 2 deletions
diff --git a/perl-install/NEWS b/perl-install/NEWS index 40bac8890..734770470 100644 --- a/perl-install/NEWS +++ b/perl-install/NEWS @@ -1,6 +1,8 @@ - service_harddrake: o adapt splash handling for plymouth (for showing dialogs) o add/remove nokmsboot boot option if needed when switching the driver + o ask for a reboot after a driver switch if needed, and load the new driver + if no reboot is needed Version 13.42 - 24 February 2011 - increase default disk size to suggest /home partition diff --git a/perl-install/standalone/service_harddrake b/perl-install/standalone/service_harddrake index 6989ac24b..63104fa57 100755 --- a/perl-install/standalone/service_harddrake +++ b/perl-install/standalone/service_harddrake @@ -30,6 +30,7 @@ use Storable qw(store retrieve); my $force = member('--force', @ARGV); +my $reboot_needed; my $invert_do_it = $ARGV[0] eq 'X11' ? 1 : 0; my ($hw_sysconfdir, $timeout) = ("/etc/sysconfig/harddrake2", $invert_do_it ? 600 : 25); @@ -124,6 +125,15 @@ sub switch_x_driver { log::explanations("switch X.org driver from '$old_driver' to '$new_driver' ($reason)"); Xconfig::card::libgl_config_and_more({ Driver => $new_driver }); Xconfig::various::setup_kms(); + + # If a wrong driver is loaded, ask for a reboot. + my $reboot_needed = -x "/sbin/display_driver_helper" && system("/sbin/display_driver_helper", "--check-loaded") != 0; + if (!$reboot_needed) { + # Load any new drivers. + system("udevadm", "trigger", "--subsystem-match=pci", "--attr-match=class=0x03*"); + system("udevadm", "settle", "--timeout=10"); + } + $reboot_needed; } sub should_reconfigure_x_driver { @@ -188,7 +198,7 @@ foreach my $device (@devices) { # auto reconfigure x11 only on first time default driver have changed: my ($should_reconfigure, $reason) = should_reconfigure_x_driver($card_data, $device, $current_driver); if ($should_reconfigure) { - switch_x_driver($current_driver, $card_data->{Driver}, $reason); + $reboot_needed |= switch_x_driver($current_driver, $card_data->{Driver}, $reason); schedule_warn_about_switch($reason) if any { $current_driver =~ $_->{xorg_driver_regexp} } @cards; # Update $current_driver with the new one $current_driver = $card_data->{Driver}; @@ -229,7 +239,7 @@ foreach my $card (@cards) { if ($old_driver) { my $reason = N("The proprietary kernel driver was not found for '%s' X.org driver", $old_driver); - switch_x_driver($card->{xorg_driver_regexp}, $driver, $reason); + $reboot_needed |= switch_x_driver($card->{xorg_driver_regexp}, $driver, $reason); schedule_warn_about_switch($reason); } } @@ -391,4 +401,15 @@ foreach my $hw_class (@harddrake::data::tree) { log::explanations("created file $last_boot_config"); Storable::store(\%config, $last_boot_config); +# Handle $reboot_needed from earlier: +my ($reply, $timedout); +# Don't do autoreboot if X was somehow already started (not normally the case). +if ($reboot_needed && ! -e "/tmp/.X11-unix/X0") { + ($reply, $timedout) = ask_with_timeout(N("Display driver setup"), N("The system has to be rebooted due to a display driver change.") . "\n\n" + . N("Press Cancel within %d seconds to abort.", 30), 30, $plymouth); + if ($reply || $timedout) { + exec("/sbin/reboot"); + } +} + $in->exit(0) if $in; |