From 7205391ff143f201ccc699c7348402a5e6d279f7 Mon Sep 17 00:00:00 2001 From: Sebastian Schmelzer Date: Thu, 4 Jun 2009 13:26:19 +0000 Subject: fix "Module not found" bug of distroutils in plugin install routine git-svn-id: http://svn.openslx.org/svn/openslx/openslx/trunk@2932 95ad53e4-c205-0410-b2fa-d234c58c8868 --- lib/OpenSLX/DistroUtils/Engine.pm | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) (limited to 'lib') diff --git a/lib/OpenSLX/DistroUtils/Engine.pm b/lib/OpenSLX/DistroUtils/Engine.pm index 354210e3..2a369ca2 100644 --- a/lib/OpenSLX/DistroUtils/Engine.pm +++ b/lib/OpenSLX/DistroUtils/Engine.pm @@ -29,17 +29,38 @@ sub new sub loadDistro { my $self = shift; my $distroName = shift; + $distroName = ucfirst($distroName); my $distro; + + my $pathToClass = "$openslxConfig{'base-path'}/lib"; + my $flags = {}; + if ($pathToClass) { + $flags->{incPaths} = [ $pathToClass ]; + # if you call this function inside a plugin's install method we have to add /mnt + # in front of the include path! + $flags->{incPaths} = [ "/mnt/$pathToClass" ]; + } + my $loaded = eval { - $distro = instantiateClass("OpenSLX::DistroUtils::${distroName}"); + $distro = instantiateClass("OpenSLX::DistroUtils::${distroName}", $flags); + return 0 if !$distro; # module does not exist, try next + 1; + }; + + if (!$loaded) { + vlog(1, "can't find distro specific class, try base class.."); + $loaded = eval { + $distro = instantiateClass("OpenSLX::DistroUtils::Base", $flags); return 0 if !$distro; # module does not exist, try next 1; }; + } + if (!$loaded) { - $distro = instantiateClass("OpenSLX::DistroUtils::Base"); - print ('couldnt load distro class'); + vlog(1, "failed to load DistroUtils!"); } + return $distro; } -- cgit v1.2.3-55-g7522