package install_steps; # $Id$ use diagnostics; use strict; use vars qw(@filesToSaveForUpgrade @filesNewerToUseAfterUpgrade); #-###################################################################################### #- misc imports #-###################################################################################### use common; use install_any qw(:all); use partition_table; use detect_devices; use fs::type; use modules; use run_program; use lang; use keyboard; use fsedit; use do_pkgs; use pkgs; use any; use log; our @ISA = qw(do_pkgs); @filesToSaveForUpgrade = qw( /etc/ld.so.conf /etc/fstab /etc/hosts /etc/conf.modules /etc/modules.conf ); @filesNewerToUseAfterUpgrade = qw( /etc/profile ); #-###################################################################################### #- OO Stuff #-###################################################################################### sub new($$) { my ($type, $o) = @_; bless $o, ref($type) || $type; return $o; } sub charsetChanged { my ($_o) = @_; } #-###################################################################################### #- In/Out Steps Functions #-###################################################################################### sub enteringStep { my ($_o, $step) = @_; log::l("starting step `$step'"); } sub leavingStep { my ($o, $step) = @_; log::l("step `$step' finished"); if (-d "$o->{prefix}/root/drakx") { eval { cp_af("/tmp/ddebug.log", "$o->{prefix}/root/drakx") }; output(install_any::auto_inst_file(), install_any::g_auto_install(1)); } foreach my $s (@{$o->{orderedSteps}}) { #- the reachability property must be recomputed each time to take #- into account failed step. next if $o->{steps}{$s}{done} && !$o->{steps}{$s}{redoable}; my $reachable = 1; if (my $needs = $o->{steps}{$s}{needs}) { my @l = ref($needs) ? @$needs : $needs; $reachable = min(map { $o->{steps}{$_}{done} || 0 } @l); } $o->{steps}{$s}{reachable} = 1 if $reachable; } $o->{steps}{$step}{reachable} = $o->{steps}{$step}{redoable}; while (my $f = shift @{$o->{steps}{$step}{toBeDone} || []}) { eval { &$f() }; $o->ask_warn(N("Error"), [ N("An error occurred, but I do not know how to handle it nicely. Continue at your own risk."), formatError($@) || $@ ]) if $@; } } sub errorInStep { my ($_o, $err) = @_; print "error :(\n"; print "$err\n\n"; c::_exit(1); } sub kill_action {} #-###################################################################################### #- Steps Functions #-###################################################################################### #------------------------------------------------------------------------------ sub selectLanguage { my ($o) = @_; #- for auto_install compatibility with old $o->{lang} $o->{locale} = lang::system_locales_to_ourlocale($o->{lang}, $o->{lang}) if $o->{lang}; $o->{locale}{langs} ||= { $o->{locale}{lang} => 1 }; if (!exists $o->{locale}{country}) { my $h = lang::analyse_locale_name(lang::l2locale($o->{locale}{lang})); $o->{locale}{country} = $h->{country} if $h->{country}; $o->{locale}{IM} = lang::get_default_im($o->{locale}{lang}); } lang::set($o->{locale}, !$o->isa('interactive::gtk')); add2hash_($o->{locale}, { utf8 => lang::utf8_should_be_needed($o->{locale}) }); log::l("selectLanguage: pack_langs: ", lang::pack_langs($o->{locale}{langs}), " utf8-flag: ", to_bool($o->{locale}{utf8})); #- for auto_install compatibility with old $o->{keyboard} containing directly $o->{keyboard}{KEYBOARD} $o->{keyboard} = { KEYBOARD => $o->{keyboard} } if $o->{keyboard} && !ref($o->{keyboard}); if (!$o->{keyboard} || $o->{keyboard}{unsafe}) { $o->{keyboard} = keyboard::default($o->{locale}); $o->{keyboard}{unsafe} = 1; keyboard::setup_install($o->{keyboard}); } $o->charsetChanged; addToBeDone { lang::write_langs($o->{locale}{langs}); } 'formatPartitions'; addToBeDone { lang::write_and_install($o->{locale}, $o->do_pkgs); } 'installPackages'; } #------------------------------------------------------------------------------ sub selectKeyboard { my ($o) = @_; $o->{keyboard}{KBCHARSET} = lang::l2charset($o->{locale}{lang}); keyboard::setup_install($o->{keyboard}); addToBeDone { keyboard::write($o->{keyboard}); } 'installPackages' if !$o->{isUpgrade} || !$o->{keyboard}{unsafe}; if ($o->{raw_X}) { require Xconfig::default; Xconfig::default::config_keyboard($o->{raw_X}, $o->{keyboard}); $o->{raw_X}->write; } } #------------------------------------------------------------------------------ sub acceptLicense {} #------------------------------------------------------------------------------ sub setupSCSI { my ($o) = @_; install_any::configure_pcmcia($o->{modules_conf}, $o->{pcmcia}) if $o->{pcmcia}; modules::load(modules::category2modules('disk/cdrom')); modules::load_category($o->{modules_conf}, 'bus/firewire'); modules::load_category($o->{modules_conf}, 'disk/ide|scsi|hardware_raid|sata|firewire'); install_any::getHds($o); } #------------------------------------------------------------------------------ sub selectInstallClass { my ($o) = @_; if ($o->{partitioning}{use_existing_root} || $o->{isUpgrade}) { # either one root is defined (and all is ok), or we take the first one we find my $p = fs::get::root_($o->{fstab}) || (first(install_any::find_root_parts($o->{fstab}, $o->{prefix})) || die)->{part}; $o->{migrate_device_names} = install_any::use_root_part($o->{all_hds}, $p); } } #------------------------------------------------------------------------------ sub doPartitionDisksBefore { my ($o) = @_; eval { eval { fs::mount::umount("$::prefix/sys") }; eval { fs::mount::umount("$::prefix/proc/bus/usb") }; eval { fs::mount::umount("$::prefix/proc") }; eval { fs::mount::umount_all($o->{fstab}) }; eval { sleep 1; fs::mount::umount_all($o->{fstab}) } if $@; #- HACK } if $o->{fstab} && !$::testing; } #------------------------------------------------------------------------------ sub doPartitionDisksAfter { my ($o) = @_; if (!$::testing) { my $hds = $o->{all_hds}{hds}; partition_table::write($_) foreach @$hds; $_->{rebootNeeded} and $o->rebootNeeded foreach @$hds; } fs::set_removable_mntpoints($o->{all_hds}); fs::mount_options::set_all_default($o->{all_hds}, %$o, lang::fs_options($o->{locale})) if !$o->{isUpgrade} || $o->{isUpgrade} =~ /redhat|conectiva/; $o->{fstab} = [ fs::get::fstab($o->{all_hds}) ]; if ($::local_install) { my $p = fs::get::mntpoint2part($::prefix, [ fs::read_fstab('', '/proc/mounts') ]); my $part = fs::get::device2part($p->{device}, $o->{fstab}); $part->{mntpoint} = '/'; $part->{isMounted} = 1; } fs::get::root_($o->{fstab}) or die "Oops, no root partition"; if (arch() =~ /ppc/ && detect_devices::get_mac_generation() =~ /NewWorld/) { die "Need bootstrap partition to boot system!" if !(defined $partition_table::mac::bootstrap_part); } if (arch() =~ /ia64/ && !fs::get::has_mntpoint("/boot/efi", $o->{all_hds})) { die N("You must have a FAT partition mounted in /boot/efi"); } if ($o->{partitioning}{use_existing_root}) { #- ensure those partitions are mounted so that they are not proposed in choosePartitionsToFormat fs::mount::part($_) foreach sort { $a->{mntpoint} cmp $b->{mntpoint} } grep { $_->{mntpoint} && maybeFormatted($_) } @{$o->{fstab}}; } cat_("/proc/mounts") =~ m|(\S+)\s+/tmp/nfsimage| && !any { $_->{mntpoint} eq "/mnt/nfs" } @{$o->{all_hds}{nfss}} and push @{$o->{all_hds}{nfss}}, { fs_type => 'nfs', mntpoint => "/mnt/nfs", device => $1, options => "noauto,ro,nosuid,soft,rsize=8192,wsize=8192" }; } #------------------------------------------------------------------------------ sub doPartitionDisks { my ($o) = @_; if ($o->{partitioning}{auto_allocate}) { catch_cdie { fsedit::auto_allocate($o->{all_hds}, $o->{partitions}) } sub { 1 }; } } #------------------------------------------------------------------------------ sub ask_mntpoint_s {#-}}} my ($_o, $fstab) = @_; #- TODO: set the mntpoints my %m; foreach (@$fstab) { my $m = $_->{mntpoint}; $m && $m =~ m!^/! or next; #- there may be a lot of swaps or "none" $m{$m} and die N("Duplicate mount point %s", $m); $m{$m} = 1; #- in case the type does not correspond, force it to ext3 fs::type::set_fs_type($_, 'ext3') if !isTrueFS($_) && !isOtherAvailableFS($_); } 1; } sub rebootNeeded($) { my ($_o) = @_; log::l("Rebooting..."); c::_exit(0); } sub choosePartitionsToFormat($$) { my ($_o, $fstab) = @_; return if $::local_install; foreach (@$fstab) { $_->{mntpoint} = "swap" if isSwap($_); $_->{mntpoint} or next; add2hash_($_, { toFormat => $_->{notFormatted} }) if $_->{fs_type}; #- eg: do not set toFormat for isRawRAID (0xfd) $_->{toFormatUnsure} ||= member($_->{mntpoint}, '/', '/usr'); if (!$_->{toFormat}) { my $fs_type = fs::type::fs_type_from_magic($_); if (!$fs_type || $fs_type ne $_->{fs_type}) { log::l("setting toFormatUnsure for $_->{device} because <$_->{fs_type}> ne <$fs_type>"); $_->{toFormatUnsure} = 1; } } } } sub formatMountPartitions { my ($o) = @_; fs::format::formatMount_all($o->{all_hds}, $o->{fstab}, undef); } #------------------------------------------------------------------------------ sub setPackages { my ($o) = @_; install_any::setPackages($o, sub {}); } sub deselectFoundMedia { my (undef, $hdlists) = @_; return $hdlists, 0; } sub selectSupplMedia { '' } sub askSupplMirror { '' } sub choosePackages { my ($o) = @_; #- now for upgrade, package that must be upgraded are #- selected first, after is used the same scheme as install. #- make sure we kept some space left for available else the system may #- not be able to start (xfs at least). my $available = install_any::getAvailableSpace($o); my $availableCorrected = pkgs::invCorrectSize($available / sqr(1024)) * sqr(1024); log::l(sprintf "available size %s (corrected %s)", formatXiB($available), formatXiB($availableCorrected)); add2hash_($o, { compssListLevel => 5 }) if !$::auto_install; #- !! destroying user selection of packages (they may have done individual selection before) exists $o->{compssListLevel} and pkgs::setSelectedFromCompssList($o->{packages}, $o->{rpmsrate_flags_chosen}, $o->{compssListLevel}, $availableCorrected); $availableCorrected; } sub upgrading_redhat() { #- remove weird config files that bother Xconfig::* too much unlink "$::prefix/etc/X11/XF86Config"; unlink "$::prefix/etc/X11/XF86Config-4"; sub prefering_mdk { my ($lpkg, $rpkg_ver, $c) = @_; my $lpkg_ver = $lpkg->version . '-' . $lpkg->release; log::l($lpkg->name . ' ' . ': prefering ' . ($c == 1 ? "$lpkg_ver over $rpkg_ver" : "$rpkg_ver over $lpkg_ver")); } my $old_compare_pkg = \&URPM::Package::compare_pkg; undef *URPM::Package::compare_pkg; *URPM::Package::compare_pkg = sub { my ($lpkg, $rpkg) = @_; my $c = ($lpkg->release =~ /mdk$/ ? 1 : 0) - ($rpkg->release =~ /mdk$/ ? 1 : 0); if ($c) { prefering_mdk($lpkg, $rpkg->version . '-' . $rpkg->release, $c); $c; } else { &$old_compare_pkg; } }; my $old_compare = \&URPM::Package::compare; undef *URPM::Package::compare; *URPM::Package::compare = sub { my ($lpkg, $rpkg_ver) = @_; my $c = ($lpkg->release =~ /mdk$/ ? 1 : 0) - ($rpkg_ver =~ /mdk$/ ? 1 : 0); if ($c) { prefering_mdk($lpkg, $rpkg_ver, $c); return $c; } &$old_compare; }; } sub beforeInstallPackages { my ($o) = @_; read_bootloader_config($o); #- save these files in case of upgrade failure. if ($o->{isUpgrade}) { foreach (@filesToSaveForUpgrade) { unlink "$o->{prefix}/$_.mdkgisave"; if (-e "$o->{prefix}/$_") { eval { cp_af("$o->{prefix}/$_", "$o->{prefix}/$_.mdkgisave") }; } } foreach (@filesNewerToUseAfterUpgrade) { unlink "$o->{prefix}/$_.rpmnew"; } } #- mainly for upgrading redhat packages, but it can help other my @should_not_be_dirs = qw(/usr/X11R6/lib/X11/xkb /usr/share/locale/zh_TW/LC_TIME /usr/include/GL); my @should_be_dirs = qw(/etc/X11/xkb); my @to_remove = ( (grep { !-l $_ && -d $_ } map { "$::prefix$_" } @should_not_be_dirs), (grep { -l $_ || !-d $_ && -e $_ } map { "$::prefix$_" } @should_be_dirs), ); rm_rf(@to_remove); if ($o->{isUpgrade} eq 'redhat') { upgrading_redhat(); } #- some packages need such files for proper installation. install_any::write_fstab($o); require network::network; network::network::add2hosts("localhost", "127.0.0.1"); log::l("setting excludedocs to $o->{excludedocs}"); substInFile { s/%_excludedocs.*//; $_ .= "%_excludedocs yes\n" if eof && $o->{excludedocs} } "$o->{prefix}/etc/rpm/macros"; #- add oem theme if the files exists. mkdir_p("$o->{prefix}/usr/share"); install_any::getAndSaveFile("install/oem-theme.rpm", "$o->{prefix}/usr/share/oem-theme.rpm"); } #- returns number of packages installed, 0 if none were selected. sub pkg_install { my ($o, @l) = @_; log::l("selecting packages " . join(" ", @l)); require pkgs; if ($::testing) { log::l(qq(selecting package "$_")) foreach @l; } else { pkgs::selectPackage($o->{packages}, pkgs::packageByName($o->{packages}, $_) || die "$_ rpm not found") foreach @l; } my @toInstall = pkgs::packagesToInstall($o->{packages}); if (@toInstall) { log::l("installing packages"); $o->installPackages; } else { log::l("all packages selected are already installed, nothing to do"); 0; } } sub installCallback { # my (undef, $msg, @para) = @_; # log::l("$msg: " . join(',', @para)); } sub installPackages { #- complete REWORK, TODO and TOCHECK! my ($o) = @_; my $packages = $o->{packages}; pkgs::remove_marked_ask_remove($packages, \&installCallback); #- small transaction will be built based on this selection and depslist. my @toInstall = pkgs::packagesToInstall($packages); my $time = time(); { local $ENV{DURING_INSTALL} = 1; local $ENV{TMPDIR} = '/tmp'; local $ENV{TMP} = '/tmp'; pkgs::install($o->{isUpgrade}, \@toInstall, $packages, \&installCallback); } any::writeandclean_ldsoconf($o->{prefix}); run_program::rooted_or_die($o->{prefix}, 'ldconfig'); eval { run_program::rooted($o->{prefix}, 'gdk-pixbuf-query-loaders', '>', '/etc/gtk-2.0/gdk-pixbuf.loaders.' . (arch() =~ /64/ ? 'lib64' : 'lib')); run_program::rooted($o->{prefix}, 'gtk-query-immodules-2.0', '>', '/etc/gtk-2.0/gtk.immodules.' . (arch() =~ /64/ ? 'lib64' : 'lib')); run_program::rooted($o->{prefix}, 'pango-querymodules-' . (arch() =~ /64/ ? '64' : '32'), '>', '/etc/pango/' . (arch() =~ /i.86/ ? 'i386' : arch()) . '/pango.modules'); }; log::l("Install took: ", formatTimeRaw(time() - $time)); install_any::log_sizes($o); scalar(@toInstall); #- return number of packages installed. } sub afterInstallPackages($) { my ($o) = @_; read_bootloader_config($o) if $o->{isUpgrade} && is_empty_hash_ref($o->{bootloader}); die N("Some important packages did not get installed properly. Either your cdrom drive or your cdrom is defective. Check the cdrom on an installed computer using \"rpm -qpl media/main/*.rpm\" ") if any { m|read failed: Input/output error| } cat_("$o->{prefix}/root/drakx/install.log"); if (arch() !~ /^sparc/) { #- TODO restore it as may be needed for sparc -x "$o->{prefix}/usr/bin/dumpkeys" or $::testing or die "Some important packages did not get installed properly. Please switch to console 2 (using ctrl-alt-f2) and look at the log file /tmp/ddebug.log Consoles 1,3,4,7 may also contain interesting information"; } #- why not? cuz weather is nice today :-) [pixel] common::sync(); common::sync(); #- generate /etc/lvmtab needed for rc.sysinit run_program::rooted($o->{prefix}, 'lvm2', 'vgscan') if -e '/etc/lvmtab'; #- configure PCMCIA services if needed. require harddrake::autoconf; harddrake::autoconf::pcmcia($o->{pcmcia}); #- for mandrake_firstime touch "$o->{prefix}/var/lock/TMP_1ST"; any::config_dvd($o->{prefix}, 0); any::config_mtools($o->{prefix}); #- make sure wins is disabled in /etc/nsswitch.conf #- else if eth0 is not existing, glibc segfaults. substInFile { s/\s*wins// if /^\s*hosts\s*:/ } "$o->{prefix}/etc/nsswitch.conf"; #- make sure some services have been enabled (or a catastrophic restart will occur). #- these are normally base package post install scripts or important services to start. run_program::rooted($o->{prefix}, "chkconfig", "--add", $_) foreach qw(netfs network rawdevices sound kheader keytable syslog crond portmap); if ($o->{mouse}{device} =~ /ttyS/) { log::l("disabling gpm for serial mice (does not get along nicely with X)"); run_program::rooted($o->{prefix}, "chkconfig", "--del", "gpm"); } #- install urpmi before as rpmdb will be opened, this will cause problem with update-menus. $o->install_urpmi; #- update menu scheme before calling update menus if desktop mode. if ($o->{meta_class} eq 'desktop') { run_program::rooted($o->{prefix}, "touch", "/etc/menu/do-not-create-menu-link"); run_program::rooted($o->{prefix}, "touch", "/etc/menu/enable_simplified"); } elsif (!$o->{isUpgrade}) { run_program::rooted($o->{prefix}, "touch", "/etc/menu/do-not-create-menu-link"); } if ($o->{pcmcia}) { substInFile { s/.*(TaskBarShowAPMStatus).*/$1=1/ } "$o->{prefix}/usr/lib/X11/icewm/preferences"; eval { cp_af("$o->{prefix}/usr/share/applnk/System/kapm.kdelnk", "$o->{prefix}/etc/skel/Desktop/Autostart/kapm.kdelnk") }; } if ($o->{brltty}) { output("$o->{prefix}/etc/brltty.conf", <{brltty}{driver} braille-device $o->{brltty}{device} text-table $o->{brltty}{table} EOF } install_any::disable_user_view() if $o->{security} >= 3 || $o->{authentication}{NIS}; run_program::rooted($o->{prefix}, "kdeDesktopCleanup"); #- move some file after an upgrade that may be seriously annoying. #- and rename saved files to .mdkgiorig. if ($o->{isUpgrade}) { my $pkg = pkgs::packageByName($o->{packages}, 'rpm'); $pkg && ($pkg->flag_selected || $pkg->flag_installed) && $pkg->compare(">= 4.0") and pkgs::cleanOldRpmDb(); log::l("moving previous desktop files that have been updated to Trash of each user"); install_any::kdemove_desktop_file($o->{prefix}); foreach (@filesToSaveForUpgrade) { renamef("$o->{prefix}/$_.mdkgisave", "$o->{prefix}/$_.mdkgiorig") if -e "$o->{prefix}$_.mdkgisave"; } foreach (@filesNewerToUseAfterUpgrade) { if (-e "$o->{prefix}/$_.rpmnew" && -e "$o->{prefix}/$_") { renamef("$o->{prefix}/$_", "$o->{prefix}/$_.mdkgiorig"); renamef("$o->{prefix}/$_.rpmnew", "$o->{prefix}/$_"); } } } renamef(pkgs::removed_pkgs_to_upgrade_file(), pkgs::removed_pkgs_to_upgrade_file() . '.done'); unlink(glob("$::prefix/root/drakx/*.upgrading")); if ($o->{upgrade_by_removing_pkgs_matching}) { if (cat_("$::prefix/etc/inittab.rpmsave") =~ /^id:5:initdefault:\s*$/m) { $o->{X}{xdm} = 1; require Xconfig::various; Xconfig::various::runlevel(5); } } any::fix_broken_alternatives($o->{isUpgrade} eq 'redhat'); #- update theme directly from a package (simplest). if (-s "$o->{prefix}/usr/share/oem-theme.rpm") { run_program::rooted($o->{prefix}, "rpm", "-U", "/usr/share/oem-theme.rpm"); unlink "/usr/share/oem-theme.rpm"; } #- call update-menus at the end of package installation push @{$o->{waitpids}}, run_program::raw({ root => $o->{prefix}, detach => 1 }, "update-menus", "-n"); if ($o->{updatemodules}) { $o->updatemodules($ENV{THIRDPARTY_DEVICE}, $ENV{THIRDPARTY_DIR}); } } sub install_urpmi { my ($o) = @_; my $pkg = pkgs::packageByName($o->{packages}, 'urpmi'); if ($pkg && ($pkg->flag_selected || $pkg->flag_installed) #- this is a workaround. if many urpmi packages are found in the #- provides of all media, packagesProviding() might return the wrong #- one. This probably needs to be fixed in URPM || run_program::rooted_get_stdout($::prefix, '/usr/bin/rpm', '-q', 'urpmi') =~ /urpmi/ ) { install_any::install_urpmi($o->{method}, $o->{packages}); pkgs::saveCompssUsers($o->{packages}, $o->{compssUsers}); } else { log::l("skipping install_urpmi, urpmi not installed"); } } sub updatemodules { my ($_o, $dev, $rel_dir) = @_; return if $::testing; $dev = devices::make($dev) or log::l("updatemodules: bad device $dev"), return; my $mount_dir = '/updatemodules'; find { eval { fs::mount::mount($dev, $mount_dir, $_, 0); 1 }; } 'ext2', 'vfat' or log::l("updatemodules: can't mount $dev"), return; my $dir = "$mount_dir$rel_dir"; foreach my $kernel_version (all("$::prefix/lib/modules")) { log::l("examining updated modules for kernel $kernel_version"); -d "$dir/$kernel_version" or next; log::l("found updatable modules"); run_program::run("cd $dir/$kernel_version ; find -type f | cpio -pdu $::prefix/lib/modules/$kernel_version"); run_program::rooted($::prefix, 'depmod', '-a', '-F', "/boot/System.map-$kernel_version", $kernel_version); } my $category; foreach (cat_("$dir/to_load")) { chomp; if (/^#/) { ($category) = $1 if /\[list_modules: (.*?)\]/; } elsif ($category) { log::l("adding $_ to $category\n"); my $r = \%list_modules::l; $r = $r->{$_} foreach split('/', $category); push @$r, $_; $category = ''; } } fs::mount::umount($mount_dir); } #------------------------------------------------------------------------------ sub selectMouse($) { my ($_o) = @_; } #------------------------------------------------------------------------------ sub configureNetwork { my ($o) = @_; require network::network; network::network::configure_network($o->{net}, $o, $o->{modules_conf}); configure_firewall($o) if !$o->{isUpgrade}; #- only a http proxy can be used by stage1 #- the method is http even for ftp connections through a http proxy #- use this http proxy for both http and ftp connections if ($o->{method} eq "http" && $ENV{PROXY}) { my $proxy = "http://$ENV{PROXY}" . ($ENV{PROXYPORT} && ":$ENV{PROXYPORT}"); add2hash($o->{miscellaneous} ||= {}, { http_proxy => $proxy, ftp_proxy => $proxy, }); network::network::proxy_configure($o->{miscellaneous}); } } sub configure_firewall { my ($o) = @_; #- set up a firewall if ports have been specified or if the security level is high enough if (exists $o->{firewall_ports} || $o->{security} >= 3) { require network::drakfirewall; $o->{firewall_ports} ||= ''; #- don't open any port by default network::drakfirewall::set_ports($o->do_pkgs, 0, $o->{firewall_ports}); network::drakfirewall::set_ifw($o->do_pkgs, 1, [ 'psd' ], ''); } } #------------------------------------------------------------------------------ sub installUpdates { my ($o) = @_; my $u = $o->{updates} or return; $u->{updates} or return; upNetwork($o); require crypto; crypto::getPackages($o->{packages}, $u->{mirror}) and $o->pkg_install(@{$u->{packages} || []}); #- re-install urpmi with update security medium. $o->install_urpmi; } sub summaryBefore {} sub summary { my ($o) = @_; configureTimezone($o); configurePrinter($o) if $o->{printer} && $o->{printer}{SPOOLER}; } sub summaryAfter { my ($_o) = @_; } #------------------------------------------------------------------------------ sub configureTimezone { my ($o) = @_; install_any::preConfigureTimezone($o); $o->pkg_install('ntp') if $o->{timezone}{ntp}; require timezone; timezone::write($o->{timezone}); } #------------------------------------------------------------------------------ sub configureServices { my ($o) = @_; if ($o->{services}) { require services; services::doit($o, $o->{services}); } } #------------------------------------------------------------------------------ sub configurePrinter { my ($o) = @_; eval { $o->do_pkgs->install('foomatic-filters', 'foomatic-db-engine', 'foomatic-db', 'foomatic-db-hpijs', 'gutenprint-foomatic', 'postscript-ppds', 'printer-utils', 'printer-filters', 'printer-testpages', if_($o->do_pkgs->is_installed('gimp'), 'gutenprint-gimp2')); }; if ($@ =~ /rpm not found/) { log::l("ERROR: $@"); if ($o->{printer}) { require printer::printerdrake; printer::printerdrake::final_cleanup($o->{printer}); } return; } require printer::main; eval { add2hash($o->{printer} ||= {}, printer::main::getinfo($o->{prefix})) }; #- get existing configuration. require printer::printerdrake; printer::printerdrake::install_spooler($o->{printer}, $o->{security}, $o->do_pkgs); foreach (values %{$o->{printer}{configured} || {}}) { log::l("configuring printer queue " . $_->{queuedata}{queue} || $_->{QUEUE}); #- when copy is so adulee (sorry french taste :-) #- and when there are some configuration in one place and in another place... $o->{printer}{currentqueue} = {}; printer::main::copy_printer_params($_->{queuedata}, $o->{printer}{currentqueue}); printer::main::copy_printer_params($_, $o->{printer}); #- setup all configured queues, which is not the case interactively where #- only the working queue is setup on configuration. printer::main::configure_queue($o->{printer}); } } #------------------------------------------------------------------------------ sub setRootPassword { my ($o) = @_; $o->{superuser} ||= {}; require authentication; authentication::set_root_passwd($o->{superuser}, $o->{authentication}); install_any::set_authentication($o); } #------------------------------------------------------------------------------ sub addUser { my ($o) = @_; my $users = $o->{users} ||= []; if ($::prefix) { #- getpwnam, getgrnam, getgrid works symlinkf("$::prefix/etc/passwd", '/etc/passwd'); symlinkf("$::prefix/etc/group", '/etc/group'); } any::add_users($users, $o->{authentication}); if ($o->{autologin}) { $o->{desktop} ||= first(any::sessions()); $o->pkg_install("autologin") if !member($o->{desktop}, 'KDE', 'GNOME'); } any::set_autologin($o->{autologin}, $o->{desktop}); install_any::disable_user_view() if @$users == (); } #------------------------------------------------------------------------------ sub read_bootloader_config { my ($o) = @_; require bootloader; eval { add2hash($o->{bootloader} ||= {}, bootloader::read($o->{all_hds})) }; $@ && $o->{isUpgrade} and log::l("read_bootloader_config failed: $@"); $o->{bootloader}{bootUnsafe} = 0 if $o->{bootloader}{boot}; #- when upgrading, do not ask where to install the bootloader (mbr vs boot partition) } sub setupBootloaderBefore { my ($o) = @_; require bootloader; #- auto_install backward compatibility #- one should now use {message_text} if ($o->{bootloader}{message} =~ m!^[^/]!) { $o->{bootloader}{message_text} = delete $o->{bootloader}{message}; } #- remove previous ide-scsi lines bootloader::modify_append($o->{bootloader}, sub { my ($_simple, $dict) = @_; @$dict = grep { $_->[1] ne 'ide-scsi' } @$dict; }); if (cat_("/proc/cmdline") =~ /mem=nopentium/) { bootloader::set_append_with_key($o->{bootloader}, mem => 'nopentium'); } if (cat_("/proc/cmdline") =~ /\b(pci)=(\S+)/) { bootloader::set_append_with_key($o->{bootloader}, $1, $2); } if (my ($acpi) = cat_("/proc/cmdline") =~ /\bacpi=(\w+)/) { if ($acpi eq 'ht') { #- the user is using the default, which may not be the best my $year = detect_devices::computer_info()->{BIOS_Year}; if ($year >= 2002) { log::l("forcing ACPI on recent bios ($year)"); $acpi = ''; } } bootloader::set_append_with_key($o->{bootloader}, acpi => $acpi); } if (cat_("/proc/cmdline") =~ /\bnoapic/) { bootloader::set_append_simple($o->{bootloader}, 'noapic'); } my ($MemTotal) = cat_("/proc/meminfo") =~ /^MemTotal:\s*(\d+)/m; if (my ($biggest_swap) = sort { $b->{size} <=> $a->{size} } grep { isSwap($_) } @{$o->{fstab}}) { log::l("MemTotal: $MemTotal < ", $biggest_swap->{size} / 2); if ($MemTotal < $biggest_swap->{size} / 2) { bootloader::set_append_with_key($o->{bootloader}, resume => devices::make($biggest_swap->{device})); } } #- check for valid fb mode to enable a default boot with frame buffer. my $vga = $o->{allowFB} && (!detect_devices::matching_desc__regexp('3D Rage LT') && !detect_devices::matching_desc__regexp('Rage Mobility [PL]') && !detect_devices::matching_desc__regexp('i740') && !detect_devices::matching_desc__regexp('Matrox') && !detect_devices::matching_desc__regexp('Tseng.*ET6\d00') && !detect_devices::matching_desc__regexp('SiS.*SG86C2.5') && !detect_devices::matching_desc__regexp('SiS.*559[78]') && !detect_devices::matching_desc__regexp('SiS.*300') && !detect_devices::matching_desc__regexp('SiS.*540') && !detect_devices::matching_desc__regexp('SiS.*6C?326') && !detect_devices::matching_desc__regexp('SiS.*6C?236') && !detect_devices::matching_desc__regexp('Voodoo [35]|Voodoo Banshee') && #- 3d acceleration seems to bug in fb mode !detect_devices::matching_desc__regexp('828[14][05].* CGC') #- i810 & i845 now have FB support during install but we disable it afterwards ); my $force_vga = $o->{allowFB} && (detect_devices::matching_desc__regexp('SiS.*630') || #- SiS 630 need frame buffer. detect_devices::matching_desc__regexp('GeForce.*Integrated') #- needed for fbdev driver (hack). ); #- propose the default fb mode for kernel fb, if aurora or bootsplash is installed. my $need_fb = do { my $p = pkgs::packageByName($o->{packages}, 'bootsplash'); $p && $p->flag_installed; }; bootloader::suggest($o->{bootloader}, $o->{all_hds}, vga_fb => ($force_vga || $vga && $need_fb) && $o->{vga}, quiet => $o->{meta_class} ne 'server'); $o->{bootloader}{keytable} ||= keyboard::keyboard2kmap($o->{keyboard}); } sub setupBootloader { my ($o) = @_; any::install_acpi_pkgs($o->do_pkgs, $o->{bootloader}); require bootloader; bootloader::install($o->{bootloader}, $o->{all_hds}); } #------------------------------------------------------------------------------ sub configureXBefore { my ($o) = @_; #- keep this here if the package has to be updated. $o->pkg_install("xorg-x11"); } sub configureX { my ($o) = @_; configureXBefore($o); require Xconfig::default; $o->{raw_X} = Xconfig::default::configure($o->do_pkgs, $o->{keyboard}, $o->{mouse}); require Xconfig::main; Xconfig::main::configure_everything_auto_install($o->{raw_X}, $o->do_pkgs, $o->{X}, install_any::X_options_from_o($o)); configureXAfter($o); } sub configureXAfter { my ($_o) = @_; } #------------------------------------------------------------------------------ sub miscellaneousBefore { my ($o) = @_; require security::level; require security::various; $o->{security} ||= security::level::get(); $o->{security_user} ||= security::various::config_security_user($o->{prefix}); $o->{libsafe} ||= security::various::config_libsafe($o->{prefix}); log::l("security $o->{security}"); add2hash_($o->{miscellaneous} ||= {}, { numlock => !detect_devices::isLaptop() }); } sub miscellaneous { my ($_o) = @_; #- keep some given parameters #-TODO } sub miscellaneousAfter { my ($o) = @_; add2hash_ $o, { useSupermount => $o->{security} < 4 ? 'magicdev' : 0 }; $ENV{SECURE_LEVEL} = $o->{security}; #- deprecated with chkconfig 1.3.4-2mdk, uses /etc/sysconfig/msec addToBeDone { addVarsInSh("$o->{prefix}/etc/sysconfig/system", { META_CLASS => $o->{meta_class} || 'PowerPack', }); substInFile { s/KEYBOARD_AT_BOOT=.*/KEYBOARD_AT_BOOT=yes/ } "$o->{prefix}/etc/sysconfig/usb" if detect_devices::usbKeyboards(); eval { install_any::set_security($o) }; } 'installPackages'; } #------------------------------------------------------------------------------ sub exitInstall { my ($o) = @_; eval { my $report = '/root/drakx/report.bug'; unlink "$::prefix$report", "$::prefix$report.gz"; output "$::prefix$report", install_any::report_bug(); run_program::rooted($::prefix, 'gzip', $report); }; eval { install_any::getAndSaveAutoInstallFloppies($o, 1) } if arch() !~ /^ppc/; eval { output "$o->{prefix}/root/drakx/README", "This directory contains several installation-related files, mostly log files (very useful if you ever report a bug!). Beware that some Mandriva Linux tools rely on the contents of some of these files... so remove any file from here at your own risk! " }; install_any::deploy_server_notify($o) if exists $o->{deploy_server}; #- wait for remaining processes. foreach (@{$o->{waitpids}}) { waitpid $_, 0; log::l("pid $_ returned $?"); } install_any::ejectCdrom(); install_any::log_sizes($o); } #------------------------------------------------------------------------------ sub hasNetwork { my ($o) = @_; $o->{net}{type} && $o->{net}{network}{NETWORKING} ne 'no' and return 1; log::l("no network seems to be configured for internet ($o->{net}{type},$o->{net}{network}{NETWORKING})"); 0; } sub network_is_cheap { my ($o) = @_; member($o->{net}{type}, qw(adsl lan cable)); } #------------------------------------------------------------------------------ sub upNetwork { my ($o, $b_pppAvoided) = @_; member($o->{method}, qw(ftp http nfs)) and return 1; $o->{modules_conf}->write; if (hasNetwork($o)) { if (network_is_cheap($o)) { log::l("starting network ($o->{net}{type})"); require network::netconnect; network::netconnect::start_internet($o); return 1; } elsif (!$b_pppAvoided) { log::l("starting network (ppp: $o->{net}{type})"); eval { modules::load(qw(serial ppp bsd_comp ppp_deflate)) }; run_program::rooted($o->{prefix}, "/etc/rc.d/init.d/syslog", "start"); require network::netconnect; network::netconnect::start_internet($o); return 1; } else { log::l(qq(not starting network (b/c ppp avoided and type is "$o->{net}{type})")); } } $::testing; } #------------------------------------------------------------------------------ sub downNetwork { my ($o, $costlyOnly) = @_; $o->{method} eq "ftp" || $o->{method} eq "http" || $o->{method} eq "nfs" and return 1; $o->{modules_conf}->write; if (hasNetwork($o)) { if (!$costlyOnly) { require network::netconnect; network::netconnect::stop_internet($o); return 1; } elsif (!network_is_cheap($o)) { require network::netconnect; network::netconnect::stop_internet($o); run_program::rooted($o->{prefix}, "/etc/rc.d/init.d/syslog", "stop"); eval { modules::unload(qw(ppp_deflate bsd_comp ppp serial)) }; return 1; } } $::testing; } #------------------------------------------------------------------------------ sub cleanIfFailedUpgrade($) { my ($o) = @_; #- if an upgrade has failed, there should be .mdkgisave files around. if ($o->{isUpgrade}) { foreach (@filesToSaveForUpgrade) { if (-e "$o->{prefix}/$_" && -e "$o->{prefix}/$_.mdkgisave") { rename "$o->{prefix}/$_", "$o->{prefix}/$_.mdkginew"; #- keep new files around in case ! rename "$o->{prefix}/$_.mdkgisave", "$o->{prefix}/$_"; } } } } 1; d='n890' href='#n890'>890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230
package install_steps_interactive;


