summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPascal Rigaux <pixel@mandriva.com>1999-07-01 12:55:28 +0000
committerPascal Rigaux <pixel@mandriva.com>1999-07-01 12:55:28 +0000
commit3b8e5409e6265e10709f46ac179f3ea7d014fcac (patch)
treebf01ae2f5351a8bb6afe3ef30389af4eeef23d4e
parent776c50b96e47354b7c32b56f5b1965d266fd23a7 (diff)
downloaddrakx-backup-do-not-use-3b8e5409e6265e10709f46ac179f3ea7d014fcac.tar
drakx-backup-do-not-use-3b8e5409e6265e10709f46ac179f3ea7d014fcac.tar.gz
drakx-backup-do-not-use-3b8e5409e6265e10709f46ac179f3ea7d014fcac.tar.bz2
drakx-backup-do-not-use-3b8e5409e6265e10709f46ac179f3ea7d014fcac.tar.xz
drakx-backup-do-not-use-3b8e5409e6265e10709f46ac179f3ea7d014fcac.zip
*** empty log message ***
-rw-r--r--perl-install/Makefile3
-rw-r--r--perl-install/fs.pm4
-rw-r--r--perl-install/fsedit.pm2
-rw-r--r--perl-install/install2.pm228
-rw-r--r--perl-install/install_steps.pm263
-rw-r--r--perl-install/keyboard.pm28
-rw-r--r--perl-install/lang.pm7
-rw-r--r--perl-install/modules.pm2
-rw-r--r--perl-install/pkgs.pm78
-rw-r--r--perl-install/swap.pm3
10 files changed, 197 insertions, 421 deletions
diff --git a/perl-install/Makefile b/perl-install/Makefile
index 68fe70782..178b3c15a 100644
--- a/perl-install/Makefile
+++ b/perl-install/Makefile
@@ -14,7 +14,8 @@ tags:
clean:
test ! -e c/Makefile || $(MAKE) -C c clean
- find . -name "*~" -name "TAGS" -name "*.old" | xargs rm -f
+ rm -f c/c.xs
+ find . -name "*~" -o -name "TAGS" -o -name "*.old" | xargs rm -f
tar: clean
cd .. ; tar cfy perl-install.tar.bz2 --exclude perl-install/perl perl-install
diff --git a/perl-install/fs.pm b/perl-install/fs.pm
index cf29fe014..225f5341b 100644
--- a/perl-install/fs.pm
+++ b/perl-install/fs.pm
@@ -95,8 +95,6 @@ sub mount($$$;$) {
my ($dev, $where, $fs, $rdonly) = @_;
log::l("mounting $dev on $where as type $fs");
- $::testing and return;
-
-d $where or commands::mkdir_('-p', $where);
if ($fs eq 'nfs') {
@@ -187,8 +185,6 @@ sub write($$) {
# is not what we want to symlink to /dev/cdrom.
my $cddev = first(grep { $_ ne 'root' } map { $_->{device} } @cd_drives);
- $::testing and return 1;
-
log::l("resetting /etc/mtab");
local *F;
open F, "> $prefix/etc/mtab" or die "error resetting $prefix/etc/mtab";
diff --git a/perl-install/fsedit.pm b/perl-install/fsedit.pm
index fb2703e8f..62c384832 100644
--- a/perl-install/fsedit.pm
+++ b/perl-install/fsedit.pm
@@ -42,7 +42,7 @@ sub hds($$) {
eval { $rc = partition_table::read($hd, $flags->{clearall}) };
if ($@) {
$@ =~ /bad magic number/ or die;
- $flags->{forcezero} && !$::testing ? partition_table_raw::zero_MBR($hd) : die;
+ partition_table_raw::zero_MBR($hd) if $flags->{forcezero};
}
$rc ? push @hds, $hd : log::l("An error occurred reading the partition table for the block device $_->{device}");
}
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");
diff --git a/perl-install/install_steps.pm b/perl-install/install_steps.pm
index 123507929..9e4a3c1c0 100644
--- a/perl-install/install_steps.pm
+++ b/perl-install/install_steps.pm
@@ -3,70 +3,84 @@ package install_steps;
use diagnostics;
use strict;
+use common qw(:file :system);
use lang;
use keyboard;
use pkgs;
use cpio;
use log;
use fsedit;
-
+use commands;
+use smp;
1;
-sub new($) {
- my ($type, $I) = @_;
+sub new($$) {
+ my ($type, $o) = @_;
- bless $I, ref $type || $type;
+ bless $o, ref $type || $type;
}
+sub selectInstallOrUpgrade($) {
+ my ($o) = @_;
+ $o->{isUpgrade} || $o->{default}->{isUpgrade} || 0;
+}
+sub selectInstallClass($) {
+ my ($o) = @_;
+ $o->{installClass} || $o->{default}->{installClass} || 'Custom';
+}
+sub setupSCSIInterfaces {
+ die "TODO";
+}
sub doPartitionDisks($$$) {
- my ($I, $hds) = @_;
- fsedit::auto_allocate($hds, $I->{partitions});
+ my ($o, $hds) = @_;
+ fsedit::auto_allocate($hds, $o->{partitions});
}
-sub choosePackages($$$$) {
- my ($I, $packages, $comps, $isUpgrade) = @_;
+sub choosePackages($$$) {
+ my ($o, $packages, $comps) = @_;
- foreach ('base', @{$I->{comps}}) {
+ foreach ('base', @{$o->{comps}}) {
$comps->{$_}->{selected} = 1;
foreach (@{$_->{packages}}) { $_->{selected} = 1; }
}
- foreach (@{$I->{packages}}) { $_->{selected} = 1; }
+ foreach (@{$o->{packages}}) { $_->{selected} = 1; }
smp::detect() and $packages->{"kernel-smp"}->{selected} = 1;
}
-sub beforeInstallPackages($$$) {
- my ($I, $method, $fstab, $isUpgrade) = @_;
+sub beforeInstallPackages($$) {
+ my ($o, $fstab) = @_;
- $method->prepareMedia($fstab);
+ $o->{method}->prepareMedia($fstab);
foreach (qw(dev etc home mnt tmp var var/tmp var/lib var/lib/rpm)) {
- mkdir "$prefix/$_", 0755;
+ mkdir "$o->{prefix}/$_", 0755;
}
- unless ($isUpgrade) {
+ unless ($o->{isUpgrade}) {
local *F;
- open F, "> $prefix/etc/hosts" or die "Failed to create etc/hosts: $!";
+ open F, "> $o->{prefix}/etc/hosts" or die "Failed to create etc/hosts: $!";
print F "127.0.0.1 localhost localhost.localdomain\n";
}
}
-sub installPackages($$$$$) {
- my ($I, $prefix, $method, $packages, $isUpgrade) = @_;
-
- pkgs::install($prefix, $method, $packages, $isUpgrade, 0);
+sub installPackages($$) {
+ my ($o, $packages) = @_;
+ my $toInstall = [ $packages->{basesystem},
+ grep { $_->{selected} && $_->{name} ne "basesystem" } values %$packages ];
+ pkgs::install($o->{prefix}, $o->{method}, $toInstall, $o->{isUpgrade}, 0);
}
-sub afterInstallPackages($$$$) {
- my ($prefix, $keymap, $isUpgrade) = @_;
+sub afterInstallPackages($$) {
+ my ($o, $keymap) = @_;
- unless ($isUpgrade) {
- keyboard::write($prefix, $keymap);
- lang::write($prefix);
+ unless ($o->{isUpgrade}) {
+ keyboard::write($o->{prefix}, $keymap);
+ lang::write($o->{prefix});
}
# why not?
sync(); sync();
@@ -74,46 +88,44 @@ sub afterInstallPackages($$$$) {
# configPCMCIA($o->{rootPath}, $o->{pcmcia});
}
-sub addUser($$) {
- my ($I, $prefix) = @_;
+sub addUser($) {
+ my ($o) = @_;
+ my $p = $o->{prefix};
my $new_uid;
- #my @uids = map { (split)[2] } cat__("$prefix/etc/passwd");
+ #my @uids = map { (split)[2] } cat__("$p/etc/passwd");
#for ($new_uid = 500; member($new_uid, @uids); $new_uid++) {}
for ($new_uid = 500; getpwuid($new_uid); $new_uid++) {}
my $new_gid;
- #my @gids = map { (split)[2] } cat__("$prefix/etc/group");
+ #my @gids = map { (split)[2] } cat__("$p/etc/group");
#for ($new_gid = 500; member($new_gid, @gids); $new_gid++) {}
for ($new_gid = 500; getgrgid($new_gid); $new_gid++) {}
- my $homedir = "$prefix/home/$default->{user}->{name}";
+ my $homedir = "$p/home/$o->{user}->{name}";
- my $pw = crypt_($default->{user}->{password});
+ my $pw = crypt_($o->{user}->{password});
- unless ($testing) {
- {
- local *F;
- open F, ">> $prefix/etc/passwd" or die "can't append to passwd file: $!";
- print F "$default->{user}->{name}:$pw:$new_uid:$new_gid:$default->{user}->{realname}:/home/$default->{user}->{name}:$default->{user}->{shell}\n";
+ local *F;
+ open F, ">> $p/etc/passwd" or die "can't append to passwd file: $!";
+ print F "$o->{user}->{name}:$pw:$new_uid:$new_gid:$o->{user}->{realname}:/home/$o->{user}->{name}:$o->{user}->{shell}\n";
- open F, ">> $prefix/etc/group" or die "can't append to group file: $!";
- print F "$default->{user}->{name}::$new_gid:\n";
- }
- eval { commands::cp("-f", "$prefix/etc/skel", $homedir) }; $@ and log::l("copying of skel failed: $@"), mkdir($homedir, 0750);
- commands::chown_("-r", "$new_uid.$new_gid", $homedir);
- }
+ open F, ">> $p/etc/group" or die "can't append to group file: $!";
+ print F "$o->{user}->{name}::$new_gid:\n";
+
+ eval { commands::cp("-f", "$p/etc/skel", $homedir) }; $@ and log::l("copying of skel failed: $@"), mkdir($homedir, 0750);
+ commands::chown_("-r", "$new_uid.$new_gid", $homedir);
}
sub setRootPassword($$) {
- my ($I, $prefix) = @_;
-
- my $pw = $default->{rootPassword};
+ my ($o) = @_;
+ my $p = $o->{prefix};
+ my $pw = $o->{rootPassword};
$pw = crypt_($pw);
- my @lines = cat_("$prefix/etc/passwd", 'die');
+ my @lines = cat_("$p/etc/passwd", 'die');
local *F;
- open F, "> $prefix/etc/passwd" or die "can't write in passwd: $!\n";
+ open F, "> $p/etc/passwd" or die "can't write in passwd: $!\n";
foreach (@lines) {
s/^root:.*?:/root:$pw:/;
print F $_;
@@ -122,99 +134,68 @@ sub setRootPassword($$) {
sub setupXfree {
-# my ($method, $prefix, $psp) = @_;
-# int fd, i;
-# char buf[200], * chptr;
-# char server[50];
-# int rc;
-# char * path;
-# char * procPath;
-# rpmdb db;
-# rpmTransactionSet trans;
-# struct callbackInfo cbi;
-# rpmProblemSet probs;
-#
-# if (rpmdbOpen(prefix, &db, O_RDWR | O_CREAT, 0644)) {
-# errorWindow(_("Fatal error reopening RPM database"));
-# return INST_ERROR;
-# }
-# log::l("reopened rpm database");
-#
-# path = alloca(strlen(prefix) + 200);
-# procPath = alloca(strlen(prefix) + 50);
-# sprintf(path, "%s/usr/X11R6/bin/Xconfigurator", prefix);
-#
-# # This is a cheap trick to see if our X component was installed
-# if (access(path, X_OK)) {
-# log::l("%s cannot be run", path);
-# return INST_OKAY;
-# }
-#
-# # need proc to do pci probing
-# sprintf(procPath, "%s/proc", prefix);
-# umount(procPath);
-# if ((rc = doMount("/proc", procPath, "proc", 0, 0))) {
-# return INST_ERROR;
-# }
-#
-# # this handles kickstart and normal/expert modes
-# if ((rc=xfree86Config(prefix, "--pick")))
-# return INST_ERROR;
-#
-# sprintf(path, "%s/tmp/SERVER", prefix);
-# if ((fd = open(path, O_RDONLY)) < 0) {
-# log::l("failed to open %s: %s", path, strerror(errno));
-# return INST_ERROR;
-# }
-#
-# buf[0] = '\0';
-# read(fd, buf, sizeof(buf));
-# close(fd);
-# chptr = buf;
-# while (chptr < (buf + sizeof(buf) - 1) && *chptr && *chptr != ' ')
-# chptr++;
-#
-# if (chptr >= (buf + sizeof(buf) - 1) || *chptr != ' ') {
-# log::l("couldn't find ' ' in %s", path);
-# return INST_ERROR;
-# }
-#
-# *chptr = '\0';
-# strcpy(server, "XFree86-");
-# strcat(server, buf);
-#
-# log::l("I will install the %s package", server);
-#
-# for (i = 0; i < psp->numPackages; i++) {
-# if (!strcmp(psp->packages[i]->name, server)) {
-# log::l("\tfound package: %s", psp->packages[i]->name);
-# swOpen(1, psp->packages[i]->size);
-# trans = rpmtransCreateSet(db, prefix);
-# rpmtransAddPackage(trans, psp->packages[i]->h, NULL,
-# psp->packages[i], 0, NULL);
-#
-# cbi.method = method;
-# cbi.upgrade = 0;
-#
-# rpmRunTransactions(trans, swCallback, &cbi, NULL, &probs, 0,
-# 0xffffffff);
-#
-# swClose();
-# break;
-# }
-# }
-#
-# # this handles kickstart and normal/expert modes
-# if ((rc=xfree86Config(prefix, "--continue")))
-# return INST_ERROR;
-#
-# # done with proc now
-# umount(procPath);
-#
-# rpmdbClose(db);
-#
-# log::l("rpm database closed");
-#
-# return INST_OKAY;
+
+ if (rpmdbOpen(prefix, &db, O_RDWR | O_CREAT, 0644)) {
+ errorWindow(_("Fatal error reopening RPM database"));
+ return INST_ERROR;
+ }
+ log::l("reopened rpm database");
+
+ sprintf(path, "%s/tmp/SERVER", prefix);
+ if ((fd = open(path, O_RDONLY)) < 0) {
+ log::l("failed to open %s: %s", path, strerror(errno));
+ return INST_ERROR;
+ }
+
+ buf[0] = '\0';
+ read(fd, buf, sizeof(buf));
+ close(fd);
+ chptr = buf;
+ while (chptr < (buf + sizeof(buf) - 1) && *chptr && *chptr != ' ')
+ chptr++;
+
+ if (chptr >= (buf + sizeof(buf) - 1) || *chptr != ' ') {
+ log::l("couldn't find ' ' in %s", path);
+ return INST_ERROR;
+ }
+
+ *chptr = '\0';
+ strcpy(server, "XFree86-");
+ strcat(server, buf);
+
+ log::l("I will install the %s package", server);
+
+ for (i = 0; i < psp->numPackages; i++) {
+ if (!strcmp(psp->packages[i]->name, server)) {
+ log::l("\tfound package: %s", psp->packages[i]->name);
+ swOpen(1, psp->packages[i]->size);
+ trans = rpmtransCreateSet(db, prefix);
+ rpmtransAddPackage(trans, psp->packages[i]->h, NULL,
+ psp->packages[i], 0, NULL);
+
+ cbi.method = method;
+ cbi.upgrade = 0;
+
+ rpmRunTransactions(trans, swCallback, &cbi, NULL, &probs, 0,
+ 0xffffffff);
+
+ swClose();
+ break;
+ }
+ }
+
+ # this handles kickstart and normal/expert modes
+ if ((rc=xfree86Config(prefix, "--continue")))
+ return INST_ERROR;
+
+ # done with proc now
+ umount(procPath);
+
+ rpmdbClose(db);
+
+ log::l("rpm database closed");
+
+ return INST_OKAY;
}
+sub exitInstall {}
diff --git a/perl-install/keyboard.pm b/perl-install/keyboard.pm
index 233aafda1..267b0be95 100644
--- a/perl-install/keyboard.pm
+++ b/perl-install/keyboard.pm
@@ -43,21 +43,18 @@ sub load($) {
my $key = 0;
foreach my $value (@keymap) {
c::KTYP($value) != c::KT_SPEC() or next;
- ioctl(F, c::KDSKBENT(), pack("CCS", $_, $key++, $value)) or log::l("keymap ioctl failed: $!");
+ ioctl(F, c::KDSKBENT(), pack("CCS", $_, $key++, $value)) or die "keymap ioctl failed: $!";
$key++;
}
$count++;
}
log::l("loaded $count keymap tables");
- 1;
}
sub setup($) {
my ($defkbd) = @_;
my $t;
- #$::testing and return 1;
-
$defkbd ||= $defaultKeyboards{$ENV{LANG}} || "us";
local *F;
@@ -77,24 +74,21 @@ sub setup($) {
}
foreach (@infoTable) {
- read F, $t, $_->[0] or log::l("error reading $_->[0] bytes from file: $!"), return;
+ read F, $t, $_->[0] or die "error reading keymap data: $!";
if ($defkbd eq $_->[1]) {
log::l("using keymap $_->[1]");
- load($t) or return;
- &write("/tmp", $_->[1]) or log::l("write keyboard config failed");
- return $_->[1];
+ load($t);
+ &write("/tmp", $_->[1]);
+ return;
}
}
- undef;
+ die "keyboard $defkbd not found in /etc/keymaps";
}
sub write($$) {
my ($prefix, $keymap) = @_;
- $keymap or return 1;
- $::testing and return 1;
-
local *F;
open F, ">$prefix/etc/sysconfig/keyboard" or die "failed to create keyboard configuration: $!";
print F "KEYTABLE=$keymap\n" or die "failed to write keyboard configuration: $!";
@@ -102,7 +96,7 @@ sub write($$) {
# write default keymap
if (fork) {
wait;
- $? == 0 or log::l('dumpkeys failed');
+ $? == 0 or die "dumpkeys failed";
} else {
chroot $prefix;
CORE::system("/usr/bin/dumpkeys > /etc/sysconfig/console/default.kmap 2>/dev/null");
@@ -114,15 +108,13 @@ sub read($) {
my ($file) = @_;
local *F;
- open F, "$file" or # fail silently -- old bootdisks won't create this
- log::l("failed to read keyboard configuration (probably ok)"), return;
+ open F, "$file" or die "failed to read keyboard configuration";
foreach (<F>) {
- ($_) = /^KEYTABLE=(.*)/ or die "unrecognized entry in keyboard configuration file";
+ ($_) = /^KEYTABLE=(.*)/ or log::l("unrecognized entry in keyboard configuration file ($_)"), next;
s/\"//g;
s/\.[^.]*//; # remove extension
return basename($_);
}
- log::l("empty keyboard configuration file");
- undef;
+ die "empty keyboard configuration file";
}
diff --git a/perl-install/lang.pm b/perl-install/lang.pm
index 708a6b5da..1d2d6a7f8 100644
--- a/perl-install/lang.pm
+++ b/perl-install/lang.pm
@@ -43,11 +43,11 @@ sub write {
my ($prefix) = @_;
my $lang = $ENV{LANG};
- $::testing || !$lang and return 0;
+ $lang or return;
local *F;
- open F, "> $prefix/etc/sysconfig/i18n";
-
+ open F, "> $prefix/etc/sysconfig/i18n" or die "failed to reset $prefix/etc/sysconfig/i18n for writing";
my $f = sub { $_[1] and print F "$_[0]=$_[1]\n"; };
+
&$f("LANG", $lang);
&$f("LINGUAS", $lang);
if (my $l = $languages{$lang}) {
@@ -61,7 +61,6 @@ sub write {
glob_("$p/consoletrans/$l->{map}*"),
"$prefix/etc/sysconfig/console");
}
- 1;
}
sub load_font {
diff --git a/perl-install/modules.pm b/perl-install/modules.pm
index b6e2ebd9b..8e072ec25 100644
--- a/perl-install/modules.pm
+++ b/perl-install/modules.pm
@@ -262,8 +262,6 @@ sub write_conf {
my ($file, $append) = @_;
my ($tr, $eth, $scsi) = (0, 0, 0);
- $::testing and return 1;
-
$append or rename($file, "$file.orig"), log::l("backing up old conf.modules");
local *F;
diff --git a/perl-install/pkgs.pm b/perl-install/pkgs.pm
index 1f4764d22..e5d4247ac 100644
--- a/perl-install/pkgs.pm
+++ b/perl-install/pkgs.pm
@@ -8,13 +8,23 @@ use log;
use smp;
use fs;
-my @skipList = qw(XFree86-8514 XFree86-AGX XFree86-Mach32 XFree86-Mach64 XFree86-Mach8 XFree86-Mono
- XFree86-P9000 XFree86-S3 XFree86-S3V XFree86-SVGA XFree86-W32 XFree86-I128
- XFree86-Sun XFree86-SunMono XFree86-Sun24 XFree86-3DLabs kernel-boot
- metroess metrotmpl);
+my @skipThesesPackages = qw(XFree86-8514 XFree86-AGX XFree86-Mach32 XFree86-Mach64
+ XFree86-Mach8 XFree86-Mono XFree86-P9000 XFree86-S3 XFree86-S3V
+ XFree86-SVGA XFree86-W32 XFree86-I128 XFree86-Sun XFree86-SunMono
+ XFree86-Sun24 XFree86-3DLabs kernel-boot metroess metrotmpl);
1;
+sub skipThisPackage { member($_[0], @skipList) }
+
+sub addInfosFromHeader($$) {
+ my ($packages, $header) = @_;
+
+ $packages{c::headerGetEntry($header, 'name')} = {
+ header => $header, size => c::headerGetEntry($header, 'size'),
+ group => c::headerGetEntry($header, 'group') || "(unknown group)",
+ };
+}
sub psUsingDirectory {
my ($dirname) = @_;
@@ -27,13 +37,7 @@ sub psUsingDirectory {
open F, $_ or log::l("failed to open package $_: $!");
my $header = c::rpmReadPackageHeader($_) or log::l("failed to rpmReadPackageHeader $basename: $!");
my $name = c::headerGetEntry($header, 'name');
-
- $packages{lc $name} = {
- header => $header, selected => 0, manuallySelected => 0, name => $name,
- size => c::headerGetEntry($header, 'size'),
- group => c::headerGetEntry($header, 'group') || "(unknown group)",
- inmenu => skipPackage($name),
- };
+ addInfosFromHeader($package, $header);
}
\%packages;
}
@@ -57,9 +61,9 @@ sub psReadComponentsFile {
if ($inComp) { if (/^end$/) {
$inComp = 0;
- $comps{lc $current{name}} = { %current };
+ $comps{$current{name}} = { %current };
} else {
- push @{$current{packages}}, $packages->{lc $_} || log::w "package $_ does not exist (line $n of comps file)";
+ push @{$current{packages}}, $packages->{$_} || log::w "package $_ does not exist (line $n of comps file)";
}
} else {
my ($selected, $hidden, $name) = /^([01])\s*(--hide)?\s*(.*)/ or die "bad comps file at line $n";
@@ -124,15 +128,7 @@ sub psFromHeaderListDesc {
$noSeek and last;
die "error reading header at offset ", sysseek($fd, 0, 1);
}
-
- my $name = c::headerGetEntry($header, 'name');
-
- $packages{lc $name} = {
- header => $header, size => c::headerGetEntry($header, 'size'),
- inmenu => skipPackage($name), name => $name,
- group => c::headerGetEntry($header, 'group') || "(unknown group)",
- };
-
+ addInfosFromHeader($packages, $header);
$noSeek or $end <= sysseek($fd, 0, 1) and last;
}
@@ -148,41 +144,29 @@ sub psFromHeaderListFile {
psFromHeaderListDesc(\*F, 0);
}
-sub skipPackage { member($_[0], @skipList) }
-
-sub printSize { }
-sub printGroup { }
-sub printPkg { }
-sub selectPackagesByGroup { }
-sub showPackageInfo { }
-sub queryIndividual { }
+sub init_db {
+ my ($prefix, $isUpgrade) = @_;
-
-sub install {
- my ($rootPath, $method, $packages, $isUpgrade, $force) = @_;
-
- my $f = "$rootPath/tmp/" . ($isUpgrade ? "upgrade" : "install") . ".log";
- local *F;
- open(F, "> $f") ? log::l("opened $f") : log::l("Failed to open $f. No upgrade log will be kept.");
+ my $f = "$prefix/tmp/" . ($isUpgrade ? "upgrade" : "install") . ".log";
+ open(F, "> $f") ? log::l("opened $f") : log::l("Failed to open $f. No install log will be kept.");
my $fd = fileno(F) || log::fd() || 2;
c::rpmErrorSetCallback($fd);
# c::rpmSetVeryVerbose();
- # FIXME: we ought to read /mnt/us/lib/rpmrc if we're in the midst of an upgrade, but it's not obvious how to get RPM to do that.
- # if we set netshared path to "" then we get no files installed
- # addMacro(&globalMacroContext, "_netsharedpath", NULL, netSharedPath ? netSharedPath : "" , RMIL_RPMRC);
-
- $isUpgrade ? c::rpmdbRebuild($rootPath) : c::rpmdbInit($rootPath, 0644) or die "creation/rebuilding of rpm database failed: ", c::rpmErrorString();
+ $isUpgrade ? c::rpmdbRebuild($prefix) : c::rpmdbInit($prefix, 0644) or die "creation/rebuilding of rpm database failed: ", c::rpmErrorString();
+}
+
+sub install {
+ my ($prefix, $method, $toInstall, $isUpgrade, $force) = @_;
- my $db = c::rpmdbOpen($rootPath) or die "error opening RPM database: ", c::rpmErrorString();
+ my $db = c::rpmdbOpen($prefix) or die "error opening RPM database: ", c::rpmErrorString();
log::l("opened rpm database");
- my $trans = c::rpmtransCreateSet($db, $rootPath);
+ my $trans = c::rpmtransCreateSet($db, $prefix);
my ($total, $nb);
- foreach my $p ($packages->{basesystem},
- grep { $_->{selected} && $_->{name} ne "basesystem" } values %$packages) {
+ foreach my $p (@$toInstall) {
my $fullname = sprintf "%s-%s-%s.%s.rpm",
$p->{name},
map { c::headerGetEntry($p->{header}, $_) } qw(version release arch);
@@ -194,7 +178,7 @@ sub install {
c::rpmdepOrder($trans) or c::rpmdbClose($db), c::rpmtransFree($trans), die "error ordering package list: ", c::rpmErrorString();
c::rpmtransSetScriptFd($trans, $fd);
- eval { fs::mount("/proc", "$rootPath/proc", "proc", 0) };
+ eval { fs::mount("/proc", "$prefix/proc", "proc", 0) };
log::ld("starting installation: ", $nb, " packages, ", $total, " bytes");
diff --git a/perl-install/swap.pm b/perl-install/swap.pm
index 675c521a7..4f9fcf1f3 100644
--- a/perl-install/swap.pm
+++ b/perl-install/swap.pm
@@ -64,9 +64,6 @@ sub make($;$) {
my $badpages = 0;
my ($version, $maxpages);
- $devicename or die "nowhere to set up swap on?";
- $::testing and return;
-
$devicename = devices::make($devicename);
my $nbpages = divide(devices::size($devicename), $pagesize);