diff options
Diffstat (limited to 'perl-install/install/steps.pm')
-rw-r--r-- | perl-install/install/steps.pm | 154 |
1 files changed, 97 insertions, 57 deletions
diff --git a/perl-install/install/steps.pm b/perl-install/install/steps.pm index 5a5e867ae..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; @@ -126,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); @@ -143,12 +149,6 @@ sub selectKeyboard { 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 {} @@ -182,9 +182,10 @@ sub selectInstallClass { #------------------------------------------------------------------------------ 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 @@ -196,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 @@ -264,6 +268,9 @@ sub selectSupplMedia { '' } sub choosePackages { 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. @@ -280,12 +287,9 @@ sub choosePackages { $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_mdv { + 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")); @@ -295,9 +299,9 @@ sub upgrading_redhat() { undef *URPM::Package::compare_pkg; *URPM::Package::compare_pkg = sub { my ($lpkg, $rpkg) = @_; - my $c = ($lpkg->release =~ /mdv|mnb/ ? 1 : 0) - ($rpkg->release =~ /mdv|mnb/ ? 1 : 0); + my $c = ($lpkg->release =~ /mga/ ? 1 : 0) - ($rpkg->release =~ /mga/ ? 1 : 0); if ($c) { - prefering_mdv($lpkg, $rpkg->version . '-' . $rpkg->release, $c); + prefering_mga($lpkg, $rpkg->version . '-' . $rpkg->release, $c); $c; } else { &$old_compare_pkg; @@ -308,15 +312,21 @@ sub upgrading_redhat() { undef *URPM::Package::compare; *URPM::Package::compare = sub { my ($lpkg, $rpkg_ver) = @_; - my $c = ($lpkg->release =~ /mdv|mnb/ ? 1 : 0) - ($rpkg_ver =~ /mdv|mnb/ ? 1 : 0); + my $c = ($lpkg->release =~ /mga/ ? 1 : 0) - ($rpkg_ver =~ /mga/ ? 1 : 0); if ($c) { - prefering_mdv($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) = @_; @@ -324,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/$_") { @@ -337,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 @@ -348,6 +364,8 @@ sub beforeInstallPackages { ); rm_rf(@to_remove); + live_patch_URPM() if $o->{isUpgrade} !~ /mageia/; + if ($o->{isUpgrade} eq 'redhat') { upgrading_redhat(); } @@ -361,18 +379,17 @@ 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"); } - if (-e '/tmp/.X11-unix') { - mkdir "$::prefix/tmp/.X11-unix"; - run_program::run('mount', '--bind', '/tmp/.X11-unix', "$::prefix/tmp/.X11-unix"); + foreach ('/run', '/tmp/.X11-unix') { + if (-e $_) { + mkdir "$::prefix/$_"; + run_program::run('mount', '--bind', $_, "$::prefix/$_"); + } } log::l("setting excludedocs to $o->{excludedocs}"); @@ -410,6 +427,12 @@ sub installCallback { 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); @@ -417,20 +440,23 @@ sub installPackages { #- 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'; local $ENV{HOME}; local $packages->{options}{auto} = !$o_interactive; - install::pkgs::install($o->{isUpgrade}, \@toInstall, $packages, \&installCallback); + $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. } @@ -445,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. @@ -468,6 +494,14 @@ Consoles 1,3,4,7 may also contain interesting information"; 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"; @@ -478,11 +512,6 @@ Consoles 1,3,4,7 may also contain interesting information"; #- 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"); @@ -630,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 @@ -678,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}); @@ -721,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', 'KDE4', '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 == (); } @@ -743,8 +782,9 @@ 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 { @@ -802,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'; } @@ -822,25 +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); }; output("$::prefix/root/drakx/package_list.pl", install::any::selected_leaves_pl($o)); - eval { install::any::getAndSaveAutoInstallFloppies($o, 1) } if arch() !~ /^ppc/; - eval { output "$::prefix/root/drakx/README", "This directory contains several installation-related files, + 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(); } @@ -885,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; @@ -910,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; } } |