From 6fb82427d4e3cb76e20700d8e0cfb609056ec2b9 Mon Sep 17 00:00:00 2001 From: Bastian Wissler Date: Fri, 5 Jun 2009 18:17:40 +0000 Subject: Various changes to xserver plugin: * added support for kernel version detection - yet from local function * now falls back to ati package installation, if download fails ATTENTION: If you have a recent Kernel Version in Suse-11.1, consider downgrading your Kernel to support fglrx-drivers from their RPM repository. git-svn-id: http://svn.openslx.org/svn/openslx/openslx/trunk@2937 95ad53e4-c205-0410-b2fa-d234c58c8868 --- lib/OpenSLX/DistroUtils.pm | 22 ++++++++++++++++++++++ lib/OpenSLX/DistroUtils/Base.pm | 35 ++++++++++++++++++++++++++++++++++- lib/OpenSLX/DistroUtils/Engine.pm | 8 ++++++-- 3 files changed, 62 insertions(+), 3 deletions(-) (limited to 'lib') diff --git a/lib/OpenSLX/DistroUtils.pm b/lib/OpenSLX/DistroUtils.pm index dd29a46a..1bda311f 100644 --- a/lib/OpenSLX/DistroUtils.pm +++ b/lib/OpenSLX/DistroUtils.pm @@ -19,6 +19,8 @@ use warnings; use OpenSLX::Utils; use OpenSLX::Basics; +use Data::Dumper; + use OpenSLX::DistroUtils::Engine; use OpenSLX::DistroUtils::InitFile; @@ -34,6 +36,7 @@ $VERSION = 1.01; newInitFile getInitFileForDistro simpleInitFile + getKernelVersionForDistro ); @@ -68,6 +71,25 @@ sub getInitFileForDistro { return $distro->generateInitFile($initFile); } +sub getKernelVersionForDistro { + my $kernelPath = shift; + my $distroName = shift; + + + print Dumper(@INC); + + my $engine = OpenSLX::DistroUtils::Engine->new(); + my $distro; + + if ($distroName) { + $distro = $engine->loadDistro($distroName); + } else { + $distro = $engine->loadDistro('Base'); + } + + return $distro->getKernelVersion($kernelPath); + +} diff --git a/lib/OpenSLX/DistroUtils/Base.pm b/lib/OpenSLX/DistroUtils/Base.pm index 90cad7a0..f4eb45c8 100644 --- a/lib/OpenSLX/DistroUtils/Base.pm +++ b/lib/OpenSLX/DistroUtils/Base.pm @@ -356,5 +356,38 @@ sub generateInitFile } +sub getKernelVersion +{ + my $self = shift; + my $kernelPath = shift; + + + my $newestKernelFile; + my $newestKernelFileSortKey = ''; + my $kernelPattern = '{vmlinuz,kernel-genkernel-x86}-*'; + foreach my $kernelFile (glob("$kernelPath/$kernelPattern")) { + next unless $kernelFile =~ m{ + (?:vmlinuz|x86)-(\d+)\.(\d+)\.(\d+)(?:\.(\d+))?-(\d+(?:\.\d+)?) + }x; + my $sortKey + = sprintf("%02d.%02d.%02d.%02d-%2.1f", $1, $2, $3, $4||0, $5); + if ($newestKernelFileSortKey lt $sortKey) { + $newestKernelFile = $kernelFile; + $newestKernelFileSortKey = $sortKey; + } + } + + if (!defined $newestKernelFile) { + die _tr("unable to pick a kernel-file from path '%s'!", $kernelPath); + } + + $newestKernelFile =~ /.*?-([.\-0-9]*)-([a-zA-Z]*?)$/; + my $kernel = {}; + $kernel->{'version'} = $1; + $kernel->{'suffix'} = $2; + return $kernel; + +} + -1; \ No newline at end of file +1; diff --git a/lib/OpenSLX/DistroUtils/Engine.pm b/lib/OpenSLX/DistroUtils/Engine.pm index 88a1f166..839e6564 100644 --- a/lib/OpenSLX/DistroUtils/Engine.pm +++ b/lib/OpenSLX/DistroUtils/Engine.pm @@ -14,6 +14,7 @@ package OpenSLX::DistroUtils::Engine; use OpenSLX::Basics; +use Data::Dumper; use strict; use warnings; @@ -35,11 +36,13 @@ sub loadDistro { my $pathToClass = "$openslxConfig{'base-path'}/lib"; my $flags = {}; - $flags->{incPaths} = [ $pathToClass, "/mnt/$pathToClass" ]; + #$flags->{incPaths} = [ $pathToClass, "/mnt/$pathToClass" ]; # for the case we call this function inside the chrooted environment of a plugin's # install method we add the corrected searchpath to INC # TODO: fix this problem via plugin engine + print 'DUMP INC 2'; + print Dumper(@INC); my $loaded = eval { $distro = instantiateClass("OpenSLX::DistroUtils::${distroName}", $flags); return 0 if !$distro; # module does not exist, try next @@ -57,9 +60,10 @@ sub loadDistro { if (!$loaded) { vlog(1, "failed to load DistroUtils!"); + vlog(1, $distroName); } return $distro; } -1; \ No newline at end of file +1; -- cgit v1.2.3-55-g7522