From fde7d8f091d03b8d2c0c14e3f56eab700082beba Mon Sep 17 00:00:00 2001 From: Oliver Tappe Date: Sun, 27 Jan 2008 14:51:47 +0000 Subject: Hopefully finished the adjustments of the tools with respect to theme naming and other recent discussions of user interface. * adjusted and simplified code to the fact that plugins are now named in all lowercase * slxos-plugin --verbose list now shows description for each plugin and a list of supported attributes * fixed some outstanding issues with respect to lowercasing of plugin names * Separated theme::name into theme::splash, theme::displaymanager and theme::desktop, leading to DB-schema 0.24. Please note that although these attributes exist, currently only theme::splash is being used (the new ones will be used by the reimplemented mkdxsinitrd) * moved some information gathering from OSPlugin::Engine into OSPlugin::Roster, where it belongs git-svn-id: http://svn.openslx.org/svn/openslx/trunk@1500 95ad53e4-c205-0410-b2fa-d234c58c8868 --- config-db/OpenSLX/AttributeRoster.pm | 8 +-- config-db/OpenSLX/DBSchema.pm | 36 ++++++++++++- config-db/slxconfig | 15 +++--- config-db/slxconfig-demuxer | 9 ++-- os-plugins/OpenSLX/OSPlugin/Engine.pm | 10 ---- os-plugins/OpenSLX/OSPlugin/Roster.pm | 63 ++++++++++++++++++++-- os-plugins/plugins/example/XX_example.sh | 2 +- os-plugins/plugins/theme/OpenSLX/OSPlugin/theme.pm | 26 +++++++-- os-plugins/plugins/theme/XX_theme.sh | 2 +- os-plugins/slxos-plugin | 22 +++++++- 10 files changed, 154 insertions(+), 39 deletions(-) diff --git a/config-db/OpenSLX/AttributeRoster.pm b/config-db/OpenSLX/AttributeRoster.pm index 0308540e..e196b5d3 100644 --- a/config-db/OpenSLX/AttributeRoster.pm +++ b/config-db/OpenSLX/AttributeRoster.pm @@ -410,14 +410,14 @@ sub getAttrInfo } elsif (defined $params->{scope}) { my %MatchingAttributeInfo; - my $lcScope = lc($params->{scope}); + my $selectedScope = lc($params->{scope}); foreach my $attr (keys %AttributeInfo) { my $attrScope = ''; if ($attr =~ m{^(.+?)::}) { - $attrScope = $1; + $attrScope = lc($1); } - if ((!$attrScope && $lcScope eq 'core') - || lc($attrScope) eq $lcScope) { + if ((!$attrScope && $selectedScope eq 'core') + || $attrScope eq $selectedScope) { $MatchingAttributeInfo{$attr} = $AttributeInfo{$attr}; } } diff --git a/config-db/OpenSLX/DBSchema.pm b/config-db/OpenSLX/DBSchema.pm index aa6ef1c1..ede1b9a3 100644 --- a/config-db/OpenSLX/DBSchema.pm +++ b/config-db/OpenSLX/DBSchema.pm @@ -35,7 +35,7 @@ use OpenSLX::Basics; ### fk => foreign key (integer) ################################################################################ -my $VERSION = 0.23; +my $VERSION = 0.24; my $DbSchema = { 'version' => $VERSION, @@ -622,6 +622,40 @@ sub _schemaUpgradeDBFrom $metaDB->schemaSetDBVersion(0.23); + return 1; + }, + 0.24 => sub { + my $metaDB = shift; + + vlog(0, "upgrading schema version to 0.24"); + + # split theme::name into theme::splash, theme::displaymanager and + # theme::desktop + foreach my $system ($metaDB->fetchSystemByFilter()) { + my $attrs = $system->{attrs} || {}; + next if !exists $attrs->{'theme::name'}; + $attrs->{'theme::splash'} + = $attrs->{'theme::displaymanager'} + = $attrs->{'theme::desktop'} + = $attrs->{'theme::name'}; + delete $attrs->{'theme::name'}; + $metaDB->setSystemAttrs($system->{id}, $attrs); + } + + # force all theme names to lowercase + foreach my $vendorOS ($metaDB->fetchVendorOSByFilter()) { + my @installedPlugins + = $metaDB->fetchInstalledPlugins($vendorOS->{id}); + foreach my $plugin (@installedPlugins) { + my $pluginName = $plugin->{plugin_name}; +print "$vendorOS->{id} $pluginName\n"; + $metaDB->removeInstalledPlugin($vendorOS->{id}, $pluginName); + $metaDB->addInstalledPlugin($vendorOS->{id}, lc($pluginName)); + } + } + + $metaDB->schemaSetDBVersion(0.24); + return 1; }, ); diff --git a/config-db/slxconfig b/config-db/slxconfig index da4e31f1..a357bc4a 100755 --- a/config-db/slxconfig +++ b/config-db/slxconfig @@ -93,7 +93,9 @@ elsif ($action =~ m[^change-c]i) { changeClientInConfigDB(@ARGV); } elsif ($action =~ m[^list-a]) { - print _tr("List of known attributes:\n"); + print @ARGV + ? _tr("List of known attributes for scope '%s':\n", $ARGV[0]) + : _tr("List of known attributes:\n"); listAttributes(@ARGV); } elsif ($action =~ m[^list-c]) { @@ -352,6 +354,7 @@ sub listAttributes map { my $attr = dclone($attrInfo->{$_}); $attr->{name} = $_; + delete $attr->{content_regex}; # no use for display purposes $attr; } sort keys %$attrInfo @@ -516,8 +519,7 @@ sub listSystems ); my $mergedAttrs = $mergedSystem->{attrs} || {}; foreach my $plugin (@installedPlugins) { - my $pluginScope = lc($plugin); - next if !$mergedAttrs->{"${pluginScope}::active"}; + next if !$mergedAttrs->{"${plugin}::active"}; push @activePlugins, $plugin; } if ($inherited) { @@ -695,12 +697,11 @@ sub searchSystems $openslxDB->mergeDefaultAttributesIntoSystem($mergedSystem); my $mergedAttrs = $mergedSystem->{attrs} || {}; foreach my $plugin (@installedPlugins) { - my $pluginScope = lc($plugin); - next if !$mergedAttrs->{"${pluginScope}::active"}; + next if !$mergedAttrs->{"${plugin}::active"}; my $precedence = sprintf( - "%02d", $mergedAttrs->{"${pluginScope}::precedence"} + "%02d", $mergedAttrs->{"${plugin}::precedence"} ); - push(@activePlugins, "$precedence...$plugin"); + push(@activePlugins, $plugin); } } $_->{PLUGINS} = [ sort @activePlugins ]; diff --git a/config-db/slxconfig-demuxer b/config-db/slxconfig-demuxer index 24501a97..c715caac 100755 --- a/config-db/slxconfig-demuxer +++ b/config-db/slxconfig-demuxer @@ -498,7 +498,7 @@ sub generateInitialRamFS $cmd .= "-S $info->{name} "; # pass on theme, if any - my $theme = $attrs->{'theme::name'} || ''; + my $theme = $attrs->{'theme::splash'} || ''; if (length $theme) { $cmd .= "-s $theme "; } @@ -705,8 +705,7 @@ sub writePluginConfigurationsForSystem vlog(2, _tr("checking configuration of plugin '%s'", $pluginName)); # skip inactive plugins - my $pluginScope = lc($pluginName); - next unless $attrs->{"${pluginScope}::active"}; + next unless $attrs->{"${pluginName}::active"}; push @activePlugins, $pluginName; @@ -717,7 +716,7 @@ sub writePluginConfigurationsForSystem vlog(2, _tr("writing configuration file for plugin '%s'", $pluginName)); # write plugin configuration to a file: my $content; - my @pluginAttrs = grep { $_ =~ m{^${pluginScope}::} } keys %$attrs; + my @pluginAttrs = grep { $_ =~ m{^${pluginName}::} } keys %$attrs; foreach my $attr (sort @pluginAttrs) { my $attrVal = $attrs->{$attr}; next if !defined $attrVal; @@ -734,7 +733,7 @@ sub writePluginConfigurationsForSystem # copy runlevel script to be used in stage3: my $precedence - = sprintf('%02d', $attrs->{"${pluginScope}::precedence"}); + = sprintf('%02d', $attrs->{"${pluginName}::precedence"}); my $pluginFolder = "$openslxConfig{'base-path'}/lib/plugins/$pluginName"; my $scriptName = "$pluginFolder/XX_${pluginName}.sh"; diff --git a/os-plugins/OpenSLX/OSPlugin/Engine.pm b/os-plugins/OpenSLX/OSPlugin/Engine.pm index bdf259f4..fe2bf1ac 100644 --- a/os-plugins/OpenSLX/OSPlugin/Engine.pm +++ b/os-plugins/OpenSLX/OSPlugin/Engine.pm @@ -36,16 +36,6 @@ sub new 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; diff --git a/os-plugins/OpenSLX/OSPlugin/Roster.pm b/os-plugins/OpenSLX/OSPlugin/Roster.pm index 776907e4..832b0bb3 100644 --- a/os-plugins/OpenSLX/OSPlugin/Roster.pm +++ b/os-plugins/OpenSLX/OSPlugin/Roster.pm @@ -18,6 +18,46 @@ use warnings; use OpenSLX::Basics; +my %plugins; + +=item C + +Returns a hash that keys the names of available plugins to their info hash. + +=cut + +sub getAvailablePlugins +{ + my $class = shift; + + $class->_init() if !%plugins; + + my %pluginInfo; + foreach my $pluginName (keys %plugins) { + $pluginInfo{$pluginName} = $plugins{$pluginName}->getInfo(); + } + return \%pluginInfo; +} + +=item C + +Returns a hash that contains info about the attributes support by the +given plugin + +=cut + +sub getPluginAttrInfo +{ + my $class = shift; + my $pluginName = shift; + + $class->_init() if !%plugins; + + return if !$plugins{$pluginName}; + + return $plugins{$pluginName}->getAttrInfo(); +} + =item C Fetches attribute info from all available plugins and adds it to the given @@ -38,6 +78,22 @@ sub addAllDefaultAttributesToHash my $class = shift; my $attrInfo = shift; + $class->_init() if !%plugins; + + foreach my $plugin (values %plugins) { + my $pluginAttrInfo = $plugin->getAttrInfo(); + foreach my $attr (keys %$pluginAttrInfo) { + $attrInfo->{$attr} = $pluginAttrInfo->{$attr}; + } + } + return 1; +} + +sub _init +{ + my $class = shift; + + %plugins = (); my $pluginPath = "$openslxConfig{'base-path'}/lib/plugins"; foreach my $modulePath (glob("$pluginPath/*")) { next if $modulePath !~ m{/([^/]+)$}; @@ -45,12 +101,9 @@ sub addAllDefaultAttributesToHash my $class = "OpenSLX::OSPlugin::$pluginName"; vlog(2, "loading plugin $class from path '$modulePath'"); my $plugin = instantiateClass($class, { pathToClass => $modulePath }); - my $pluginAttrInfo = $plugin->getAttrInfo(); - foreach my $attr (keys %$pluginAttrInfo) { - $attrInfo->{$attr} = $pluginAttrInfo->{$attr}; - } + $plugins{$pluginName} = $plugin; } - return 1; + return; } 1; diff --git a/os-plugins/plugins/example/XX_example.sh b/os-plugins/plugins/example/XX_example.sh index ae8bcd64..d4496102 100644 --- a/os-plugins/plugins/example/XX_example.sh +++ b/os-plugins/plugins/example/XX_example.sh @@ -26,7 +26,7 @@ if [ -e /initramfs/plugin-conf/example.conf ]; then . /initramfs/plugin-conf/example.conf - if [ $Example_active -ne 0 ]; then + if [ $example_active -ne 0 ]; then [ $DEBUGLEVEL -gt 0 ] && echo "executing the 'example' os-plugin ..."; # for this example plugin, we simply take a filename from the diff --git a/os-plugins/plugins/theme/OpenSLX/OSPlugin/theme.pm b/os-plugins/plugins/theme/OpenSLX/OSPlugin/theme.pm index 17170fbf..c6635ccb 100644 --- a/os-plugins/plugins/theme/OpenSLX/OSPlugin/theme.pm +++ b/os-plugins/plugins/theme/OpenSLX/OSPlugin/theme.pm @@ -40,7 +40,7 @@ sub getInfo return { description => unshiftHereDoc(<<' End-of-Here'), - applies a graphical theme to the bootsplash and the displaymanager + Applies a graphical theme to the bootsplash and the displaymanager. End-of-Here mustRunAfter => [], }; @@ -78,11 +78,31 @@ sub getAttrInfo default => 30, }, - 'theme::name' => { + 'theme::splash' => { applies_to_systems => 1, applies_to_clients => 0, description => unshiftHereDoc(<<' End-of-Here'), - the name of the theme to apply (or unset for no theme) + name of the theme to apply to bootsplash (unset for no theme) + End-of-Here + content_regex => undef, + content_descr => undef, + default => 'openslx', + }, + 'theme::displaymanager' => { + applies_to_systems => 1, + applies_to_clients => 0, + description => unshiftHereDoc(<<' End-of-Here'), + name of the theme to apply to displaymanager (unset for no theme) + End-of-Here + content_regex => undef, + content_descr => undef, + default => 'openslx', + }, + 'theme::desktop' => { + applies_to_systems => 1, + applies_to_clients => 0, + description => unshiftHereDoc(<<' End-of-Here'), + name of the theme to apply to desktop (unset for no theme) End-of-Here content_regex => undef, content_descr => undef, diff --git a/os-plugins/plugins/theme/XX_theme.sh b/os-plugins/plugins/theme/XX_theme.sh index 4d166c13..2d2b0f0f 100644 --- a/os-plugins/plugins/theme/XX_theme.sh +++ b/os-plugins/plugins/theme/XX_theme.sh @@ -6,7 +6,7 @@ . /etc/sysconfig/config if [ -e /initramfs/plugin-conf/theme.conf ]; then . /initramfs/plugin-conf/theme.conf - if [ $Theme_active -ne 0 ]; then + if [ $theme_active -ne 0 ]; then [ $DEBUGLEVEL -gt 0 ] && echo "executing the 'theme' os-plugin ..."; testmkd /mnt/var/lib/openslx/themes/displaymanager diff --git a/os-plugins/slxos-plugin b/os-plugins/slxos-plugin index 981e6b41..52c80796 100755 --- a/os-plugins/slxos-plugin +++ b/os-plugins/slxos-plugin @@ -59,12 +59,30 @@ openslxInit(); my $action = shift @ARGV || ''; -if ($action =~ m[^list-av]i) { +if ($action =~ m[^list]i) { my @pluginFolders = glob("$openslxConfig{'base-path'}/lib/plugins/*"); print _tr("List of available plugins:\n"); + require OpenSLX::OSPlugin::Roster; + my $pluginInfo = OpenSLX::OSPlugin::Roster->getAvailablePlugins(); print join( '', - map { "\t$_\n" } OpenSLX::OSPlugin::Engine->getAvailablePlugins() + map { + if ($verbose) { + my $description = $pluginInfo->{$_}->{description}; + $description + .= "\t " + . _tr("The following attributes are suppported:") + . "\n\t "; + my $pluginAttrs + = OpenSLX::OSPlugin::Roster->getPluginAttrInfo($_); + $description .= join("\n\t ", sort keys %$pluginAttrs); + "\n\t$_\n\t $description\n"; + } + else { + "\t$_\n"; + } + } + sort keys %$pluginInfo ); } elsif ($action =~ m[^install]i) { if (scalar(@ARGV) != 2) { -- cgit v1.2.3-55-g7522