summaryrefslogtreecommitdiffstats
path: root/perl-install/install2.pm
diff options
context:
space:
mode:
Diffstat (limited to 'perl-install/install2.pm')
-rw-r--r--perl-install/install2.pm228
1 files changed, 28 insertions, 200 deletions
diff --git a/perl-install/install2.pm b/perl-install/install2.pm
index 5d2bd900b..d752a17d6 100644
--- a/perl-install/install2.pm
+++ b/perl-install/install2.pm
@@ -7,6 +7,7 @@ use strict;
use vars qw($testing $error $cancel $INSTALL_VERSION);
use lib qw(/usr/bin/perl-install . c/blib/arch);
+use install2more;
use c;
use common qw(:common :file :system);
use devices;
@@ -56,7 +57,7 @@ my @installSteps = (
);
# this table is translated at run time
-my %upgradeSteps = (
+my @upgradeSteps = (
selectPath => [ "Select installation path", 0, 0 , 'none' ],
setupSCSI => [ "Setup SCSI", 0, 0 ],
upgrFindInstall => [ "Find current installation", 0, 0 ],
@@ -67,7 +68,7 @@ my %upgradeSteps = (
setupBootloader => [ "Install bootloader", 0, 0 ],
exitInstall => [ "Exit install", 0, 0 , undef, 'done' ],
);
-
+my (%installSteps, %upgradeSteps);
for (my $i = 0; $i < @installSteps; $i += 2) {
my %h; @h{@installStepsFields} = @{ $installSteps[$i + 1] };
$h{prev} ||= $installSteps[$i - 2];
@@ -94,7 +95,6 @@ my @serverPartitioning = (
{ mntpoint => "swap", size => 64 << 11, type => 0x82 }
);
-my $o = {};
my $default = {
display => "129.104.42.9:0",
user => { name => 'foo', password => 'foo', shell => '/bin/bash', realname => 'really, it is foo' },
@@ -115,36 +115,16 @@ my $default = {
{ mntpoint => "swap", size => 64 << 11, type => 0x82 }
],
};
-
+my $o = { default => $default };
sub selectPath {
+ $o->{isUpgrade} = $o->selectInstallOrUpgrade;
$o->{steps} = $o->{isUpgrade} ? \%upgradeSteps : \%installSteps;
}
sub selectInstallClass {
-# my @choices = qw(Workstation Server Custom);
-
- $o->{installClass} eq 'Custom' and return;
-
- $o->{bootloader}->{onmbr} = 1;
- $o->{bootloader}->{uselinear} = 1;
-
- foreach (qw(skipntsysv autoformat nologmessage auth autoswap skipbootloader forceddruid)) {
- $o->{hints}->{flags}->{$_} = 1;
- }
- $o->{hints}->{auth}->{shadow} = 1;
- $o->{hints}->{auth}->{md5} = 1;
-
- if ($o->{installClass} eq 'Server') {
- $o->{hints}->{flags}->{skipprinter} = 1;
- $o->{hints}->{flags}->{skipresize} = 1;
- $o->{hints}->{partitioning}->{flags}->{clearall} = 1;
- $o->{hints}->{partitioning}->{attempts} = 'serverPartitioning';
- } else { # workstation
- $o->{hints}->{flags}->{autoscsi} = 1;
- $o->{hints}->{partitioning}->{flags}->{clearlinux} = 1;
- }
+ $o->{installClass} = $o->selectInstallClass;
}
sub setupSCSI {
@@ -154,7 +134,7 @@ sub setupSCSI {
while (my ($k, $v) = each %modules::loaded) {
$v->{type} eq 'scsi' and return;
}
- #setupSCSIInterfaces(0, \%modules::loaded, $o->{hints}->{flags}->{autoscsi}, $o->{direction});
+# $o->setupSCSIInterfaces(0, \%modules::loaded, $o->{hints}->{flags}->{autoscsi}, $o->{direction});
}
sub partitionDisks {
@@ -163,7 +143,7 @@ sub partitionDisks {
@{$o->{hds}} > 0 or die "An error has occurred - no valid devices were found on which to create new filesystems. Please check your hardware for the cause of this problem";
unless ($o->{isUpgrade}) {
- $o->{install}->doPartitionDisks($o->{hds}, $o->{fstab_wanted});
+ $o->doPartitionDisks($o->{hds}, $o->{fstab_wanted});
# Write partitions to disk
foreach (@{$o->{hds}}) { partition_table::write($_); }
@@ -185,22 +165,20 @@ sub partitionDisks {
}
sub findInstallFiles {
- $o->{packages} = $o->{method}->getPackageSet() and
- $o->{comps} = $o->{method}->getComponentSet($o->{packages});
+ $o->{packages} = $o->{method}->getPackageSet;
+ $o->{comps} = $o->{method}->getComponentSet($o->{packages});
}
sub choosePackages {
-# $o->{hints}->{component} && $o->{direction} < 0 and return cancel();
-
- $o->{install}->choosePackages($o->{packages}, $o->{comps}, $o->{isUpgrade});
+ $o->choosePackages($o->{packages}, $o->{comps}, $o->{isUpgrade});
}
sub doInstallStep {
$testing and return 0;
- $o->{install}->beforeInstallPackages($o->{method}, $o->{fstab});
- $o->{install}->installPackages($o->{rootPath}, $o->{method}, $o->{packages}, $o->{isUpgrade});
- $o->{install}->afterInstallPackages($o->{rootPath}, $o->{keyboard}, $o->{isUpgrade});
+ $o->beforeInstallPackages($o->{fstab});
+ $o->installPackages($o->{packages});
+ $o->afterInstallPackages($o->{keyboard});
}
sub configureMouse { setup::mouseConfig($o->{rootPath}); }
@@ -233,11 +211,11 @@ sub configureServices { setup::servicesConfig($o->{rootPath}) }
sub setRootPassword {
$testing and return 0;
- $o->{install}->setRootPassword($o->{rootPath});
+ $o->setRootPassword($o->{rootPath});
}
sub addUser {
- $o->{install}->addUser($o->{rootPath});
+ $o->addUser($o->{rootPath});
}
sub createBootdisk {
@@ -256,188 +234,38 @@ sub setupBootloader {
lilo::install("/mnt", $o->{hds}, $o->{fstab}, $versionString, $o->{bootloader});
}
-sub configureX { $o->{install}->setupXfree($o->{method}, $o->{rootPath}, $o->{packages}); }
-
-sub exitInstall { 1 }
-
-sub upgrFindInstall {
-# int rc;
-#
-# if (!$o->{table}.parts) {
-# rc = findAllPartitions(NULL, &$o->{table});
-# if (rc) return rc;
-# }
-#
-# umountFilesystems(&$o->{fstab});
-#
-# # rootpath upgrade support
-# if (strcmp($o->{rootPath} ,"/mnt"))
-# return INST_OKAY;
-#
-# # this also turns on swap for us
-# rc = readMountTable($o->{table}, &$o->{fstab});
-# if (rc) return rc;
-#
-# if (!testing) {
-# mountFilesystems(&$o->{fstab});
-#
-# if ($o->{method}->prepareMedia) {
-# rc = $o->{method}->prepareMedia($o->{method}, &$o->{fstab});
-# if (rc) {
-# umountFilesystems(&$o->{fstab});
-# return rc;
-# }
-# }
-# }
-#
-# return 0;
-}
-
-sub upgrChoosePackages {
-# static int firstTime = 1;
-# char * rpmconvertbin;
-# int rc;
-# char * path;
-# char * argv[] = { NULL, NULL };
-# char buf[128];
-#
-# if (testing)
-# path = "/";
-# else
-# path = $o->{rootPath};
-#
-# if (firstTime) {
-# snprintf(buf, sizeof(buf), "%s%s", $o->{rootPath},
-# "/var/lib/rpm/packages.rpm");
-# if (access(buf, R_OK)) {
-# snprintf(buf, sizeof(buf), "%s%s", $o->{rootPath},
-# "/var/lib/rpm/packages");
-# if (access(buf, R_OK)) {
-# errorWindow("No RPM database exists!");
-# return INST_ERROR;
-# }
-#
-# if ($o->{method}->getFile($o->{method}, "rpmconvert",
-# &rpmconvertbin)) {
-# return INST_ERROR;
-# }
-#
-# symlink("/mnt/var", "/var");
-# winStatus(35, 3, _("Upgrade"), _("Converting RPM database..."));
-# chmod(rpmconvertbin, 0755);
-# argv[0] = rpmconvertbin;
-# rc = runProgram(RUN_LOG, rpmconvertbin, argv);
-# if ($o->{method}->rmFiles)
-# unlink(rpmconvertbin);
-#
-# newtPopWindow();
-# if (rc) return INST_ERROR;
-# }
-# winStatus(35, 3, "Upgrade", _("Finding packages to upgrade..."));
-# rc = ugFindUpgradePackages(&$o->{packages}, path);
-# newtPopWindow();
-# if (rc) return rc;
-# firstTime = 0;
-# psVerifyDependencies(&$o->{packages}, 1);
-# }
-#
-# return psSelectPackages(&$o->{packages}, &$o->{comps}, NULL, 0, 1);
-}
-
-
-sub versionString {
- my $kernel = $o->{packages}->{kernel} or die "I couldn't find the kernel package!";
-
- c::headerGetEntry($kernel->{header}, 'version') . "-" .
- c::headerGetEntry($kernel->{header}, 'release');
-}
-
-sub getNextStep {
- my ($lastStep) = @_;
+sub configureX { $o->setupXfree($o->{method}, $o->{rootPath}, $o->{packages}); }
- $error and die "an error occured in step $lastStep";
- $cancel and die "cancel called in step $lastStep";
-
- $o->{direction} = 1;
-
- return $o->{lastChoice} = $o->{steps}->{$lastStep}->{next};
-}
-
-sub doSuspend {
- $o->{exitOnSuspend} and exit(1);
-
- if (my $pid = fork) {
- waitpid $pid, 0;
- } else {
- print "\n\nType <exit> to return to the install program.\n\n";
- exec {"/bin/sh"} "-/bin/sh";
- warn "error execing /bin/sh";
- sleep 5;
- exit 1;
- }
-}
-
-
-sub spawnShell {
- $testing and return;
-
- -x "/bin/sh" or log::l("cannot open shell - /usr/bin/sh doesn't exist"), return;
-
- fork and return;
-
- local *F;
- sysopen F, "/dev/tty2", 2 or log::l("cannot open /dev/tty2 -- no shell will be provided"), return;
-
- open STDIN, "<&F" or die;
- open STDOUT, ">&F" or die;
- open STDERR, ">&F" or die;
- close F;
-
- c::setsid();
-
- ioctl(STDIN, c::TIOCSCTTY(), 0) or warn "could not set new controlling tty: $!";
-
- exec {"/bin/sh"} "-/bin/sh" or log::l("exec of /bin/sh failed: $!");
-}
+sub exitInstall { $o->exitInstall }
sub main {
+ SIG{__DIE__} = sub { log::l("ERROR: $_[0]") };
# if this fails, it's okay -- it might help with free space though
unlink "/sbin/install";
print STDERR "in second stage install\n";
-
- $o->{rootPath} = "/mnt";
-
- $o->{method} = install_methods->new('cdrom');
- $o->{install} = install_steps_graphical->new($o);
-
- unless ($testing || $o->{localInstall}) {
- if (fork == 0) {
- while (1) { sleep(30); sync(); }
- }
- }
- $o->{exitOnSuspend} = $o->{localInstall} || $testing;
-
log::openLog(($testing || $o->{localInstall}) && 'debug.log');
-
log::l("second stage install running (version $INSTALL_VERSION)");
-
log::ld("extra log messages are enabled");
- $o->{rootPath} eq '/mnt' and spawnShell();
+ spawnSync();
+ eval { spawnShell() };
-# chooseLanguage('fr');
+ $o->{rootPath} = "/mnt";
+ $o->{method} = install_methods->new('cdrom');
+ $o = install_steps_graphical->new($o);
- $o->{netc} = net::readNetConfig("/tmp");
+ $o->{lang} = $o->chooseLanguage;
+ $o->{netc} = net::readNetConfig("/tmp");
if (my ($file) = glob_('/tmp/ifcfg-*')) {
log::l("found network config file $file");
$o->{intf} = net::readNetInterfaceConfig($file);
}
log::l("reading /usr/lib/rpm/rpmrc");
- c::rpmReadConfigFiles_();
+ c::rpmReadConfigFiles() or die "can't read rpm config files";
log::l("\tdone");
modules::load_deps("/modules/modules.dep");
@@ -447,7 +275,7 @@ sub main {
$ENV{PATH} = "/usr/bin:/bin:/sbin:/usr/sbin";
$ENV{LD_LIBRARY_PATH} = "";
- $o->{keyboard} = keyboard::read("/tmp/keyboard") || $default->{keyboard};
+ $o->{keyboard} = eval { keyboard::read("/tmp/keyboard") } || $default->{keyboard};
for (my $step = $o->{steps}->{first}; $step ne 'done'; $step = getNextStep($step)) {
log::l("entering step $step");