diff options
Diffstat (limited to 'perl-install/install/steps.pm')
| -rw-r--r-- | perl-install/install/steps.pm | 236 |
1 files changed, 125 insertions, 111 deletions
diff --git a/perl-install/install/steps.pm b/perl-install/install/steps.pm index b29697d05..0319a6575 100644 --- a/perl-install/install/steps.pm +++ b/perl-install/install/steps.pm @@ -1,4 +1,4 @@ -package install::steps; # $Id$ +package install::steps; use diagnostics; use strict; @@ -103,8 +103,6 @@ sub kill_action {} 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}) { @@ -128,7 +126,13 @@ sub selectLanguage { $o->charsetChanged; addToBeDone { - lang::write_langs($o->{locale}{langs}); + if ($o->{isUpgrade}) { + #- preserve existing locale settings (mga#24671) + $o->{locale} = lang::read(); + $o->{locale}{langs}{$o->{locale}{lang}} = 1; + } else { + lang::write_langs($o->{locale}{langs}); + } } 'formatPartitions'; addToBeDone { lang::write_and_install($o->{locale}, $o->do_pkgs); @@ -140,14 +144,11 @@ sub selectKeyboard { keyboard::setup_install($o->{keyboard}); addToBeDone { + #- the bkmap keymaps in installer are deficient, we need to load the real one before keyboard::write which will generate /etc/sysconfig/console/default.kmap + run_program::rooted($::prefix, 'loadkeys', keyboard::keyboard2kmap($o->{keyboard})) + or log::l("loadkeys failed"); 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 {} @@ -158,7 +159,10 @@ sub setupSCSI { install::any::configure_pcmcia($o); 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'); + modules::load_category($o->{modules_conf}, 'disk/scsi'); + #- load disk/scsi before disk/ide since libata is now the default + #- (to prevent modules::load_category from loading ide-generic too early) + modules::load_category($o->{modules_conf}, 'disk/ide|hardware_raid|sata|firewire'); install::any::getHds($o); } @@ -171,15 +175,17 @@ sub selectInstallClass { # 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}, $::prefix)) || die)->{part}; $o->{migrate_device_names} = install::any::use_root_part($o->{all_hds}, $p); + $o->{previous_release} = $p if $o->{isUpgrade}; } } #------------------------------------------------------------------------------ sub doPartitionDisksBefore { my ($o) = @_; + log::l("fdisk before:\n" . any::fdisk()); eval { + eval { fs::mount::umount("$::prefix/sys/kernel/debug/usb") }; 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 @@ -191,16 +197,19 @@ sub doPartitionDisksAfter { my ($o) = @_; fs::any::write_hds($o->{all_hds}, $o->{fstab}, !$o->{isUpgrade}, sub { $o->rebootNeeded }, $o); + log::l("fdisk after\n" . any::fdisk()); if ($::local_install) { - my $p = fs::get::mntpoint2part($::prefix, [ fs::read_fstab('', '/proc/mounts') ]); - my $part = find { fs::get::is_same_hd($p, $_) } @{$o->{fstab}}; - $part ||= $o->{fstab}[0]; + #- We skipped the setupSCSI step, so $o->{fstab} will be empty. We need to + #- add a fake entry, to satisfy the following check for a root partition. + my $fstab = [ fs::read_fstab('', '/proc/mounts') ]; + my $part = fs::get::mntpoint2part($::prefix, $fstab) || $fstab->[0]; $part->{mntpoint} = '/'; $part->{isMounted} = 1; + $o->{fstab} = [ $part ]; } - fs::any::check_hds_boot_and_root($o->{all_hds}, $o->{fstab}); + fs::any::check_hds_boot_and_root($o->{all_hds}, $o->{fstab}, $o->{isUpgrade}, $o->{match_all_hardware}); if ($o->{partitioning}{use_existing_root}) { #- ensure those partitions are mounted so that they are not proposed in choosePartitionsToFormat @@ -249,16 +258,19 @@ sub ask_deselect_media__copy_on_disk { } sub ask_change_cd { - my (undef, $phys_m, $_o_rel_file) = @_; - log::l("change to medium " . install::media::phys_medium_to_string($phys_m) . " refused (it can't be done automatically)"); + my (undef, $phys_m) = @_; + log::l("change to medium $phys_m refused (it can't be done automatically)"); 0; } sub selectSupplMedia { '' } sub choosePackages { - my ($o) = @_; + my ($o, $o_compssListLevel) = @_; + #- clear the mirror cache before upgrading: + eval { rm_rf("$::prefix/var/cache/urpmi/mirrors.cache") }; + #- now for upgrade, package that must be upgraded are #- selected first, after is used the same scheme as install. @@ -268,21 +280,16 @@ sub choosePackages { my $availableCorrected = install::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 install::pkgs::setSelectedFromCompssList($o->{packages}, $o->{rpmsrate_flags_chosen}, $o->{compssListLevel}, $availableCorrected); + exists $o->{compssListLevel} || defined $o_compssListLevel + and install::pkgs::setSelectedFromCompssList($o->{packages}, $o->{rpmsrate_flags_chosen}, $o_compssListLevel || $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 live_patch_URPM() { - sub prefering_mdk { + sub prefering_mga { 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")); @@ -292,9 +299,9 @@ sub upgrading_redhat() { 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); + my $c = ($lpkg->release =~ /mga/ ? 1 : 0) - ($rpkg->release =~ /mga/ ? 1 : 0); if ($c) { - prefering_mdk($lpkg, $rpkg->version . '-' . $rpkg->release, $c); + prefering_mga($lpkg, $rpkg->version . '-' . $rpkg->release, $c); $c; } else { &$old_compare_pkg; @@ -305,15 +312,21 @@ sub upgrading_redhat() { undef *URPM::Package::compare; *URPM::Package::compare = sub { my ($lpkg, $rpkg_ver) = @_; - my $c = ($lpkg->release =~ /mdk$/ ? 1 : 0) - ($rpkg_ver =~ /mdk$/ ? 1 : 0); + my $c = ($lpkg->release =~ /mga/ ? 1 : 0) - ($rpkg_ver =~ /mga/ ? 1 : 0); if ($c) { - prefering_mdk($lpkg, $rpkg_ver, $c); + prefering_mga($lpkg, $rpkg_ver, $c); return $c; } &$old_compare; }; } +sub upgrading_redhat() { + #- remove weird config files that bother Xconfig::* too much + unlink "$::prefix/etc/X11/XF86Config"; + unlink "$::prefix/etc/X11/XF86Config-4"; +} + sub beforeInstallPackages { my ($o) = @_; @@ -321,10 +334,8 @@ sub beforeInstallPackages { if ($o->{isUpgrade}) { $o->{modules_conf}->merge_into(modules::any_conf->read); - } - #- save these files in case of upgrade failure. - if ($o->{isUpgrade}) { + #- save these files in case of upgrade failure. foreach (@filesToSaveForUpgrade) { unlink "$::prefix/$_.mdkgisave"; if (-e "$::prefix/$_") { @@ -334,6 +345,14 @@ sub beforeInstallPackages { foreach (@filesNewerToUseAfterUpgrade) { unlink "$::prefix/$_.rpmnew"; } + + log::l("converting filesystem for usrmove"); + if (!run_program::run('/usr/lib/dracut/modules.d/30convertfs/convertfs.sh', $::prefix)) { + mkdir_p("$::prefix/root/drakx") if ! -d "$::prefix/root/drakx"; + # logs are only copied to $::prefix/root/drakx at the end of each step, so do it manually now + eval { cp_af("/tmp/ddebug.log", "$::prefix/root/drakx") }; + die "Unable to convert filesystem prior to upgrade. Check ddebug.log for details"; + } } #- mainly for upgrading redhat packages, but it can help other @@ -345,6 +364,8 @@ sub beforeInstallPackages { ); rm_rf(@to_remove); + live_patch_URPM() if $o->{isUpgrade} !~ /mageia/; + if ($o->{isUpgrade} eq 'redhat') { upgrading_redhat(); } @@ -358,15 +379,19 @@ sub beforeInstallPackages { #- some packages need such files for proper installation. install::any::write_fstab($o); - require network::network; - network::network::add2hosts("localhost", "127.0.0.1"); - #- resolv.conf will be modified at boot time #- the following will ensure we have a working DNS during install if (-e "/etc/resolv.conf" && ! -e "$::prefix/etc/resolv.conf") { cp_af("/etc/resolv.conf", "$::prefix/etc"); } + foreach ('/run', '/tmp/.X11-unix') { + if (-e $_) { + mkdir "$::prefix/$_"; + run_program::run('mount', '--bind', $_, "$::prefix/$_"); + } + } + log::l("setting excludedocs to $o->{excludedocs}"); substInFile { s/%_excludedocs.*//; $_ .= "%_excludedocs yes\n" if eof && $o->{excludedocs} } "$::prefix/etc/rpm/macros"; @@ -400,8 +425,14 @@ sub installCallback { # log::l("$msg: " . join(',', @para)); } -sub installPackages { #- complete REWORK, TODO and TOCHECK! - my ($o) = @_; +sub installPackages { + my ($o, $o_interactive) = @_; + + my $p = fs::get::root_($o->{fstab}); + if (isLUKS($p)) { + install::pkgs::selectPackage($o->{packages}, install::pkgs::packageByName($o->{packages}, 'plymouth')); + } + my $packages = $o->{packages}; install::pkgs::remove_marked_ask_remove($packages, \&installCallback); @@ -409,18 +440,23 @@ sub installPackages { #- complete REWORK, TODO and TOCHECK! #- small transaction will be built based on this selection and depslist. my @toInstall = install::pkgs::packagesToInstall($packages); + my $exit_code; my $time = time(); { local $ENV{DURING_INSTALL} = 1; + local $ENV{LOCAL_INSTALL} = 1 if $::local_install; local $ENV{TMPDIR} = '/tmp'; local $ENV{TMP} = '/tmp'; - install::pkgs::install($o->{isUpgrade}, \@toInstall, $packages, \&installCallback); + local $ENV{HOME}; + local $packages->{options}{auto} = !$o_interactive; + $exit_code = install::pkgs::install($o->{isUpgrade}, \@toInstall, $packages, \&installCallback); } any::writeandclean_ldsoconf($::prefix); - run_program::rooted_or_die($::prefix, 'ldconfig'); - log::l("Install took: ", formatTimeRaw(time() - $time)); + run_program::rooted_or_die($::prefix, 'ldconfig') if !$o->{justdb}; + + $exit_code and die "Installation failed"; install::media::log_sizes(); scalar(@toInstall); #- return number of packages installed. } @@ -435,7 +471,7 @@ 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_("$::prefix/root/drakx/install.log"); - if (arch() !~ /^sparc/) { #- TODO restore it as may be needed for sparc + if (!$o->{justdb}) { -x "$::prefix/usr/bin/dumpkeys" or $::testing or die "Some important packages did not get installed properly. @@ -456,29 +492,31 @@ Consoles 1,3,4,7 may also contain interesting information"; harddrake::autoconf::pcmcia($o->{pcmcia}); #- configure CPU frequency modules harddrake::autoconf::cpufreq(); + harddrake::autoconf::floppy(); + + # prevent slow boot on first boot: + my $cfg_file = "$::prefix/etc/sysconfig/harddrake2/kernel"; + if (-f $cfg_file) { + my %kernel_config = getVarsFromSh($cfg_file); + $kernel_config{IS_LAPTOP} = bool2text(detect_devices::isLaptop()); + setVarsInSh($cfg_file, \%kernel_config); + } #- for mandrake_firstime touch "$::prefix/var/lock/TMP_1ST"; + fs::any::set_cdrom_symlink($o->{all_hds}{raw_hds}); any::config_mtools($::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*:/ } "$::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($::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($::prefix, "chkconfig", "--del", "gpm"); } - #- install urpmi before as rpmdb will be opened, this will cause problem with update-menus. - $o->install_urpmi; - if ($o->{pcmcia}) { substInFile { s/.*(TaskBarShowAPMStatus).*/$1=1/ } "$::prefix/usr/lib/X11/icewm/preferences"; eval { cp_af("$::prefix/usr/share/applnk/System/kapm.kdelnk", @@ -494,7 +532,7 @@ EOF } - install::any::disable_user_view() if $o->{security} >= 3 || $o->{authentication}{NIS}; + install::any::disable_user_view() if $o->{security} > 1 || $o->{authentication}{NIS}; run_program::rooted($::prefix, "kdeDesktopCleanup"); #- move some file after an upgrade that may be seriously annoying. @@ -568,26 +606,7 @@ sub install_urpmi { sub install_hardware_packages { my ($o) = @_; if ($o->{match_all_hardware}) { - my @l; - - require Xconfig::card; - require Xconfig::proprietary; - my $cards = Xconfig::card::readCardsDB("$ENV{SHARE_PATH}/ldetect-lst/Cards+"); - my @drivers = grep { $_ } uniq(map { $_->{Driver2} } values %$cards); - push @l, map { Xconfig::proprietary::pkgs_for_Driver2($_, $o->do_pkgs) } @drivers; - - require network::connection; - require network::thirdparty; - foreach my $type (network::connection->get_types) { - $type->can('get_thirdparty_settings') or next; - foreach my $settings (@{$type->get_thirdparty_settings || []}) { - foreach (@network::thirdparty::thirdparty_types) { - my @packages = network::thirdparty::get_required_packages($_, $settings); - push @l, network::thirdparty::get_available_packages($_, $o, @packages); - } - } - } - + my @l = pkgs::detect_hardware_packages($o->do_pkgs, $o->{match_all_hardware}); $o->do_pkgs->install(@l) if @l; } } @@ -640,7 +659,8 @@ sub configureNetwork { my ($o) = @_; require network::network; network::network::configure_network($o->{net}, $o, $o->{modules_conf}); - configure_firewall($o) if !$o->{isUpgrade}; + + configure_firewall($o) if !$o->{isUpgrade} && !$o->{justdb}; #- only a http proxy can be used by stage1 #- the method is http even for ftp connections through a http proxy @@ -659,7 +679,7 @@ sub configure_firewall { my ($o) = @_; #- set up a firewall if ports have been specified or if the security level is high enough - $o->{firewall_ports} ||= '' if $o->{security} >= 3 && !exists $o->{firewall_ports}; + $o->{firewall_ports} ||= '' if $o->{security} >= 1 && !exists $o->{firewall_ports}; if (defined $o->{firewall_ports}) { require network::drakfirewall; @@ -670,24 +690,7 @@ sub configure_firewall { } #------------------------------------------------------------------------------ -sub installUpdates { - my ($o) = @_; - my $u = $o->{updates} or return; - $u->{url} or return; - - upNetwork($o); - require mirror; - - my $phys_medium = install::media::url2mounted_phys_medium($o, $u->{url} . '/media/main/updates'); - - my $update_medium = { name => "Updates for Mandriva Linux " . $o->{product_id}{version}, update => 1 }; - install::media::get_standalone_medium($o, $phys_medium, $o->{packages}, $update_medium); - - $o->pkg_install(@{$u->{packages} || []}); - - #- re-install urpmi with update security medium. - install_urpmi($o); -} +sub installUpdates {} sub summaryBefore {} @@ -705,7 +708,14 @@ sub configureTimezone { my ($o) = @_; install::any::preConfigureTimezone($o); - $o->pkg_install('ntp') if $o->{timezone}{ntp}; + if ($o->{timezone}{ntp}) { + # We prefer chrony, but we'll deal with ntpd for the sake of upgrades + my $pkg = install::pkgs::packageByName($o->{packages}, 'chrony'); + unless ($pkg && $pkg->flag_installed) { + $pkg = install::pkgs::packageByName($o->{packages}, 'ntp'); + $o->pkg_install('chrony') unless $pkg && $pkg->flag_installed; + } + } require timezone; timezone::write($o->{timezone}); @@ -748,11 +758,13 @@ sub addUser { any::add_users($users, $o->{authentication}); - if ($o->{autologin}) { - $o->{desktop} ||= first(any::sessions()); - $o->pkg_install("autologin") if !member($o->{desktop}, 'KDE', 'GNOME'); + if ($o->{rpmsrate_flags_chosen}{CAT_X}) { + my $autologin = any::get_autologin(); + $autologin->{user} = $o->{autologin}; + $autologin->{desktop} = $o->{desktop} if $o->{desktop}; + $autologin->{dm} = $o->{dm} if $o->{dm}; + any::set_autologin($o->do_pkgs, $autologin, $o->{step}{auto}); } - any::set_autologin($o->do_pkgs, $o->{autologin}, $o->{desktop}); install::any::disable_user_view() if @$users == (); } @@ -770,14 +782,15 @@ sub read_bootloader_config { sub setupBootloaderBefore { my ($o) = @_; + my $bool = $o->{meta_class} ne 'server'; any::setupBootloaderBefore($o->do_pkgs, $o->{bootloader}, $o->{all_hds}, $o->{fstab}, $o->{keyboard}, - $o->{allowFB}, $o->{vga}, $o->{meta_class} ne 'server'); + $o->{allowFB}, $o->{vga}, $bool, $bool); } sub setupBootloader { my ($o) = @_; - any::install_acpi_pkgs($o->do_pkgs, $o->{bootloader}); + any::install_bootloader_pkgs($o->do_pkgs, $o->{bootloader}); require bootloader; bootloader::install($o->{bootloader}, $o->{all_hds}); @@ -813,7 +826,6 @@ sub miscellaneousBefore { require security::various; $o->{security} ||= security::level::get(); $o->{security_user} ||= security::various::config_security_user($::prefix); - $o->{libsafe} ||= security::various::config_libsafe($::prefix); log::l("security level is $o->{security}"); } @@ -830,7 +842,7 @@ sub miscellaneousAfter { addToBeDone { addVarsInSh("$::prefix/etc/sysconfig/system", { META_CLASS => $o->{meta_class} }); - eval { install::any::set_security($o) }; + eval { install::any::set_security($o) } if !$o->{isUpgrade}; } 'installPackages'; } @@ -850,23 +862,25 @@ sub exitInstall { 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); + run_program::rooted($::prefix, 'xz', $report); }; - eval { install::any::getAndSaveAutoInstallFloppies($o, 1) } if arch() !~ /^ppc/; - eval { output "$::prefix/root/drakx/README", "This directory contains several installation-related files, + output("$::prefix/root/drakx/package_list.pl", install::any::selected_leaves_pl($o)); + + eval { install::any::getAndSaveAutoInstallFloppies($o, 1) }; + eval { output "$::prefix/root/drakx/README", sprintf("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 +Beware that some %s tools rely on the contents of some of these files... so remove any file from here at your own risk! -" }; +", "Mageia") }; #- wait for remaining processes. foreach (@{$o->{waitpids}}) { waitpid $_, 0; log::l("pid $_ returned $?"); } install::media::umount_media($o->{packages}); - install::media::openCdromTray(install::media::first_medium($o->{packages})->{phys_medium}{device}) if !detect_devices::is_xbox() && $o->{method} eq 'cdrom'; + install::media::openCdromTray($o->{stage2_phys_medium}{device}) if !detect_devices::is_xbox() && $o->{method} eq 'cdrom'; install::media::log_sizes(); } @@ -911,8 +925,8 @@ sub upNetwork { start_network_interface($o); return 1; } elsif (!$b_pppAvoided) { - log::l("starting network (ppp: $o->{net}{type})"); - eval { modules::load(qw(serial ppp bsd_comp ppp_deflate)) }; + log::l("starting network (PPP: $o->{net}{type})"); + eval { modules::load(qw(serial bsd_comp ppp_deflate)) }; run_program::rooted($::prefix, "/etc/rc.d/init.d/syslog", "start"); start_network_interface($o); return 1; @@ -936,7 +950,7 @@ sub downNetwork { } elsif (!network_is_cheap($o)) { stop_network_interface($o); run_program::rooted($::prefix, "/etc/rc.d/init.d/syslog", "stop"); - eval { modules::unload(qw(ppp_deflate bsd_comp ppp serial)) }; + eval { modules::unload(qw(ppp_deflate bsd_comp serial)) }; return 1; } } |
