From cbce11c51c6aa5674b01821a7adc7c31f7999c7e Mon Sep 17 00:00:00 2001 From: Oliver Tappe Date: Sat, 28 Jul 2007 14:11:27 +0000 Subject: * changed several class interfaces as a result of trying to integrate support for Debian & Ubunto installation (which is still not complete, though) * fixed some bugs along the way (especially the meta-packagers trying to invoke a private function of OpenSLX::OSSetup::Engine) git-svn-id: http://svn.openslx.org/svn/openslx/trunk@1281 95ad53e4-c205-0410-b2fa-d234c58c8868 --- installer/OpenSLX/OSSetup/Distro/Base.pm | 62 +++++++++++++++++++++++++++++--- 1 file changed, 58 insertions(+), 4 deletions(-) (limited to 'installer/OpenSLX/OSSetup/Distro/Base.pm') diff --git a/installer/OpenSLX/OSSetup/Distro/Base.pm b/installer/OpenSLX/OSSetup/Distro/Base.pm index 9b59a828..020215ea 100644 --- a/installer/OpenSLX/OSSetup/Distro/Base.pm +++ b/installer/OpenSLX/OSSetup/Distro/Base.pm @@ -20,6 +20,7 @@ our $VERSION = 1.01; # API-version . implementation-version use File::Basename; use OpenSLX::Basics; +use OpenSLX::Utils; ################################################################################ ### interface methods @@ -121,6 +122,63 @@ sub initDistroInfo sub startSession { + my $self = shift; + my $osDir = shift; + + # ensure that the session will be finished even if the script crashes: + addCleanupFunction( + "slxos-setup::distro::chroot", sub { $self->finishSession(); } + ); + + # make sure there's a /dev/zero and /dev/null + if (!-e "$osDir/dev" && !mkdir("$osDir/dev")) { + die _tr("unable to create folder '%s' (%s)\n", "$osDir/dev", $!); + } + if (!-e "$osDir/dev/zero" && slxsystem("mknod $osDir/dev/zero c 1 5")) { + die _tr("unable to create node '%s' (%s)\n", "$osDir/dev/zero", $!); + } + if (!-e "$osDir/dev/null" && slxsystem("mknod $osDir/dev/null c 1 3")) { + die _tr("unable to create node '%s' (%s)\n", "$osDir/dev/null", $!); + } + + # fake proc, depending on what is needed ... + if (!-e "$osDir/proc" && !mkdir("$osDir/proc")) { + die _tr("unable to create folder '%s' (%s)\n", "$osDir/proc", $!); + } + if (!-e "$osDir/proc/cpuinfo" && slxsystem("cp /proc/cpuinfo $osDir/proc/")) { + die _tr("unable to copy file '%s' (%s)\n", "/proc/cpuinfo", $!); + } + # TODO: alternatively, we could mount proc, but that causes problems + # when we are not able to umount it properly (which may happen + # if 'umount' is not available in the chroot!) + # + # mount /proc +# if (!-e "$osDir/proc") { +# slxsystem("mkdir -p $osDir/proc"); +# } +# if (slxsystem("mount -t proc proc $osDir/proc 2>/dev/null")) { +# die _tr("unable to mount '%s' (%s)\n", "$osDir/proc", $!); +# } + + # enter chroot jail + chrootInto($osDir); + $ENV{PATH} = "/bin:/sbin:/usr/bin:/usr/sbin"; + + return; +} + +sub finishSession +{ + my $self = shift; + + removeCleanupFunction('slxos-setup::distro::chroot'); + + # unmount /proc +# if (slxsystem('ash', '-c', 'umount /proc 2>/dev/null')) { +# die _tr("unable to unmount '%s' (%s)\n", "/proc", $!); +# } + + return; } sub updateDistroConfig @@ -130,10 +188,6 @@ sub updateDistroConfig } } -sub finishSession -{ -} - sub pickKernelFile { my $self = shift; -- cgit v1.2.3-55-g7522