diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/OpenSLX/DistroUtils/Engine.pm | 27 |
1 files changed, 24 insertions, 3 deletions
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; } |