From 112bbb1bf3d2d7f1fd66fa6f8e558744d0784226 Mon Sep 17 00:00:00 2001 From: Oliver Tappe Date: Sun, 23 Mar 2008 15:18:42 +0000 Subject: * moved syscall related code into a module of its own right * activated mounting of /proc again in startSession() and finishSession(), this time in a more robust fashion (which tries hard to unmount it again) git-svn-id: http://svn.openslx.org/svn/openslx/openslx/trunk@1677 95ad53e4-c205-0410-b2fa-d234c58c8868 --- installer/OpenSLX/OSSetup/Distro/Base.pm | 67 +++++++++++++++----------------- installer/OpenSLX/OSSetup/Engine.pm | 37 +++++------------- 2 files changed, 41 insertions(+), 63 deletions(-) (limited to 'installer/OpenSLX') diff --git a/installer/OpenSLX/OSSetup/Distro/Base.pm b/installer/OpenSLX/OSSetup/Distro/Base.pm index d2931046..39572e5d 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 Fcntl qw(:DEFAULT :flock); use File::Basename; +use File::Path; use OpenSLX::Basics; use OpenSLX::Utils; @@ -126,9 +127,13 @@ sub startSession "slxos-setup::distro::chroot", sub { $self->finishSession(); } ); + # setup a fixed locale environment to avoid warnings about unset locales + # (like for instance shown by apt-get) + $ENV{LC_ALL} = 'POSIX'; + # make sure there's a /dev/zero, /dev/null and /dev/urandom # /dev/urandom for passwd chroot - if (!-e "$osDir/dev" && !mkdir("$osDir/dev")) { + if (!-e "$osDir/dev" && !mkpath("$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")) { @@ -141,30 +146,36 @@ sub startSession die _tr("unable to create node '%s' (%s)\n", "$osDir/dev/urandom", $!); } - - # 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} = join(':', @{$self->getDefaultPathList()}); + # mount /proc (if we have 'mount' available) + if (qx{which mount 2>/dev/null}) { + if (!-e "$osDir/proc" && !mkpath("$osDir/proc")) { + die _tr("unable to create folder '%s' (%s)\n", "$osDir/proc", $!); + } + if (slxsystem("mount -t proc proc '/proc'")) { + warn _tr("unable to mount '%s' (%s)\n", "$osDir/proc", $!); + } + } + + return; +} + +sub finishSession +{ + my $self = shift; + + removeCleanupFunction('slxos-setup::distro::chroot'); + + # umount /proc (if we have 'umount' available) + if (qx{which umount 2>/dev/null}) { + if (slxsystem("umount /proc")) { + warn _tr("unable to umount '%s' (%s)\n", "/proc", $!); + } + } + return; } @@ -186,20 +197,6 @@ sub getDefaultPathList ) ]; } -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 { if (slxsystem("ldconfig")) { diff --git a/installer/OpenSLX/OSSetup/Engine.pm b/installer/OpenSLX/OSSetup/Engine.pm index 9030beaa..9518c74a 100644 --- a/installer/OpenSLX/OSSetup/Engine.pm +++ b/installer/OpenSLX/OSSetup/Engine.pm @@ -31,6 +31,7 @@ use File::Basename; use URI; use OpenSLX::Basics; +use OpenSLX::Syscall; use OpenSLX::Utils; use vars qw(%supportedDistros); @@ -1521,8 +1522,13 @@ sub _setupStage1D $self->_stage1D_setupPackageSources(); $self->_stage1D_updateBasicVendorOS(); $self->{distro}->preSystemInstallationHook(); - $self->_stage1D_installPackageSelection(); + my $ok = eval { + $self->_stage1D_installPackageSelection(); + 1; + }; + my $err = $ok ? undef : $@; $self->{distro}->postSystemInstallationHook(); + die $err if defined $err; }, updateConfig => 1, }); @@ -1576,7 +1582,7 @@ sub _callChrootedFunction 'updateConfig' => '?', }); - $self->{'distro'}->startSession($params->{chrootDir}); + $self->{distro}->startSession($params->{chrootDir}); # invoke given function: $params->{function}->(); @@ -1757,36 +1763,11 @@ sub _changePersonalityIfNeeded my $distroName = $self->{'distro-name'}; if ($self->_hostIs64Bit() && $distroName !~ m[_64]) { - # trying to handle a 32-bit vendor-OS on a 64-bit machine, so we change - # the personality accordingly (from 64-bit to 32-bit): - $self->_loadPerlHeader('syscall.ph') - or die _tr("unable to load perl header '%s'\n", 'syscall.ph'); - $self->_loadPerlHeader('linux/personality.ph') - || $self->_loadPerlHeader('sys/personality.ph') - or die _tr("unable to load perl header '%s'\n", 'personality.ph'); - - syscall &SYS_personality, PER_LINUX32(); + OpenSLX::Syscall->enter32BitPersonality(); } return; } -sub _loadPerlHeader -{ - my $self = shift; - my $phFile = shift; - - if (!eval { require $phFile }) { - # perl-header has not been provided by host-OS, so we create it - # manually from C-header (via h2ph): - (my $hFile = $phFile) =~ s{\.ph$}{.h}; - return if !-e "/usr/include/$hFile"; - my $libDir = "$openslxConfig{'base-path'}/lib"; - slxsystem("cd /usr/include && h2ph -d $libDir $hFile") == 0 - or die _tr("unable to create %s! (%s)", $phFile, $!); - } - return eval { require $phFile; 1 }; -} - sub _hostIs64Bit { my $self = shift; -- cgit v1.2.3-55-g7522