diff options
Diffstat (limited to 'perl-install/install/install2.pm')
-rw-r--r-- | perl-install/install/install2.pm | 168 |
1 files changed, 140 insertions, 28 deletions
diff --git a/perl-install/install/install2.pm b/perl-install/install/install2.pm index 0a763358b..50bde4ad9 100644 --- a/perl-install/install/install2.pm +++ b/perl-install/install/install2.pm @@ -1,4 +1,4 @@ -package install::install2; # $Id: install2.pm 255825 2009-04-08 11:54:23Z tv $ +package install::install2; use diagnostics; use strict; @@ -6,6 +6,12 @@ use vars qw($o); BEGIN { $::isInstall = 1 } +=head1 SYNOPSYS + +The installer stage2 real entry point + +=cut + #-###################################################################################### #- misc imports #-###################################################################################### @@ -30,10 +36,26 @@ use fs::mount; use messages; #-####################################################################################### -#-$O -#-the big struct which contain, well everything (globals + the interactive methods ...) -#-if you want to do a kickstart file, you just have to add all the required fields (see for example -#-the variable $default) +=head1 Data Structure + +=head2 $O; + +$o (or $::o in other modules) is the big struct which contain, well everything: + +=over 4 + +=item * globals + +=item * the interactive methods + +=item * ... + +=back + +if you want to do a kickstart file, you just have to add all the required fields (see for example +the variable $default) + +=cut #-####################################################################################### $o = $::o = { # bootloader => { linear => 0, message => 1, timeout => 5, restricted => 0 }, @@ -77,21 +99,40 @@ $o = $::o = { }; +=head1 Steps Navigation + +=over + +=cut sub installStepsCall { my ($o, $auto, $fun, @args) = @_; $fun = "install::steps::$fun" if $auto; $o->$fun(@args); } + +=item getNextStep($o) + +Returns next step + +=cut + sub getNextStep { my ($o) = @_; find { !$o->{steps}{$_}{done} && $o->{steps}{$_}{reachable} } @{$o->{orderedSteps}}; } #-###################################################################################### -#- Steps Functions -#- each step function are called with two arguments : clicked(because if you are a -#- beginner you can force the the step) and the entered number + +=back + +=head1 Steps Functions + +Each step function are called with two arguments : clicked(because if you are a +beginner you can force the the step) and the entered number + +=cut + #-###################################################################################### #------------------------------------------------------------------------------ @@ -200,7 +241,8 @@ sub choosePackages { log::l("rpmsrate_flags_chosen's: ", join(' ', sort @flags)); #- check pre-condition that basesystem package must be selected. - install::pkgs::packageByName($o->{packages}, 'basesystem')->flag_available or die "basesystem package not selected"; + my $base_pkg = install::pkgs::packageByName($o->{packages}, 'basesystem'); + $base_pkg->flag_available or $base_pkg->flag_installed or die "basesystem package not selected"; #- check if there are packages that need installation. $o->{steps}{installPackages}{done} = 0 if $o->{steps}{installPackages}{done} && install::pkgs::packagesToInstall($o->{packages}) > 0; @@ -289,20 +331,21 @@ sub exitInstall { } #-###################################################################################### -#- Udev Functions + +=head1 Udev Functions + +=over + +=cut + #-###################################################################################### -sub start_udev() { - return if fuzzy_pidofs('udevd'); +=item start_udev() - # Ensure /run is mounted - mkdir("/run", 0755); - run_program::run("mount -t tmpfs -o mode=0755,nosuid,nodev tmpfs /run"); +=cut - # Fake dracut boot (due to checks employed when running dracut during install) - # as we know that we'll have the needed metadata in udevadm db due to us - # starting udev nice and early here. - mkdir_p("/run/initramfs"); +sub start_udev() { + return if fuzzy_pidofs('udevd'); # Start up udev: mkdir_p("/run/udev/rules.d"); @@ -313,14 +356,26 @@ sub start_udev() { run_program::run("udevadm", "trigger", "--type=devices", "--action=add"); } +=item stop_udev() + +=cut + sub stop_udev() { kill 15, fuzzy_pidofs('udevd'); sleep(2); - fs::mount::umount($_) foreach '/dev/pts', '/dev/shm', '/run'; + fs::mount::umount($_) foreach '/dev/pts', '/dev/shm'; } #-###################################################################################### -#- Other Functions + +=back + +=head1 Other Functions + +=over + +=cut + #-###################################################################################### sub init_local_install { @@ -419,12 +474,18 @@ sub sig_segv_handler() { install::steps_auto_install_non_interactive::errorInStep($o, $msg); } +=item read_stage1_net_conf() { + +Reads back netork configuration done by stage1 (see L<stages>). + +=cut + sub read_stage1_net_conf() { require network::network; #- get stage1 network configuration if any. log::l('found /tmp/network'); add2hash($o->{net}{network} ||= {}, network::network::read_conf('/tmp/network')); - if (my ($file) = glob_('/tmp/ifcfg-*')) { + if (my ($file) = grep { -f $_ } glob_('/tmp/ifcfg-*')) { log::l("found network config file $file"); my $l = network::network::read_interface_conf($file); $o->{net}{ifcfg}{$l->{DEVICE}} ||= $l; @@ -447,6 +508,12 @@ sub read_stage1_net_conf() { } } +=item parse_args($cfg, $patch) + +Parse arguments (which came from either the boot loader command line or its configuration file). + +=cut + sub parse_args { my ($cfg, $patch); my %cmdline = map { @@ -574,17 +641,46 @@ sub process_auto_steps() { } } +=item process_patch($cfg, $patch) + +Handle installer live patches: + +=over 4 + +=item * OEM patch (C<install/patch-oem.pl>) + +=item * defcfg (the file indicated by the defcfg option) + +=item * patch (C<patch> file) + +=back + +=cut + sub process_patch { my ($cfg, $patch) = @_; #- oem patch should be read before to still allow patch or defcfg. eval { $o = $::o = install::any::loadO($o, "install/patch-oem.pl"); log::l("successfully read oem patch") }; - #- patch should be read after defcfg in order to take precedance. + #- patch should be read after defcfg in order to take precedence. eval { $o = $::o = install::any::loadO($o, $cfg); log::l("successfully read default configuration: $cfg") } if $cfg; eval { $o = $::o = install::any::loadO($o, "patch"); log::l("successfully read patch") } if $patch; } #-###################################################################################### -#- MAIN + +=item main() + +This is the main function, the installer entry point called by runinstall2: + +=over 4 + +=item * initialization + +=item * steps + +=back + +=cut #-###################################################################################### sub main { $SIG{SEGV} = \&sig_segv_handler; @@ -607,7 +703,6 @@ sub main { log::l("second stage install running (", install::any::drakx_version($o), ")"); - eval { output('/proc/sys/kernel/modprobe', "\n") } if !$::local_install && !$::testing; #- disable kmod eval { touch('/root/non-chrooted-marker.DrakX') }; #- helps distinguishing /root and /mnt/root when we don't know if we are chrooted if ($::local_install) { @@ -619,7 +714,7 @@ sub main { } $o->{prefix} = $::prefix = $::testing ? "/tmp/test-perl-install" : "/mnt"; - mkdir $::prefix, 0755; + mkdir $::prefix, 0755 if ! -d $::prefix; init_path(); @@ -693,15 +788,22 @@ sub main { finish_install(); } +=item real_main() { + +Go through the steps cycle + +=cut + sub real_main() { - #-the main cycle MAIN: for ($o->{step} = $o->{steps}{first};; $o->{step} = getNextStep($o)) { $o->{steps}{$o->{step}}{entered}++; $o->enteringStep($o->{step}); + my $time = time(); eval { &{$install::install2::{$o->{step}}}($o->{steps}{$o->{step}}{auto}); }; my $err = $@; + log::l("step \"$o->{step}\" took: ", formatTimeRaw(time() - $time)); $o->kill_action; if ($err) { local $_ = $err; @@ -723,6 +825,12 @@ sub real_main() { } } +=item finish_install() { + +Clean up the installer before the final reboot. + +=cut + sub finish_install() { unlink $install::any::compressed_image_on_disk; install::media::clean_postinstall_rpms(); @@ -738,7 +846,7 @@ sub finish_install() { install::steps::cleanIfFailedUpgrade($o); #- drop urpmi DB if urpmi is not installed: - -e "$::prefix/usr/sbin/urpmi.update" or eval { rm_rf("$::prefix/var/lib/urpmi") }; + -e "$::prefix/usr/sbin/urpmi" or eval { rm_rf("$::prefix/var/lib/urpmi") }; system("chroot", $::prefix, "bash", "-c", $o->{postInstallBeforeReboot}) if $o->{postInstallBeforeReboot}; @@ -754,4 +862,8 @@ sub finish_install() { print "\n" x 80 if !$::local_install; } +=back + +=cut + 1; |