summaryrefslogtreecommitdiffstats
path: root/os-plugins/OpenSLX
diff options
context:
space:
mode:
authorOliver Tappe2007-07-03 01:48:23 +0200
committerOliver Tappe2007-07-03 01:48:23 +0200
commit041f05422528bad639db5c2668bf3313643be244 (patch)
treee94ea7edff715ce90b7b5b3c3a1938a9b52817cc /os-plugins/OpenSLX
parent* added support for os-plugins: (diff)
downloadcore-041f05422528bad639db5c2668bf3313643be244.tar.gz
core-041f05422528bad639db5c2668bf3313643be244.tar.xz
core-041f05422528bad639db5c2668bf3313643be244.zip
* added the 'os-plugins'-folder I missed with last commit
git-svn-id: http://svn.openslx.org/svn/openslx/trunk@1221 95ad53e4-c205-0410-b2fa-d234c58c8868
Diffstat (limited to 'os-plugins/OpenSLX')
-rw-r--r--os-plugins/OpenSLX/OSPlugin/Engine.pm124
1 files changed, 124 insertions, 0 deletions
diff --git a/os-plugins/OpenSLX/OSPlugin/Engine.pm b/os-plugins/OpenSLX/OSPlugin/Engine.pm
new file mode 100644
index 00000000..57850229
--- /dev/null
+++ b/os-plugins/OpenSLX/OSPlugin/Engine.pm
@@ -0,0 +1,124 @@
+# Copyright (c) 2007 - OpenSLX GmbH
+#
+# This program is free software distributed under the GPL version 2.
+# See http://openslx.org/COPYING
+#
+# If you have any feedback please consult http://openslx.org/feedback and
+# send your suggestions, praise, or complaints to feedback@openslx.org
+#
+# General information about OpenSLX can be found at http://openslx.org/
+# -----------------------------------------------------------------------------
+# Engine.pm
+# - provides driver engine for the OSPlugin API.
+# -----------------------------------------------------------------------------
+package OpenSLX::OSPlugin::Engine;
+
+use strict;
+use warnings;
+
+our $VERSION = 1.01; # API-version . implementation-version
+
+use File::Basename;
+
+use OpenSLX::Basics;
+use OpenSLX::OSSetup::Engine;
+use OpenSLX::Utils;
+
+################################################################################
+### interface methods
+################################################################################
+sub new
+{
+ my $class = shift;
+
+ my $self = {};
+
+ return bless $self, $class;
+}
+
+sub getAvailablePlugins
+{ # Class-method!
+ my $class = shift;
+
+ return
+ map { basename($_); }
+ sort
+ glob("$openslxConfig{'base-path'}/lib/plugins/*");
+}
+
+sub initialize
+{
+ my $self = shift;
+ my $pluginName = shift;
+ my $vendorOSName = shift;
+
+ $self->{'plugin-name'} = $pluginName;
+ $self->{'vendor-os-name'} = $vendorOSName;
+
+ $self->{'vendor-os-path'}
+ = "$openslxConfig{'private-path'}/stage1/$vendorOSName";
+ vlog(1, "vendor-OS path is '$self->{'vendor-os-path'}'");
+
+ $self->{'plugin-path'}
+ = "$openslxConfig{'base-path'}/lib/plugins/$pluginName";
+ vlog(1, "plugin path is '$self->{'plugin-path'}'");
+
+ $self->{'plugin'} = $self->_loadPlugin();
+}
+
+sub installPlugin
+{
+ my $self = 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;
+ $self->{'distro-name'} = $osSetupEngine->{'distro-name'};
+
+ my $chrootedPluginRepoPath
+ = "$openslxConfig{'base-path'}/plugin-repo/$self->{'plugin-name'}";
+ my $pluginRepoPath = "$self->{'vendor-os-path'}/$chrootedPluginRepoPath";
+ my $chrootedPluginTempPath = "/tmp/slx-plugin/$self->{'plugin-name'}";
+ my $pluginTempPath = "$self->{'vendor-os-path'}/$chrootedPluginTempPath";
+ foreach my $path ($pluginRepoPath, $pluginTempPath) {
+ if (slxsystem("mkdir -p $path")) {
+ croak(_tr("unable to create path '%s'! (%s)", $path, $!));
+ }
+ }
+
+ $self->{plugin}->preInstallationPhase($pluginRepoPath, $pluginTempPath);
+
+ $self->{'os-setup-engine'}->callChrootedFunctionForVendorOS(
+ sub {
+ $self->{plugin}->installationPhase(
+ $chrootedPluginRepoPath, $chrootedPluginTempPath
+ );
+ }
+ );
+
+ $self->{plugin}->postInstallationPhase($pluginRepoPath, $pluginTempPath);
+}
+
+sub getPlugin
+{
+ my $self = shift;
+
+ return $self->{plugin};
+}
+
+sub removePlugin
+{
+}
+
+sub _loadPlugin
+{
+ my $self = shift;
+
+ my $pluginModule = "OpenSLX::OSPlugin::$self->{'plugin-name'}";
+ my $plugin = instantiateClass(
+ $pluginModule, { pathToClass => $self->{'plugin-path'} }
+ );
+ $plugin->initialize($self);
+ return $plugin;
+}