summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xconfig-db/slxconfig-demuxer5
-rw-r--r--installer/OpenSLX/OSExport/ExportType/NBD_Squash.pm39
-rw-r--r--lib/OpenSLX/Utils.pm19
3 files changed, 45 insertions, 18 deletions
diff --git a/config-db/slxconfig-demuxer b/config-db/slxconfig-demuxer
index f6ebc6f8..65a4ef05 100755
--- a/config-db/slxconfig-demuxer
+++ b/config-db/slxconfig-demuxer
@@ -379,9 +379,10 @@ sub generateInitalRamFS
# (since the latter is unable to fetch NIS-stuff).
# ...set kernel version...
- my $kernelFile = readlink($info->{'kernel-file'});
+ my $kernelFile = basename(followLink($info->{'kernel-file'}));
$kernelFile =~ m[-(.+)$];
- $cmd .= "-k $1 ";
+ my $kernelVersion = $1;
+ $cmd .= "-k $kernelVersion ";
# ...add version info...
my $slxver = `slxversion`;
chomp $slxver;
diff --git a/installer/OpenSLX/OSExport/ExportType/NBD_Squash.pm b/installer/OpenSLX/OSExport/ExportType/NBD_Squash.pm
index d5782b59..a581bfcc 100644
--- a/installer/OpenSLX/OSExport/ExportType/NBD_Squash.pm
+++ b/installer/OpenSLX/OSExport/ExportType/NBD_Squash.pm
@@ -23,6 +23,7 @@ use File::Basename;
use OpenSLX::Basics;
use OpenSLX::ConfigDB qw(:support);
use OpenSLX::OSExport::ExportType::Base 1.01;
+use OpenSLX::Utils;
################################################################################
### interface methods
@@ -68,34 +69,38 @@ sub checkRequirements
my $self = shift;
my $vendorOSPath = shift;
my $kernel = shift || 'vmlinuz';
+ my $info = shift;
- while (-l "$vendorOSPath/boot/$kernel") {
- $kernel = readlink "$vendorOSPath/boot/$kernel";
- }
- if ($kernel !~ m[^vmlinuz-(.+)$]) {
+ $kernel = basename(followLink("$vendorOSPath/boot/$kernel"));
+ if ($kernel !~ m[-(.+)$]) {
die _tr("unable to determine version of kernel '%s'!", $kernel);
}
my $kernelVer = $1;
- if (!locateKernelModule(
+ my $nbdMod = locateKernelModule(
$vendorOSPath,
'nbd.ko',
- ["$vendorOSPath/lib/modules/$kernelVer/kernel/drivers/block"])
- ) {
+ ["$vendorOSPath/lib/modules/$kernelVer/kernel/drivers/block"]
+ );
+ if (!defined $nbdMod) {
warn _tr("unable to find nbd-module for kernel version '%s'.",
$kernelVer);
- return 0;
+ return undef;
}
- if (!locateKernelModule(
+ my $squashfsMod = locateKernelModule(
$vendorOSPath,
'squashfs.ko',
["$vendorOSPath/lib/modules/$kernelVer/kernel/fs/squashfs",
- "$vendorOSPath/lib/modules/$kernelVer/kernel/fs"])
- ) {
+ "$vendorOSPath/lib/modules/$kernelVer/kernel/fs"]
+ );
+ if (!defined $squashfsMod) {
warn _tr("unable to find squashfs-module for kernel version '%s'.",
$kernelVer);
- return 0;
+ return undef;
}
- 1;
+ if (defined $info) {
+ $info->{'kernel-mods'} = [ $nbdMod, $squashfsMod ];
+ };
+ return 1;
}
sub addExportToConfigDB
@@ -232,7 +237,8 @@ sub locateKernelModule
# check default paths first:
foreach my $defPath (@$defaultPaths) {
vlog 2, "trying $defPath/$moduleName";
- return "$defPath/$moduleName" if -e "$defPath/$moduleName";
+ my $target = followLink("$defPath/$moduleName", $vendorOSPath);
+ return $target unless !-e $target;
}
# use brute force to search for the newest incarnation of the module:
use File::Find;
@@ -247,7 +253,10 @@ sub locateKernelModule
vlog 2, "located at $location (age=$locationAge days)";
}
}, "$vendorOSPath/lib/modules";
- return $location;
+ if (defined $location) {
+ return followLink($location, $vendorOSPath);
+ }
+ return undef;
}
1;
diff --git a/lib/OpenSLX/Utils.pm b/lib/OpenSLX/Utils.pm
index d86167a2..779640d5 100644
--- a/lib/OpenSLX/Utils.pm
+++ b/lib/OpenSLX/Utils.pm
@@ -21,7 +21,7 @@ $VERSION = 1.01;
@ISA = qw(Exporter);
@EXPORT = qw(
- &copyFile &fakeFile &linkFile &slurpFile
+ &copyFile &fakeFile &linkFile &slurpFile &followLink
);
################################################################################
@@ -86,4 +86,21 @@ sub slurpFile
return $text;
}
+sub followLink
+{
+ my $path = shift;
+ my $prefixedPath = shift || '';
+
+ my $target;
+ while (-l "$path") {
+ $target = readlink "$path";
+ if (substr($target, 1, 1) eq '/') {
+ $path = "$prefixedPath/$target";
+ } else {
+ $path = $prefixedPath.dirname($path).'/'.$target;
+ }
+ }
+ return $path;
+}
+
1; \ No newline at end of file