use diagnostics;
use strict;
use vars qw(@ISA);

@ISA = qw(install_steps);

#-######################################################################################
#- misc imports
#-######################################################################################
use common qw(:common :file :functional :system);
use partition_table qw(:types);
use install_steps;
use install_any;
use detect_devices;
use run_program;
use commands;
use devices;
use fsedit;
use network;
use raid;
use mouse;
use modules;
use lang;
use keyboard;
use fs;
use log;

#-######################################################################################
#- In/Out Steps Functions
#-######################################################################################
sub errorInStep($$) {
    my ($o, $err) = @_;
    $err =~ s/ at .*?$/\./ unless $::testing; #- avoid error message.
    $o->ask_warn(_("Error"), [ _("An error occurred"), $err ]);
}

sub kill_action {
    my ($o) = @_;
    $o->kill;
}

#-######################################################################################
#- Steps Functions
#-######################################################################################
#------------------------------------------------------------------------------
sub selectLanguage($) {
    my ($o) = @_;

    $o->{lang} =
      lang::text2lang($o->ask_from_list("Language",
					_("Which language do you want?"),
					# the translation may be used for the help
					[ lang::list() ],
					lang::lang2text($o->{lang})));
    install_steps::selectLanguage($o);

#-    $o->{useless_thing_accepted} = $o->ask_from_list_('', 
#-"Warning no warranty", 
#-			 [ __("Accept"), __("Refuse") ], "Accept") eq "Accept" or _exit(1) unless $o->{useless_thing_accepted};
}
#------------------------------------------------------------------------------
sub selectKeyboard($) {
    my ($o) = @_;
    $o->{keyboard} =
      keyboard::text2keyboard($o->ask_from_list_(_("Keyboard"),
						 _("What is your keyboard layout?"),
						 [ keyboard::list() ],
						 keyboard::keyboard2text($o->{keyboard})));
    delete $o->{keyboard_unsafe};
    install_steps::selectKeyboard($o);
}
#------------------------------------------------------------------------------
sub selectPath($) {
    my ($o) = @_;
    $o->{isUpgrade} =
      $o->ask_from_list_(_("Install/Upgrade"),
			 _("Is this an install or an upgrade?"),
			 [ __("Install"), __("Upgrade") ],
			 $o->{isUpgrade} ? "Upgrade" : "Install") eq "Upgrade";
    install_steps::selectPath($o);
}
#------------------------------------------------------------------------------
sub selectRootPartition($@) {
    my ($o, @parts) = @_;
    $o->{upgradeRootPartition} =
      $o->ask_from_list(_("Root Partition"),
			_("What is the root partition (/) of your system?"),
			[ @parts ], $o->{upgradeRootPartition});
#- TODO check choice, then mount partition in $o->{prefix} and autodetect.
#-    install_steps::selectRootPartition($o);
}
#------------------------------------------------------------------------------
sub selectInstallClass($@) {
    my ($o, @classes) = @_;
    my @c = qw(beginner specific expert);
    my %c = (
	     beginner  => _("Recommended"),
	     specific  => _("Customized"),
	     expert    => _("Expert"),
	    );
    my $installClass = ${{reverse %c}}{$o->ask_from_list(_("Install Class"),
							 _("What installation class do you want?"),
							 [ map { $c{$_} } @c ], $c{$o->{installClass}} || $c{beginner})};
    $::expert   = $installClass eq "expert";
    $::beginner = $installClass eq "beginner";

    if ($::beginner) {
	$o->{installClass} = "normal";
    } else {
	my %c = (
		 normal    => _("Normal"),
		 developer => _("Development"),
		 server    => _("Server"),
		);
	$o->{installClass} = ${{reverse %c}}{$o->ask_from_list(_("Install Class"),
							       _("What usage do you want?"),
							       [ values %c ], $c{$o->{installClass}})};
    }
    install_steps::selectInstallClass($o);
}

