summaryrefslogtreecommitdiffstats
path: root/os-plugins
diff options
context:
space:
mode:
authorOliver Tappe2008-02-16 18:18:42 +0100
committerOliver Tappe2008-02-16 18:18:42 +0100
commit78a77be447311f092e92c19b0371379f533c4ec5 (patch)
treec6d0fd0d52cd29e346362250d3579e0ca8f2be3b /os-plugins
parent* when invoking init-hook scripts and plugin scripts, now only *.sh files (diff)
downloadcore-78a77be447311f092e92c19b0371379f533c4ec5.tar.gz
core-78a77be447311f092e92c19b0371379f533c4ec5.tar.xz
core-78a77be447311f092e92c19b0371379f533c4ec5.zip
Refactored call-out to plugins when making the initramfs:
* The code for setting up the plugin in the initramfs has been moved into the plugin base, as this makes it possible for any plugin to override it (should the need ever arise). * The plugin scripts themselves are now being copied into the initramfs, instead of being part of the config-TGZ - they are static scripts, so there's no need to make them part of the config. Only the actual settings of each plugin are part of the config-TGZ now. * Cleaned up most accesses from plugins to private data of the makeInitRamFS- engine. I have tested with these changes with Ubuntu and Debian, and splashy still works for both, so it should be ok. git-svn-id: http://svn.openslx.org/svn/openslx/trunk@1551 95ad53e4-c205-0410-b2fa-d234c58c8868
Diffstat (limited to 'os-plugins')
-rw-r--r--os-plugins/OpenSLX/OSPlugin/Base.pm73
-rw-r--r--os-plugins/plugins/example/OpenSLX/OSPlugin/example.pm4
-rw-r--r--os-plugins/plugins/theme/OpenSLX/OSPlugin/theme.pm14
-rw-r--r--os-plugins/plugins/vmware/OpenSLX/OSPlugin/vmware.pm8
4 files changed, 81 insertions, 18 deletions
diff --git a/os-plugins/OpenSLX/OSPlugin/Base.pm b/os-plugins/OpenSLX/OSPlugin/Base.pm
index 51990912..c1945c95 100644
--- a/os-plugins/OpenSLX/OSPlugin/Base.pm
+++ b/os-plugins/OpenSLX/OSPlugin/Base.pm
@@ -146,11 +146,10 @@ sub postRemovalPhase
sub suggestAdditionalKernelParams
{ # called by config-demuxer in order to give the plugin a chance to add
# any kernel params it requires.
- # In order to do so, the plugin should analyse the contents of the
- # given string ('kernel-params') and return a list of additional params
- # that it would like to see added.
- my $self = shift;
- my $kernelParams = shift;
+ # In order to do so, the plugin should return a list of additional kernel
+ # params that it would like to see added.
+ my $self = shift;
+ my $makeInitRamFSEngine = shift;
return;
}
@@ -171,7 +170,8 @@ sub copyRequiredFilesIntoInitramfs
# all required files from the vendor-OS into the initramfs.
# N.B.: Only files that are indeed required by the initramfs should be
# copied here, i.e. files that are needed *before* the root-fs
- # has been mounted!
+ # has been mounted.
+ # All other files should be taken from the root-fs instead!
my $self = shift;
my $targetPath = shift;
my $attrs = shift;
@@ -179,3 +179,64 @@ sub copyRequiredFilesIntoInitramfs
return;
}
+
+sub setupPluginInInitramfs
+{ # called by config-demuxer in order to let the plugin setup all the files
+ # it requires in the initramfs.
+ # Normally, you don't need to override this method in your own plugin,
+ # as it is usually enough to override suggestAdditionalKernelParams(),
+ # suggestAdditionalKernelModules() and maybe copyRequiredFilesIntoInitramfs().
+ my $self = shift;
+ my $attrs = shift;
+ my $makeInitRamFSEngine = shift;
+
+ my $pluginName = $self->{name};
+ my $pluginSrcPath = "$openslxConfig{'base-path'}/lib/plugins";
+ my $buildPath = $makeInitRamFSEngine->{'build-path'};
+ my $pluginInitdPath = "$buildPath/etc/plugin-init.d";
+ my $initHooksPath = "$buildPath/etc/init-hooks";
+
+ # copy runlevel script
+ my $precedence
+ = sprintf('%02d', $attrs->{"${pluginName}::precedence"});
+ my $scriptName = "$pluginSrcPath/$pluginName/XX_${pluginName}.sh";
+ my $targetName = "$pluginInitdPath/${precedence}_${pluginName}.sh";
+ if (-e $scriptName) {
+ $makeInitRamFSEngine->addCMD("cp $scriptName $targetName");
+ $makeInitRamFSEngine->addCMD("chmod a+x $targetName");
+ }
+
+ # copy init hook scripts, if any
+ if (-d "$pluginSrcPath/$pluginName/init-hooks") {
+ my $hookSrcPath = "$pluginSrcPath/$pluginName/init-hooks";
+ $makeInitRamFSEngine->addCMD(
+ "cp -r $hookSrcPath/* $buildPath/etc/init-hooks/"
+ );
+ }
+
+ # invoke hook methods to suggest additional kernel params ...
+ my @suggestedParams
+ = $self->suggestAdditionalKernelParams($makeInitRamFSEngine);
+ if (@suggestedParams) {
+ my $params = join ' ', @suggestedParams;
+ vlog(1, "plugin $pluginName suggests these kernel params: $params");
+ $makeInitRamFSEngine->addKernelParams(@suggestedParams);
+ }
+
+ # ... and kernel modules
+ my @suggestedModules
+ = $self->suggestAdditionalKernelModules($makeInitRamFSEngine);
+ if (@suggestedModules) {
+ my $modules = join(',', @suggestedModules);
+ vlog(1, "plugin $pluginName suggests these kernel modules: $modules");
+ $makeInitRamFSEngine->addKernelModules(@suggestedModules);
+ }
+
+ # invoke hook method to copy any further files that are required in stage3
+ # before the root-fs has been mounted
+ $self->copyRequiredFilesIntoInitramfs(
+ $buildPath, $attrs, $makeInitRamFSEngine
+ );
+
+ return 1;
+}
diff --git a/os-plugins/plugins/example/OpenSLX/OSPlugin/example.pm b/os-plugins/plugins/example/OpenSLX/OSPlugin/example.pm
index 787991c3..252e8ae7 100644
--- a/os-plugins/plugins/example/OpenSLX/OSPlugin/example.pm
+++ b/os-plugins/plugins/example/OpenSLX/OSPlugin/example.pm
@@ -30,7 +30,9 @@ sub new
{
my $class = shift;
- my $self = {};
+ my $self = {
+ name => 'example',
+ };
return bless $self, $class;
}
diff --git a/os-plugins/plugins/theme/OpenSLX/OSPlugin/theme.pm b/os-plugins/plugins/theme/OpenSLX/OSPlugin/theme.pm
index c2897eec..4bd83c69 100644
--- a/os-plugins/plugins/theme/OpenSLX/OSPlugin/theme.pm
+++ b/os-plugins/plugins/theme/OpenSLX/OSPlugin/theme.pm
@@ -29,7 +29,9 @@ sub new
{
my $class = shift;
- my $self = {};
+ my $self = {
+ name => 'theme',
+ };
return bless $self, $class;
}
@@ -113,20 +115,18 @@ sub getAttrInfo
sub suggestAdditionalKernelParams
{
- my $self = shift;
- my $kernelParams = shift;
+ my $self = shift;
+ my $makeInitRamFSEngine = shift;
my @suggestedParams;
# add vga=0x317 unless explicit vga-mode is already set
- if ($kernelParams !~ m{\bvga=}) {
- vlog(1, "theme-plugin: adding kernel-param vga=0x317");
+ if (!$makeInitRamFSEngine->haveKernelParam(qr{\bvga=})) {
push @suggestedParams, 'vga=0x317';
}
# add quiet, if not already set
- if ($kernelParams !~ m{\bquiet\b}) {
- vlog(1, "theme-plugin: adding kernel-param quiet");
+ if (!$makeInitRamFSEngine->haveKernelParam('quiet')) {
push @suggestedParams, 'quiet';
}
diff --git a/os-plugins/plugins/vmware/OpenSLX/OSPlugin/vmware.pm b/os-plugins/plugins/vmware/OpenSLX/OSPlugin/vmware.pm
index b466dd17..d3d5375a 100644
--- a/os-plugins/plugins/vmware/OpenSLX/OSPlugin/vmware.pm
+++ b/os-plugins/plugins/vmware/OpenSLX/OSPlugin/vmware.pm
@@ -25,7 +25,9 @@ sub new
{
my $class = shift;
- my $self = {};
+ my $self = {
+ name => 'vmware',
+ };
return bless $self, $class;
}
@@ -83,9 +85,7 @@ sub suggestAdditionalKernelModules
my $makeInitRamFSEngine = shift;
# simply suggest these and see where we go from there (what is vmblock?)
- my @suggestedModules = qw( vmmon vmnet vmblock );
-
- return @suggestedModules;
+ return qw( vmmon vmnet vmblock );
}
1;