From 78a77be447311f092e92c19b0371379f533c4ec5 Mon Sep 17 00:00:00 2001 From: Oliver Tappe Date: Sat, 16 Feb 2008 17:18:42 +0000 Subject: 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 --- initramfs/OpenSLX/MakeInitRamFS/Engine.pm | 80 +++++++++++++++++-------------- 1 file changed, 44 insertions(+), 36 deletions(-) (limited to 'initramfs/OpenSLX/MakeInitRamFS/Engine.pm') diff --git a/initramfs/OpenSLX/MakeInitRamFS/Engine.pm b/initramfs/OpenSLX/MakeInitRamFS/Engine.pm index bd30d15f..577cb168 100644 --- a/initramfs/OpenSLX/MakeInitRamFS/Engine.pm +++ b/initramfs/OpenSLX/MakeInitRamFS/Engine.pm @@ -93,6 +93,41 @@ sub execute return; } +sub haveKernelParam +{ + my $self = shift; + my $param = shift; + + return ref $param eq 'Regexp' + ? grep { $_ =~ $param } @{ $self->{'kernel-params'} } + : grep { $_ eq $param } @{ $self->{'kernel-params'} }; +} + +sub addKernelParams +{ + my $self = shift; + + push @{ $self->{'kernel-params'} }, @_; + + return; +} + +sub kernelParams +{ + my $self = shift; + + return @{ $self->{'kernel-params'} }; +} + +sub addKernelModules +{ + my $self = shift; + + push @{ $self->{'suggested-kernel-modules'} }, @_; + + return; +} + ################################################################################ ### implementation methods ################################################################################ @@ -128,7 +163,7 @@ sub _collectCMDs $self->_copyDebugTools(); } - $self->_handlePlugins(); + $self->_calloutToPlugins(); $self->{distro}->applyChanges($self); @@ -446,10 +481,10 @@ sub _copyRequiredLayeredFSTools my $self = shift; my @tools; - if ($self->{'kernel-params'} =~ m{\bunionfs\b}) { + if ($self->haveKernelParam('unionfs')) { push @tools, 'unionctl'; } - if ($self->{'kernel-params'} =~ m{\bcowloop\b}) { + if ($self->haveKernelParam('cowloop')) { push @tools, 'cowdev'; } foreach my $tool (@tools) { @@ -695,45 +730,18 @@ sub _writeSlxSystemConf return; } -sub _handlePlugins +sub _calloutToPlugins { my $self = shift; - my $pluginSrcPath = "$openslxConfig{'base-path'}/lib/plugins"; - my $buildPath = $self->{'build-path'}; + my $pluginInitdPath = "$self->{'build-path'}/etc/plugin-init.d"; + my $initHooksPath = "$self->{'build-path'}/etc/init-hooks"; + $self->addCMD("mkdir -p $pluginInitdPath $initHooksPath"); + foreach my $pluginName (@{$self->{'plugins'}}) { - if (-d "$pluginSrcPath/$pluginName/init-hooks") { - my $hookSrcPath = "$pluginSrcPath/$pluginName/init-hooks"; - $self->addCMD("cp -r $hookSrcPath/* $buildPath/etc/init-hooks/"); - } my $plugin = OpenSLX::OSPlugin::Roster->getPlugin($pluginName); next if !$plugin; - - my @suggestedKernelParams - = $plugin->suggestAdditionalKernelParams($self->{'kernel-params'}); - if (@suggestedKernelParams) { - my $paramsList = join ' ', @suggestedKernelParams; - vlog( - 2, - "plugin $pluginName suggests these kernel params: $paramsList" - ); - $self->{'kernel-params'} - .= ($self->{'kernel-params'} ? ' ' : '') . $paramsList; - } - - my @suggestedModules = $plugin->suggestAdditionalKernelModules($self); - if (@suggestedModules) { - vlog( - 2, - "plugin $pluginName suggests these kernel modules: " - . join(',', @suggestedModules) - ); - push @{ $self->{'suggested-kernel-modules'} }, @suggestedModules; - } - - $plugin->copyRequiredFilesIntoInitramfs( - $self->{'build-path'}, $self->{attrs}, $self - ); + $plugin->setupPluginInInitramfs($self->{attrs}, $self); } return; } -- cgit v1.2.3-55-g7522