#------------------------------------------------------------------------------
sub selectMouse {
    my ($o, $force) = @_;

    my $name = $o->{mouse}{FULLNAME};
    if (!$name || $::expert || $force) {
	$name ||= "Generic Mouse (serial)";
	$name = $o->ask_from_list_('', _("What is the type of your mouse?"), [ mouse::names() ], $name);
	$o->{mouse} = mouse::name2mouse($name);
    }
    $o->{mouse}{XEMU3} = 'yes' if $o->{mouse}{nbuttons} < 3; #- if $o->{mouse}{nbuttons} < 3 && $o->ask_yesorno('', _("Emulate third button?"), 1);

    if ($o->{mouse}{device} eq "ttyS") {
	$o->set_help('selectSerialPort');
	$o->{mouse}{device} = mouse::serial_ports_names2dev(
	  $o->ask_from_list(_("Mouse Port"),
			    _("Which serial port is your mouse connected to?"),
			    [ mouse::serial_ports_names() ]));
    }

    $o->setup_thiskind('serial_usb', !$::expert, 0) if $o->{mouse}{device} eq "usbmouse";

    $o->SUPER::selectMouse;
}
#------------------------------------------------------------------------------
sub setupSCSI { setup_thiskind($_[0], 'scsi', $_[1], $_[2]) }

