From 86463959539587187b098eb1762d2238d856587d Mon Sep 17 00:00:00 2001 From: Oliver Tappe Date: Fri, 20 Mar 2009 12:28:32 +0000 Subject: * in an attempt to solve #399 (and #398), we now mount the host's perl core path into the vendor-OS before chrooting into it for every plugin, which seems to solve the dynamic loading issue described in these two tickets git-svn-id: http://svn.openslx.org/svn/openslx/openslx/trunk@2749 95ad53e4-c205-0410-b2fa-d234c58c8868 --- os-plugins/OpenSLX/OSPlugin/Engine.pm | 33 ++++++++++++++++++++++++++++++--- 1 file changed, 30 insertions(+), 3 deletions(-) (limited to 'os-plugins/OpenSLX/OSPlugin') diff --git a/os-plugins/OpenSLX/OSPlugin/Engine.pm b/os-plugins/OpenSLX/OSPlugin/Engine.pm index c5e6a99f..112a7683 100644 --- a/os-plugins/OpenSLX/OSPlugin/Engine.pm +++ b/os-plugins/OpenSLX/OSPlugin/Engine.pm @@ -18,6 +18,7 @@ use warnings; our $VERSION = 1.01; # API-version . implementation-version +use Config; use File::Basename; use File::Path; use Storable; @@ -631,13 +632,18 @@ sub _callChrootedFunctionForPlugin # via other processes (which could cause problems) my $osSetupEngine = $self->_osSetupEngine(); - # bind-mount openslx basepath to /mnt/openslx of vendor-OS: + # prepare bind-mount of openslx base and config paths to /mnt of + # vendor-OS: my $basePath = $openslxConfig{'base-path'}; my $basePathInChroot = "$self->{'vendor-os-path'}/mnt/opt/openslx"; mkpath($basePathInChroot); my $configPath = $openslxConfig{'config-path'}; my $configPathInChroot = "$self->{'vendor-os-path'}/mnt/etc/opt/openslx"; mkpath($configPathInChroot); + # prepare bind-mount of host's perl corelib path to /mnt of vendor-OS: + my $hostPerlCorePath = $Config{privlibexp}; + my $hostPerlCorePathInChroot = "$self->{'vendor-os-path'}/mnt/host-perl"; + mkpath($hostPerlCorePathInChroot); my $pluginSession = OpenSLX::ScopedResource->new({ name => 'osplugin::session', @@ -655,17 +661,38 @@ sub _callChrootedFunctionForPlugin "unable to bind mount '%s' to '%s'! (%s)", $configPath, $configPathInChroot, $! ); + # Bind mount hosts perl core path into vendor-OS and add it to + # perl's search paths, in order to let dynamic loading of perl + # modules/scripts work. Currently, we hope that only the perl core + # path (privlibexp) is required for that, but we might have to + # mount the architecture dependent path (archlibexp) or the + # vendor perl paths (vendorlibexp and vendorarchexp), too. + slxsystem( + "mount -o bind -o ro $hostPerlCorePath $hostPerlCorePathInChroot" + ) == 0 + or die _tr( + "unable to bind mount '%s' to '%s'! (%s)", + $hostPerlCorePath, $hostPerlCorePathInChroot, $! + ); + unshift @INC, '/mnt/host-perl'; 1 }, release => sub { - slxsystem("umount $basePathInChroot") == 0 + if ($INC[0] eq '/mnt/host-perl') { + shift @INC; + } + slxsystem("umount $hostPerlCorePathInChroot") == 0 or die _tr( - "unable to umount '%s'! (%s)", $basePathInChroot, $! + "unable to umount '%s'! (%s)", $hostPerlCorePathInChroot, $! ); slxsystem("umount $configPathInChroot") == 0 or die _tr( "unable to umount '%s'! (%s)", $configPathInChroot, $! ); + slxsystem("umount $basePathInChroot") == 0 + or die _tr( + "unable to umount '%s'! (%s)", $basePathInChroot, $! + ); 1 }, }); -- cgit v1.2.3-55-g7522