package install_steps_interactive; # $Id$
use strict;
use vars qw(@ISA $new_bootstrap);
@ISA = qw(install_steps);
#-######################################################################################
#- misc imports
#-######################################################################################
use common;
use partition_table;
use fs::type;
use install_steps;
use install_interactive;
use install_any;
use install_messages;
use detect_devices;
use run_program;
use devices;
use fsedit;
use mouse;
use modules;
use modules::interactive;
use lang;
use keyboard;
use any;
use log;
#-######################################################################################
#- In/Out Steps Functions
#-######################################################################################
sub errorInStep {
my ($o, $err) = @_;
$o->ask_warn(N("Error"), [ N("An error occurred"), formatError($err) ]);
}
sub kill_action {
my ($o) = @_;
$o->kill;
}
#-######################################################################################
#- Steps Functions
#-######################################################################################
#------------------------------------------------------------------------------
sub selectLanguage {
my ($o) = @_;
any::selectLanguage_install($o, $o->{locale});
install_steps::selectLanguage($o);
if ($o->isa('interactive::gtk')) {
$o->ask_warn('', formatAlaTeX(
"If you see this message it is because you chose a language for
which DrakX does not include a translation yet; however the fact
that it is listed means there is some support for it anyway.
That is, once GNU/Linux will be installed, you will be able to at
least read and write in that language; and possibly more (various
fonts, spell checkers, various programs translated etc. that
varies from language to language).")) if $o->{locale}{lang} !~ /^en/ && !lang::load_mo();
} else {
#- no need to have this in po since it is never translated
$o->ask_warn('', "The characters of your language can not be displayed in console,
so the messages will be displayed in english during installation") if $ENV{LANGUAGE} eq 'C';
}
}
sub acceptLicense {
my ($o) = @_;
$o->{release_notes} = join("\n\n", map {
my $f = install_any::getFile($_);
$f && cat__($f);
} 'release-notes.txt', 'release-notes.' . arch() . '.txt');
return if $o->{useless_thing_accepted};
my $r = $::testing ? 'Accept' : 'Refuse';
$o->ask_from_({ title => N("License agreement"),
cancel => N("Quit"),
messages => formatAlaTeX(install_messages::main_license() . "\n\n\n" . install_messages::warning_about_patents()),
interactive_help_id => 'acceptLicense',
if_(!$::globetrotter, more_buttons => [ [ N("Release Notes"), sub { $o->ask_warn(N("Release Notes"), $o->{release_notes}) }, 1 ] ]),
callbacks => { ok_disabled => sub { $r eq 'Refuse' } },
},
[ { list => [ N_("Accept"), N_("Refuse") ], val => \$r, type => 'list', format => sub { translate($_[0]) } } ])
or do {
if ($::globetrotter) {
run_program::run('killall', 'Xorg');
exec("/sbin/reboot");
}
install_any::ejectCdrom();
$o->exit;
};
}
#------------------------------------------------------------------------------
sub selectKeyboard {
my ($o, $clicked) = @_;
my $from_usb = keyboard::from_usb();
my $l = keyboard::lang2keyboards(lang::langs($o->{locale}{langs}));
if ($::expert || $clicked || !($from_usb || @$l && $l->[0][1] >= 90) || listlength(lang::langs($o->{locale}{langs})) > 1) {
add2hash($o->{keyboard}, $from_usb);
my @best = uniq($from_usb ? $from_usb->{KEYBOARD} : (), map { $_->[0] } @$l);
my $format = sub { translate(keyboard::KEYBOARD2text($_[0])) };
my $other;
my $ext_keyboard = my $KEYBOARD = $o->{keyboard}{KEYBOARD};
$o->ask_from_(
{ title => N("Keyboard"),
messages => N("Please choose your keyboard layout."),
interactive_help_id => 'selectKeyboard',
advanced_messages => N("Here is the full list of available keyboards"),
advanced_label => N("More"),
callbacks => { changed => sub { $other = $_[0] == 1 } },
},
[ if_(@best > 1, { val => \$KEYBOARD, type => 'list', format => $format, sort => 1,
list => [ @best ] }),
{ val => \$ext_keyboard, type => 'list', format => $format,
list => [ difference2([ keyboard::KEYBOARDs() ], \@best) ], advanced => @best > 1 }
]);
$o->{keyboard}{KEYBOARD} = @best <= 1 || $other ? $ext_keyboard : $KEYBOARD;
delete $o->{keyboard}{unsafe};
}
keyboard::group_toggle_choose($o, $o->{keyboard}) or goto &selectKeyboard;
install_steps::selectKeyboard($o);
}
#------------------------------------------------------------------------------
sub selectInstallClass {
my ($o) = @_;
if (my @l = install_any::find_root_parts($o->{fstab}, $o->{prefix})) {
log::l("proposing to upgrade partitions " . join(" ", map { $_->{part} && $_->{part}{device} } @l));
my @releases = uniq(map { $_->{release} } @l);
if (@releases != @l) {
#- same release name so adding the device to differentiate them:
$_->{release} .= " ($_->{part}{device})" foreach @l;
}
my $p;
$o->ask_from_({ title => N("Install/Upgrade"),
messages => N("Is this an install or an upgrade?"),
interactive_help_id => 'selectInstallClass',
},
[ { val => \$p,
list => [ @l, N_("Install") ],
type => 'list',
format => sub { ref($_[0]) ? N("Upgrade %s", $_[0]{release}) : translate($_[0]) }
} ]);
if (ref $p) {
if ($p->{part}) {
log::l("choosing to upgrade partition $p->{part}{device}");
$o->{migrate_device_names} = install_any::use_root_part($o->{all_hds}, $p->{part}, $o);
}
foreach (grep { $_->{mntpoint} } @{$o->{fstab}}) {
my ($options, $_unknown) = fs::mount_options::unpack($_);
$options->{encrypted} or next;
$o->ask_from_({ focus_first => 1 },
[ { label => N("Encryption key for %s", $_->{mntpoint}),
hidden => 1, val => \$_->{encrypt_key} } ]);
}
$o->{isUpgrade} = $p->{release_file} =~ /redhat/ ? 'redhat' : 'mandrake';
}
}
}
#------------------------------------------------------------------------------
sub selectMouse {
my ($o, $force) = @_;
$force ||= $o->{mouse}{unsafe};
if ($force) {
my $prev = $o->{mouse}{type} . '|' . $o->{mouse}{name};
$o->ask_from_({ messages => N("Please choose your type of mouse."),
interactive_help_id => 'selectMouse',
},
|