sub ask_mntpoint_s {
    my ($o, $fstab) = @_;
    my @fstab = grep { isExt2($_) } @$fstab;
    @fstab = grep { isSwap($_) } @$fstab if @fstab == 0;
#    @fstab = @$fstab if @fstab == 0;
    die _("no available partitions") if @fstab == 0;

    my $msg = sub { "$_->{device} " . _("(%dMb)", $_->{size} / 1024 / 2) };
    
    if (@fstab == 1) {
	$fstab[0]->{mntpoint} = '/';
    } elsif ($::beginner) {
	my %l; $l{&$msg} = $_ foreach @fstab;
	my $e = $o->ask_from_list('', 
				  _("Which partition do you want to use as your root partition"), 
				  [ sort keys %l ]);
	(fsedit::get_root($fstab) || {})->{mntpoint} = '';
	$l{$e}{mntpoint} = '/';
    } else {
	$o->ask_from_entries_ref
	  ('', 
	   _("Choose the mount points"),
	   [ map { &$msg } @fstab ],
	   [ map { +{ val => \$_->{mntpoint}, 
		      list => [ '', fsedit::suggestions_mntpoint([]) ]
		    } } @fstab ]);
    }
    $o->SUPER::ask_mntpoint_s($fstab);
}

#------------------------------------------------------------------------------
sub rebootNeeded($) {
    my ($o) = @_;
    $o->ask_warn('', _("You need to reboot for the partition table modifications to take place"));

    install_steps::rebootNeeded($o);
}

