home *** CD-ROM | disk | FTP | other *** search
/ Inter.Net 55-2 / Inter.Net 55-2.iso / Mandrake / mdkinst / usr / bin / perl-install / install2.pm < prev    next >
Encoding:
Perl POD Document  |  2000-01-12  |  19.8 KB  |  665 lines

  1.  
  2. package install2;
  3.  
  4.  
  5.  
  6. use Data::Dumper;
  7.  
  8.  
  9.  
  10.  
  11.  
  12.  
  13. use common qw(:common :file :system :functional);
  14. use install_any qw(:all);
  15. use log;
  16. use commands;
  17. use network;
  18. use lang;
  19. use keyboard;
  20. use mouse;
  21. use fs;
  22. use raid;
  23. use fsedit;
  24. use devices;
  25. use partition_table qw(:types);
  26. use modules;
  27. use detect_devices;
  28. use run_program;
  29.  
  30. use install_steps;
  31. #use install_steps_interactive;
  32.  
  33.  
  34.  
  35.  
  36. $::VERSION = "7.0";
  37.  
  38. my (%installSteps, @orderedInstallSteps);
  39. {    
  40.     my @installStepsFields = qw(text redoable onError hidden needs); 
  41.     #entered reachable toBeDone next done;
  42.     my @installSteps = (
  43.   selectLanguage     => [ __("Choose your language"), 1, 1, '' ],
  44.   selectInstallClass => [ __("Select installation class"), 1, 1, '' ],
  45.   setupSCSI          => [ __("Setup SCSI"), 1, 0, '' ],
  46.   selectPath         => [ __("Choose install or upgrade"), 0, 0, '', "selectInstallClass" ],
  47.   selectMouse        => [ __("Configure mouse"), 1, 1, 'beginner', "selectPath" ],
  48.   selectKeyboard     => [ __("Choose your keyboard"), 1, 1, '', "selectPath" ],
  49.   miscellaneous      => [ __("Miscellaneous"), 1, 1, 'beginner' ],
  50.   partitionDisks     => [ __("Setup filesystems"), 1, 0, '', "selectPath" ],
  51.   formatPartitions   => [ __("Format partitions"), 1, -1, '', "partitionDisks" ],
  52.   choosePackages     => [ __("Choose packages to install"), 1, 1, 'beginner', "selectPath" ],
  53.   doInstallStep      => [ __("Install system"), 1, -1, '', ["formatPartitions", "selectPath"] ],
  54.   configureNetwork   => [ __("Configure networking"), 1, 1, 'beginner', "formatPartitions" ],
  55.   installCrypto      => [ __("Cryptographic"), 1, 1, '!expert', "configureNetwork" ],
  56.   configureTimezone  => [ __("Configure timezone"), 1, 1, '', "doInstallStep" ],
  57.  
  58.   configurePrinter   => [ __("Configure printer"), 1, 0, '', "doInstallStep" ],
  59.   setRootPassword    => [ __("Set root password"), 1, 1, '', "formatPartitions" ],
  60.   addUser            => [ __("Add a user"), 1, 1, '', "doInstallStep" ],
  61.   createBootdisk     => [ __("Create a bootdisk"), 1, 0, '', "doInstallStep" ],
  62.   setupBootloader    => [ __("Install bootloader"), 1, 1, '', "doInstallStep" ],
  63.   configureX         => [ __("Configure X"), 1, 0, '', ["formatPartitions", "setupBootloader"] ],
  64.   exitInstall        => [ __("Exit install"), 0, 0, 'beginner' ],
  65. );
  66.     for (my $i = 0; $i < @installSteps; $i += 2) {
  67.     my %h; @h{@installStepsFields} = @{ $installSteps[$i + 1] };
  68.     $h{previous}= $installSteps[$i - 2] if $i >= 2;
  69.     $h{next}    = $installSteps[$i + 2];
  70.     $h{entered} = 0;
  71.     $h{onError} = $installSteps[$i + 2 * $h{onError}];
  72.     $h{reachable} = !$h{needs};
  73.     $installSteps{ $installSteps[$i] } = \%h;
  74.     push @orderedInstallSteps, $installSteps[$i];
  75.     }
  76.     $installSteps{first} = $installSteps[0];
  77. }
  78.  
  79.  
  80.  
  81.  
  82.  
  83. my @install_classes = (__("beginner"), __("developer"), __("server"), __("expert"));
  84.  
  85.  
  86.  
  87.  
  88.  
  89. my %suggestedPartitions = (
  90.   normal => [
  91.     { mntpoint => "/boot", size =>  10 << 11, type => 0x83, maxsize => 30 << 11 },
  92.     { mntpoint => "/",     size => 300 << 11, type => 0x83, ratio => 5, maxsize => 2500 << 11 },
  93.     { mntpoint => "swap",  size =>  64 << 11, type => 0x82, ratio => 1, maxsize => 250 << 11 },
  94.     { mntpoint => "/home", size => 300 << 11, type => 0x83, ratio => 2 },
  95.   ],
  96.   developer => [
  97.     { mntpoint => "/boot", size =>  10 << 11, type => 0x83, maxsize => 30 << 11 },
  98.     { mntpoint => "swap",  size =>  64 << 11, type => 0x82, ratio => 1, maxsize => 250 << 11 },
  99.     { mntpoint => "/",     size => 150 << 11, type => 0x83, ratio => 1, maxsize => 300 << 11 },
  100.     { mntpoint => "/usr",  size => 300 << 11, type => 0x83, ratio => 4, maxsize =>1500 << 11 },
  101.     { mntpoint => "/home", size => 100 << 11, type => 0x83, ratio => 5 },
  102.   ],
  103.   server => [
  104.     { mntpoint => "/boot", size =>  10 << 11, type => 0x83, maxsize => 30 << 11 },
  105.     { mntpoint => "swap",  size =>  64 << 11, type => 0x82, ratio => 2, maxsize => 400 << 11 },
  106.     { mntpoint => "/",     size => 150 << 11, type => 0x83, ratio => 1, maxsize => 250 << 11 },
  107.     { mntpoint => "/usr",  size => 300 << 11, type => 0x83, ratio => 3, maxsize =>1500 << 11 },
  108.     { mntpoint => "/var",  size => 100 << 11, type => 0x83, ratio => 4 },
  109.     { mntpoint => "/home", size => 100 << 11, type => 0x83, ratio => 5 },
  110.   ],
  111. );
  112.  
  113.  
  114.  
  115.  
  116.  
  117.  
  118.  
  119. $o = $::o = {
  120. #    bootloader => { linear => 0, message => 1, timeout => 5, restricted => 0 },
  121.     autoSCSI   => 0,
  122.     mkbootdisk => 1, 
  123.  
  124.     partitioning => { clearall => 0, eraseBadPartitions => 0, auto_allocate => 0, autoformat => 0 }, 
  125.  
  126.   partitions => [
  127.     { mntpoint => "/boot", size =>  10 << 11, type => 0x83, maxsize => 30 << 11 },
  128.     { mntpoint => "/",     size => 300 << 11, type => 0x83, ratio => 5, maxsize => 1500 << 11 },
  129.     { mntpoint => "swap",  size =>  64 << 11, type => 0x82, ratio => 1, maxsize => 250 << 11 },
  130.     { mntpoint => "/home", size => 300 << 11, type => 0x83, ratio => 5 },
  131.   ],
  132.  
  133.  
  134.  
  135.  
  136.  
  137.  
  138.  
  139.  
  140.  
  141.  
  142.  
  143.  
  144.     shells => [ map { "/bin/$_" } qw(bash tcsh zsh ash ksh) ],
  145.     authentication => { md5 => 1, shadow => 1 },
  146.     lang         => 'en',
  147.     isUpgrade    => 0,
  148.     toRemove     => [],
  149.     toSave       => [],
  150.  
  151.  
  152.  
  153.     timezone => {
  154.  
  155.  
  156.                 },
  157.     printer => {
  158.                  want         => 0,
  159.                  complete     => 0,
  160.                  str_type     => $printer::printer_type_default,
  161.                  QUEUE        => "lp",
  162.                  SPOOLDIR     => "/var/spool/lpd/lp",
  163.                  DBENTRY      => "PostScript",
  164.                  PAPERSIZE    => "letter",
  165.                  CRLF         => 0,
  166.                  AUTOSENDEOF  => 1,
  167.  
  168.                  DEVICE       => "/dev/lp0",
  169.  
  170.                  REMOTEHOST   => "",
  171.                  REMOTEQUEUE  => "",
  172.  
  173.                  NCPHOST      => "", 
  174.                  NCPQUEUE     => "", 
  175.                  NCPUSER      => "", 
  176.                  NCPPASSWD    => "", 
  177.  
  178.                  SMBHOST      => "", 
  179.                  SMBHOSTIP    => "", 
  180.                  SMBSHARE     => "", 
  181.                  SMBUSER      => "", 
  182.                  SMBPASSWD    => "", 
  183.                  SMBWORKGROUP => "", 
  184.                },
  185.  
  186.  
  187.  
  188.  
  189.  
  190.     steps        => \%installSteps,
  191.     orderedSteps => \@orderedInstallSteps,
  192.  
  193.     base => [ qw(basesystem sed initscripts console-tools mkbootdisk utempter ld.so ldconfig chkconfig ntsysv setup filesystem SysVinit bdflush crontabs dev e2fsprogs etcskel fileutils findutils getty_ps grep gzip hdparm info initscripts isapnptools kernel less ldconfig lilo logrotate losetup man mkinitrd mingetty modutils mount net-tools passwd procmail procps psmisc mandrake-release rootfiles rpm sash ash setserial shadow-utils sh-utils stat sysklogd tar termcap textutils time tmpwatch util-linux vim-minimal vixie-cron which perl-base msec) ],
  194.  
  195.  
  196.  
  197.  
  198.  
  199.  
  200.  
  201.  
  202.  
  203.  
  204.  
  205.  
  206.  
  207.  
  208.  
  209. };
  210.  
  211.  
  212.  
  213.  
  214.  
  215.  
  216.  
  217.  
  218. sub selectLanguage {
  219.     $o->selectLanguage($_[1] == 1);
  220.  
  221.     addToBeDone {
  222.     lang::write($o->{prefix});
  223.     keyboard::write($o->{prefix}, $o->{keyboard});
  224.     } 'doInstallStep' unless $::g_auto_install;
  225. }
  226.  
  227.  
  228. sub selectMouse {
  229.     my ($clicked) = $_[0];
  230.  
  231.     add2hash($o->{mouse} ||= {}, { mouse::read($o->{prefix}) }) if $o->{isUpgrade} && !$clicked;
  232.  
  233.     $o->selectMouse($clicked);
  234.     addToBeDone { mouse::write($o->{prefix}, $o->{mouse}) } 'doInstallStep';
  235. }
  236.  
  237.  
  238. sub selectKeyboard {
  239.     my ($clicked) = $_[0];
  240.  
  241.     return unless $o->{isUpgrade} || !$::beginner || $clicked;
  242.  
  243.     $o->{keyboard} = (keyboard::read($o->{prefix}))[0] if $o->{isUpgrade} && !$clicked && $o->{keyboard_unsafe};
  244.     $o->selectKeyboard if !$::beginner || $clicked;
  245.  
  246.     
  247.     addToBeDone {
  248.     keyboard::write($o->{prefix}, $o->{keyboard});
  249.     } 'doInstallStep' unless $::g_auto_install;
  250. }
  251.  
  252.  
  253. sub selectPath {
  254.     $o->selectPath;
  255.     install_any::searchAndMount4Upgrade($o) if $o->{isUpgrade};
  256. }
  257.  
  258.  
  259. sub selectInstallClass {
  260.     $o->selectInstallClass(@install_classes);
  261.  
  262.     $o->{partitions} ||= $suggestedPartitions{$o->{installClass}};
  263.  
  264.     if ($o->{steps}{choosePackages}{entered} >= 1 && !$o->{steps}{doInstallStep}{done}) {
  265.         $o->setPackages(\@install_classes);
  266.         $o->selectPackagesToUpgrade() if $o->{isUpgrade};
  267.     }
  268. }
  269.  
  270.  
  271. sub setupSCSI {
  272.     my ($clicked) = $_[0];
  273.     $o->{autoSCSI} ||= $::beginner;
  274.  
  275.     $o->setupSCSI($o->{autoSCSI} && !$clicked, $clicked);
  276. }
  277.  
  278.  
  279. sub partitionDisks {
  280.     return
  281.       $o->{fstab} = [
  282.     { device => "loop7", type => 0x83, size => ((cat_('/dos/lnx4win/size.txt'))[0]*2048), mntpoint => "/", isFormatted => 1, isMounted => 1 },
  283.     { device => "/initrd/dos/lnx4win/swapfile", type => 0x82, mntpoint => "swap", isFormatted => 1, isMounted => 1 },
  284.       ] if $o->{lnx4win};
  285.     return if $o->{isUpgrade};
  286.  
  287.     ($o->{hd_dev}) = cat_("/proc/mounts") =~ m|/tmp/(\S+)\s+/tmp/hdimage|;
  288.  
  289.     $::o->{steps}{formatPartitions}{done} = 0;
  290.     eval { fs::umount_all($o->{fstab}, $o->{prefix}) } if $o->{fstab} && !$::testing;
  291.  
  292.     my $ok = fsedit::get_root($o->{fstab} || []) ? 1 : install_any::getHds($o);
  293.     my $auto = $ok && !$o->{partitioning}{readonly} &&
  294.     ($o->{partitioning}{auto_allocate} || $::beginner && fsedit::get_fstab(@{$o->{hds}}) < 3);
  295.  
  296.     eval { fsedit::auto_allocate($o->{hds}, $o->{partitions}) } if $auto;
  297.  
  298.     if ($auto && fsedit::get_root_($o->{hds}) && $_[1] == 1) {
  299.     
  300.     $o->install_steps::doPartitionDisks($o->{hds});    
  301.     } elsif ($o->{partitioning}{readonly}) {
  302.     $o->ask_mntpoint_s($o->{fstab});
  303.     } else {
  304.     $o->doPartitionDisks($o->{hds}, $o->{raid} ||= {});
  305.     }
  306.     unless ($::testing) {
  307.     $o->rebootNeeded foreach grep { $_->{rebootNeeded} } @{$o->{hds}};
  308.     }
  309.     $o->{fstab} = [ fsedit::get_fstab(@{$o->{hds}}, $o->{raid}) ];
  310.     fsedit::get_root($o->{fstab}) or die 
  311. _("You must have a root partition.
  312. For this, create a partition (or click on an existing one).
  313. Then choose action ``Mount point'' and set it to `/'");
  314.  
  315.     cat_("/proc/mounts") =~ m|(\S+)\s+/tmp/rhimage nfs| &&
  316.       !grep { $_->{mntpoint} eq "/mnt/nfs" } @{$o->{manualFstab} || []} and
  317.     push @{$o->{manualFstab}}, { type => "nfs", mntpoint => "/mnt/nfs", device => $1, options => "noauto,ro,nosuid,rsize=8192,wsize=8192" };
  318. }
  319.  
  320. sub formatPartitions {
  321.     unless ($o->{lnx4win} || $o->{isUpgrade}) {
  322.     $o->choosePartitionsToFormat($o->{fstab});
  323.  
  324.     unless ($::testing) {
  325.         $o->formatPartitions(@{$o->{fstab}});
  326.         fs::mount_all([ grep { isSwap($_) } @{$o->{fstab}} ], $o->{prefix});
  327.         die _("Not enough swap to fulfill installation, please add some") if availableMemory < 40 * 1024;
  328.         fs::mount_all([ grep { isExt2($_) } @{$o->{fstab}} ], $o->{prefix}, $o->{hd_dev});
  329.     }
  330.     eval { $o = $::o = install_any::loadO($o) } if $_[1] == 1;
  331.  
  332.     }
  333.     mkdir "$o->{prefix}/$_", 0755 foreach 
  334.       qw(dev etc etc/profile.d etc/sysconfig etc/sysconfig/console etc/sysconfig/network-scripts
  335.     home mnt tmp var var/tmp var/lib var/lib/rpm);
  336.     mkdir "$o->{prefix}/$_", 0700 foreach qw(root);
  337.  
  338.     raid::prepare_prefixed($o->{raid}, $o->{prefix});
  339.  
  340.     
  341.     
  342.     
  343.     
  344.     $o->{pcmcia} and $_->{options} = "noatime" foreach grep { isExt2($_) } @{$o->{fstab}};
  345. }
  346.  
  347.  
  348. sub choosePackages {
  349.     require pkgs;
  350.     $o->setPackages if $_[1] == 1;
  351.     $o->selectPackagesToUpgrade($o) if $o->{isUpgrade} && $_[1] == 1;
  352.     if ($_[1] > 1 || !$o->{isUpgrade} || $::expert) {
  353.     if ($_[1] == 1) { 
  354.         $o->{compssUsersChoice}{$_} = 1 foreach @{$o->{compssUsersSorted}}, 'Miscellaneous';
  355.         $o->{compssUsersChoice}{KDE} = 0 if $o->{lang} =~ /ja|el|ko|th|vi|zh/; 
  356.  
  357.     }
  358.     $o->choosePackages($o->{packages}, $o->{compss}, 
  359.                $o->{compssUsers}, $o->{compssUsersSorted}, $_[1] == 1);
  360.     pkgs::unselect($o->{packages}, $o->{packages}{kdesu}) if $o->{packages}{kdesu} && $o->{security} > 3;
  361.     $o->{packages}{$_}{selected} = 1 foreach @{$o->{base}}; 
  362.     }
  363. }
  364.  
  365.  
  366. sub doInstallStep {
  367.     $o->readBootloaderConfigBeforeInstall if $_[1] == 1;
  368.  
  369.     $o->beforeInstallPackages;
  370.     $o->installPackages($o->{packages});
  371.     $o->afterInstallPackages;
  372. }
  373.  
  374. sub miscellaneous {
  375.     $o->miscellaneous($_[0]); 
  376.  
  377.     addToBeDone {
  378.     setVarsInSh("$o->{prefix}/etc/sysconfig/system", { 
  379.             HDPARM => $o->{miscellaneous}{HDPARM},
  380.             CLASS => $::expert && "expert" || $::beginner && "beginner" || "medium",
  381.             TYPE => $o->{installClass},
  382.             SECURITY => $o->{security},
  383.         });
  384.     install_any::fsck_option();
  385.  
  386.     local $ENV{LILO_PASSWORD} = $o->{lilo}{password};
  387.     run_program::rooted($o->{prefix}, "/etc/security/msec/init.sh", $o->{security});
  388.     } 'doInstallStep';
  389. }
  390.  
  391.  
  392. sub configureNetwork {
  393.     my ($clicked) = @_;
  394.  
  395.     if ($o->{isUpgrade} && !$clicked) {
  396.     $o->{netc} or $o->{netc} = {};
  397.     add2hash($o->{netc}, network::read_conf("$o->{prefix}/etc/sysconfig/network")) if -r "$o->{prefix}/etc/sysconfig/network";
  398.     add2hash($o->{netc}, network::read_resolv_conf("$o->{prefix}/etc/resolv.conf")) if -r "$o->{prefix}/etc/resolv.conf";
  399.     foreach (all("$o->{prefix}/etc/sysconfig/network-scripts")) {
  400.         if (/ifcfg-(\w+)/) {
  401.         push @{$o->{intf}}, { getVarsFromSh("$o->{prefix}/etc/sysconfig/network-scripts/$_") };
  402.         }
  403.     }
  404.     }
  405.     $o->configureNetwork($_[1] == 1);
  406. }
  407.  
  408. sub installCrypto { $o->installCrypto }
  409.  
  410.  
  411. sub configureTimezone {
  412.     my ($clicked) = @_;
  413.     my $f = "$o->{prefix}/etc/sysconfig/clock";
  414.  
  415.     require timezone;
  416.     if ($o->{isUpgrade} && -r $f && -s $f > 0) {
  417.     return if $_[1] == 1 && !$clicked;
  418.     
  419.     add2hash($o->{timezone}, { timezone::read($f) });
  420.     }
  421.     $o->{timezone}{UTC} = !$::beginner && !grep { isFat($_) } @{$o->{fstab}} unless exists $o->{timezone}{UTC};
  422.     $o->timeConfig($f, $clicked);
  423. }
  424.  
  425. sub configureServices {
  426.     return if $o->{lnx4win};
  427.  
  428.     $o->servicesConfig;
  429. }
  430.  
  431. sub configurePrinter  { $o->printerConfig   }
  432.  
  433. sub setRootPassword {
  434.     return if $o->{isUpgrade};
  435.  
  436.     $o->setRootPassword($_[0]);
  437.     addToBeDone { install_any::setAuthentication() } 'doInstallStep';
  438. }
  439.  
  440. sub addUser {
  441.     return if $o->{isUpgrade};
  442.  
  443.     $o->addUser($_[0]);
  444.     install_any::setAuthentication();
  445. }
  446.  
  447.  
  448.  
  449. sub createBootdisk {
  450.     modules::write_conf("$o->{prefix}/etc/conf.modules", 'append');
  451.  
  452.     return if $o->{lnx4win};
  453.     $o->createBootdisk($_[1] == 1);
  454. }
  455.  
  456.  
  457. sub setupBootloader {
  458.     return if $o->{lnx4win} || $::g_auto_install;
  459.  
  460.     $o->setupBootloaderBefore if $_[1] == 1;
  461.     $o->setupBootloader($_[1] - 1);
  462. }
  463.  
  464. sub configureX {
  465.     my ($clicked) = $_[0];
  466.  
  467.     
  468.     fs::write($o->{prefix}, $o->{fstab}, $o->{manualFstab}, $o->{useSupermount});
  469.     modules::write_conf("$o->{prefix}/etc/conf.modules", 'append');
  470.  
  471.     $o->setupXfree if $o->{packages}{XFree86}{installed} || $clicked;
  472. }
  473.  
  474. sub exitInstall { $o->exitInstall(getNextStep() eq "exitInstall") }
  475.  
  476.  
  477.  
  478.  
  479.  
  480. sub main {
  481.     $SIG{__DIE__} = sub { chomp(my $err = $_[0]); log::l("warning: $err") };
  482.  
  483.     $::beginner = $::expert = $::g_auto_install = 0;
  484.  
  485.     my ($cfg, $patch);
  486.     my %cmdline; map { 
  487.     my ($n, $v) = split '=';
  488.     $cmdline{$n} = $v || 1;
  489.     } split ' ', cat_("/proc/cmdline");
  490.  
  491.     my $opt; foreach (@_) {
  492.     if (/^--?(.*)/) {
  493.         $cmdline{$opt} = 1 if $opt;
  494.         $opt = $1;
  495.     } else {
  496.         $cmdline{$opt} = $_ if $opt;
  497.         $opt = '';
  498.     }
  499.     } $cmdline{$opt} = 1 if $opt;
  500.     
  501.     map_each {
  502.     my ($n, $v) = @_;
  503.     my $f = ${{
  504.         method    => sub { $o->{method} = $v },
  505.         pcmcia    => sub { $o->{pcmcia} = $v },
  506.         vga       => sub { $o->{vga16} = $v },
  507.         step      => sub { $o->{steps}{first} = $v },
  508.         expert    => sub { $::expert = 1 },
  509.         beginner  => sub { $::beginner = 1 },
  510.         class     => sub { $o->{installClass} = $v },
  511.         lnx4win   => sub { $o->{lnx4win} = 1 },
  512.         readonly  => sub { $o->{partitioning}{readonly} = $v ne "0" },
  513.         display   => sub { $o->{display} = $v },
  514.         security  => sub { $o->{security} = $v },
  515.         test      => sub { $::testing = 1 },
  516.         patch     => sub { $patch = 1 },
  517.         defcfg    => sub { $cfg = $v },
  518.         newt      => sub { $o->{interactive} = "newt" },
  519.         text      => sub { $o->{interactive} = "newt" },
  520.         stdio     => sub { $o->{interactive} = "stdio"},
  521.         ks        => sub { $::auto_install = 1 },
  522.         kickstart => sub { $::auto_install = 1 },
  523.         auto_install => sub { $::auto_install = 1 },
  524.         simple_themes => sub { $o->{simple_themes} = 1 },
  525.         alawindows => sub { $o->{security} = 0; $o->{partitioning}{clearall} = 1; $o->{bootloader}{crushMbr} = 1 },
  526.         g_auto_install => sub { $::testing = $::g_auto_install = 1; $o->{partitioning}{auto_allocate} = 1 },
  527.         nomouseprobe => sub { $o->{nomouseprobe} = $v },
  528.     }}{lc $n}; &$f if $f;
  529.     } %cmdline;    
  530.  
  531.     if ($::g_auto_install) {
  532.     (my $root = `/bin/pwd`) =~ s|(/[^/]*){5}$||;
  533.     symlinkf $root, "/tmp/rhimage" or die "unable to create link /tmp/rhimage";
  534.     }
  535.  
  536.     unlink "/sbin/insmod"  unless $::testing;
  537.     unlink "/modules/pcmcia_core.o" unless $::testing; 
  538.     unlink "/modules/i82365.o" unless $::testing;
  539.     unlink "/modules/tcic.o" unless $::testing;
  540.     unlink "/modules/ds.o" unless $::testing;
  541.  
  542.     print STDERR "in second stage install\n";
  543.     log::openLog(($::testing || $o->{localInstall}) && 'debug.log');
  544.     log::l("second stage install running");
  545.     log::ld("extra log messages are enabled");
  546.  
  547.     eval { spawnShell() };
  548.  
  549.     $o->{prefix} = $::testing ? "/tmp/test-perl-install" : "/mnt";
  550.     $o->{root}   = $::testing ? "/tmp/root-perl-install" : "/";
  551.     mkdir $o->{prefix}, 0755;
  552.     mkdir $o->{root}, 0755;
  553.  
  554.     
  555.     $ENV{PATH} = "/usr/bin:/bin:/sbin:/usr/sbin:/usr/X11R6/bin:$o->{prefix}/sbin:$o->{prefix}/bin:$o->{prefix}/usr/sbin:$o->{prefix}/usr/bin:$o->{prefix}/usr/X11R6/bin" unless $::g_auto_install;
  556.  
  557.     $o->{interactive} ||= 'gtk';
  558.     if ($o->{interactive} eq "gtk" && availableMemory < 22 * 1024) {
  559.     log::l("switching to newt install cuz not enough memory");
  560.     $o->{interactive} = "newt";
  561.     }
  562.  
  563.     if ($::auto_install) {
  564.     require install_steps_auto_install;
  565.     eval { $o = $::o = install_any::loadO($o, "floppy") };
  566.     if ($@) {
  567.         log::l("error using auto_install, continuing");
  568.         undef $::auto_install;
  569.     }
  570.     }
  571.     unless ($::auto_install) {
  572.     $o->{interactive} ||= 'gtk';
  573.     require"install_steps_$o->{interactive}.pm";
  574.     }
  575.     eval { $o = $::o = install_any::loadO($o, "patch") } if $patch;
  576.     eval { $o = $::o = install_any::loadO($o, $cfg) } if $cfg;
  577.  
  578.     $o->{prefix} = $::testing ? "/tmp/test-perl-install" : "/mnt";
  579.     mkdir $o->{prefix}, 0755;
  580.  
  581.  
  582.  
  583.  
  584.  
  585.  
  586.  
  587.     
  588.     eval { ($o->{mouse}, $o->{wacom}) = mouse::detect() } unless $o->{nomouseprobe} || $o->{mouse};
  589.  
  590.     $::o = $o = $::auto_install ?
  591.       install_steps_auto_install->new($o) :
  592.     $o->{interactive} eq "stdio" ?
  593.       install_steps_stdio->new($o) :
  594.     $o->{interactive} eq "newt" ?
  595.       install_steps_newt->new($o) :
  596.     $o->{interactive} eq "gtk" ?
  597.       install_steps_gtk->new($o) :
  598.     die "unknown install type";
  599.  
  600.     $o->{netc} = network::read_conf("/tmp/network");
  601.     if (my ($file) = glob_('/tmp/ifcfg-*')) {
  602.     log::l("found network config file $file");
  603.     my $l = network::read_interface_conf($file);
  604.     add2hash(network::findIntf($o->{intf} ||= [], $l->{DEVICE}), $l);
  605.     }
  606.  
  607.     modules::unload($_) foreach qw(vfat msdos fat);
  608.     modules::load_deps("/modules/modules.dep");
  609.     modules::read_stage1_conf("/tmp/conf.modules");
  610.     modules::read_already_loaded();
  611.  
  612.     install_any::lnx4win_preinstall() if $o->{lnx4win};
  613.  
  614.     
  615.     my $clicked = 0;
  616.     MAIN: for ($o->{step} = $o->{steps}{first};; $o->{step} = getNextStep()) {
  617.     $o->{steps}{$o->{step}}{entered}++;
  618.     $o->enteringStep($o->{step});
  619.     eval {
  620.         &{$install2::{$o->{step}}}($clicked, $o->{steps}{$o->{step}}{entered});
  621.     };
  622.     $o->kill_action;
  623.     $clicked = 0;
  624.     while ($@) {
  625.         local $_ = $@;
  626.         $o->kill_action;
  627.         /^setstep (.*)/ and $o->{step} = $1, $clicked = 1, redo MAIN;
  628.         /^theme_changed$/ and redo MAIN;
  629.         unless (/^already displayed/ || /^ask_from_list cancel/) {
  630.         eval { $o->errorInStep($_) };
  631.         $@ and next;
  632.         }
  633.         $o->{step} = $o->{steps}{$o->{step}}{onError};
  634.         next MAIN unless $o->{steps}{$o->{step}}{reachable}; 
  635.         redo MAIN;
  636.     }
  637.     $o->{steps}{$o->{step}}{done} = 1;
  638.     $o->leavingStep($o->{step});
  639.  
  640.     last if $o->{step} eq 'exitInstall';
  641.     }
  642.     fs::write($o->{prefix}, $o->{fstab}, $o->{manualFstab}, $o->{useSupermount});
  643.     modules::write_conf("$o->{prefix}/etc/conf.modules", 'append');
  644.  
  645.     install_any::lnx4win_postinstall($o->{prefix}) if $o->{lnx4win};
  646.     install_any::killCardServices();
  647.  
  648.     
  649.     install_steps::cleanIfFailedUpgrade($o);
  650.  
  651.     
  652.     eval { commands::cp('-f', "/tmp/ddebug.log", "$o->{prefix}/root") };
  653.  
  654.     
  655.     sync(); sync();
  656.  
  657.     log::l("installation complete, leaving");
  658.     print "\n" x 30;
  659. }
  660.  
  661.  
  662.  
  663.  
  664. 1;
  665.