From b943b09340c3e3c59f83823946ceeb3e453b3e52 Mon Sep 17 00:00:00 2001 From: Oliver Tappe Date: Mon, 26 May 2008 19:22:00 +0000 Subject: * reworked plugin-API concerning the way the parameters are passed into installationPhase() and removalPhase() - now we use a hash as the amount of parameters has become too large * adjusted all plugins to these API change * now not only the openslx base path, but the openslx config path is bind mounted into the vendor-OS chroot, such that plugins can check the available local configuration extensions git-svn-id: http://svn.openslx.org/svn/openslx/openslx/trunk@1803 95ad53e4-c205-0410-b2fa-d234c58c8868 --- .../plugins/desktop/OpenSLX/OSPlugin/desktop.pm | 125 ++++++++++----------- .../plugins/example/OpenSLX/OSPlugin/example.pm | 43 ++++--- .../plugins/syslog/OpenSLX/OSPlugin/syslog.pm | 15 +-- .../vmchooser/OpenSLX/OSPlugin/vmchooser.pm | 49 ++------ .../plugins/vmware/OpenSLX/OSPlugin/vmware.pm | 26 ++--- .../plugins/x11vnc/OpenSLX/OSPlugin/x11vnc.pm | 48 ++++---- 6 files changed, 138 insertions(+), 168 deletions(-) (limited to 'os-plugins/plugins') diff --git a/os-plugins/plugins/desktop/OpenSLX/OSPlugin/desktop.pm b/os-plugins/plugins/desktop/OpenSLX/OSPlugin/desktop.pm index bfaee875..7f20f852 100644 --- a/os-plugins/plugins/desktop/OpenSLX/OSPlugin/desktop.pm +++ b/os-plugins/plugins/desktop/OpenSLX/OSPlugin/desktop.pm @@ -64,24 +64,24 @@ sub getAttrInfo content_descr => '1 means active - 0 means inactive', default => '1', }, - 'desktop::manager' => { + 'desktop::kind' => { applies_to_systems => 1, applies_to_clients => 1, description => unshiftHereDoc(<<' End-of-Here'), - which display manager to start: gdm, kdm or xdm? + which desktop environment shall be used: gnome, kde, or xfce? End-of-Here - content_regex => qr{^(gdm|kdm|xdm)$}, - content_descr => '"gdm", "kdm" or "xdm"', + content_regex => qr{^(gnome|kde|xfce)$}, + content_descr => '"gnome", "kde" or "xfce"', default => undef, }, - 'desktop::kind' => { + 'desktop::manager' => { applies_to_systems => 1, applies_to_clients => 1, description => unshiftHereDoc(<<' End-of-Here'), - which desktop environment shall be used: gnome, kde, or xfce? + which display manager to start: gdm, kdm or xdm? End-of-Here - content_regex => qr{^(gnome|kde|xfce)$}, - content_descr => '"gnome", "kde" or "xfce"', + content_regex => qr{^(gdm|kdm|xdm)$}, + content_descr => '"gdm", "kdm" or "xdm"', default => undef, }, 'desktop::mode' => { @@ -106,15 +106,6 @@ sub getAttrInfo }, # stage1 - 'desktop::supported_themes' => { - applies_to_vendor_os => 1, - description => unshiftHereDoc(<<' End-of-Here'), - name of all themes that shall be installed in vendor-OS (such - that they can be selected via 'desktop::theme' in stage 3). - End-of-Here - content_descr => 'a comma-separated list of theme names', - default => 'openslx', - }, 'desktop::gdm' => { applies_to_vendor_os => 1, description => unshiftHereDoc(<<' End-of-Here'), @@ -124,37 +115,46 @@ sub getAttrInfo content_descr => '"0", "1" or "-" (for unset)', default => undef, }, - 'desktop::kdm' => { + 'desktop::gnome' => { applies_to_vendor_os => 1, description => unshiftHereDoc(<<' End-of-Here'), - should kdm be available (installed in vendor-OS)? + should gnome be available (installed in vendor-OS)? End-of-Here content_regex => qr{^0|1$}, content_descr => '"0", "1" or "-" (for unset)', default => undef, }, - 'desktop::xdm' => { + 'desktop::kde' => { applies_to_vendor_os => 1, description => unshiftHereDoc(<<' End-of-Here'), - should xdm be available (installed in vendor-OS)? + should kde be available (installed in vendor-OS)? End-of-Here content_regex => qr{^0|1$}, content_descr => '"0", "1" or "-" (for unset)', default => undef, }, - 'desktop::gnome' => { + 'desktop::kdm' => { applies_to_vendor_os => 1, description => unshiftHereDoc(<<' End-of-Here'), - should gnome be available (installed in vendor-OS)? + should kdm be available (installed in vendor-OS)? End-of-Here content_regex => qr{^0|1$}, content_descr => '"0", "1" or "-" (for unset)', default => undef, }, - 'desktop::kde' => { + 'desktop::supported_themes' => { applies_to_vendor_os => 1, description => unshiftHereDoc(<<' End-of-Here'), - should kde be available (installed in vendor-OS)? + name of all themes that shall be installed in vendor-OS (such + that they can be selected via 'desktop::theme' in stage 3). + End-of-Here + content_descr => 'a comma-separated list of theme names', + default => undef, + }, + 'desktop::xdm' => { + applies_to_vendor_os => 1, + description => unshiftHereDoc(<<' End-of-Here'), + should xdm be available (installed in vendor-OS)? End-of-Here content_regex => qr{^0|1$}, content_descr => '"0", "1" or "-" (for unset)', @@ -314,11 +314,13 @@ sub checkStage3AttrValues sub installationPhase { my $self = shift; + my $info = shift; - $self->{pluginRepositoryPath} = shift; - $self->{pluginTempPath} = shift; - $self->{openslxPath} = shift; - $self->{attrs} = shift; + $self->{pluginRepositoryPath} = $info->{'plugin-repo-path'}; + $self->{pluginTempPath} = $info->{'plugin-temp-path'}; + $self->{openslxBasePath} = $info->{'openslx-base-path'}; + $self->{openslxConfigPath} = $info->{'openslx-config-path'}; + $self->{attrs} = $info->{'plugin-attrs'}; # We are going to change some of the stage1 attributes during installation # (basically we are filling the ones that are not defined). Since the result @@ -332,6 +334,7 @@ sub installationPhase $self->{gnome} = $self->{attrs}->{'desktop::gnome'}; $self->{kde} = $self->{attrs}->{'desktop::kde'}; $self->{xcfe} = $self->{attrs}->{'desktop::xfce'}; + $self->{supported_themes} = $self->{attrs}->{'desktop::supported_themes'}; $self->_installRequiredPackages(); $self->_fillUnsetStage1Attrs(); @@ -355,9 +358,8 @@ sub installationPhase sub removalPhase { my $self = shift; - my $pluginRepositoryPath = shift; - my $pluginTempPath = shift; - + my $info = shift; + return; } @@ -368,40 +370,9 @@ sub copyRequiredFilesIntoInitramfs my $attrs = shift; my $makeInitRamFSEngine = shift; - my $themeDir = "$openslxConfig{'base-path'}/share/themes"; - my $desktopXdmcp = $attrs->{'desktop::xdmcp'} || ''; - my $xdmcpConfigDir - = "$openslxConfig{'base-path'}/lib/plugins/desktop/files/$desktopXdmcp"; - my $desktopTheme = $attrs->{'desktop::theme'} || ''; - if ($desktopTheme) { - my $desktopThemeDir - = "$themeDir/$desktopTheme/desktop/$desktopXdmcp"; - if (-d $desktopThemeDir) { - $makeInitRamFSEngine->addCMD( - "mkdir -p $targetPath/usr/share/files" - ); - $makeInitRamFSEngine->addCMD( - "mkdir -p $targetPath/usr/share/themes" - ); - $makeInitRamFSEngine->addCMD( - "cp -a $desktopThemeDir $targetPath/usr/share/themes/" - ); - $makeInitRamFSEngine->addCMD( - "cp -a $xdmcpConfigDir $targetPath/usr/share/files" - ); - } - } - else { - $desktopTheme = ''; - } + my $desktopTheme = $attrs->{'desktop::theme'} || ''; - vlog( - 1, - _tr( - "desktop-plugin: desktop=%s", - $desktopTheme - ) - ); + vlog(1, _tr("desktop-plugin: desktop=%s", $desktopTheme)); return; } @@ -456,6 +427,9 @@ sub _fillUnsetStage1Attrs if (!defined $self->{'xdm'}) { $self->{'xdm'} = $self->{distro}->isXDMInstalled(); } + if (!defined $self->{'supported_themes'}) { +# $self->{'supported_themes'} = $self->{distro}->getSupportedThemes(); + } return 1; } @@ -474,7 +448,7 @@ sub _ensureSensibleStage3Attrs "no desktop kind is possible, plugin 'desktop' wouldn't work!" ); } - print _tr("selecting %s as desktop kind\n", $desktops[0]); + vlog(0, _tr("selecting %s as desktop kind\n", $desktops[0])); $self->{attrs}->{'desktop::kind'} = $desktops[0]; } @@ -488,10 +462,25 @@ sub _ensureSensibleStage3Attrs "no desktop manager is possible, plugin 'desktop' wouldn't work!" ); } - print _tr("selecting %s as desktop manager\n", $managers[0]); + vlog(0, _tr("selecting %s as desktop manager\n", $managers[0])); $self->{attrs}->{'desktop::manager'} = $managers[0]; } + # check if current theme is supported at all and select another one, if it + # isn't + my $theme = $self->{attrs}->{'desktop::theme'} || ''; + my @supportedThemes = split ",", $self->{'supported_themes'} || ''; + if (!grep { $_ eq $theme } @supportedThemes) { + if (!@supportedThemes) { + vlog( 0, _tr("no themes are supported, using no theme!")); + $self->{attrs}->{'desktop::theme'} = undef; + } + else { + vlog(0, _tr("selecting %s as theme\n", $supportedThemes[0])); + $self->{attrs}->{'desktop::theme'} = $supportedThemes[0]; + } + } + return 1; } @@ -603,7 +592,7 @@ sub _setupSupportedThemes my @supportedThemes = split m{\s*,\s*}, $supportedThemes; return if !@supportedThemes; - my $themeBaseDir = "$self->{openslxPath}/lib/plugins/desktop/themes"; + my $themeBaseDir = "$self->{openslxBasePath}/lib/plugins/desktop/themes"; THEME: for my $theme (@supportedThemes) { my $themeDir = "$themeBaseDir/$theme"; diff --git a/os-plugins/plugins/example/OpenSLX/OSPlugin/example.pm b/os-plugins/plugins/example/OpenSLX/OSPlugin/example.pm index ae7bb4ef..6228ed5d 100644 --- a/os-plugins/plugins/example/OpenSLX/OSPlugin/example.pm +++ b/os-plugins/plugins/example/OpenSLX/OSPlugin/example.pm @@ -89,41 +89,45 @@ sub installationPhase { # called while chrooted to the vendor-OS root in order to give the plugin # a chance to install required files into the vendor-OS. my $self = shift; + my $info = shift; - my $pluginRepositoryPath = shift; + my $pluginRepoPath = $info->{'plugin-repo-path'}; # The folder where the stage1-plugin should store all files # required by the corresponding stage3 runlevel script. # As this method is being executed while chrooted into the vendor-OS, # this path is relative to that root (i.e. directly usable). - my $pluginTempPath = shift; + my $pluginTempPath = $info->{'plugin-temp-path'}; # A temporary playground that will be cleaned up automatically. # As this method is being executed while chrooted into the vendor-OS, # this path is relative to that root (i.e. directly usable). - my $openslxPath = shift; - # the openslx base path bind-mounted into the chroot (/mnt/openslx) + my $openslxBasePath = $info->{'openslx-base-path'}; + # the openslx base path (/opt/openslx) bind-mounted into the chroot + my $openslxConfigPath = $info->{'openslx-config-path'}; + # the openslx config path (/etc/opt/openlsx) bind-mounted into the + # chroot + my $attrs = $info->{'plugin-attrs'}; + # attributes in effect for this installation # for this example plugin, we simply create two files: - spitFile("$pluginRepositoryPath/right", "(-;\n"); - spitFile("$pluginRepositoryPath/left", ";-)\n"); + spitFile("$pluginRepoPath/right", "(-;\n"); + spitFile("$pluginRepoPath/left", ";-)\n"); # Some plugins have to copy files from their plugin folder into the - # vendor-OS. In order to make this possible while chrooted, the host's - # /opt/openslx folder will be mounted to /mnt/openslx in the vendor-OS. - # So each plugin could copy some files like this: + # vendor-OS. Here's an example for how to do that: # # # get our own name: # my $pluginName = $self->{'name'}; # # # get our own base path: - # my $pluginBasePath = "/mnt/openslx/lib/plugins/$pluginName"; + # my $pluginBasePath = "$openslxBasePath/lib/plugins/$pluginName"; # # # copy all needed files now: # foreach my $file ( qw( file1, file2 ) ) { - # copyFile("$pluginBasePath/$file", "$pluginRepositoryPath/"); + # copyFile("$pluginBasePath/$file", "$pluginRepoPath/"); # } # name of current os - # $self->{'os-plugin-engine'}->{'vendor-os-name'} + # my $vendorOSName = $self->{'os-plugin-engine'}->{'vendor-os-name'} return; } @@ -132,10 +136,17 @@ sub removalPhase { # called while chrooted to the vendor-OS root in order to give the plugin # a chance to uninstall no longer required files from the vendor-OS. my $self = shift; - my $pluginRepositoryPath = shift; - # the repository folder, relative to the vendor-OS root - my $pluginTempPath = shift; - # the temporary folder, relative to the vendor-OS root + my $info = shift; + + my $pluginRepoPath = $info->{'plugin-repo-path'}; + # The folder where the stage1-plugin should store all files + # required by the corresponding stage3 runlevel script. + # As this method is being executed while chrooted into the vendor-OS, + # this path is relative to that root (i.e. directly usable). + my $pluginTempPath = $info->{'plugin-temp-path'}; + # A temporary playground that will be cleaned up automatically. + # As this method is being executed while chrooted into the vendor-OS, + # this path is relative to that root (i.e. directly usable). return; } diff --git a/os-plugins/plugins/syslog/OpenSLX/OSPlugin/syslog.pm b/os-plugins/plugins/syslog/OpenSLX/OSPlugin/syslog.pm index e5e63c29..6e810869 100644 --- a/os-plugins/plugins/syslog/OpenSLX/OSPlugin/syslog.pm +++ b/os-plugins/plugins/syslog/OpenSLX/OSPlugin/syslog.pm @@ -108,11 +108,13 @@ sub getAttrInfo sub installationPhase { my $self = shift; + my $info = shift; - $self->{pluginRepositoryPath} = shift; - $self->{pluginTempPath} = shift; - $self->{openslxPath} = shift; - $self->{attrs} = shift; + $self->{pluginRepositoryPath} = $info->{'plugin-repo-path'}; + $self->{pluginTempPath} = $info->{'plugin-temp-path'}; + $self->{openslxBasePath} = $info->{'openslx-base-path'}; + $self->{openslxConfigPath} = $info->{'openslx-config-path'}; + $self->{attrs} = $info->{'plugin-attrs'}; # We are going to change some of the stage1 attributes during installation # (basically we are filling the ones that are not defined). Since the result @@ -167,9 +169,8 @@ die 'sorry, support for kind "syslogd" is not implemented yet!'; sub removalPhase { my $self = shift; - my $pluginRepositoryPath = shift; - my $pluginTempPath = shift; - + my $info = shift; + return; } diff --git a/os-plugins/plugins/vmchooser/OpenSLX/OSPlugin/vmchooser.pm b/os-plugins/plugins/vmchooser/OpenSLX/OSPlugin/vmchooser.pm index 778e419c..2db3c315 100644 --- a/os-plugins/plugins/vmchooser/OpenSLX/OSPlugin/vmchooser.pm +++ b/os-plugins/plugins/vmchooser/OpenSLX/OSPlugin/vmchooser.pm @@ -65,56 +65,27 @@ sub getAttrInfo sub installationPhase -{ # called while chrooted to the vendor-OS root in order to give the plugin - # a chance to install required files into the vendor-OS. +{ my $self = shift; + my $info = shift; - my $pluginRepositoryPath = shift; - # The folder where the stage1-plugin should store all files - # required by the corresponding stage3 runlevel script. - # As this method is being executed while chrooted into the vendor-OS, - # this path is relative to that root (i.e. directly usable). - my $pluginTempPath = shift; - # A temporary playground that will be cleaned up automatically. - # As this method is being executed while chrooted into the vendor-OS, - # this path is relative to that root (i.e. directly usable). - my $openslxPath = shift; - # the openslx base path bind-mounted into the chroot (/mnt/openslx) - - # for this example plugin, we simply create two files: - #spitFile("$pluginRepositoryPath/right", "(-;\n"); - #spitFile("$pluginRepositoryPath/left", ";-)\n"); - - # Some plugins have to copy files from their plugin folder into the - # vendor-OS. In order to make this possible while chrooted, the host's - # /opt/openslx folder will be mounted to /mnt/openslx in the vendor-OS. - # get our own name: - my $pluginName = $self->{'name'}; - - - # get our own base path: - my $pluginBasePath = "/mnt/openslx/lib/plugins/$pluginName/files"; - + my $pluginRepoPath = $info->{'plugin-repo-path'}; + my $openslxBasePath = $info->{'openslx-base-path'}; + # copy all needed files now: - #system( "bash") ; + my $pluginName = $self->{'name'}; + my $pluginBasePath = "$openslxBasePath/lib/plugins/$pluginName/files"; foreach my $file ( qw( vmchooser ) ) { - copyFile("$pluginBasePath/$file", "$pluginRepositoryPath/"); + copyFile("$pluginBasePath/$file", "$pluginRepoPath/"); } - # name of current os - # $self->{'os-plugin-engine'}->{'vendor-os-name'} - return; } sub removalPhase -{ # called while chrooted to the vendor-OS root in order to give the plugin - # a chance to uninstall no longer required files from the vendor-OS. +{ my $self = shift; - my $pluginRepositoryPath = shift; - # the repository folder, relative to the vendor-OS root - my $pluginTempPath = shift; - # the temporary folder, relative to the vendor-OS root + my $info = shift; return; } diff --git a/os-plugins/plugins/vmware/OpenSLX/OSPlugin/vmware.pm b/os-plugins/plugins/vmware/OpenSLX/OSPlugin/vmware.pm index 16dfe520..e04aed0b 100644 --- a/os-plugins/plugins/vmware/OpenSLX/OSPlugin/vmware.pm +++ b/os-plugins/plugins/vmware/OpenSLX/OSPlugin/vmware.pm @@ -171,12 +171,14 @@ sub getAttrInfo sub installationPhase { - my $self = shift; - - $self->{pluginRepositoryPath} = shift; - $self->{pluginTempPath} = shift; - $self->{openslxPath} = shift; - $self->{attrs} = shift; + my $self = shift; + my $info = shift; + + $self->{pluginRepositoryPath} = $info->{'plugin-repo-path'}; + $self->{pluginTempPath} = $info->{'plugin-temp-path'}; + $self->{openslxBasePath} = $info->{'openslx-base-path'}; + $self->{openslxConfigPath} = $info->{'openslx-config-path'}; + $self->{attrs} = $info->{'plugin-attrs'}; # kinds we will configure and install @@ -194,11 +196,9 @@ sub installationPhase sub removalPhase { - my $self = shift; - my $pluginRepositoryPath = shift; - my $pluginTempPath = shift; - - rmtree ( [ $pluginRepositoryPath ] ); + my $self = shift; + my $info = shift; + # restore old start scripts - to be discussed my @files = qw( vmware vmplayer ); foreach my $file (@files) { @@ -314,7 +314,7 @@ sub _localInstallation my $vmbuildversion = ""; my $pluginFilesPath - = "$self->{'openslxPath'}/lib/plugins/$self->{'name'}/files"; + = "$self->{'openslxBasePath'}/lib/plugins/$self->{'name'}/files"; my $installationPath = "$self->{'pluginRepositoryPath'}/$kind"; mkpath($installationPath); @@ -410,7 +410,7 @@ sub _vmpl2Installation { my $vmbuildversion = "TODO_we_need_it_for_enhanced_runvmware_config_in_stage1"; my $pluginFilesPath - = "$self->{'openslxPath'}/lib/plugins/$self->{'name'}/files"; + = "$self->{'openslxBasePath'}/lib/plugins/$self->{'name'}/files"; my $installationPath = "$self->{'pluginRepositoryPath'}/$kind"; mkpath($installationPath); diff --git a/os-plugins/plugins/x11vnc/OpenSLX/OSPlugin/x11vnc.pm b/os-plugins/plugins/x11vnc/OpenSLX/OSPlugin/x11vnc.pm index 16bf4fe1..37dc14bd 100644 --- a/os-plugins/plugins/x11vnc/OpenSLX/OSPlugin/x11vnc.pm +++ b/os-plugins/plugins/x11vnc/OpenSLX/OSPlugin/x11vnc.pm @@ -176,40 +176,39 @@ sub getAttrInfo sub installationPhase { my $self = shift; - my $pluginRepositoryPath = shift; - my $pluginTempPath = shift; - my $openslxPath = shift; + my $info = shift; + + my $pluginRepositoryPath = $info->{'plugin-repo-path'}; + my $pluginTempPath = $info->{'plugin-temp-path'}; + my $openslxBasePath = $info->{'openslx-base-path'}; # get path of files we need to install - my $pluginFilesPath = "$openslxPath/lib/plugins/$self->{'name'}/files"; + my $pluginFilesPath = "$openslxBasePath/lib/plugins/$self->{'name'}/files"; # copy all needed files now copyFile("$pluginFilesPath/x11vnc", "/etc/init.d"); vlog(3, "install init file"); if ( !-x "/usr/bin/x11vnc" ) { - # let's install x11vnc - if ( $self->{'os-plugin-engine'}->{'vendor-os-name'} =~ m/(debian|ubuntu)/i ) { - my $cmd = "aptitude -y install x11vnc"; - vlog(3, "executing: $cmd"); - if (slxsystem($cmd)) { - die _tr( - "unable to execute shell-cmd\n\t%s", $cmd - ); + # let's install x11vnc + my $vendorOSName = $self->{'os-plugin-engine'}->{'vendor-os-name'}; + if ( $vendorOSName =~ m/(debian|ubuntu)/i ) { + my $cmd = "aptitude -y install x11vnc"; + vlog(3, "executing: $cmd"); + if (slxsystem($cmd)) { + die _tr("unable to execute shell-cmd\n\t%s", $cmd); + } } - } - if ( $self->{'os-plugin-engine'}->{'vendor-os-name'} =~ m/suse/i ) { - # PLEASE TEST THIS!!! - my $cmd = "zypper -n in x11vnc"; - vlog(3, "executing: $cmd"); - if (slxsystem($cmd)) { - die _tr( - "unable to execute shell-cmd\n\t%s", $cmd - ); + if ( $vendorOSName =~ m/suse/i ) { + # PLEASE TEST THIS!!! + my $cmd = "zypper -n in x11vnc"; + vlog(3, "executing: $cmd"); + if (slxsystem($cmd)) { + die _tr("unable to execute shell-cmd\n\t%s", $cmd); + } } - } } else { - vlog(3, "x11vnc is already installed"); + vlog(3, "x11vnc is already installed"); } } @@ -217,8 +216,7 @@ sub installationPhase sub removalPhase { my $self = shift; - my $pluginRepositoryPath = shift; - my $pluginTempPath = shift; + my $info = shift; } 1; -- cgit v1.2.3-55-g7522