#------------------------------------------------------------------------------
sub choosePartitionsToFormat($$) {
    my ($o, $fstab) = @_;

    $o->SUPER::choosePartitionsToFormat($fstab);

    my @l = grep { !$_->{isFormatted} && $_->{mntpoint} && !($::beginner && isSwap($_)) } @$fstab;
    $_->{toFormat} = 1 foreach grep {  $::beginner && isSwap($_) } @$fstab;

    return if $::beginner && 0 == grep { ! $_->{toFormat} } @l;

    $_->{toFormat} ||= $_->{toFormatUnsure} foreach @l;
    log::l("preparing to format $_->{mntpoint}") foreach grep { $_->{toFormat} } @l;

    my %label;
    $label{$_} = (isSwap($_) ? type2name($_->{type}) : $_->{mntpoint}) . "   ($_->{device})" foreach @l;

    $o->ask_many_from_list_ref('', _("Choose the partitions you want to format"),
			       [ map { $label{$_} } @l ],
			       [ map { \$_->{toFormat} } @l ]) or die "cancel";
    @l = grep { $_->{toFormat} } @l;
    $o->ask_many_from_list_ref('', _("Check bad blocks?"),
			       [ map { $label{$_} } @l ],
			       [ map { \$_->{toFormatCheck} } @l ]) or goto &choosePartitionsToFormat if $::expert;
}

sub formatPartitions {
    my $o = shift;
    my $w = $o->wait_message('', '');
    foreach (@_) {
	if ($_->{toFormat}) {
	    $w->set(_("Formatting partition %s", $_->{device}));
	    raid::format_part($o->{raid}, $_);
	}
    }
}

