package interactive_gtk; # $Id$ use diagnostics; use strict; use vars qw(@ISA); @ISA = qw(interactive); use interactive; use common qw(:common :functional); use my_gtk qw(:helpers :wrappers); 1; sub new { $::windowheight ||= 400 if $::isStandalone; goto &interactive::new; } sub enter_console { my ($o) = @_; $o->{suspended} = common::setVirtual(1) } sub leave_console { my ($o) = @_; common::setVirtual(delete $o->{suspended}) } sub suspend {} sub resume {} sub exit { gtkset_mousecursor_normal(); #- for restoring a normal in any case on standalone my_gtk::flush(); c::_exit($_[0]) #- workaround } sub ask_from_listW { my ($o, $title, $messages, $l, $def) = @_; ask_from_list_with_helpW($o, $title, $messages, $l, undef, $def); } sub ask_from_list_with_helpW { my ($o, $title, $messages, $l, $help, $def) = @_; my $r; my $w = my_gtk->new(first(deref($title)), %$o); #gtkset_usize(createScrolledWindow($tree), 300, min(350, $::windowheight - 60)), $w->{retval} = $def || $l->[0]; #- nearly especially for the X test case (see timeout in Xconfigurator.pm) $w->{rwindow}->set_policy(0, 0, 1) if $::isWizard; if (@$l < 5 or $::isWizard) { my $defW; my $tips = new Gtk::Tooltips; my $g = sub { $w->{retval} = $_[1]; }; my $f = sub { $w->{retval} = $_[1]; Gtk->main_quit }; my $b; $w->sync; $::isWizard and my $pixmap = new Gtk::Pixmap( gtkcreate_xpm($w->{window}, $::wizard_xpm)) || die "pixmap $! not found."; if ($::isWizard) { gtkset_usize($w->{rwindow}, 500, 400); } gtkadd($w->{window}, gtkpack2_(create_box_with_title($w, @$messages), 1, gtkpack3( $::isWizard, new Gtk::HBox(0,0), $::isWizard ? ($pixmap, gtkset_usize(new Gtk::VBox(0,0),30, 0)) : (), gtkpack2__( $::isWizard ? new Gtk::VBox(0,0): ( @$l < 3 && sum(map { length $_ } @$l) < 60 ? create_hbox() : create_vbox()), $::isWizard ? gtkset_usize(new Gtk::VBox(0,0), 0, 30) : (), map { $::isWizard ? $b = new Gtk::RadioButton($b ? ($_, $b) : $_) : ($b = new Gtk::Button($_)); $tips->set_tip($b, $help->{$_}) if $help && $help->{$_}; $_ eq $def and $defW = $b; $b->signal_connect(clicked => [ $::isWizard ? $g : $f, $_ ]); $b; } @$l, )), 0, new Gtk::HSeparator, $::isWizard ? (0, $w->create_okcancel()) : (), ), ); $defW->grab_focus if $defW; $r = $w->main; } else { #- use ask_from_list_with_help only when needed, as key bindings are #- dropped by List (CList does not seems to accepts Tooltips). $help ? $w->_ask_from_list_with_help($title, $messages, $l, $help, $def) : $w->_ask_from_list($title, $messages, $l, $def); $r = $w->main; } $r or $::isWizard ? 0 : die "ask_from_list cancel"; } sub ask_from_treelistW { my ($o, $title, $messages, $separator, $l, $def) = @_; my $sep = quotemeta $separator; my $w = my_gtk->new($title); my $tree = Gtk::CTree->new(1, 0); my %wtree; my $parent; $parent = sub { if (my $w = $wtree{"$_[0]$separator"}) { return $w } my $s; foreach (split $sep, $_[0]) { $wtree{"$s$_$separator"} ||= $tree->insert_node($s ? $parent->($s) : undef, undef, [$_], 5, (undef) x 4, 0, 0); $s .= "$_$separator"; } $wtree{$s}; }; my ($root, $leaf, $wdef, $ndef); foreach (@$l) { ($root, $leaf) = /(.*)$sep(.+)/ or ($root, $leaf) = ('', $_); my $node = $tree->insert_node($parent->($root), undef, [$leaf], 5, (undef) x 4, 1, 0); if ($def eq $_) { $wdef = $node; my $s; $tree->expand($wtree{$s .= "$_$separator"}) foreach split $sep, $root; foreach my $nb (1 .. @$l) { if ($tree->node_nth($nb) == $node) { $tree->set_focus_row($ndef = $nb); last; } } } } undef %wtree; my $curr; my $leave = sub { $curr->row->is_leaf or return; my @l; for (; $curr; $curr = $curr->row->parent) { unshift @l, first $tree->node_get_pixtext($curr, 0); } $w->{retval} = join $separator, @l; Gtk->main_quit; }; $w->{ok_clicked} = $leave; $w->{cancel_clicked} = sub { $w->destroy; die "ask_from_list cancel" }; #- make sure windows doesn't live any more. gtkadd($w->{window}, gtkpack($w->create_box_with_title(@$messages), gtkpack_(new Gtk::VBox(0,7), 1, gtkset_usize(createScrolledWindow($tree), 300, min(350, $::windowheight - 60)), 0, $w->create_okcancel))); $tree->set_column_auto_resize(0, 1); $tree->set_selection_mode('browse'); $tree->signal_connect(tree_select_row => sub { $curr = $_[1]; }); $tree->signal_connect(button_press_event => sub { &$leave if $_[1]{type} =~ /^2/ }); $tree->signal_connect(key_press_event => sub { my ($w, $e) = @_; my $c = chr($e->{keyval} & 0xff); $curr or return; if ($e->{keyval} >= 0x100 ? $c eq "\r" || $c eq "\x8d" : $c eq ' ') { if ($curr->row->is_leaf) { &$leave } else { $tree->toggle_expansion($curr) } } 1; }); $tree->grab_focus; $tree->set_row_height($tree->style->font->ascent + $tree->style->font->descent + 1); $w->{rwindow}->show; if ($wdef) { $tree->select($wdef); $tree->node_moveto($wdef, 0, 0.5, 0); } $w->main or die "ask_from_list cancel"; } sub ask_many_from_listW { my ($o, $title, $messages, @l) = @_; my $w = my_gtk->new('', %$o); $w->sync; # for XPM's creation my $tips = new Gtk::Tooltips; my @boxes; @boxes = map { my $l = $_; my $box = gtkpack(new Gtk::VBox(0, @{$l->{icons}} ? 10 : 0), map_index { my $i = $::i; my $o = Gtk::CheckButton->new($_); $tips->set_tip($o, $l->{help}[$i]) if $l->{help}[$i]; $o->set_active(${$l->{ref}[$i]}); $o->signal_connect(clicked => sub { my $v = invbool($l->{ref}[$i]); $boxes[$l->{shadow}]->set_sensitive(!$v) if exists $l->{shadow}; }); my $f = $l->{icons}[$i]; -e $f ? gtkpack_(new Gtk::HBox(0,10), 0, new Gtk::Pixmap(gtkcreate_xpm($w->{window}, $f)), 1, $o) : $o; } @{$l->{labels}}); @{$l->{labels}} > (@{$l->{icons}} ? 5 : 11) ? gtkset_usize(createScrolledWindow($box), @{$l->{icons}} ? 350 : 0, $::windowheight - 200) : $box; } @l; gtkadd($w->{window}, gtkpack_(create_box_with_title($w, @$messages), (map {; 1, $_, 0, '' } @boxes), 0, $w->create_okcancel, ) ); $w->{ok}->grab_focus; $w->main; } sub ask_from_entries_refW { my ($o, $title, $messages, $l, $val, %hcallback) = @_; my ($title_, @okcancel) = deref($title); my $ignore = 0; #-to handle recursivity my $w = my_gtk->new($title_, %$o); $w->sync; # for XPM's creation my $set_icon = sub { my ($i, $button) = @_; gtkdestroy($i->{icon}); my $f = $i->{icon2f}->(${$i->{val}}); $i->{icon} = -e $f ? new Gtk::Pixmap(gtkcreate_xpm($w->{window}, $f)) : new Gtk::Label(translate(${$i->{val}})); $button->add($i->{icon}); $i->{icon}->show; }; #-the widgets my @widgets = map { my $i = $_; $i->{type} = "iconlist" if $i->{type} eq "list" && $i->{not_edit} && $i->{icon2f}; if ($i->{type} eq "list") { my $w = new Gtk::Combo; $w->set_use_arrows_always(1); $w->entry->set_editable(!$i->{not_edit}); $w->set_popdown_strings(@{$i->{list}}); $w->disable_activate; $w; } elsif ($i->{type} eq "iconlist") { my $w = new Gtk::Button; $w->signal_connect(clicked => sub { ${$i->{val}} = next_val_in_array(${$i->{val}}, $i->{list}); $set_icon->($i, $w); }); $set_icon->($i, $w); gtkpack_(new Gtk::HBox(0,10), 1, new Gtk::HBox(0,0), 0, $w, 1, new Gtk::HBox(0,0), ); } elsif ($i->{type} eq "bool") { my $w = Gtk::CheckButton->new($i->{text}); $w->set_active(${$i->{val}}); $w->signal_connect(clicked => sub { $ignore or invbool \${$i->{val}} }); $w; } elsif ($i->{type} eq "range") { my $adj = create_adjustment(${$i->{val}}, $i->{min}, $i->{max}); $adj->signal_connect(value_changed => sub { ${$i->{val}} = $adj->get_value }); my $w = new Gtk::HScale($adj); $w->set_digits(0); $w; } else { new Gtk::Entry; } } @$val; my $ok = $w->create_okcancel(@okcancel); sub widget { my ($w, $ref) = @_; ($ref->{type} eq "list" && @{$ref->{list}}) ? $w->entry : $w } my @updates = mapn { my ($w, $ref) = @_; sub { $ref->{type} =~ /bool|range|iconlist/ and return; ${$ref->{val}} = widget($w, $ref)->get_text; }; } \@widgets, $val; my @updates_inv = mapn { my ($w, $ref) = @_; sub { $ref->{type} =~ /iconlist/ and return; $ref->{type} eq "bool" ? $w->set_active(${$ref->{val}}) : widget($w, $ref)->set_text(${$ref->{val}}) }; } \@widgets, $val; for (my $i = 0; $i < @$l; $i++) { my $ind = $i; #-cos lexical bindings pb !! my $widget = widget($widgets[$i], $val->[$i]); my $changed_callback = sub { return if $ignore; #-handle recursive deadlock &{$updates[$ind]}; if ($hcallback{changed}) { &{$hcallback{changed}}($ind); #update all the value $ignore = 1; &$_ foreach @updates_inv; $ignore = 0; }; }; my $may_go_to_next = sub { my ($W, $e) = @_; if (($e->{keyval} & 0x7f) == 0xd) { $W->signal_emit_stop("key_press_event"); if ($ind == $#$l) { @$l == 1 ? $w->{ok}->clicked : $w->{ok}->grab_focus; } else { widget($widgets[$ind+1],$val->[$ind+1])->grab_focus; } } }; if ($hcallback{focus_out}) { my $focusout_callback = sub { return if $ignore; &{$hcallback{focus_out}}($ind); #update all the value $ignore = 1; &$_ foreach @updates_inv; $ignore = 0; }; $widget->signal_connect(focus_out_event => $focusout_callback); } if (ref $widget eq "Gtk::HScale") { $widget->signal_connect(key_press_event => $may_go_to_next); } if (ref $widget eq "Gtk::Entry") { $widget->signal_connect(changed => $changed_callback); $widget->signal_connect(key_press_event => $may_go_to_next); $widget->set_text(${$val->[$i]{val}}); $widget->set_visibility(0) if $val->[$i]{hidden}; } &{$updates[$i]}; } my @entry_list = mapn { [($_[0], $_[1])]} $l, \@widgets; gtkadd($w->{window}, gtkpack( create_box_with_title($w, @$messages), create_packtable({}, @entry_list), $ok )); widget($widgets[0],$val->[0])->grab_focus(); if ($hcallback{complete}) { my $callback = sub { my ($error, $focus) = &{$hcallback{complete}}; #-update all the value $ignore = 1; foreach (@updates_inv) { &{$_};} $ignore = 0; if ($error) { $focus ||= 0; widget($widgets[$focus], $val->[$focus])->grab_focus(); } else { return 1; } }; $w->main($callback); } else { $w->main(); } } sub wait_messageW($$$) { my ($o, $title, $messages) = @_; my $w = my_gtk->new($title, %$o, grab => 1); gtkadd($w->{window}, my $hbox = new Gtk::HBox(0,0)); $hbox->pack_start(my $box = new Gtk::VBox(0,0), 1, 1, 10); $box->pack_start($_, 1, 1, 4) foreach my @l = map { new Gtk::Label($_) } @$messages; ($w->{wait_messageW} = $l[$#l])->signal_connect(expose_event => sub { $w->{displayed} = 1 }); $w->{rwindow}->set_position('center') if $::isStandalone; $w->{window}->show_all; $w->sync until $w->{displayed}; $w; } sub wait_message_nextW { my ($o, $messages, $w) = @_; my $msg = join "\n", @$messages; return if $msg eq $w->{wait_messageW}->get; #- needed otherwise no expose_event :( $w->{displayed} = 0; $w->{wait_messageW}->set($msg); $w->flush until $w->{displayed}; } sub wait_message_endW { my ($o, $w) = @_; $w->destroy; } sub kill { my ($o) = @_; $o->{before_killing} ||= 0; while (my $e = shift @tempory::objects) { $e->destroy } while (@interactive::objects > $o->{before_killing}) { my $w = pop @interactive::objects; $w->destroy; } $o->{before_killing} = @interactive::objects; } 'n172' href='#n172'>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 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674
package install2; # $Id$
use diagnostics;
use strict;
use vars qw($o $version);
#-######################################################################################
#- misc imports
#-######################################################################################
use steps;
use common;
use install_any qw(:all);
use install_steps;
use install_any;
use lang;
use keyboard;
use mouse;
use devices;
use partition_table;
use modules;
use detect_devices;
use run_program;
use any;
use log;
use fs;
#-#######################################################################################
#-$O
#-the big struct which contain, well everything (globals + the interactive methods ...)
#-if you want to do a kickstart file, you just have to add all the required fields (see for example
#-the variable $default)
#-#######################################################################################
$o = $::o = {
# bootloader => { linear => 0, message => 1, timeout => 5, restricted => 0 },
#- packages => [ qw() ],
partitioning => { clearall => 0, eraseBadPartitions => 0, auto_allocate => 0 }, #-, readonly => 0 },
authentication => { md5 => 1, shadow => 1 },
locale => { lang => 'en_US' },
#- isUpgrade => 0,
toRemove => [],
toSave => [],
#- simple_themes => 1,
timezone => {
#- timezone => "Europe/Paris",
#- UTC => 1,
},
#- superuser => { password => 'a', shell => '/bin/bash', realname => 'God' },
#- user => { name => 'foo', password => 'bar', home => '/home/foo', shell => '/bin/bash', realname => 'really, it is foo' },
#- keyboard => 'de',
#- display => "192.168.1.19:1",
steps => \%steps::installSteps,
orderedSteps => \@steps::orderedInstallSteps,
#- for the list of fields available for user and superuser, see @etc_pass_fields in install_steps.pm
#- intf => { eth0 => { DEVICE => "eth0", IPADDR => '1.2.3.4', NETMASK => '255.255.255.128' } },
netc => {},
intf => {},
#-step : the current one
#-prefix
#-mouse
#-keyboard
#-netc
#-methods
#-packages compss
#-printer haveone entry(cf printer.pm)
};
sub installStepsCall {
my ($o, $auto, $fun, @args) = @_;
$fun = "install_steps::$fun" if $auto;
$o->$fun(@args);
}
#-######################################################################################
#- Steps Functions
#- each step function are called with two arguments : clicked(because if you are a
#- beginner you can force the the step) and the entered number
#-######################################################################################
#------------------------------------------------------------------------------
sub selectLanguage {
my ($_clicked, $ent_number, $auto) = @_;
installStepsCall($o, $auto, 'selectLanguage', $ent_number == 1);
}
sub acceptLicense {
my ($_clicked, $_ent_number, $auto) = @_;
installStepsCall($o, $auto, 'acceptLicense');
}
#------------------------------------------------------------------------------
sub selectMouse {
my ($clicked, $ent_number, $auto) = @_;
require pkgs;
my $first_time = $ent_number == 1;
installStepsCall($o, $auto, 'selectMouse', !$first_time || $clicked);
addToBeDone { mouse::write($o->do_pkgs, $o->{mouse}) if !$o->{isUpgrade} || $clicked } 'installPackages';
}
#------------------------------------------------------------------------------
sub setupSCSI {
my ($clicked, $_ent_number, $auto) = @_;
if (!$::testing && !$::uml_install) {
-d '/lib/modules/' . c::kernel_version() ||
-s modules::cz_file() or die N("Can not access kernel modules corresponding to your kernel (file %s is missing), this generally means your boot floppy in not in sync with the Installation medium (please create a newer boot floppy)", modules::cz_file());
}
installStepsCall($o, $auto, 'setupSCSI', $clicked);
}
#------------------------------------------------------------------------------
sub selectKeyboard {
my ($clicked, $_ent_number, $auto) = @_;
installStepsCall($o, $auto, 'selectKeyboard', $clicked);
#- read keyboard ASAP (so that summary displays ok)
addToBeDone {
$o->{keyboard}{unsafe} or return;
if (my $keyboard = keyboard::read()) {
$o->{keyboard} = $keyboard;
}
} 'formatPartitions';
}
#------------------------------------------------------------------------------
sub selectInstallClass {
my ($clicked, $_ent_number, $auto) = @_;
installStepsCall($o, $auto, 'selectInstallClass', $clicked);
if ($o->{isUpgrade}) {
$o->{keepConfiguration} and @{$o->{orderedSteps}} = grep { !/selectMouse|selectKeyboard|miscellaneous|setRootPassword|addUser|configureNetwork|installUpdates|summary|configureServices|configureX/ } @{$o->{orderedSteps}};
}
}
#------------------------------------------------------------------------------
sub doPartitionDisks {
my ($_clicked, $_ent_number, $auto) = @_;
$o->{steps}{formatPartitions}{done} = 0;
installStepsCall($o, $auto, 'doPartitionDisksBefore');
installStepsCall($o, $auto, 'doPartitionDisks');
installStepsCall($o, $auto, 'doPartitionDisksAfter');
}
sub formatPartitions {
my ($_clicked, $_ent_number, $auto) = @_;
$o->{steps}{choosePackages}{done} = 0;
installStepsCall($o, $auto, 'choosePartitionsToFormat', $o->{fstab}) if !$o->{isUpgrade};
my $want_root_formated = fs::get::root($o->{fstab})->{toFormat};
if ($want_root_formated) {
foreach ('/usr') {
my $part = fs::get::mntpoint2part($_, $o->{fstab}) or next;
$part->{toFormat} or die N("You must also format %s", $_);
}
}
installStepsCall($o, $auto, 'formatMountPartitions', $o->{fstab}) if !$::testing;
if ($want_root_formated) {
#- we formatted /, ensure /var/lib/rpm is cleaned otherwise bad things can happen
#- (especially when /var is *not* formatted)
eval { rm_rf("$o->{prefix}/var/lib/rpm") };
}
mkdir "$o->{prefix}/$_", 0755 foreach
qw(dev etc etc/profile.d etc/rpm etc/sysconfig etc/sysconfig/console
etc/sysconfig/network-scripts etc/sysconfig/console/consolefonts
etc/sysconfig/console/consoletrans
home mnt tmp var var/tmp var/lib var/lib/rpm var/lib/urpmi);
mkdir "$o->{prefix}/$_", 0700 foreach qw(root root/tmp root/drakx);
devices::make("$o->{prefix}/dev/null");
chmod 0666, "$o->{prefix}/dev/null";
eval { fs::mount('none', "$o->{prefix}/proc", 'proc') };
eval { fs::mount('none', "$o->{prefix}/sys", 'sysfs') };
eval { fs::mount_usbfs($o->{prefix}) };
install_any::screenshot_dir__and_move();
install_any::move_clp_to_disk();
any::rotate_logs($o->{prefix});
if (any { $_->{usb_media_type} && any { $_->{mntpoint} } partition_table::get_normal_parts($_) } @{$o->{all_hds}{hds}}) {
log::l("we use a usb-storage based drive, so keep it as a normal scsi_hostadapter");
} else {
log::l("we do not need usb-storage for booting system, rely on hotplug");
#- when usb-storage is in scsi_hostadapter,
#- hotplug + scsimon do not load sd_mod/sr_mod when needed
#- (eg: when plugging a usb key)
$o->{modules_conf}->remove_probeall('scsi_hostadapter', 'usb-storage');
}
require raid;
raid::prepare_prefixed($o->{all_hds}{raids});
#- needed by lilo
if (my @vgs = map { $_->{VG_name} } @{$o->{all_hds}{lvms}}) {
cp_af("/dev/$_", "$::prefix/dev") foreach 'mapper', @vgs;
}
}
#------------------------------------------------------------------------------
sub choosePackages {
my ($_clicked, $ent_number, $auto) = @_;
require pkgs;
#- always setPackages as it may have to copy hdlist and synthesis files.
installStepsCall($o, $auto, 'setPackages', $o->{isUpgrade} && $ent_number == 1);
installStepsCall($o, $auto, 'choosePackages', $o->{packages}, $o->{compssUsers}, $ent_number == 1);
my @flags = map_each { if_($::b, $::a) } %{$o->{rpmsrate_flags_chosen}};
log::l("rpmsrate_flags_chosen's: ", join(' ', sort @flags));
#- check pre-condition that basesystem package must be selected.
pkgs::packageByName($o->{packages}, 'basesystem')->flag_available or die "basesystem package not selected";
#- check if there are packages that need installation.
$o->{steps}{installPackages}{done} = 0 if $o->{steps}{installPackages}{done} && pkgs::packagesToInstall($o->{packages}) > 0;
}
#------------------------------------------------------------------------------
sub installPackages {
my ($_clicked, $ent_number, $auto) = @_;
installStepsCall($o, $auto, 'readBootloaderConfigBeforeInstall') if $ent_number == 1;
installStepsCall($o, $auto, 'beforeInstallPackages');
installStepsCall($o, $auto, 'installPackages');
installStepsCall($o, $auto, 'afterInstallPackages');
}
#------------------------------------------------------------------------------
sub miscellaneous {
my ($clicked, $_ent_number, $auto) = @_;
installStepsCall($o, $auto, 'miscellaneousBefore', $clicked);
installStepsCall($o, $auto, 'miscellaneous', $clicked);
installStepsCall($o, $auto, 'miscellaneousAfter', $clicked);
}
#------------------------------------------------------------------------------
sub summary {
my ($_clicked, $ent_number, $auto) = @_;
installStepsCall($o, $auto, 'summaryBefore');
installStepsCall($o, $auto, 'summary', $ent_number == 1);
installStepsCall($o, $auto, 'summaryAfter');
}
#------------------------------------------------------------------------------
sub configureNetwork {
my ($_clicked, $_ent_number, $auto) = @_;
#- get current configuration of network device.
require network::network;
eval { network::network::read_all_conf($o->{prefix}, $o->{netc}, $o->{intf}) };
installStepsCall($o, $auto, 'configureNetwork') if !$o->{isUpgrade};
}
#------------------------------------------------------------------------------
sub installUpdates {
my ($_clicked, $_ent_number, $auto) = @_;
installStepsCall($o, $auto, 'installUpdates') if $o->{meta_class} ne 'firewall';
}
#------------------------------------------------------------------------------
sub configureServices {
my ($clicked, $_ent_number, $auto) = @_;
installStepsCall($o, $auto, 'configureServices', $clicked);
}
#------------------------------------------------------------------------------
sub setRootPassword {
my ($clicked, $_ent_number, $auto) = @_;
return if $o->{isUpgrade};
installStepsCall($o, $auto, 'setRootPassword', $clicked);
}
#------------------------------------------------------------------------------
sub addUser {
my ($clicked, $_ent_number, $auto) = @_;
installStepsCall($o, $auto, 'addUser', $clicked) if !$o->{isUpgrade};
}
#------------------------------------------------------------------------------
sub setupBootloader {
my ($_clicked, $ent_number, $auto) = @_;
return if $::uml_install;
$o->{modules_conf}->write;
installStepsCall($o, $auto, 'setupBootloaderBefore') if $ent_number == 1;
installStepsCall($o, $auto, 'setupBootloader', $ent_number);
eval { install_any::set_security($o) };
}
#------------------------------------------------------------------------------
sub configureX {
my ($_clicked, $_ent_number, $auto) = @_;
#- done here and also at the end of install2.pm, just in case...
install_any::write_fstab($o);
$o->{modules_conf}->write;
require pkgs;
installStepsCall($o, $auto, 'configureX') if !$::testing && eval { pkgs::packageByName($o->{packages}, 'xorg-x11')->flag_installed } && !$o->{X}{disabled};
}
#------------------------------------------------------------------------------
sub exitInstall {
my ($_clicked, $_xent_number, $auto) = @_;
installStepsCall($o, $auto, 'exitInstall', getNextStep($::o) eq 'exitInstall');
}
sub start_i810fb() {
my ($vga) = cat_('/proc/cmdline') =~ /vga=(\S+)/;
return if !$vga || listlength(cat_('/proc/fb'));
my %vga_to_xres = (0x311 => '640', 0x314 => '800', 0x317 => '1024');
my $xres = $vga_to_xres{$vga} || '800';
log::l("trying to load i810fb module with xres <$xres> (vga was <$vga>)");
eval { modules::load('intel-agp') };
eval {
any::monitor_full_edid(); # keep the result otherwise monitor-edid does not return good results afterwards
my $opt = "xres=$xres hsync1=32 hsync2=48 vsync1=50 vsync2=70 vram=2 bpp=16 accel=1 mtrr=1"; #- this sucking i810fb does not accept floating point numbers in hsync!
modules::load_with_options([ 'i810fb' ], { i810fb => $opt });
};
}
#-######################################################################################
#- MAIN
#-######################################################################################
sub main {
$SIG{SEGV} = sub {
my $msg = "segmentation fault: seems like memory is missing as the install crashes"; log::l($msg);
$o->ask_warn('', $msg);
setVirtual(1);
require install_steps_auto_install;
install_steps_auto_install_non_interactive::errorInStep($o, $msg);
};
$ENV{PERL_BADLANG} = 1;
$ENV{LD_ASSUME_KERNEL} = '2.4.1';
delete $ENV{TERMINFO};
umask 022;
$::isInstall = 1;
$::isWizard = 1;
$::no_ugtk_init = 1;
$::expert = 0;
#- c::unlimit_core() unless $::testing;
my ($cfg, $patch, @auto);
my %cmdline = map {
my ($n, $v) = split /=/;
$n => $v || 1;
} split ' ', cat_("/proc/cmdline");
my $opt; foreach (@_) {
if (/^--?(.*)/) {
$cmdline{$opt} = 1 if $opt;
$opt = $1;
} else {
$cmdline{$opt} = $_ if $opt;
$opt = '';
}
} $cmdline{$opt} = 1 if $opt;
#- from stage1
put_in_hash(\%ENV, { getVarsFromSh('/tmp/env') });
exists $ENV{$_} and $cmdline{lc($_)} = $ENV{$_} foreach qw(METHOD PCMCIA KICKSTART);
map_each {
my ($n, $v) = @_;
my $f = ${{
lang => sub { $o->{locale}{lang} = $v },
flang => sub { $o->{locale}{lang} = $v; push @auto, 'selectLanguage' },
method => sub { $o->{method} = $v },
pcmcia => sub { $o->{pcmcia} = $v },
vga16 => sub { $o->{vga16} = $v },
vga => sub { $o->{vga} = $v },
step => sub { $o->{steps}{first} = $v },
meta_class => sub { $o->{meta_class} = $v },
freedriver => sub { $o->{freedriver} = $v },
no_bad_drives => sub { $o->{partitioning}{no_bad_drives} = 1 },
readonly => sub { $o->{partitioning}{readonly} = $v ne "0" },
display => sub { $o->{display} = $v },
askdisplay => sub { print "Please enter the X11 display to perform the install on ? "; $o->{display} = chomp_(scalar(<STDIN>)) },
security => sub { $o->{security} = $v },
noauto => sub { $::noauto = 1 },
testing => sub { $::testing = 1 },
patch => sub { $patch = 1 },
defcfg => sub { $cfg = $v },
newt => sub { $o->{interactive} = "newt" },
text => sub { $o->{interactive} = "newt" },
stdio => sub { $o->{interactive} = "stdio" },
kickstart => sub { $::auto_install = $v },
uml_install => sub { $::uml_install = 1 },
auto_install => sub { $::auto_install = $v },
simple_themes => sub { $o->{simple_themes} = 1 },
theme => sub { $o->{theme} = $v },
doc => sub { $o->{doc} = 1 }, #- will be used to know that we're running for the doc team,
#- e.g. we want screenshots with a good B&W contrast
useless_thing_accepted => sub { $o->{useless_thing_accepted} = 1 },
alawindows => sub { $o->{security} = 0; $o->{partitioning}{clearall} = 1; $o->{bootloader}{crushMbr} = 1 },
fdisk => sub { $o->{partitioning}{fdisk} = 1 },
nomouseprobe => sub { $o->{nomouseprobe} = $v },
updatemodules => sub { $o->{updatemodules} = 1 },
move => sub { $::move = 1 },
globetrotter => sub { $::move = 1; $::globetrotter = 1 },
suppl => sub { $o->{supplmedia} = 1 },
askmedia => sub { $o->{askmedia} = 1 },
}}{lc $n}; &$f if $f;
} %cmdline;
if ($::testing) {
$ENV{SHARE_PATH} ||= "/export/install/stage2/live/usr/share";
$ENV{SHARE_PATH} = "/usr/share" if !-e $ENV{SHARE_PATH};
} else {
$ENV{SHARE_PATH} ||= "/usr/share";
}
undef $::auto_install if $cfg;
if (!$::testing) {
unlink $_ foreach "/modules/modules.mar", "/sbin/stage1";
}
log::openLog(($::testing || $o->{localInstall}) && 'debug.log');
log::l("second stage install running (", install_any::drakx_version(), ")");
eval { output('/proc/sys/kernel/modprobe', "\n") } if !$::testing; #- disable kmod, otherwise we get a different behaviour in kernel vs kernel-BOOT
eval { fs::mount('none', '/sys', 'sysfs', 1) };
if ($::move) {
require move;
move::init($o);
}
cp_f(glob('/stage1/tmp/*'), '/tmp');
#- free up stage1 memory
eval { fs::umount($_) } foreach qw(/stage1/proc/bus/usb /stage1/proc /stage1);
$o->{prefix} = $::prefix = $::testing ? "/tmp/test-perl-install" : $::move ? "" : "/mnt";
mkdir $o->{prefix}, 0755;
#- make sure we do not pick up any gunk from the outside world
my $remote_path = "$o->{prefix}/sbin:$o->{prefix}/bin:$o->{prefix}/usr/sbin:$o->{prefix}/usr/bin:$o->{prefix}/usr/X11R6/bin";
$ENV{PATH} = "/usr/bin:/bin:/sbin:/usr/sbin:/usr/X11R6/bin:$remote_path";
eval { spawnShell() };
modules::load_dependencies(($::testing ? ".." : "") . "/modules/modules.dep");
require modules::any_conf;
require modules::modules_conf;
$o->{modules_conf} = modules::modules_conf::read(modules::any_conf::vnew(), '/tmp/modules.conf');
modules::read_already_loaded($o->{modules_conf});
#- done before auto_install is called to allow the -IP feature on auto_install file name
if (-e '/tmp/network') {
require network::network;
#- get stage1 network configuration if any.
log::l('found /tmp/network');
$o->{netc} ||= {};
add2hash($o->{netc}, network::network::read_conf('/tmp/network'));
if (my ($file) = glob_('/tmp/ifcfg-*')) {
log::l("found network config file $file");
my $l = network::network::read_interface_conf($file);
$o->{intf}{$l->{DEVICE}} ||= $l;
}
if (-e '/etc/resolv.conf') {
my $file = '/etc/resolv.conf';
log::l("found network config file $file");
add2hash($o->{netc}, network::network::read_resolv_conf($file));
}
}
#- done after module dependencies are loaded for "vfat depends on fat"
if ($::auto_install) {
if ($::auto_install =~ /-IP(\.pl)?$/) {
my ($ip) = cat_('/tmp/stage1.log') =~ /configuring device (?!lo)\S+ ip: (\S+)/;
my $normalized_ip = join('', map { sprintf "%02X", $_ } split('\.', $ip));
$::auto_install =~ s/-IP(\.pl)?$/-$normalized_ip$1/;
}
require install_steps_auto_install;
eval { $o = $::o = install_any::loadO($o, $::auto_install) };
if ($@) {
if ($o->{useless_thing_accepted}) { #- Pixel's hack to be able to fail through
log::l("error using auto_install, continuing");
undef $::auto_install;
} else {
install_steps_auto_install_non_interactive::errorInStep($o, "Error using auto_install\n" . formatError($@));
}
} else {
log::l("auto install config file loaded successfully");
#- normalize for people not using our special scheme
foreach (@{$o->{manualFstab} || []}) {
$_->{device} =~ s!^/dev/!!;
}
}
}
$o->{interactive} ||= 'gtk' if !$::auto_install;
if ($o->{interactive} eq "gtk" && availableMemory() < 22 * 1024) {
log::l("switching to newt install cuz not enough memory");
$o->{interactive} = "newt";
}
if (my ($s) = cat_("/proc/cmdline") =~ /brltty=(\S*)/) {
my ($driver, $device, $table) = split(',', $s);
$table = "text.$table.tbl" if $table !~ /\.tbl$/;
log::l("brltty option $driver $device $table");
$o->{brltty} = { driver => $driver, device => $device, table => $table };
$o->{interactive} = 'newt';
$o->{nomouseprobe} = 1;
}
# perl_checker: require install_steps_gtk
# perl_checker: require install_steps_newt
# perl_checker: require install_steps_stdio
require "install_steps_$o->{interactive}.pm" if $o->{interactive};
#- needed before accessing floppy (in case of usb floppy)
modules::load_category($o->{modules_conf}, 'bus/usb');
#- oem patch should be read before to still allow patch or defcfg.
eval { $o = $::o = install_any::loadO($o, "install/patch-oem.pl"); log::l("successfully read oem patch") };