summaryrefslogtreecommitdiffstats
path: root/os-plugins/OpenSLX/OSPlugin/Base.pm
diff options
context:
space:
mode:
authorOliver Tappe2008-07-23 20:27:33 +0200
committerOliver Tappe2008-07-23 20:27:33 +0200
commitc13e5631307f48236be9155aea76fc9951741020 (patch)
tree8b864474bc810a039df5bfec4cb4f67b6ac18c84 /os-plugins/OpenSLX/OSPlugin/Base.pm
parentvmchooser changes: (diff)
downloadcore-c13e5631307f48236be9155aea76fc9951741020.tar.gz
core-c13e5631307f48236be9155aea76fc9951741020.tar.xz
core-c13e5631307f48236be9155aea76fc9951741020.zip
implemented plugin dependency handling:
* installing a plugin into a vendor-OS is now only possible when required plugins are already installed * removing a plugin from a vendor-OS is now only possible when now plugins that depend on this one are still installed * the config-demuxer will check the plugin depedency hierarchy and bail if any plugin is missing * when several plugins are being auto-installed (e.g. when copying all plugins from the '<<<default>>>' vendor-OS) the order of the plugins is adjusted to comply with the dependency hierarchy * declared one single dependency: vmchooser depends on vmware (please shout if that is incorrect) git-svn-id: http://svn.openslx.org/svn/openslx/openslx/trunk@1936 95ad53e4-c205-0410-b2fa-d234c58c8868
Diffstat (limited to 'os-plugins/OpenSLX/OSPlugin/Base.pm')
-rw-r--r--os-plugins/OpenSLX/OSPlugin/Base.pm47
1 files changed, 47 insertions, 0 deletions
diff --git a/os-plugins/OpenSLX/OSPlugin/Base.pm b/os-plugins/OpenSLX/OSPlugin/Base.pm
index 2b6075f5..734a74f5 100644
--- a/os-plugins/OpenSLX/OSPlugin/Base.pm
+++ b/os-plugins/OpenSLX/OSPlugin/Base.pm
@@ -61,6 +61,7 @@ implementation, please drop a mail to: ot@openslx.com, or join the IRC-channel
=cut
use OpenSLX::Basics;
+use OpenSLX::OSPlugin::Roster;
=head1 PLUGIN API
@@ -122,6 +123,13 @@ a higher precedence).
Valid values range from 0-99. If your plugin does not have any requirements
in this context, just specify the default value '50'.
+=item B<required>
+
+Specifies the list of plugins that are required by this plugin.
+
+Before any plugin can be installed, all other plugins that are required by it
+must have been installed.
+
=back
=cut
@@ -209,6 +217,23 @@ sub checkStage3AttrValues
return;
}
+=item dependsOnPlugin()
+
+=cut
+
+sub dependsOnPlugin
+{
+ my $self = shift;
+ my $otherName = shift;
+
+ if (!defined $self->{dependsOn}) {
+ my @dependsOn = $self->_determineAllPluginsWeDependOn();
+ $self->{dependsOn} = \@dependsOn;
+ }
+
+ return grep { $_ eq $otherName } @{$self->{dependsOn}};
+}
+
=back
=head2 Vendor-OS Interface
@@ -439,6 +464,28 @@ sub setupPluginInInitramfs
return 1;
}
+sub _determineAllPluginsWeDependOn
+{
+ my $self = shift;
+ my $seen = shift || {};
+
+ return if $seen->{$self->{name}};
+ $seen->{$self->{name}} = 1;
+
+ my %dependsOn;
+ if ($self->getInfo()->{required}) {
+ @dependsOn{@{$self->getInfo()->{required}}} = ();
+ }
+
+ foreach my $depName (keys %dependsOn) {
+ my $depPlugin = OpenSLX::OSPlugin::Roster->getPlugin($depName);
+ my @subDeps = $depPlugin->_determineAllPluginsWeDependOn($seen);
+ @dependsOn{@subDeps} = ();
+ }
+
+ return keys %dependsOn;
+}
+
=back
1;