summaryrefslogtreecommitdiffstats
path: root/os-plugins
diff options
context:
space:
mode:
authorOliver Tappe2008-05-22 22:01:34 +0200
committerOliver Tappe2008-05-22 22:01:34 +0200
commit2a614b1103699d60e7e2999030d64e2adc9a6955 (patch)
tree0e0ffd2962e5835f08e3749d258cd36d9e3a7a79 /os-plugins
parent* supress lib error while giving vmware its own font config (diff)
downloadcore-2a614b1103699d60e7e2999030d64e2adc9a6955.tar.gz
core-2a614b1103699d60e7e2999030d64e2adc9a6955.tar.xz
core-2a614b1103699d60e7e2999030d64e2adc9a6955.zip
* attributes set via slxconfig are now being checked not only against the respective
regex, but the corresponding plugin is being invoked to do a check of its own, too (where it has the chance to look at the vendor-OS attributes and determine the possible stage3-values from their state). * listing a vendor-OS in verbose mode now shows the vendor-OS attributes (stage1 & stage3), too * used Clone::clone instead of Storable::dclone since the latter is not capable of cloning compiled regexes git-svn-id: http://svn.openslx.org/svn/openslx/openslx/trunk@1783 95ad53e4-c205-0410-b2fa-d234c58c8868
Diffstat (limited to 'os-plugins')
-rw-r--r--os-plugins/OpenSLX/OSPlugin/Base.pm26
-rw-r--r--os-plugins/OpenSLX/OSPlugin/Engine.pm40
-rw-r--r--os-plugins/OpenSLX/OSPlugin/Roster.pm6
-rw-r--r--os-plugins/plugins/desktop/OpenSLX/OSPlugin/desktop.pm112
4 files changed, 168 insertions, 16 deletions
diff --git a/os-plugins/OpenSLX/OSPlugin/Base.pm b/os-plugins/OpenSLX/OSPlugin/Base.pm
index b89f73fa..8c314ff5 100644
--- a/os-plugins/OpenSLX/OSPlugin/Base.pm
+++ b/os-plugins/OpenSLX/OSPlugin/Base.pm
@@ -182,29 +182,33 @@ sub getDefaultAttrsForVendorOS
return $self->getAttrInfo();
}
-=item checkValueForKey()
+=item checkStage3AttrValues()
-Checks if the given value is allowed (and makes sense) for the given key.
-If the value is ok, this method returns 1 - if not, it dies with an appropriate
-message.
+Checks if the stage3 values given in B<$stage3Attrs> are allowed and makes
+sense.
-Plugins may override this implementation to do checks that for instance look
-at the vendor-OS (stage1-)attributes.
+If all values are ok, this method returns 1 - if not, it dies with an appropriate message.
+
+Plugins may override this implementation to do checks that for instance look
+at the stage1 vendor-OS-attributes given in B<$vendorOSAttrs>.
+
+N.B.: this method is called while being chrooted into the vendor-OS, so it
+ may invoke all distro methods that expect to be run in this environment,
+ too
=cut
-sub checkValueForKey
+sub checkStage3AttrValues
{
- my $self = shift;
- my $key = shift;
- my $value = shift;
+ my $self = shift;
+ my $stage3Attrs = shift;
+ my $vendorOSAttrs = shift;
# this default implementation does no further checks (thus relying on the
# attributte regex check that is done in the AttributeRoster)
return 1;
}
-
=back
=head2 Vendor-OS Interface
diff --git a/os-plugins/OpenSLX/OSPlugin/Engine.pm b/os-plugins/OpenSLX/OSPlugin/Engine.pm
index 0672aa5e..ada0af79 100644
--- a/os-plugins/OpenSLX/OSPlugin/Engine.pm
+++ b/os-plugins/OpenSLX/OSPlugin/Engine.pm
@@ -126,6 +126,7 @@ sub initialize
? $dbAttrs->{$attrName}
: $defaultAttrs->{$attrName}->{default};
}
+ $self->{'vendorOS-attrs'} = $dbAttrs;
}
return 1;
@@ -377,7 +378,6 @@ sub getInstallablePackagesForSelection
);
}
-
=item installPackages($packages)
Installs the given packages into the vendor-OS.
@@ -447,6 +447,44 @@ sub removePackages
=back
+=head2 Driver Interface
+
+The following methods are invoked by the slxos-plugin script in order to
+install/remove a plugin into/from a vendor-OS:
+
+=over
+
+=item checkStage3AttrValues()
+
+Checks if the stage3 values given in B<$stage3Attrs> are allowed and make sense.
+
+If all values are ok, this method returns 1 - if not, it dies with an
+appropriate message.
+
+This method chroots into the vendor-OS and then asks the plugin itself to check
+the attributes.
+
+=cut
+
+sub checkStage3AttrValues
+{
+ my $self = shift;
+ my $stage3Attrs = shift;
+
+ $self->_callChrootedFunctionForPlugin(
+ sub {
+ # let plugin check by itself
+ $self->{plugin}->checkStage3AttrValues(
+ $stage3Attrs, $self->{'vendorOS-attrs'}
+ );
+ }
+ );
+
+ return 1;
+}
+
+=back
+
=cut
sub _loadPlugin
diff --git a/os-plugins/OpenSLX/OSPlugin/Roster.pm b/os-plugins/OpenSLX/OSPlugin/Roster.pm
index 023abb4c..7bfed044 100644
--- a/os-plugins/OpenSLX/OSPlugin/Roster.pm
+++ b/os-plugins/OpenSLX/OSPlugin/Roster.pm
@@ -17,7 +17,7 @@ use strict;
use warnings;
use OpenSLX::Basics;
-use Storable qw(dclone);
+use Clone qw(clone);
my %plugins;
@@ -56,7 +56,7 @@ sub getPlugin
my $plugin = $plugins{$pluginName};
return if !$plugin;
- return dclone($plugin);
+ return clone($plugin);
}
=item C<getPluginAttrInfo()>
@@ -179,7 +179,7 @@ sub _addAttributesToHash
my $pluginAttrInfo = $plugin->getAttrInfo();
foreach my $attr (keys %$pluginAttrInfo) {
next if !$testFunc->($pluginAttrInfo->{$attr});
- $attrInfo->{$attr} = dclone($pluginAttrInfo->{$attr});
+ $attrInfo->{$attr} = clone($pluginAttrInfo->{$attr});
}
}
return 1;
diff --git a/os-plugins/plugins/desktop/OpenSLX/OSPlugin/desktop.pm b/os-plugins/plugins/desktop/OpenSLX/OSPlugin/desktop.pm
index 03c26454..92b1e9a9 100644
--- a/os-plugins/plugins/desktop/OpenSLX/OSPlugin/desktop.pm
+++ b/os-plugins/plugins/desktop/OpenSLX/OSPlugin/desktop.pm
@@ -53,6 +53,7 @@ sub getAttrInfo
my $self = shift;
return {
+ # stage3
'desktop::active' => {
applies_to_systems => 1,
applies_to_clients => 1,
@@ -69,7 +70,7 @@ sub getAttrInfo
description => unshiftHereDoc(<<' End-of-Here'),
which display manager to start: gdm, kdm or xdm?
End-of-Here
- content_regex => qr{^(g|k|x)dm$},
+ content_regex => qr{^(gdm|kdm|xdm)$},
content_descr => '"gdm", "kdm" or "xdm"',
default => undef,
},
@@ -103,6 +104,8 @@ sub getAttrInfo
content_descr => 'one of the entries in "supported_themes"',
default => 'openslx',
},
+
+ # stage1
'desktop::supported_themes' => {
applies_to_vendor_os => 1,
description => unshiftHereDoc(<<' End-of-Here'),
@@ -197,6 +200,113 @@ sub getDefaultAttrsForVendorOS
return $attrs;
}
+sub checkStage3AttrValues
+{
+ my $self = shift;
+ my $stage3Attrs = shift;
+ my $vendorOSAttrs = shift;
+
+ my $manager = $stage3Attrs->{'desktop::manager'} || '';
+ if ($manager eq 'kdm') {
+ if (!defined $vendorOSAttrs->{'desktop::kdm'}) {
+ if (!$self->{distro}->isKDMInstalled()) {
+ die _tr(
+ "KDM is not installed in vendor-OS, so using it as desktop manager wouldn't work!"
+ );
+ }
+ }
+ elsif ($vendorOSAttrs->{'desktop::kdm'} == 0) {
+ die _tr(
+ "desktop::kdm is 0, so using KDM as desktop manager is not allowed for this vendor-OS!"
+ );
+ }
+ }
+ elsif ($manager eq 'gdm') {
+ if (!defined $vendorOSAttrs->{'desktop::gdm'}) {
+ if (!$self->{distro}->isGDMInstalled()) {
+ die _tr(
+ "GDM is not installed in vendor-OS, so using it as desktop manager wouldn't work!"
+ );
+ }
+ }
+ elsif ($vendorOSAttrs->{'desktop::gdm'} == 0) {
+ die _tr(
+ "desktop::gdm is 0, so using GDM as desktop manager is not allowed for this vendor-OS!"
+ );
+ }
+ }
+ elsif ($manager eq 'xdm') {
+ if (!defined $vendorOSAttrs->{'desktop::xdm'}) {
+ if (!$self->{distro}->isXDMInstalled()) {
+ die _tr(
+ "XDM is not installed in vendor-OS, so using it as desktop manager wouldn't work!"
+ );
+ }
+ }
+ elsif ($vendorOSAttrs->{'desktop::xdm'} == 0) {
+ die _tr(
+ "desktop::xdm is 0, so using XDM as desktop manager is not allowed for this vendor-OS!"
+ );
+ }
+ }
+
+ my $kind = $stage3Attrs->{'desktop::kind'} || '';
+ if ($kind eq 'kde') {
+ if (!defined $vendorOSAttrs->{'desktop::kde'}) {
+ if (!$self->{distro}->isKDEInstalled()) {
+ die _tr(
+ "KDE is not installed in vendor-OS, so using it as desktop kind wouldn't work!"
+ );
+ }
+ }
+ elsif ($vendorOSAttrs->{'desktop::kde'} == 0) {
+ die _tr(
+ "desktop::kde is 0, so using KDE as desktop kind is not allowed for this vendor-OS!"
+ );
+ }
+ }
+ elsif ($kind eq 'gnome') {
+ if (!defined $vendorOSAttrs->{'desktop::gnome'}) {
+ if (!$self->{distro}->isGNOMEInstalled()) {
+ die _tr(
+ "GNOME is not installed in vendor-OS, so using it as desktop kind wouldn't work!"
+ );
+ }
+ }
+ elsif ($vendorOSAttrs->{'desktop::gnome'} == 0) {
+ die _tr(
+ "desktop::gnome is 0, so using GNOME as desktop kind is not allowed for this vendor-OS!"
+ );
+ }
+ }
+ elsif ($kind eq 'xfce') {
+ if (!defined $vendorOSAttrs->{'desktop::xfce'}) {
+ if (!$self->{distro}->isXFCEInstalled()) {
+ die _tr(
+ "XFCE is not installed in vendor-OS, so using it as desktop kind wouldn't work!"
+ );
+ }
+ }
+ elsif ($vendorOSAttrs->{'desktop::xfce'} == 0) {
+ die _tr(
+ "desktop::xfce is 0, so using XFCE as desktop kind is not allowed for this vendor-OS!"
+ );
+ }
+ }
+
+ my @supportedThemes
+ = split ',', $vendorOSAttrs->{'desktop::supported_themes'} || '';
+ my $theme = $stage3Attrs->{'desktop::theme'};
+ if (defined $theme && !grep { $_ eq $theme } @supportedThemes) {
+ die _tr(
+ "'%s' is not a supported theme!\nSupported themes are: %s",
+ $theme, $vendorOSAttrs->{'desktop::supported_themes'} || ''
+ );
+ }
+
+ return 1;
+}
+
sub installationPhase
{
my $self = shift;