#------------------------------------------------------------------------------
sub setPackages {
    my ($o) = @_;
    my $w = $o->wait_message('', _("Looking for available packages"));
    $o->SUPER::setPackages;
}
#------------------------------------------------------------------------------
sub selectPackagesToUpgrade {
    my ($o) = @_;
    my $w = $o->wait_message('', _("Finding packages to upgrade"));
    $o->SUPER::selectPackagesToUpgrade();
}
#------------------------------------------------------------------------------
sub choosePackages {
    my ($o, $packages, $compss, $compssUsers, $compssUsersSorted, $first_time) = @_;

    require pkgs;
    unless ($o->{isUpgrade}) {
	my $available = pkgs::invCorrectSize(install_any::getAvailableSpace($o) / sqr(1024)) * sqr(1024);
	
	foreach (values %$packages) {
	    delete $_->{skip};
	    delete $_->{unskip};
	}
	pkgs::unselect_all($packages);
	pkgs::select($o->{packages}, $o->{packages}{$_} || next) foreach @{$o->{default_packages}};

	pkgs::setSelectedFromCompssList($o->{compssListLevels}, $packages, $::expert ? 90 : 80, $available, $o->{installClass});
	my $min_size = pkgs::size_selected($packages);

	$o->chooseGroups($packages, $compssUsers, $compssUsersSorted);

	my %save_selected; $save_selected{$_->{name}} = $_->{selected} foreach values %$packages;
	pkgs::setSelectedFromCompssList($o->{compssListLevels}, $packages, 1, 0, $o->{installClass});
	my $max_size = pkgs::size_selected($packages);
	$_->{selected} = $save_selected{$_->{name}} foreach values %$packages;	

	if (!$::beginner && $max_size > $available) {
	    $o->ask_okcancel('', 
_("You need %dMB for a full install of the groups you selected.
You can go on anyway, but be warned that you won't get all packages", $max_size / sqr(1024)), 1) or goto &choosePackages
	}

	my $size2install = $::beginner ? $available * 0.7 : $o->chooseSizeToInstall($packages, $min_size, min($max_size, $available * 0.9)) or goto &choosePackages;

	($o->{packages_}{ind}) = 
	  pkgs::setSelectedFromCompssList($o->{compssListLevels}, $packages, 1, $size2install, $o->{installClass});

#	$_->{selected} and print "$_->{name}\n" foreach values %$packages;
    }
    $o->choosePackagesTree($packages, $compss) if $::expert;
}

sub chooseSizeToInstall {
    my ($o, $packages, $min, $max) = @_;
    install_any::getAvailableSpace($o) * 0.7;
}
sub choosePackagesTree {}

sub chooseGroups {
    my ($o, $packages, $compssUsers, $compssUsersSorted) = @_;

    $o->ask_many_from_list_ref('',
			       _("Package Group Selection"),
			       [ @$compssUsersSorted, "Miscellaneous" ],
			       [ map { \$o->{compssUsersChoice}{$_} } @$compssUsersSorted, "Miscellaneous" ]
			       ) or goto &chooseGroups unless $::beginner;

    unless ($o->{compssUsersChoice}{Miscellaneous}) {
	my %l;
	$l{@{$compssUsers->{$_}}} = () foreach @$compssUsersSorted;
	exists $l{$_} or $packages->{$_}{skip} = 1 foreach keys %$packages;
    }
    foreach (@$compssUsersSorted) {
	$o->{compssUsersChoice}{$_} or pkgs::skip_set($packages, @{$compssUsers->{$_}});
    }
    foreach (@$compssUsersSorted) {
	$o->{compssUsersChoice}{$_} or next;
	foreach (@{$compssUsers->{$_}}) {
	    $_->{unskip} = 1;
	    delete $_->{skip};
	}
    }
}

#------------------------------------------------------------------------------
sub installPackages {
    my ($o, $packages) = @_;
    my ($current, $total) = 0;

    my $w = $o->wait_message(_("Installing"), _("Preparing installation"));

    my $old = \&pkgs::installCallback;
    local *pkgs::installCallback = sub {
	my $m = shift;
	if ($m =~ /^Starting installation/) {
	    $total = $_[1];
	} elsif ($m =~ /^Starting installing package/) {
	    my $name = $_[0];
	    $w->set(_("Installing package %s\n%d%%", $name, $total && 100 * $current / $total));
	    $current += c::headerGetEntry($o->{packages}{$name}{header}, 'size');
	} else { unshift @_, $m; goto $old }
    };
    $o->SUPER::installPackages($packages);
}

sub afterInstallPackages($) {
    my ($o) = @_;
    my $w = $o->wait_message('', _("Post install configuration"));
    $o->SUPER::afterInstallPackages($o);
}

#------------------------------------------------------------------------------
sub configureNetwork($) {
    my ($o, $first_time) = @_;
    local $_;
    if ($o->{intf}) {
	if (!$::beginner && $first_time || $::expert) {
	    my @l = (
		     __("Keep the current IP configuration"),
		     __("Reconfigure network now"),
		     __("Do not set up networking"),
		    );
	    $_ = $o->ask_from_list_([ _("Network Configuration") ],
				    _("Local networking has already been configured. Do you want to:"),
				    [ @l ]) || "Do not";
	} else { $_ = "Keep"; }
    } elsif ($o->{modem}) {
	$_ = "Dialup";
    } else {
	$_ = $::beginner ? "Do not" :
	  $o->ask_from_list_([ _("Network Configuration") ],
			     _("Do you want to configure networking for your system?"),
			     [ __("Local LAN"), __("Dialup with modem"), __("Do not set up networking") ]);
    }

    if (/^Dialup/) {
	$o->pppConfig;
    } elsif (/^Do not/) {
	$o->{netc}{NETWORKING} = "false";
    } elsif (!/^Keep/) {
	$o->setup_thiskind('net', !$::expert, 1);
	my @l = detect_devices::getNet() or die _("no network card found");

	my $last; foreach ($::beginner ? $l[0] : @l) {
	    my $intf = network::findIntf($o->{intf} ||= [], $_);
	    add2hash($intf, $last);
	    add2hash($intf, { NETMASK => '255.255.255.0' });
	    $o->configureNetworkIntf($intf) or return;

	    $o->{netc} ||= {};
	    delete $o->{netc}{dnsServer};
	    delete $o->{netc}{GATEWAY};
	    $last = $intf;
	}
	#-	  {
	#-	      my $wait = $o->wait_message(_("Hostname"), _("Determining host name and domain..."));
	#-	      network::guessHostname($o->{prefix}, $o->{netc}, $o->{intf});
	#-	  }
	$last->{BOOTPROTO} =~ /^(dhcp|bootp)$/ ||
	  $o->configureNetworkNet($o->{netc}, $last ||= {}, @l) or return;
    }
    install_steps::configureNetwork($o);
}

sub configureNetworkIntf {
    my ($o, $intf) = @_;
    my $pump = $intf->{BOOTPROTO} =~ /^(dhcp|bootp)$/;
    delete $intf->{NETWORK};
    delete $intf->{BROADCAST};
    my @fields = qw(IPADDR NETMASK);
    $o->set_help('configureNetworkIP');
    $o->ask_from_entries_ref(_("Configuring network device %s", $intf->{DEVICE}),
($::isStandalone ? '' : _("Configuring network device %s", $intf->{DEVICE}) . "\n\n") .
_("Please enter the IP configuration for this machine.
Each item should be entered as an IP address in dotted-decimal
notation (for example, 1.2.3.4)."),
			     [ _("IP address:"), _("Netmask:"), _("Automatic IP") ],
			     [ \$intf->{IPADDR}, \$intf->{NETMASK}, { val => \$pump, type => "bool", text => _("(bootp/dhcp)") } ],
			     complete => sub {
				 $intf->{BOOTPROTO} = $pump ? "dhcp" : "static";
				 return 0 if $pump;
				 for (my $i = 0; $i < @fields; $i++) {
				     unless (network::is_ip($intf->{$fields[$i]})) {
					 $o->ask_warn('', _("IP address should be in format 1.2.3.4"));
					 return (1,$i);
				     }
				     return 0;
				 }
			     },
			     focus_out => sub {
				 $intf->{NETMASK} = network::netmask($intf->{IPADDR}) unless $_[0]
			     }
			    );
}

sub configureNetworkNet {
    my ($o, $netc, $intf, @devices) = @_;

    $netc->{dnsServer} ||= network::dns($intf->{IPADDR});
    $netc->{GATEWAY}   ||= network::gateway($intf->{IPADDR});

    $o->ask_from_entries_ref(_("Configuring network"),
_("Please enter your host name.
Your host name should be a fully-qualified host name,
such as ``mybox.mylab.myco.com''.
You may also enter the IP address of the gateway if you have one"),
			     [_("Host name:"), _("DNS server:"), _("Gateway:"), $::expert ? _("Gateway device:") : ()],
			     [(map { \$netc->{$_}} qw(HOSTNAME dnsServer GATEWAY)),
			      {val => \$netc->{GATEWAYDEV}, list => \@devices}]
			    );

    $o->miscellaneousNetwork();
}

#------------------------------------------------------------------------------
sub pppConfig {
    my ($o) = @_;
    my $m = $o->{modem} ||= {};

    unless ($m->{device} || $::expert && !$o->ask_yesorno('', _("Try to find a modem?"), 1)) {
	foreach (0..3) {
	    next if $o->{mouse}{device} =~ /ttyS$_/;
	    detect_devices::hasModem("$o->{prefix}/dev/ttyS$_")
		and $m->{device} = "ttyS$_", last;
	}
    }

    $m->{device} ||= $o->set_help('selectSerialPort') && 
                     mouse::serial_ports_names2dev(
	$o->ask_from_list('', _("Which serial port is your modem connected to?"),
			  [ mouse::serial_ports_names ]));

    $o->set_help('configureNetworkISP');
    install_steps::pppConfig($o) if $o->ask_from_entries_refH('',
							      _("Dialup options"), [
_("Connection name") => \$m->{connection},
_("Phone number") => \$m->{phone},
_("Login ID") => \$m->{login},
_("Password") => { val => \$m->{passwd}, hidden => 1 },
_("Authentication") => { val => \$m->{auth}, list => [ __("PAP"), __("CHAP"), __("Terminal-based"), __("Script-based") ] },
_("Domain name") => \$m->{domain},
_("First DNS Server") => \$m->{dns1},
_("Second DNS Server") => \$m->{dns2},
    ]);

    $o->miscellaneousNetwork();
}

#------------------------------------------------------------------------------
sub installCrypto {
    my ($o) = @_;
    my $u = $o->{crypto} ||= {};
    
    $::expert or return;
    if ($o->{intf} && $o->{netc}{NETWORKING} ne 'false') {
	my $w = $o->wait_message('', _("Bringing up the network"));
	network::up_it($o->{prefix}, $o->{intf});
    } elsif ($o->{modem}) {
	run_program::rooted($o->{prefix}, "ifup", "ppp0");
    } else {
	return;
    }
    
    is_empty_hash_ref($u) and $o->ask_yesorno('', 
_("You have now the possibility to download software aimed for encryption.

WARNING:

Due to different general requirements applicable to these software and imposed
by various jurisdictions, customer and/or end user of theses software should
ensure that the laws of his/their jurisdiction allow him/them to download, stock
and/or use these software.

In addition customer and/or end user shall particularly be aware to not infringe
the laws of his/their jurisdiction. Should customer and/or end user do not
respect the provision of these applicable laws, he/they will incur serious
sanctions.

In no event shall Mandrakesoft nor its manufacturers and/or suppliers be liable
for special, indirect or incidental damages whatsoever (including, but not
limited to loss of profits, business interruption, loss of commercial data and
other pecuniary losses, and eventual liabilities and indemnification to be paid
pursuant to a court decision) arising out of use, possession, or the sole
downloading of these software, to which customer and/or end user could
eventually have access after having sign up the present agreement.


For any queries relating to these agreement, please contact 
Mandrakesoft, Inc.
2400 N. Lincoln Avenue Suite 243
Altadena California 91001
USA")) || return;

    require crypto;
    eval {
      $u->{mirror} = crypto::text2mirror($o->ask_from_list('', _("Choose a mirror from which to get the packages"), [ crypto::mirrorstext() ], crypto::mirror2text($u->{mirror})));
    };
    return if $@;
    
    my @packages = do {
      my $w = $o->wait_message('', _("Contacting the mirror to get the list of available packages"));
      crypto::packages($u->{mirror});
    };

    $o->ask_many_from_list_ref('', _("Which packages do you want to install"), \@packages, [ map { \$u->{packages}{$_} } @packages ]) or return;

    my $w = $o->wait_message('', _("Downloading cryptographic packages"));
    install_steps::installCrypto($o);
}

#------------------------------------------------------------------------------
sub timeConfig {
    my ($o, $f, $clicked) = @_;

    require timezone;
    $o->{timezone}{timezone} ||= timezone::bestTimezone(lang::lang2text($o->{lang}));
    $o->{timezone}{timezone} = $o->ask_from_list('', _("Which is your timezone?"), [ timezone::getTimeZones($::g_auto_install ? '' : $o->{prefix}) ], $o->{timezone}{timezone});
    $o->{timezone}{UTC} = $o->ask_yesorno('', _("Is your hardware clock set to GMT?"), $o->{timezone}{UTC}) if $::expert || $clicked;
    install_steps::timeConfig($o,$f);
}

#------------------------------------------------------------------------------
#-sub servicesConfig {}
#------------------------------------------------------------------------------
sub printerConfig($) {
    my ($o) = @_;
    $o->{printer}{want} =
      $o->ask_yesorno(_("Printer"),
		      _("Would you like to configure a printer?"),
		      $o->{printer}{want});
    return if !$o->{printer}{want};

    require printerdrake;
    printerdrake::main($o->{prefix}, $o->{printer}, $o, sub { install_any::pkg_install($o, $_[0]) });
}

#------------------------------------------------------------------------------
sub setRootPassword($) {
    my ($o, $clicked) = @_;
    my $sup = $o->{superuser} ||= {};
    $sup->{password2} ||= $sup->{password} ||= "";

    return if $o->{security} < 1 && !$clicked;

    $o->set_help("setRootPassword", 
		 $o->{installClass} eq "server" || $::expert ? "setRootPasswordMd5" : (),
		 $::beginner ? () : "setRootPasswordNIS");

    $o->ask_from_entries_refH([_("Set root password"), _("Ok"), $o->{security} > 2 ? () : _("No password")],
			 _("Set root password"), [
_("Password") => { val => \$sup->{password},  hidden => 1 },
_("Password (again)") => { val => \$sup->{password2}, hidden => 1 },
  $o->{installClass} eq "server" || $::expert ? (
_("Use shadow file") => { val => \$o->{authentication}{shadow}, type => 'bool', text => _("shadow") },
_("Use MD5 passwords") => { val => \$o->{authentication}{md5}, type => 'bool', text => _("MD5") },
  ) : (), $::beginner ? () : (
_("Use NIS") => { val => \$o->{authentication}{NIS}, type => 'bool', text => _("yellow pages") },
  )
			 ], 
			 complete => sub {
			     $sup->{password} eq $sup->{password2} or $o->ask_warn('', [ _("The passwords do not match"), _("Please try again") ]), return (1,1);
			     length $sup->{password} < 2 * $o->{security}
			       and $o->ask_warn('', _("This password is too simple (must be at least %d characters long)", 2 * $o->{security})), return (1,0);
			     return 0
			 }
    ) or return;

    if ($o->{authentication}{NIS}) {
	$o->ask_from_entries_ref('',
				 _("Authentification NIS"),
				 [ _("NIS Domain"), _("NIS Server") ],
				 [ \ ($o->{netc}{NISDOMAIN} ||= $o->{netc}{DOMAINNAME}),
				   { val => \$o->{authentication}{NIS_server}, list => ["broadcast"] },
				 ]);
    }
    install_steps::setRootPassword($o);
}

#------------------------------------------------------------------------------
#-addUser
#------------------------------------------------------------------------------
sub addUser($) {
    my ($o, $clicked) = @_;
    my $u = $o->{user} ||= $o->{security} < 1 ? { name => "mandrake", realname => "default" } : {};
    $u->{password2} ||= $u->{password} ||= "";
    $u->{shell} ||= "/bin/bash";
    my @fields = qw(realname name password password2);
    my @shells = install_any::shells($o);

    if ($o->{security} < 2 && !$clicked || $o->ask_from_entries_refH(
        [ _("Add user"), _("Accept user"), $o->{security} > 4 && !@{$o->{users}} ? () : _("Done") ],
        _("Enter a user\n%s", $o->{users} ? _("(already added %s)", join(", ", map { $_->{realname} || $_->{name} } @{$o->{users}})) : ''),
        [ 
	 _("Real name") => \$u->{realname},
	 _("User name") => \$u->{name},
	   $o->{security} < 2 ? () : (
         _("Password") => {val => \$u->{password}, hidden => 1},
         _("Password (again)") => {val => \$u->{password2}, hidden => 1},
	   ), $::beginner ? () : (
         _("Shell") => {val => \$u->{shell}, list => \@shells, not_edit => !$::expert} 
	   ),
        ],
        focus_out => sub {
	    if ($_[0] eq 0) {
		$u->{name} ||= lc first($u->{realname} =~ /((\w|-)+)/);
	    }
	},
        complete => sub {
	    $u->{password} eq $u->{password2} or $o->ask_warn('', [ _("The passwords do not match"), _("Please try again") ]), return (1,3);
	    $o->{security} > 3 && length($u->{password}) < 6 and $o->ask_warn('', _("This password is too simple")), return (1,2);
	    $u->{name} or $o->ask_warn('', _("Please give a user name")), return (1,0);
	    $u->{name} =~ /^[a-z0-9_-]+$/ or $o->ask_warn('', _("The user name must contain only lower cased letters, numbers, `-' and `_'")), return (1,0);
	    member($u->{name}, map { $_->{name} } @{$o->{users}}) and $o->ask_warn('', _("This user name is already added")), return (1,0);
	    return 0;
	},
    )) {
	push @{$o->{users}}, $o->{user};
	$o->{user} = {};
	goto &addUser unless $o->{security} < 2 && !$clicked; #- INFO_TO_DEL: bad security level may cause deadlocks...
    }
    install_steps::addUser($o);
}




#------------------------------------------------------------------------------
sub createBootdisk {
    my ($o, $first_time) = @_;
    my @l = detect_devices::floppies();
    my %l = (
	     'fd0'  => __("First drive"),
	     'fd1'  => __("Second drive"),
	     'Skip' => __("Skip"),
	    );

    if ($first_time || @l == 1) {
	$o->ask_yesorno('',
			_("A custom bootdisk provides a way of booting into your Linux system without
depending on the normal bootloader. This is useful if you don't want to install
LILO on your system, or another operating system removes LILO, or LILO doesn't
work with your hardware configuration. A custom bootdisk can also be used with
the Mandrake rescue image, making it much easier to recover from severe system
failures. Would you like to create a bootdisk for your system?"), 
			$o->{mkbootdisk}) or return $o->{mkbootdisk} = '';
	$o->{mkbootdisk} = $l[0] if !$o->{mkbootdisk} || $o->{mkbootdisk} eq "1";
    } else {
	@l or die _("Sorry, no floppy drive available");

	$o->{mkbootdisk} = ${{reverse %l}}{$o->ask_from_list_('',
							      _("Choose the floppy drive you want to use to make the bootdisk"),
							      [ @l{@l, "Skip"} ], $o->{mkbootdisk})};
	return $o->{mkbootdisk} = '' if $o->{mkbootdisk} eq 'Skip';
    }

    $o->ask_warn('', _("Insert a floppy in drive %s", $o->{mkbootdisk}));
    my $w = $o->wait_message('', _("Creating bootdisk"));
    install_steps::createBootdisk($o);
}

#------------------------------------------------------------------------------
sub setupLILO {
    my ($o, $more) = @_;
    my $b = $o->{bootloader};

    $more++ if $b->{bootUnsafe};

    if ($::beginner && $more == 1) {
	my @l = (__("First sector of drive (MBR)"), __("First sector of boot partition"));

	$o->set_help('setupBootloaderBeginner');
	my $boot = $o->{hds}[0]{device};
	my $onmbr = "/dev/$boot" eq $b->{boot};
	$b->{boot} = "/dev/" . ($o->ask_from_list_(_("LILO Installation"),
					_("Where do you want to install the bootloader?"),
					\@l, $l[!$onmbr]) eq $l[0] 
					  ? $boot : fsedit::get_root($o->{fstab}, 'boot')->{device});
    } elsif ($more || !$::beginner) {
	$o->set_help("setupBootloaderGeneral");

	$::expert and $o->ask_yesorno('', _("Do you want to use LILO?"), 1) || return;

	my @l = (
_("Boot device") => { val => \$b->{boot}, list => [ map { "/dev/$_" } (map { $_->{device} } @{$o->{hds}}, @{$o->{fstab}}), detect_devices::floppies ], not_edit => !$::expert },
_("Linear (needed for some SCSI drives)") => { val => \$b->{linear}, type => "bool", text => _("linear") },
_("Compact") => { val => \$b->{compact}, type => "bool", text => _("compact") },
_("Delay before booting default image") => \$b->{timeout},
_("Video mode") => { val => \$b->{vga}, list => [ keys %lilo::vga_modes ], not_edit => $::beginner },
$o->{security} < 4 ? () : (
_("Password") => { val => \$b->{password}, hidden => 1 },
_("Password (again)") => { val => \$b->{password2}, hidden => 1 },
_("Restrict command line options") => { val => \$b->{restricted}, type => "bool", text => _("restrict") },
)
	);
	@l = @l[0..3] unless $::expert;

	$b->{vga} ||= 'Normal';
	$o->ask_from_entries_refH('', _("LILO main options"), \@l,
				 complete => sub {
#-				     $o->{security} > 4 && length($b->{password}) < 6 and $o->ask_warn('', _("At this level of security, a password (and a good one) in lilo is requested")), return 1;
				     $b->{restricted} && !$b->{password} and $o->ask_warn('', _("Option ``Restrict command line options'' is of no use without a password")), return 1;
				     $b->{password} eq $b->{password2} or !$b->{restricted} or $o->ask_warn('', [ _("The passwords do not match"), _("Please try again") ]), return 1;
				     0;
				 }
				) or return;
	$b->{vga} = $lilo::vga_modes{$b->{vga}} || $b->{vga};
    }

    until ($::beginner && $more <= 1) {
	$o->set_help('setupBootloaderAddEntry');
	my $c = $o->ask_from_list_([''], 
_("Here are the following entries in LILO.
You can add some more or change the existing ones."),
		[ (sort @{[map_each { "$::b->{label} ($::a)" . ($b->{default} eq $::b->{label} && "  *") } %{$b->{entries}}]}), __("Add"), __("Done") ],
	);
	$c eq "Done" and last;

	my ($e, $name);

	if ($c eq "Add") {
	    my @labels = map { $_->{label} } values %{$b->{entries}};
	    my $prefix;
	    if ($o->ask_from_list_('', _("Which type of entry do you want to add"), [ __("Linux"), __("Other OS (windows...)") ]) eq "Linux") {
		$e = { type => 'image' };
		$prefix = "linux";
	    } else {
		$e = { type => 'other' };
		$prefix = "windows";
	    }
	    $e->{label} = $prefix;
	    for (my $nb = 0; member($e->{label}, @labels); $nb++) { $e->{label} = "$prefix-$nb" }
	} else {
	    ($name) = $c =~ /\((.*?)\)/;
	    $e = $b->{entries}{$name};
	}
	my $old_name = $name;
	my %old_e = %$e;
	my $default = my $old_default = $e->{label} eq $b->{default};
	    
	my @l;
	if ($e->{type} eq "image") { 
	    @l = (
_("Image") => { val => \$name, list => [ eval { glob_("/boot/vmlinuz*") } ] },
_("Root") => { val => \$e->{root}, list => [ map { "/dev/$_->{device}" } @{$o->{fstab}} ], not_edit => !$::expert },
_("Append") => \$e->{append},
_("Initrd") => { val => \$e->{initrd}, list => [ eval { glob_("/boot/initrd*") } ] },
_("Read-write") => { val => \$e->{'read-write'}, type => 'bool' }
	    );
	    @l = @l[0..5] unless $::expert;
	} else {
	    @l = ( 
_("Root") => { val => \$name, list => [ map { "/dev/$_->{device}" } @{$o->{fstab}} ], not_edit => !$::expert },
_("Table") => { val => \$e->{table}, list => [ '', map { "/dev/$_->{device}" } @{$o->{hds}} ], not_edit => !$::expert },
_("Unsafe") => { val => \$e->{unsafe}, type => 'bool' }
	    );
	    @l = @l[0..1] unless $::expert;
	}
	@l = (
_("Label") => \$e->{label},
@l,
_("Default") => { val => \$default, type => 'bool' },
	);

	if ($o->ask_from_entries_refH($c eq "Add" ? '' : ['', _("Ok"), _("Remove entry")], 
	    '', \@l,
	    complete => sub {
		$e->{label} or $o->ask_warn('', _("Empty label not allowed")), return 1;
		member($e->{label}, map { $_->{label} } grep { $_ != $e } values %{$b->{entries}}) and $o->ask_warn('', _("This label is already in use")), return 1;
			    $name ne $old_name && $b->{entries}{$name} and $o->ask_warn('', _("A entry %s already exists", $name)), return 1;
			   }
		)) {
	    $b->{default} = $old_default || $default ? $default && $e->{label} : $b->{default};
	    
	    delete $b->{entries}{$old_name};
	    $b->{entries}{$name} = $e;
	} else {
	    delete $b->{entries}{$old_name};	    
	}
    }
    eval { $o->SUPER::setupBootloader };
    if ($@) {
	$o->ask_warn('', 
		     [ _("Installation of LILO failed. The following error occured:"),
		       grep { !/^Warning:/ } cat_("$o->{prefix}/tmp/.error") ]);
	unlink "$o->{prefix}/tmp/.error";
	die "already displayed";
    }
}

#------------------------------------------------------------------------------
sub setupSILO {
    my ($o, $more) = @_;
    my $b = $o->{bootloader};

    #- assume this default parameters.
    $b->{root} = "/dev/" . fsedit::get_root($o->{fstab})->{device};
    $b->{partition} = ($b->{root} =~ /\D*(\d*)/)[0] || '1';

    if ($::beginner && $more == 1) {
	#- nothing more to do here.
    } elsif ($more || !$::beginner) {
	$o->set_help("setupBootloaderGeneral");

	$::expert and $o->ask_yesorno('', _("Do you want to use SILO?"), 1) || return;

	my @l = (
_("Delay before booting default image") => \$b->{timeout},
$o->{security} < 4 ? () : (
_("Password") => { val => \$b->{password}, hidden => 1 },
_("Password (again)") => { val => \$b->{password2}, hidden => 1 },
_("Restrict command line options") => { val => \$b->{restricted}, type => "bool", text => _("restrict") },
)
	);

	$o->ask_from_entries_refH('', _("SILO main options"), \@l,
				 complete => sub {
#-				     $o->{security} > 4 && length($b->{password}) < 6 and $o->ask_warn('', _("At this level of security, a password (and a good one) in silo is requested")), return 1;
				     $b->{restricted} && !$b->{password} and $o->ask_warn('', _("Option ``Restrict command line options'' is of no use without a password")), return 1;
				     $b->{password} eq $b->{password2} or !$b->{restricted} or $o->ask_warn('', [ _("The passwords do not match"), _("Please try again") ]), return 1;
				     0;
				 }
				) or return;
    }

    until ($::beginner && $more <= 1) {
	$o->set_help('setupBootloaderAddEntry');
	my $c = $o->ask_from_list_([''], 
_("Here are the following entries in SILO.
You can add some more or change the existing ones."),
		[ (sort @{[map_each { "$::b->{label} ($::a)" . ($b->{default} eq $::b->{label} && "  *") } %{$b->{entries}}]}), __("Add"), __("Done") ],
	);
	$c eq "Done" and last;

	my ($e, $name);

	if ($c eq "Add") {
	    my @labels = map { $_->{label} } values %{$b->{entries}};
	    my $prefix;

	    $e = { type => 'image' };
	    $prefix = "linux";

	    $e->{label} = $prefix;
	    for (my $nb = 0; member($e->{label}, @labels); $nb++) { $e->{label} = "$prefix-$nb" }
	} else {
	    ($name) = $c =~ /\((.*?)\)/;
	    $e = $b->{entries}{$name};
	}
	my $old_name = $name;
	my %old_e = %$e;
	my $default = my $old_default = $e->{label} eq $b->{default};
	    
	my @l;
	if ($e->{type} eq "image") { 
	    @l = (
_("Image") => { val => \$name, list => [ eval { glob_("/boot/vmlinuz*") } ] },
_("Partition") => { val => \$e->{partition}, list => [ map { ("/dev/$_->{device}" =~ /\D*(\d*)/)[0] || 1} @{$o->{fstab}} ], not_edit => !$::expert },
_("Root") => { val => \$e->{root}, list => [ map { "/dev/$_->{device}" } @{$o->{fstab}} ], not_edit => !$::expert },
_("Append") => \$e->{append},
_("Initrd") => { val => \$e->{initrd}, list => [ eval { glob_("/boot/initrd*") } ] },
_("Read-write") => { val => \$e->{'read-write'}, type => 'bool' }
	    );
	    @l = @l[0..7] unless $::expert;
	} else {
	    die "Other SILO entries not supported at the moment";
	}
	@l = (
_("Label") => \$e->{label},
@l,
_("Default") => { val => \$default, type => 'bool' },
	);

	if ($o->ask_from_entries_refH($c eq "Add" ? '' : ['', _("Ok"), _("Remove entry")], 
	    '', \@l,
	    complete => sub {
		$e->{label} or $o->ask_warn('', _("Empty label not allowed")), return 1;
		member($e->{label}, map { $_->{label} } grep { $_ != $e } values %{$b->{entries}}) and $o->ask_warn('', _("This label is already in use")), return 1;
			    $name ne $old_name && $b->{entries}{$name} and $o->ask_warn('', _("A entry %s already exists", $name)), return 1;
			   }
		)) {
	    $b->{default} = $old_default || $default ? $default && $e->{label} : $b->{default};
	    
	    delete $b->{entries}{$old_name};
	    $b->{entries}{$name} = $e;
	} else {
	    delete $b->{entries}{$old_name};	    
	}
    }
    eval { $o->SUPER::setupBootloader };
    if ($@) {
	$o->ask_warn('', 
		     [ _("Installation of SILO failed. The following error occured:"),
		       grep { !/^Warning:/ } cat_("$o->{prefix}/tmp/.error") ]);
	unlink "$o->{prefix}/tmp/.error";
	die "already displayed";
    }
}

#------------------------------------------------------------------------------
sub setupBootloaderBefore {
    my ($o) = @_;
    my $w = $o->wait_message('', _("Preparing bootloader"));
    $o->SUPER::setupBootloaderBefore($o);
}

#------------------------------------------------------------------------------
sub setupBootloader {
    if (arch() =~ /^i386/) {
	$o->ask_yesorno('', _("Do you want to use aboot?"), 1) or return;
	$o->SUPER::setupBootloader;	
    } elsif (arch() =~ /^sparc/) {
	&setupSILO;
    } else {
	&setupLILO;
    }
}

#------------------------------------------------------------------------------
sub miscellaneousNetwork {
    my ($o, $clicked) = @_;
    my $u = $o->{miscellaneous} ||= {};

    $o->set_help('configureNetworkProxy');
    !$::beginner || $clicked and $o->ask_from_entries_ref('',
       _("Proxies configuration"),
       [ _("HTTP proxy"),
         _("FTP proxy"),
       ],
       [ \$u->{http_proxy},
         \$u->{ftp_proxy},
       ],
       complete => sub {
	   $u->{http_proxy} =~ m,^($|http://), or $o->ask_warn('', _("Proxy should be http://...")), return 1,3;
	   $u->{ftp_proxy} =~ m,^($|ftp://), or $o->ask_warn('', _("Proxy should be ftp://...")), return 1,4;
	   0;
       }
    ) || return;
}

#------------------------------------------------------------------------------
sub miscellaneous {
    my ($o, $clicked) = @_;
    my %l = (
	0 => _("Welcome To Crackers"),
	1 => _("Poor"),
	2 => _("Low"),
	3 => _("Medium"),
	4 => _("High"),
	5 => _("Paranoid"),
    );
    delete @l{0,1,5} unless $::expert;

    install_steps::miscellaneous($o);
    my $u = $o->{miscellaneous} ||= {};
    exists $u->{LAPTOP} or $u->{LAPTOP} = 1;
    my $s = $o->{security};

    add2hash_ $o, { useSupermount => $s < 4 };
    $s = $l{$s} || $s;

    !$::beginner || $clicked and $o->ask_from_entries_refH('',
	_("Miscellaneous questions"), [
_("Use hard drive optimisations?") => { val => \$u->{HDPARM}, type => 'bool', text => _("(may cause data corruption)") },
_("Choose security level") => { val => \$s, list => [ map { $l{$_} } ikeys %l ], not_edit => 1 },
_("Precise RAM size if needed (found %d MB)", availableRam / 1024 + 3) => \$u->{memsize}, #- add three for correction.
_("Removable media automounting") => { val => \$o->{useSupermount}, type => 'bool', text => 'supermount' },
     $u->{numlock} ? (
_("Enable num lock at startup") => { val => \$u->{numlock}, type => 'bool' },
     ) : (),
     ], complete => sub {
	    !$u->{memsize} || $u->{memsize} =~ s/^(\d+)M?$/$1M/i or $o->ask_warn('', _("Give the ram size in Mb")), return 1;
	    0;
	}
    ) || return;
    my %m = reverse %l; $ENV{SECURE_LEVEL} = $o->{security} = $m{$s};
}

#------------------------------------------------------------------------------
sub setupXfree {
    my ($o) = @_;
    $o->setupXfreeBefore;

    require Xconfig;
    require Xconfigurator;
    #- by default do not use existing configuration, so new card will be detected.
    if ($o->{isUpgrade} && -r "$o->{prefix}/etc/X11/XF86Config") {
	if ($::beginner || $o->ask_yesorno('', _("Use existing configuration for X11?"), 1)) {
	    Xconfig::getinfoFromXF86Config($o->{X}, $o->{prefix});
	}
    }
    #- strange, xfs must not be started twice...
    #- trying to stop and restart it does nothing good too...
    my $xfs_started if 0;
    run_program::rooted($o->{prefix}, "/etc/rc.d/init.d/xfs", "start") unless $xfs_started;
    $xfs_started = 1;

    { local $::testing = 0; #- unset testing
      local $::auto = $::beginner;
      local $::noauto = $::expert && !$o->ask_yesorno('', _("Try to find PCI devices?"), 1);
      $::noauto = $::noauto; #- no warning

      Xconfigurator::main($o->{prefix}, $o->{X}, $o, $o->{allowFB}, bool($o->{pcmcia}), sub {
	  install_any::pkg_install($o, "XFree86-$_[0]");
      });
    }
    $o->setupXfreeAfter;
}

#------------------------------------------------------------------------------
sub exitInstall {
    my ($o, $alldone) = @_;

    return $o->{step} = '' unless $alldone || $o->ask_yesorno('', 
_("Some steps are not completed.

Do you really want to quit now?"), 0);

    install_any::unlockCdrom;

    $o->ask_warn('',
_("Congratulations, installation is complete.
Remove the boot media and press return to reboot.

For information on fixes which are available for this release of Linux-Mandrake,
consult the Errata available from http://www.linux-mandrake.com/.

Information on configuring your system is available in the post
install chapter of the Official Linux-Mandrake User's Guide.")) if $alldone && !$::g_auto_install;

    $::global_wait = $o->wait_message('', _("Shutting down"));

    $o->SUPER::exitInstall;
}


#-######################################################################################
#- Misc Steps Functions
#-######################################################################################

#--------------------------------------------------------------------------------
sub wait_load_module {
    my ($o, $type, $text, $module) = @_;
    $o->wait_message('',
		     [ _("Installing driver for %s card %s", $type, $text),
		       $::beginner ? () : _("(module %s)", $module)
		     ]);
}


sub load_module {
    my ($o, $type) = @_;
    my @options;

    my $l = $o->ask_from_list('',
			      _("Which %s driver should I try?", $type),
			      [ modules::text_of_type($type) ]) or return;
    my $m = modules::text2driver($l);

    require modparm;
    my @names = modparm::get_options_name($m);

    if ((@names != 0) && $o->ask_from_list_('',
_("In some cases, the %s driver needs to have extra information to work
properly, although it normally works fine without. Would you like to specify
extra options for it or allow the driver to probe your machine for the
information it needs? Occasionally, probing will hang a computer, but it should
not cause any damage.", $l),
			      [ __("Autoprobe"), __("Specify options") ], "Autoprobe") ne "Autoprobe") {
      ASK:
	if (@names >= 0) {
	    my @l = $o->ask_from_entries('',
_("You may now provide its options to module %s.", $l),
					 \@names) or return;
	    @options = modparm::get_options_result($m, @l);
	} else {
	    @options = split ' ',
	      $o->ask_from_entry('',
_("You may now provide its options to module %s.
Options are in format ``name=value name2=value2 ...''.
For instance, ``io=0x300 irq=7''", $l),
				 _("Module options:"),
				);
	}
    }
    eval { 
	my $w = wait_load_module($o, $type, $l, $m);
	modules::load($m, $type, @options);
    };
    if ($@) {
	$o->ask_yesorno('',
_("Loading module %s failed.
Do you want to try again with other parameters?", $l), 1) or return;
	goto ASK;
    }
    $l, $m;
}

#------------------------------------------------------------------------------
sub load_thiskind {
    my ($o, $type) = @_;
    my $w; #- needed to make the wait_message stay alive
    my $pcmcia = $o->{pcmcia}
      unless !$::beginner && modules::pcmcia_need_config($o->{pcmcia}) && 
	     !$o->ask_yesorno('', _("Try to find PCMCIA cards?"), 1);
    $w = $o->wait_message(_("PCMCIA"), _("Configuring PCMCIA cards...")) if modules::pcmcia_need_config($pcmcia);

    if ($type =~ /scsi/i && cat_("/proc/cmdline") !~ /ide2=/) {
	require pci_probing::main;
	my @l = map { $_->[0] } grep { $_->[1] =~ /(HPT|Ultra66)/ } pci_probing::main::probe('STORAGE_OTHER', 'more');
	if (@l && $o->ask_yesorno('', 
_("Linux does not yet fully support ultra dma 66.
As a work-around i can make a custom floppy giving access the hard drive on ide2 and ide3"), 1)) {
	    log::l("HPT|Ultra66: found");
	    my $ide = sprintf "ide2=0x%x,0x%x ide3=0x%x,0x%x", 
	      map_index { hex($_) + (odd($::i) ? 1 : -1) } do {
		if (@l == 2) {
		    map { (split ' ')[3..4] } @l
		} else {
		    map { (split ' ')[3..6] } @l
		}
	    };
	    log::l("HPT|Ultra66: gonna add ($ide)");

	    my $dev = devices::make("fd0");
	    my $image = $o->{pcmcia} ? "pcmcia" :
	      ${{ hd => 'hd', cdrom => 'cdrom', 
		  ftp => 'network', nfs => 'network', http => 'network' }}{$o->{method}};
	
	    my $nb_try; 
	    for ($nb_try = 0; $nb_try <= 1; $nb_try++) {
		eval { fs::mount($dev, "/floppy", "vfat", 0) };
		last if !$@ && -e "/floppy/syslinux.cfg";

		eval { fs::umount("/floppy") };		    
		$o->ask_warn('', 
_("Enter a floppy to create an HTP enabled boot
(all data on floppy will be lost)"));
		if (my $fd = install_any::getFile("$image.img")) {
                    my $w = $o->wait_message('', _("Creating bootdisk"));
		    local *OUT;
		    open OUT, ">$dev" or log::l("failed to write $dev"), return;
		    local $/ = \ (16 * 1024);
		    print OUT foreach <$fd>;
		}
	    }
	    if (-e "/floppy/syslinux.cfg") {
		log::l("HTP: modifying syslinux.cfg");
		substInFile { s/(?=$)/ $ide/ if /^\s*append\s/ } "/floppy/syslinux.cfg";	
		fs::umount("/floppy");
		log::l("HPT|Ultra66: all done");

		$o->ask_warn('', $nb_try ? 
			     _("It is necessary to restart installation booting on the floppy") :
			     _("It is necessary to restart installation with the new parameters"));
		install_steps::rebootNeeded($o);
	    } else {
		$o->ask_warn('', 
_("Failed to create an HTP boot floppy.
You may have to restart installation and give ``%s'' at the prompt", $ide));
	    }
	}
    }

    eval { modules::load_thiskind($type, sub { $w = wait_load_module($o, $type, @_) }, $pcmcia) };
    $@ and $o->errorInStep($@);
}

#------------------------------------------------------------------------------
sub setup_thiskind {
    my ($o, $type, $auto, $at_least_one) = @_;    

    if (!exists $o->{auto_probe_pci}) {
	$o->{auto_probe_pci} = !$::expert || $o->ask_yesorno('', _("Try to find PCI devices?"), 1);
    }
    my @l = $o->load_thiskind($type) if $o->{auto_probe_pci};
    return if $auto && (@l || !$at_least_one);
    while (1) {
	my $msg = @l ?
	  [ _("Found %s %s interfaces", join(", ", map { $_->[0] } @l), $type),
	    _("Do you have another one?") ] :
	  _("Do you have any %s interface?", $type);

	my $opt = [ __("Yes"), __("No") ];
	push @$opt, __("See hardware info") if $::expert;
	my $r = "Yes";
	$r = $o->ask_from_list_('', $msg, $opt, "No") unless $at_least_one && @l == 0;
	if ($r eq "No") { return }
	elsif ($r eq "Yes") {
	    my @r = $o->load_module($type) or return;
	    push @l, \@r;
	} else {
	    #-eval { commands::modprobe("isapnp") };
	    require pci_probing::main;
	    $o->ask_warn('', [ pci_probing::main::list() ]); #-, scalar cat_("/proc/isapnp") ]);
	}
    }
}


#-######################################################################################
#- Wonderful perl :(
#-######################################################################################
1;