diff options
author | Oliver Tappe | 2008-08-27 23:18:59 +0200 |
---|---|---|
committer | Oliver Tappe | 2008-08-27 23:18:59 +0200 |
commit | 3a7e659fda90fe22bb636497548f2a7dee7261db (patch) | |
tree | 22fbde1b07436879c6ce5f6b37a99b88102e6bed | |
parent | * updated uClibc-busybox with a version that has a fixed udhcpc - please report (diff) | |
download | core-3a7e659fda90fe22bb636497548f2a7dee7261db.tar.gz core-3a7e659fda90fe22bb636497548f2a7dee7261db.tar.xz core-3a7e659fda90fe22bb636497548f2a7dee7261db.zip |
* refactored more boot-environment-specific stuff out of slxconfig-demuxer into
the corresponding class (OpenSLX::BootEnvironment::PXE) - should not cause any
functional changes yet
git-svn-id: http://svn.openslx.org/svn/openslx/openslx/trunk@2110 95ad53e4-c205-0410-b2fa-d234c58c8868
-rw-r--r-- | boot-env/OpenSLX/BootEnvironment/Base.pm | 21 | ||||
-rw-r--r-- | boot-env/OpenSLX/BootEnvironment/CD.pm | 102 | ||||
-rw-r--r-- | boot-env/OpenSLX/BootEnvironment/PXE.pm | 123 | ||||
-rwxr-xr-x | config-db/slxconfig-demuxer | 96 | ||||
-rw-r--r-- | initramfs/OpenSLX/MakeInitRamFS/Engine.pm | 7 |
5 files changed, 248 insertions, 101 deletions
diff --git a/boot-env/OpenSLX/BootEnvironment/Base.pm b/boot-env/OpenSLX/BootEnvironment/Base.pm index 3fa22666..bd8bef55 100644 --- a/boot-env/OpenSLX/BootEnvironment/Base.pm +++ b/boot-env/OpenSLX/BootEnvironment/Base.pm @@ -35,15 +35,28 @@ sub initialize my $self = shift; my $params = shift; - $self->{'build-path'} = $params->{'build-path'}; - $self->{'dry-run'} = $params->{'dry-run'}; + $self->{'target-path'} = $params->{'target-path'}; + $self->{'dry-run'} = $params->{'dry-run'}; return 1; } -sub prepareBootloaderConfigFolder +sub writeBootloaderMenuFor { - my $self = shift; + my $self = shift; + my $client = shift; + my $externalClientID = shift; + my $systemInfos = shift; + + return; +} + +sub writeFilesRequiredForBooting +{ + my $self = shift; + my $info = shift; + my $tftpbuildPath = shift; + my $slxVersion = shift; return; } diff --git a/boot-env/OpenSLX/BootEnvironment/CD.pm b/boot-env/OpenSLX/BootEnvironment/CD.pm new file mode 100644 index 00000000..9328359b --- /dev/null +++ b/boot-env/OpenSLX/BootEnvironment/CD.pm @@ -0,0 +1,102 @@ +# Copyright (c) 2008 - OpenSLX GmbH +# +# This program is free software distributed under the GPL version 2. +# See http://openslx.org/COPYING +# +# If you have any feedback please consult http://openslx.org/feedback and +# send your suggestions, praise, or complaints to feedback@openslx.org +# +# General information about OpenSLX can be found at http://openslx.org/ +# ----------------------------------------------------------------------------- +# BootEnvironment::CD.pm +# - provides CD-specific implementation of the BootEnvironment API. +# ----------------------------------------------------------------------------- +package OpenSLX::BootEnvironment::CD; + +use strict; +use warnings; + +use base qw(OpenSLX::BootEnvironment::Base); + +use Clone qw(clone); +use File::Basename; +use File::Path; + +use OpenSLX::Basics; +use OpenSLX::MakeInitRamFS::Engine; +use OpenSLX::Utils; + +sub writeFilesRequiredForBooting +{ + my $self = shift; + my $info = shift; + my $tftpbuildPath = shift; + my $slxVersion = shift; + +print "CD-boot not implemented yet\n"; + +return 1; + + my $kernelFile = $info->{'kernel-file'}; + my $kernelName = basename($kernelFile); + + my $vendorOSPath = "$tftpbuildPath/$info->{'vendor-os'}->{name}"; + mkpath $vendorOSPath unless -e $vendorOSPath || $self->{'dry-run'}; + + my $targetKernel = "$vendorOSPath/$kernelName"; + if (!-e $targetKernel) { + vlog(1, _tr('copying kernel %s to %s', $kernelFile, $targetKernel)); + slxsystem(qq[cp -p "$kernelFile" "$targetKernel"]) + unless $self->{'dry-run'}; + } + my $initramfs = "$vendorOSPath/$info->{'initramfs-name'}"; + $self->_makeInitRamFS($info, $initramfs, $slxVersion); + + return 1; +} + +sub _makeInitRamFS +{ + my $self = shift; + my $info = shift; + my $initramfs = shift; + my $slxVersion = shift; + + vlog(1, _tr('generating initialramfs %s', $initramfs)); + + my $vendorOS = $info->{'vendor-os'}; + my $kernelFile = basename(followLink($info->{'kernel-file'})); + + my $attrs = clone($info->{attrs} || {}); + + my $params = { + 'attrs' => $attrs, + 'export-name' => $info->{export}->{name}, + 'export-uri' => $info->{'export-uri'}, + 'initramfs' => $initramfs, + 'kernel-params' => [ split ' ', ($info->{kernel_params} || '') ], + 'kernel-version' => $kernelFile =~ m[-(.+)$] ? $1 : '', + 'plugins' => $info->{'active-plugins'}, + 'root-path' + => "$openslxConfig{'private-path'}/stage1/$vendorOS->{name}", + 'slx-version' => $slxVersion, + 'system-name' => $info->{name}, + }; + + # TODO: make debug-level an explicit attribute, it's used in many places! + my $kernelParams = $info->{kernel_params} || ''; + if ($kernelParams =~ m{debug(?:=(\d+))?}) { + my $debugLevel = defined $1 ? $1 : '1'; + $params->{'debug-level'} = $debugLevel; + } + + my $makeInitRamFSEngine = OpenSLX::MakeInitRamFS::Engine->new($params); + $makeInitRamFSEngine->execute($self->{'dry-run'}); + + # copy back kernel-params, as they might have been changed (by plugins) + $info->{kernel_params} = join ' ', $makeInitRamFSEngine->kernelParams(); + + return; +} + +1; diff --git a/boot-env/OpenSLX/BootEnvironment/PXE.pm b/boot-env/OpenSLX/BootEnvironment/PXE.pm index 931a2335..c362315f 100644 --- a/boot-env/OpenSLX/BootEnvironment/PXE.pm +++ b/boot-env/OpenSLX/BootEnvironment/PXE.pm @@ -18,34 +18,14 @@ use warnings; use base qw(OpenSLX::BootEnvironment::Base); +use Clone qw(clone); use File::Basename; use File::Path; use OpenSLX::Basics; +use OpenSLX::MakeInitRamFS::Engine; use OpenSLX::Utils; -sub prepareBootloaderConfigFolder -{ - my $self = shift; - - my $basePath = $openslxConfig{'base-path'}; - my $pxePath = $self->{'build-path'}; - my $pxeConfigPath = "$pxePath/pxelinux.cfg"; - - if (!$self->{'dry-run'}) { - rmtree($pxeConfigPath); - mkpath($pxeConfigPath); - - for my $file ('pxelinux.0', 'menu.c32', 'vesamenu.c32') { - if (!-e "$pxePath/$file") { - slxsystem(qq[cp -p "$basePath/share/tftpboot/$file" $pxePath/]); - } - } - } - - return 1; -} - sub writeBootloaderMenuFor { my $self = shift; @@ -53,7 +33,10 @@ sub writeBootloaderMenuFor my $externalClientID = shift; my $systemInfos = shift; - my $pxePath = $self->{'build-path'}; + $self->_prepareBootloaderConfigFolder() + unless $self->{preparedBootloaderConfigFolder}; + + my $pxePath = $self->{'target-path'}; my $pxeConfigPath = "$pxePath/pxelinux.cfg"; my $pxeConfig = $self->_getTemplate(); @@ -108,6 +91,31 @@ sub writeBootloaderMenuFor return 1; } +sub writeFilesRequiredForBooting +{ + my $self = shift; + my $info = shift; + my $buildPath = shift; + my $slxVersion = shift; + + my $kernelFile = $info->{'kernel-file'}; + my $kernelName = basename($kernelFile); + + my $vendorOSPath = "$self->{'target-path'}/$info->{'vendor-os'}->{name}"; + mkpath $vendorOSPath unless -e $vendorOSPath || $self->{'dry-run'}; + + my $targetKernel = "$vendorOSPath/$kernelName"; + if (!-e $targetKernel) { + vlog(1, _tr('copying kernel %s to %s', $kernelFile, $targetKernel)); + slxsystem(qq[cp -p "$kernelFile" "$targetKernel"]) + unless $self->{'dry-run'}; + } + my $initramfs = "$vendorOSPath/$info->{'initramfs-name'}"; + $self->_makeInitRamFS($info, $initramfs, $slxVersion); + + return 1; +} + sub _getTemplate { my $self = shift; @@ -182,7 +190,7 @@ sub _getTemplate ? "$basePath/share/themes/${pxeTheme}/pxe/$pic" : $pic; if (-e $pxeBackground && !$self->{'dry-run'}) { - slxsystem(qq[cp "$pxeBackground" $self->{'build-path'}/]); + slxsystem(qq[cp "$pxeBackground" $self->{'target-path'}/]); } } @@ -191,5 +199,72 @@ sub _getTemplate return $pxeTemplate; } +sub _prepareBootloaderConfigFolder +{ + my $self = shift; + + my $basePath = $openslxConfig{'base-path'}; + my $pxePath = $self->{'target-path'}; + my $pxeConfigPath = "$pxePath/pxelinux.cfg"; + + if (!$self->{'dry-run'}) { + rmtree($pxeConfigPath); + mkpath($pxeConfigPath); + + for my $file ('pxelinux.0', 'menu.c32', 'vesamenu.c32') { + if (!-e "$pxePath/$file") { + slxsystem(qq[cp -p "$basePath/share/tftpboot/$file" $pxePath/]); + } + } + } + + $self->{preparedBootloaderConfigFolder} = 1; + + return 1; +} + +sub _makeInitRamFS +{ + my $self = shift; + my $info = shift; + my $initramfs = shift; + my $slxVersion = shift; + + vlog(1, _tr('generating initialramfs %s', $initramfs)); + + my $vendorOS = $info->{'vendor-os'}; + my $kernelFile = basename(followLink($info->{'kernel-file'})); + + my $attrs = clone($info->{attrs} || {}); + + my $params = { + 'attrs' => $attrs, + 'export-name' => $info->{export}->{name}, + 'export-uri' => $info->{'export-uri'}, + 'initramfs' => $initramfs, + 'kernel-params' => [ split ' ', ($info->{kernel_params} || '') ], + 'kernel-version' => $kernelFile =~ m[-(.+)$] ? $1 : '', + 'plugins' => $info->{'active-plugins'}, + 'root-path' + => "$openslxConfig{'private-path'}/stage1/$vendorOS->{name}", + 'slx-version' => $slxVersion, + 'system-name' => $info->{name}, + }; + + # TODO: make debug-level an explicit attribute, it's used in many places! + my $kernelParams = $info->{kernel_params} || ''; + if ($kernelParams =~ m{debug(?:=(\d+))?}) { + my $debugLevel = defined $1 ? $1 : '1'; + $params->{'debug-level'} = $debugLevel; + } + + my $makeInitRamFSEngine = OpenSLX::MakeInitRamFS::Engine->new($params); + $makeInitRamFSEngine->execute($self->{'dry-run'}); + + # copy back kernel-params, as they might have been changed (by plugins) + $info->{kernel_params} = join ' ', $makeInitRamFSEngine->kernelParams(); + + return; +} 1; diff --git a/config-db/slxconfig-demuxer b/config-db/slxconfig-demuxer index 80c19842..accd64e7 100755 --- a/config-db/slxconfig-demuxer +++ b/config-db/slxconfig-demuxer @@ -29,7 +29,6 @@ slxconfig-demuxer Please use the --man option in order to read the full manual. ]; -use Clone qw(clone); use Config::General; use Digest::MD5 qw(md5_hex); use Fcntl qw(:DEFAULT :flock); @@ -50,7 +49,6 @@ use lib "$FindBin::RealBin"; use OpenSLX::Basics; use OpenSLX::ConfigDB qw(:support); use OpenSLX::ConfigFolder; -use OpenSLX::MakeInitRamFS::Engine; use OpenSLX::OSPlugin::Roster; use OpenSLX::ScopedResource; use OpenSLX::Utils; @@ -377,10 +375,9 @@ sub bootEnvironmentForType if (!$bootEnvMap{$bootType}) { my $bootEnv = instantiateClass("OpenSLX::BootEnvironment::$bootType"); $bootEnv->initialize( { - 'build-path' => $tftpbuildPath, - 'dry-run' => $option{dryRun}, + 'target-path' => $tftpbuildPath, + 'dry-run' => $option{dryRun}, } ); - $bootEnv->prepareBootloaderConfigFolder(); $bootEnvMap{$bootType} = $bootEnv; } @@ -413,68 +410,28 @@ sub writeBootloaderMenus return; } -sub makeInitRamFS +sub writeBootEnvironmentForSystem { my $info = shift; - my $initramfs = shift; - - vlog(1, _tr('generating initialramfs %s', $initramfs)); - - my $vendorOS = $info->{'vendor-os'}; - my $kernelFile = basename(followLink($info->{'kernel-file'})); - - my $attrs = clone($info->{attrs} || {}); - - my $params = { - 'attrs' => $attrs, - 'export-name' => $info->{export}->{name}, - 'export-uri' => $info->{'export-uri'}, - 'initramfs' => $initramfs, - 'kernel-params' => [ split ' ', ($info->{kernel_params} || '') ], - 'kernel-version' => $kernelFile =~ m[-(.+)$] ? $1 : '', - 'plugins' => $info->{'active-plugins'}, - 'root-path' - => "$openslxConfig{'private-path'}/stage1/$vendorOS->{name}", - 'slx-version' => $slxVersion, - 'system-name' => $info->{name}, - }; + my $buildPath = shift; + my $clients = shift || []; - # TODO: make debug-level an explicit attribute, it's used in many places! - my $kernelParams = $info->{kernel_params} || ''; - if ($kernelParams =~ m{debug(?:=(\d+))?}) { - my $debugLevel = defined $1 ? $1 : '1'; - $params->{'debug-level'} = $debugLevel; + # handle all different kinds of "preboot-" environments (PXE, CD, grub, ...) + my %bootTypes; + foreach my $client (@$clients) { + my $type = $client->{boot_type} || 'pxe'; + $bootTypes{$type}++; } + foreach my $bootType (sort keys %bootTypes) { + vlog(0, _tr("copying kernel and creating initramfs for $bootType boot")); + + my $bootEnv = bootEnvironmentForType($bootType); + $bootEnv->writeFilesRequiredForBooting( + $info, $buildPath, $slxVersion + ); - my $makeInitRamFSEngine = OpenSLX::MakeInitRamFS::Engine->new($params); - $makeInitRamFSEngine->execute($option{dryRun}); - - # copy back kernel-params, as they might have been changed (by plugins) - $info->{kernel_params} = join ' ', $makeInitRamFSEngine->kernelParams(); - - return; -} - -sub writeKernelAndInitramfsForSystem -{ - my $info = shift; - - vlog(0, _tr('copying kernel and creating initramfs')); - - my $kernelFile = $info->{'kernel-file'}; - my $kernelName = basename($kernelFile); - - my $vendorOSPath = "$tftpbuildPath/$info->{'vendor-os'}->{name}"; - mkpath $vendorOSPath unless -e $vendorOSPath || $option{dryRun}; - - my $targetKernel = "$vendorOSPath/$kernelName"; - if (!-e $targetKernel) { - vlog(1, _tr('copying kernel %s to %s', $kernelFile, $targetKernel)); - slxsystem(qq[cp -p "$kernelFile" "$targetKernel"]) - unless $option{dryRun}; + $initramfsCount++; } - makeInitRamFS($info, "$vendorOSPath/$info->{'initramfs-name'}"); - $initramfsCount++; return; } @@ -498,11 +455,9 @@ sub writeClientConfigurationsForSystem my $info = shift; my $buildPath = shift; my $attrFile = shift; + my $clients = shift || []; - my @clientIDs = $openslxDB->aggregatedClientIDsOfSystem($info); - my @clients = $openslxDB->fetchClientByID(\@clientIDs); - - foreach my $client (@clients) { + foreach my $client (@$clients) { next if $client->{name} eq '<<<default>>>'; # skip default client, as it doesn't need any config-tgz @@ -641,11 +596,12 @@ sub writeSystemConfiguration my $info = shift; my $isTargetSystem = shift; + $info->{'initramfs-name'} = "initramfs-$info->{id}"; + # if this is not a target system, we shall not write any configurations, # but we simply incorporate inherited attributes if (!$isTargetSystem) { $openslxDB->mergeDefaultAttributesIntoSystem($info); - $info->{'initramfs-name'} = "initramfs-$info->{id}"; return; } @@ -683,10 +639,12 @@ sub writeSystemConfiguration my $systemPath = "$tftpbuildPath/client-config/$info->{'external-id'}"; createTarOfPath($buildPath, "default.tgz", $systemPath); - $info->{'initramfs-name'} = "initramfs-$info->{id}"; - writeKernelAndInitramfsForSystem($info); + my @clientIDs = $openslxDB->aggregatedClientIDsOfSystem($info); + my @clients = $openslxDB->fetchClientByID(\@clientIDs); + + writeBootEnvironmentForSystem($info, $buildPath, \@clients); - writeClientConfigurationsForSystem($info, $buildPath, $attrFile); + writeClientConfigurationsForSystem($info, $buildPath, $attrFile, \@clients); slxsystem("rm -rf $buildPath") unless $option{dryRun}; diff --git a/initramfs/OpenSLX/MakeInitRamFS/Engine.pm b/initramfs/OpenSLX/MakeInitRamFS/Engine.pm index fbcf35a0..42ee2398 100644 --- a/initramfs/OpenSLX/MakeInitRamFS/Engine.pm +++ b/initramfs/OpenSLX/MakeInitRamFS/Engine.pm @@ -29,7 +29,6 @@ use OpenSLX::Utils; # TODO: implement support for the following (either here or as plugin): # wlan # tpm -# cdboot (must be implemented here!) ################################################################################ ### interface methods @@ -378,9 +377,9 @@ sub _copyKernelModules $self->addCMD("mkdir -p $targetPath"); $self->addCMD("cp -p $sourcePath/modules.* $targetPath/"); - # TODO: find out what's the story behing the supposedly required - # modules 'af_packet', 'unix' and 'hid' (which seem to be - # missing at least on some systems) + # add a couple of kernel modules that we expect to be used in stage3 + # (some of these modules do not exist on all distros, so they will be + # filtered out again by the respective distro object): my @kernelModules = qw( af_packet unix hid usbhid uhci-hcd ohci-hcd ); |