summaryrefslogtreecommitdiffstats
path: root/lib/OpenSLX/Syscall.pm
diff options
context:
space:
mode:
authorOliver Tappe2008-10-09 17:17:07 +0200
committerOliver Tappe2008-10-09 17:17:07 +0200
commit35f43c80343f4c37b73f96922e7f0c534dfa93f6 (patch)
tree4a95857bbd90479e59a4125b463b87da03819b35 /lib/OpenSLX/Syscall.pm
parent* tried to get PH-generator to work on more distros (diff)
downloadcore-35f43c80343f4c37b73f96922e7f0c534dfa93f6.tar.gz
core-35f43c80343f4c37b73f96922e7f0c534dfa93f6.tar.xz
core-35f43c80343f4c37b73f96922e7f0c534dfa93f6.zip
* this file was missing from last commit
git-svn-id: http://svn.openslx.org/svn/openslx/openslx/trunk@2280 95ad53e4-c205-0410-b2fa-d234c58c8868
Diffstat (limited to 'lib/OpenSLX/Syscall.pm')
-rw-r--r--lib/OpenSLX/Syscall.pm63
1 files changed, 49 insertions, 14 deletions
diff --git a/lib/OpenSLX/Syscall.pm b/lib/OpenSLX/Syscall.pm
index 3291a402..172db4d0 100644
--- a/lib/OpenSLX/Syscall.pm
+++ b/lib/OpenSLX/Syscall.pm
@@ -30,6 +30,7 @@ before trying to invoke the respective syscall.
=cut
+use Config;
use File::Path;
use OpenSLX::Basics;
@@ -60,27 +61,61 @@ sub _loadPerlHeader
{
my @phFiles = @_;
- my $phLibDir = "$openslxConfig{'base-path'}/lib/ph";
- mkpath($phLibDir) unless -e $phLibDir;
-
+ my @alreadyLoaded = grep { exists $INC{$_} } @phFiles;
+ return if @alreadyLoaded;
+
+ my $phLibDir = $Config{installsitearch};
local @INC = @INC;
- push @INC, $phLibDir;
push @INC, "$phLibDir/asm";
+ # Unability to load an existing Perl header may be caused by missing
+ # asm-(kernel-)headers, since for instance openSUSE 11 does not provide
+ # any of these).
+ # If they are missing, we just have a go at creating all of them:
+ mkpath($phLibDir) unless -e $phLibDir;
+ if (-l "/usr/include/asm" && !-e "$phLibDir/asm") {
+ my $asmFolder = readlink("/usr/include/asm");
+ slxsystem("cd /usr/include && h2ph -rQ -d $phLibDir $asmFolder") == 0
+ or die _tr('unable to create Perl-header from "asm" folder! (%s)', $!);
+ slxsystem("mv $phLibDir/$asmFolder $phLibDir/asm") == 0
+ or die _tr('unable to cleanup "asm" folder for Perl headers! (%s)', $!);
+ }
+ elsif (-d "/usr/include/asm") {
+ slxsystem("cd /usr/include && h2ph -rQ -d $phLibDir asm") == 0
+ or die _tr('unable to create Perl-header from "asm" folder! (%s)', $!);
+ }
+ else {
+ die _tr(
+ 'the folder "/usr/include/asm" is required - please install kernel headers!'
+ );
+ }
+ if (-e "usr/include/asm-generic" && !-e "$phLibDir/asm-generic") {
+ slxsystem("cd /usr/include && h2ph -rQ -d $phLibDir asm-generic") == 0
+ or die _tr('unable to create Perl-header from "asm-generic" folder! (%s)', $!);
+ }
+
for my $phFile (@phFiles) {
- 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};
- if (-e "/usr/include/$hFile") {
- slxsystem("cd /usr/include && h2ph -d $phLibDir $hFile") == 0
- or die _tr('unable to create %s! (%s)', $phFile, $!);
- }
+ return 1 if eval { require $phFile };
+
+ warn(_tr(
+ 'unable to load Perl-header "%s", trying to create it ...',
+ $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};
+ if (-e "/usr/include/$hFile") {
+ slxsystem("cd /usr/include && h2ph -aQ -d $phLibDir $hFile") == 0
+ or die _tr('unable to create %s! (%s)', $phFile, $!);
}
- return 1 if eval { require $phFile; 1 };
+
+ return 1 if eval { require $phFile };
}
+
die _tr(
- 'unable to load any of these perl headers: %s', join(',', @phFiles)
+ 'unable to load any of these perl headers: %s (%s)',
+ join(',', @phFiles), $@
);
}