diff options
| author | Oliver Tappe | 2008-03-15 19:35:27 +0100 |
|---|---|---|
| committer | Oliver Tappe | 2008-03-15 19:35:27 +0100 |
| commit | d7e11726bbd2f8ce5fb6d756fd9bad9a709d988f (patch) | |
| tree | 3be4897b4d6228c6f107e0f3e326a6f9dae2ad65 /os-plugins/OpenSLX/OSPlugin | |
| parent | * added support for stage1 attributes that are stored along each plugin insta... (diff) | |
| download | core-d7e11726bbd2f8ce5fb6d756fd9bad9a709d988f.tar.gz core-d7e11726bbd2f8ce5fb6d756fd9bad9a709d988f.tar.xz core-d7e11726bbd2f8ce5fb6d756fd9bad9a709d988f.zip | |
* intermediate checking for new desktop plugin (successor of displaymanager
with extended scope) - does not work yet, so please do not use!
git-svn-id: http://svn.openslx.org/svn/openslx/openslx/trunk@1634 95ad53e4-c205-0410-b2fa-d234c58c8868
Diffstat (limited to 'os-plugins/OpenSLX/OSPlugin')
| -rw-r--r-- | os-plugins/OpenSLX/OSPlugin/Base.pm | 17 | ||||
| -rw-r--r-- | os-plugins/OpenSLX/OSPlugin/Engine.pm | 61 |
2 files changed, 68 insertions, 10 deletions
diff --git a/os-plugins/OpenSLX/OSPlugin/Base.pm b/os-plugins/OpenSLX/OSPlugin/Base.pm index f1854f2e..5da72f2a 100644 --- a/os-plugins/OpenSLX/OSPlugin/Base.pm +++ b/os-plugins/OpenSLX/OSPlugin/Base.pm @@ -94,6 +94,7 @@ sub initialize my $self = shift; $self->{'os-plugin-engine'} = shift; + $self->{'distro'} = shift; return; } @@ -158,6 +159,22 @@ sub getAttrInfo }; } +=item getDefaultAttrsForVendorOS() + +Returns a hash-ref with the default attribute values for the given vendor-OS. + + + +=cut + +sub getDefaultAttrsForVendorOS +{ + my $self = shift; + + # the default implementation does not change the default values at all: + return $self->getAttrInfo(); +} + =back =head2 Vendor-OS Interface diff --git a/os-plugins/OpenSLX/OSPlugin/Engine.pm b/os-plugins/OpenSLX/OSPlugin/Engine.pm index d42141a7..6211bacd 100644 --- a/os-plugins/OpenSLX/OSPlugin/Engine.pm +++ b/os-plugins/OpenSLX/OSPlugin/Engine.pm @@ -81,6 +81,11 @@ sub initialize = "$openslxConfig{'base-path'}/lib/plugins/$pluginName"; vlog(1, "plugin path is '$self->{'plugin-path'}'"); + # create ossetup-engine for given vendor-OS: + my $osSetupEngine = OpenSLX::OSSetup::Engine->new; + $osSetupEngine->initialize($self->{'vendor-os-name'}, 'plugin'); + $self->{'ossetup-engine'} = $osSetupEngine; + $self->{'plugin'} = $self->_loadPlugin(); return if !$self->{'plugin'}; @@ -104,8 +109,13 @@ sub initialize $pluginName, join(',', @unknownAttrs) ); } + + # merge attributes that were not given on cmdline with the ones that + # already exists in the DB and finally with the default values $self->{'plugin-attrs'} = $givenAttrs; - my $defaultAttrs = $self->{plugin}->getAttrInfo(); + my $defaultAttrs = $self->{plugin}->getDefaultAttrsForVendorOS( + $vendorOSName + ); my $dbAttrs = $self->_fetchInstalledPluginAttrs($vendorOSName); for my $attrName (keys %$defaultAttrs) { next if exists $givenAttrs->{$attrName}; @@ -314,6 +324,15 @@ sub getInstalledPackages return $metaPackager->getInstalledPackages(); } +sub getPackagesForSelection +{ + my $self = shift; + my $selection = shift; + + return $self->{'ossetup-engine'}->getPackagesForSelection($selection); +} + + =item installPackages($packages) Installs the given packages into the vendor-OS. @@ -395,7 +414,30 @@ sub _loadPlugin ); return if !$plugin; - $plugin->initialize($self); + # if there's a distro folder, instantiate the most appropriate distro class + my $distro; + if (-d "$self->{'plugin-path'}/OpenSLX/Distro") { + my $distroName = $self->distroName(); + $distroName =~ tr{.-}{__}; + my @distroModules; + while($distroName =~ m{^(.+)_[^_]*$}) { + push @distroModules, $distroName; + $distroName = $1; + } + push @distroModules, $distroName; + push @distroModules, 'base'; + for my $distroModule (@distroModules) { +print "trying $distroModule...\n"; + last if eval { + $distro = instantiateClass( + $distroModule, { pathToClass => $self->{'plugin-path'} } + ); + 1; + }; + } + } + + $plugin->initialize($self, $distro); return $plugin; } @@ -405,11 +447,6 @@ sub _callChrootedFunctionForPlugin my $self = shift; my $function = shift; - # create ossetup-engine for given vendor-OS: - my $osSetupEngine = OpenSLX::OSSetup::Engine->new; - $osSetupEngine->initialize($self->{'vendor-os-name'}, 'plugin'); - $self->{'os-setup-engine'} = $osSetupEngine; - # bind-mount openslx basepath to /mnt/openslx of vendor-OS: my $basePath = $openslxConfig{'base-path'}; my $openslxPathInChroot = "$self->{'vendor-os-path'}/mnt/openslx"; @@ -424,14 +461,18 @@ sub _callChrootedFunctionForPlugin } # now let plugin install itself into vendor-OS - $self->{'os-setup-engine'}->callChrootedFunctionForVendorOS($function); + my $ok = eval { + $self->{'ossetup-engine'}->callChrootedFunctionForVendorOS($function); + }; if (slxsystem("umount $openslxPathInChroot")) { croak(_tr("unable to umount '%s'! (%s)", $openslxPathInChroot, $!)); } - delete $self->{'os-setup-engine'}; - + if (!$ok) { + die $@; + } + return; } |
