From 898eca2232289d3f64431bc3763da4b65bb3ae61 Mon Sep 17 00:00:00 2001 From: Oliver Tappe Date: Wed, 20 Jun 2007 18:04:19 +0000 Subject: * split export type into filesystem and (optional) blockdevice, closing ticket#139 * code-reformatting with perltidy git-svn-id: http://svn.openslx.org/svn/openslx/trunk@1176 95ad53e4-c205-0410-b2fa-d234c58c8868 --- installer/OpenSLX/OSExport/BlockDevice/AoE.pm | 98 +++++++ installer/OpenSLX/OSExport/BlockDevice/Base.pm | 62 ++++ installer/OpenSLX/OSExport/BlockDevice/NBD.pm | 91 ++++++ installer/OpenSLX/OSExport/Engine.pm | 242 ++++++++------- installer/OpenSLX/OSExport/ExportType/Base.pm | 128 -------- .../OpenSLX/OSExport/ExportType/NBD_Squash.pm | 262 ----------------- installer/OpenSLX/OSExport/ExportType/NFS.pm | 123 -------- installer/OpenSLX/OSExport/FileSystem/Base.pm | 81 ++++++ installer/OpenSLX/OSExport/FileSystem/NFS.pm | 150 ++++++++++ installer/OpenSLX/OSExport/FileSystem/SquashFS.pm | 323 +++++++++++++++++++++ installer/OpenSLX/OSSetup/Engine.pm | 144 ++++----- installer/OpenSLX/OSSetup/Packager/rpm.pm | 4 +- installer/slxos-export | 100 ++++--- 13 files changed, 1076 insertions(+), 732 deletions(-) create mode 100644 installer/OpenSLX/OSExport/BlockDevice/AoE.pm create mode 100644 installer/OpenSLX/OSExport/BlockDevice/Base.pm create mode 100644 installer/OpenSLX/OSExport/BlockDevice/NBD.pm delete mode 100644 installer/OpenSLX/OSExport/ExportType/Base.pm delete mode 100644 installer/OpenSLX/OSExport/ExportType/NBD_Squash.pm delete mode 100644 installer/OpenSLX/OSExport/ExportType/NFS.pm create mode 100644 installer/OpenSLX/OSExport/FileSystem/Base.pm create mode 100644 installer/OpenSLX/OSExport/FileSystem/NFS.pm create mode 100644 installer/OpenSLX/OSExport/FileSystem/SquashFS.pm (limited to 'installer') diff --git a/installer/OpenSLX/OSExport/BlockDevice/AoE.pm b/installer/OpenSLX/OSExport/BlockDevice/AoE.pm new file mode 100644 index 00000000..c8aad4ec --- /dev/null +++ b/installer/OpenSLX/OSExport/BlockDevice/AoE.pm @@ -0,0 +1,98 @@ +# Copyright (c) 2006, 2007 - 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/ +# ----------------------------------------------------------------------------- +# AoE.pm +# - provides ATA-over-Ethernet specific overrides of the +# OpenSLX::OSExport::BlockDevice API. +# ----------------------------------------------------------------------------- +package OpenSLX::OSExport::BlockDevice::AoE; + +use vars qw($VERSION); +use base qw(OpenSLX::OSExport::BlockDevice::Base); +$VERSION = 1.01; # API-version . implementation-version + +use strict; +use Carp; +use File::Basename; +use OpenSLX::Basics; +use OpenSLX::ConfigDB qw(:support); +use OpenSLX::OSExport::BlockDevice::Base 1; +use OpenSLX::Utils; + +# +# +# N.B.: currently this is just a stub +# +# + + +################################################################################ +### interface methods +################################################################################ +sub new +{ + my $class = shift; + my $self = {'name' => 'aoe',}; + return bless $self, $class; +} + +sub initialize +{ + my $self = shift; + my $engine = shift; + my $fs = shift; + + $self->{'engine'} = $engine; + $self->{'fs'} = $fs; +} + +sub getExportPort +{ + my $self = shift; + my $openslxDB = shift; + + return $openslxDB->incrementGlobalCounter('next-nbd-server-port'); +} + +sub generateExportURI +{ + my $self = shift; + my $export = shift; + + my $server = + length($export->{server_ip}) + ? $export->{server_ip} + : generatePlaceholderFor('serverip'); + $server .= ":$export->{port}" if length($export->{port}); + + return "aoe://$server"; +} + +sub requiredBlockDeviceModules +{ + my $self = shift; + + return 'aoe'; +} + +sub showExportConfigInfo +{ + my $self = shift; + my $export = shift; + + print(('#' x 80) . "\n"); + print _tr( + "Please make sure you start a corresponding aoe-server:\n\t%s\n", + "... (don't know how this is done yet)" + ); + print(('#' x 80) . "\n"); +} + +1; diff --git a/installer/OpenSLX/OSExport/BlockDevice/Base.pm b/installer/OpenSLX/OSExport/BlockDevice/Base.pm new file mode 100644 index 00000000..938dc6db --- /dev/null +++ b/installer/OpenSLX/OSExport/BlockDevice/Base.pm @@ -0,0 +1,62 @@ +# Copyright (c) 2006, 2007 - 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/ +# ----------------------------------------------------------------------------- +# Base.pm +# - provides empty base of the OpenSLX OSExport::BlockDevice API. +# ----------------------------------------------------------------------------- +package OpenSLX::OSExport::BlockDevice::Base; + +use vars qw($VERSION); +$VERSION = 1.01; # API-version . implementation-version + +use strict; +use Carp; + +use OpenSLX::Basics; +use OpenSLX::Utils; + +################################################################################ +### interface methods +################################################################################ +sub new +{ + confess "Creating OpenSLX::OSExport::BlockDevice::Base-objects directly makes no sense!"; +} + +sub initialize +{ +} + +sub getExportPort +{ +} + +sub generateExportURI +{ +} + +sub requiredBlockDeviceModules +{ +} + +sub showExportConfigInfo +{ +} + +1; +################################################################################ + +=pod + +=head1 NAME + +OpenSLX::OSExport::BlockDevice::Base - the base class for all OSExport::BlockDevices + +=cut diff --git a/installer/OpenSLX/OSExport/BlockDevice/NBD.pm b/installer/OpenSLX/OSExport/BlockDevice/NBD.pm new file mode 100644 index 00000000..8afaa97f --- /dev/null +++ b/installer/OpenSLX/OSExport/BlockDevice/NBD.pm @@ -0,0 +1,91 @@ +# Copyright (c) 2006, 2007 - 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/ +# ----------------------------------------------------------------------------- +# NBD.pm +# - provides NBD+Squashfs-specific overrides of the +# OpenSLX::OSExport::BlockDevice API. +# ----------------------------------------------------------------------------- +package OpenSLX::OSExport::BlockDevice::NBD; + +use vars qw($VERSION); +use base qw(OpenSLX::OSExport::BlockDevice::Base); +$VERSION = 1.01; # API-version . implementation-version + +use strict; +use Carp; +use File::Basename; +use OpenSLX::Basics; +use OpenSLX::ConfigDB qw(:support); +use OpenSLX::OSExport::BlockDevice::Base 1; +use OpenSLX::Utils; + +################################################################################ +### interface methods +################################################################################ +sub new +{ + my $class = shift; + my $self = {'name' => 'nbd',}; + return bless $self, $class; +} + +sub initialize +{ + my $self = shift; + my $engine = shift; + my $fs = shift; + + $self->{'engine'} = $engine; + $self->{'fs'} = $fs; +} + +sub getExportPort +{ + my $self = shift; + my $openslxDB = shift; + + return $openslxDB->incrementGlobalCounter('next-nbd-server-port'); +} + +sub generateExportURI +{ + my $self = shift; + my $export = shift; + + my $server = + length($export->{server_ip}) + ? $export->{server_ip} + : generatePlaceholderFor('serverip'); + $server .= ":$export->{port}" if length($export->{port}); + + return "nbd://$server"; +} + +sub requiredBlockDeviceModules +{ + my $self = shift; + + return 'nbd'; +} + +sub showExportConfigInfo +{ + my $self = shift; + my $export = shift; + + print(('#' x 80) . "\n"); + print _tr( + "Please make sure you start a corresponding nbd-server:\n\t%s\n", + "nbd-server $export->{port} $self->{fs}->{'export-path'} -r" + ); + print(('#' x 80) . "\n"); +} + +1; diff --git a/installer/OpenSLX/OSExport/Engine.pm b/installer/OpenSLX/OSExport/Engine.pm index 6668416a..5d08c177 100644 --- a/installer/OpenSLX/OSExport/Engine.pm +++ b/installer/OpenSLX/OSExport/Engine.pm @@ -14,13 +14,14 @@ package OpenSLX::OSExport::Engine; use vars qw(@ISA @EXPORT $VERSION); -$VERSION = 1.01; # API-version . implementation-version +$VERSION = 1.01; # API-version . implementation-version use Exporter; @ISA = qw(Exporter); @EXPORT = qw( - %supportedExportTypes %supportedDistros + %supportedExportFileSystems %supportedExportBlockDevices + @supportedExportTypes %supportedDistros ); use strict; @@ -30,28 +31,27 @@ use File::Basename; use OpenSLX::Basics; use OpenSLX::Utils; -use vars qw(%supportedExportTypes %supportedDistros); +use vars qw( + %supportedExportFileSystems %supportedExportBlockDevices + @supportedExportTypes %supportedDistros +); -%supportedExportTypes = ( - 'nfs' - => { module => 'NFS' }, - 'nbd' - => { module => 'NBD_Squash' }, +%supportedExportFileSystems = ( + 'nfs' => 'NFS', + 'sqfs' => 'SquashFS', ); +%supportedExportBlockDevices = ('nbd' => 'NBD', 'aoe' => 'AoE'); + +@supportedExportTypes = ('nfs', 'sqfs-aoe', 'sqfs-nbd'); + %supportedDistros = ( - '' - => { module => 'Any' }, - 'debian' - => { module => 'Debian' }, - 'fedora' - => { module => 'Fedora' }, - 'gentoo' - => { module => 'Gentoo' }, - 'suse' - => { module => 'SUSE' }, - 'ubuntu' - => { module => 'Ubuntu' }, + '' => {module => 'Any'}, + 'debian' => {module => 'Debian'}, + 'fedora' => {module => 'Fedora'}, + 'gentoo' => {module => 'Gentoo'}, + 'suse' => {module => 'SUSE'}, + 'ubuntu' => {module => 'Ubuntu'}, ); ################################################################################ @@ -61,55 +61,52 @@ sub new { my $class = shift; - my $self = { - }; + my $self = {}; return bless $self, $class; } sub initializeFromExisting { - my $self = shift; + my $self = shift; my $exportName = shift; my $openslxDB = instantiateClass("OpenSLX::ConfigDB"); $openslxDB->connect(); - my $export - = $openslxDB->fetchExportByFilter({'name' => $exportName}); + my $export = $openslxDB->fetchExportByFilter({'name' => $exportName}); if (!defined $export) { die _tr("Export '%s' not found in DB, giving up!", $exportName); } - my $vendorOS - = $openslxDB->fetchVendorOSByFilter({ 'id' => $export->{vendor_os_id} }); + my $vendorOS = + $openslxDB->fetchVendorOSByFilter({'id' => $export->{vendor_os_id}}); $openslxDB->disconnect(); - $self->_initialize($vendorOS->{name}, $vendorOS->{id}, - $export->{name}, $export->{type}); + $self->_initialize($vendorOS->{name}, $vendorOS->{id}, $export->{name}, + $export->{type}); } sub initializeForNew { - my $self = shift; + my $self = shift; my $vendorOSName = shift; - my $exportType = lc(shift); + my $exportType = lc(shift); my $openslxDB = instantiateClass("OpenSLX::ConfigDB"); $openslxDB->connect(); - my $vendorOS - = $openslxDB->fetchVendorOSByFilter({ 'name' => $vendorOSName }); + my $vendorOS = $openslxDB->fetchVendorOSByFilter({'name' => $vendorOSName}); if (!defined $vendorOS) { die _tr("vendor-OS '%s' not found in DB, giving up!", $vendorOSName); } - my $exportName = "$vendorOSName-$exportType"; + my $exportName = "$vendorOSName:$exportType"; $openslxDB->disconnect(); - $self->_initialize($vendorOS->{name}, $vendorOS->{id}, - $exportName, $exportType); + $self->_initialize($vendorOS->{name}, $vendorOS->{id}, $exportName, + $exportType); } sub exportVendorOS @@ -117,27 +114,37 @@ sub exportVendorOS my $self = shift; if (!$self->{'exporter'}->checkRequirements($self->{'vendor-os-path'})) { - die _tr("clients wouldn't be able to access the exported root-fs!\nplease install the missing module(s) or use another export-type."); + die _tr( + "clients wouldn't be able to access the exported root-fs!\nplease " + . "install the missing module(s) or use another export-type."); } - $self->{'exporter'}->exportVendorOS( - $self->{'vendor-os-path'}, - $self->{'export-path'} + $self->{'exporter'}->exportVendorOS($self->{'vendor-os-path'},); + vlog( + 0, + _tr( + "vendor-OS '%s' successfully exported to '%s'!", + $self->{'vendor-os-path'}, + $self->{exporter}->{'export-path'} + ) ); - vlog 0, _tr("vendor-OS '%s' successfully exported to '%s'!", - $self->{'vendor-os-path'}, $self->{'export-path'}); - $self->addExportToConfigDB(); + $self->_addExportToConfigDB(); } sub purgeExport { my $self = shift; - if ($self->{'exporter'}->purgeExport($self->{'export-path'})) { - vlog 0, _tr("export '%s' successfully removed!", - $self->{'export-path'}); - } - $self->removeExportFromConfigDB(); + if ($self->{'exporter'}->purgeExport()) { + vlog( + 0, + _tr( + "export '%s' successfully removed!", + $self->{exporter}->{'export-path'} + ) + ); + } + $self->_removeExportFromConfigDB(); } sub generateExportURI @@ -159,23 +166,28 @@ sub requiredFSMods ################################################################################ sub _initialize { - my $self = shift; + my $self = shift; my $vendorOSName = shift; - my $vendorOSId = shift; - my $exportName = shift; - my $exportType = lc(shift); - - if (!exists $supportedExportTypes{lc($exportType)}) { - print _tr("Sorry, export type '%s' is unsupported.\n", $exportType); - print _tr("List of supported export types:\n\t"); - print join("\n\t", sort keys %supportedExportTypes)."\n"; + my $vendorOSId = shift; + my $exportName = shift; + my $exportType = lc(shift); + + if (!grep { $_ eq $exportType } @supportedExportTypes) { + vlog(0, + _tr("Sorry, export type '%s' is unsupported.\n", $exportType) + . _tr("List of supported export types:\n\t") + . join("\n\t", sort @supportedExportTypes)); exit 1; } + $exportType =~ m[^(\w+)(?:-(\w+))?$]; + my $exportFS = lc($1); + my $exportBD = lc($2); + vlog(2, "export-fs='$exportFS' export-bd='$exportBD'"); $self->{'vendor-os-name'} = $vendorOSName; - $self->{'vendor-os-id'} = $vendorOSId; - $self->{'export-name'} = $exportName; - $self->{'export-type'} = $exportType; + $self->{'vendor-os-id'} = $vendorOSId; + $self->{'export-name'} = $exportName; + $self->{'export-type'} = $exportType; $vendorOSName =~ m[^(.+?\-[^-]+)]; my $distroName = $1; $self->{'distro-name'} = $distroName; @@ -194,55 +206,78 @@ sub _initialize } } my $distroModuleName = $supportedDistros{lc($distroName)}->{module}; - my $distro - = instantiateClass("OpenSLX::OSExport::Distro::$distroModuleName"); + my $distro = + instantiateClass("OpenSLX::OSExport::Distro::$distroModuleName"); $distro->initialize($self); $self->{distro} = $distro; # load module for the requested export type: - my $typeModuleName = $supportedExportTypes{lc($exportType)}->{module}; - my $exporter - = instantiateClass("OpenSLX::OSExport::ExportType::$typeModuleName"); - $exporter->initialize($self); + my $fsModuleName = $supportedExportFileSystems{$exportFS}; + my $exporter = + instantiateClass("OpenSLX::OSExport::FileSystem::$fsModuleName"); + if (length($exportBD)) { + my $blockModuleName = $supportedExportBlockDevices{$exportBD}; + my $blockDevice = + instantiateClass("OpenSLX::OSExport::BlockDevice::$blockModuleName"); + $blockDevice->initialize($self, $exporter); + $exporter->initialize($self, $blockDevice); + } else { + $exporter->initialize($self); + } $self->{'exporter'} = $exporter; # setup source and target paths: - $self->{'vendor-os-path'} - = "$openslxConfig{'private-path'}/stage1/$vendorOSName"; - my $exportBasePath = "$openslxConfig{'public-path'}/export"; - $self->{'export-path'} = "$exportBasePath/$exportType/$vendorOSName"; - vlog 1, _tr("vendor-OS from '%s' will be exported to '%s'", - $self->{'vendor-os-path'}, $self->{'export-path'}); + $self->{'vendor-os-path'} = + "$openslxConfig{'private-path'}/stage1/$vendorOSName"; + vlog( + 1, + _tr( + "vendor-OS from '%s' will be exported to '%s'", + $self->{'vendor-os-path'}, + $exporter->{'export-path'} + ) + ); } -sub addExportToConfigDB +sub _addExportToConfigDB { my $self = shift; my $openslxDB = instantiateClass("OpenSLX::ConfigDB"); $openslxDB->connect(); - my $export - = $openslxDB->fetchExportByFilter({ - 'name' => $self->{'export-name'}, + my $export = $openslxDB->fetchExportByFilter( + { + 'name' => $self->{'export-name'}, 'vendor_os_id' => $self->{'vendor-os-id'}, - }); + } + ); if (defined $export) { - vlog 0, _tr("No need to change export '%s' in OpenSLX-database.\n", - $self->{'export-name'}); + vlog( + 0, + _tr( + "No need to change export '%s' in OpenSLX-database.\n", + $self->{'export-name'} + ) + ); $self->{exporter}->showExportConfigInfo($export); } else { $export = { 'vendor_os_id' => $self->{'vendor-os-id'}, - 'name' => $self->{'export-name'}, - 'type' => $self->{'export-type'}, + 'name' => $self->{'export-name'}, + 'type' => $self->{'export-type'}, }; - + my $id = $self->{exporter}->addExportToConfigDB($export, $openslxDB); - vlog 0, _tr("Export '%s' has been added to DB (ID=%s)...\n", - $self->{'export-name'}, $id); + vlog( + 0, + _tr( + "Export '%s' has been added to DB (ID=%s)...\n", + $self->{'export-name'}, $id + ) + ); - $self->{exporter}->showExportConfigInfo($export) if $id; + $self->{exporter}->showExportConfigInfo($export) if $id; # now create a default system for that export, using the standard kernel: system("slxconfig add-system $self->{'export-name'}"); @@ -251,7 +286,7 @@ sub addExportToConfigDB $openslxDB->disconnect(); } -sub removeExportFromConfigDB +sub _removeExportFromConfigDB { my $self = shift; @@ -260,26 +295,32 @@ sub removeExportFromConfigDB # remove export from DB: my $exportName = $self->{'export-name'}; - my $export - = $openslxDB->fetchExportByFilter({ - 'name' => $exportName, - }); + my $export = $openslxDB->fetchExportByFilter({'name' => $exportName,}); if (!defined $export) { - vlog 0, _tr("Export '%s' doesn't exist in OpenSLX-database.\n", - $exportName); + vlog( + 0, + _tr( + "Export '%s' doesn't exist in OpenSLX-database.\n", $exportName + ) + ); } else { # remove all systems using this export and then remove the # export itself: - my @systemIDs - = map { $_->{id} } - $openslxDB->fetchSystemByFilter( - { 'export_id' => $export->{id} }, 'id' - ); - vlog 1, _tr("removing systems '%s' from DB, since they belong to the export being deleted.\n", - join ',', @systemIDs); + my @systemIDs = + map { $_->{id} } + $openslxDB->fetchSystemByFilter({'export_id' => $export->{id}}, 'id'); + vlog( + 1, + _tr( + "removing systems '%s' from DB, since they belong to the export" + . " being deleted.\n", + join ',', + @systemIDs + ) + ); $openslxDB->removeSystem(\@systemIDs); $openslxDB->removeExport($export->{id}); - vlog 0, _tr("Export '%s' has been removed from DB.\n", $exportName); + vlog(0, _tr("Export '%s' has been removed from DB.\n", $exportName)); } $openslxDB->disconnect(); @@ -301,3 +342,4 @@ OpenSLX::OSExport::Engine - ... =cut + diff --git a/installer/OpenSLX/OSExport/ExportType/Base.pm b/installer/OpenSLX/OSExport/ExportType/Base.pm deleted file mode 100644 index 7e0aa464..00000000 --- a/installer/OpenSLX/OSExport/ExportType/Base.pm +++ /dev/null @@ -1,128 +0,0 @@ -# Copyright (c) 2006, 2007 - 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/ -# ----------------------------------------------------------------------------- -# Base.pm -# - provides empty base of the OpenSLX OSExport::ExportType API. -# ----------------------------------------------------------------------------- -package OpenSLX::OSExport::ExportType::Base; - -use vars qw($VERSION); -$VERSION = 1.01; # API-version . implementation-version - -use strict; -use Carp; - -use OpenSLX::Basics; -use OpenSLX::Utils; - -################################################################################ -### interface methods -################################################################################ -sub new -{ - confess "Creating OpenSLX::OSExport::ExportType::Base-objects directly makes no sense!"; -} - -sub initialize -{ - my $self = shift; - my $engine = shift; - - $self->{'engine'} = $engine; -} - -sub exportVendorOS -{ -} - -sub purgeExport -{ -} - -sub checkRequirements -{ - return 1; -} - -sub addExportToConfigDB -{ - my $self = shift; - my $export = shift; - my $openslxDB = shift; - - return $openslxDB->addExport($export); -} - -sub generateExportURI -{ -} - -sub requiredFSMods -{ -} - -sub showExportConfigInfo -{ -} - -################################################################################ -### implementation methods -################################################################################ -sub determineIncludeExcludeList -{ - my $self = shift; - - # Rsync uses a first match strategy, so we mix the local specifications - # in front of the filterset given by the package (as the local filters - # should always overrule the vendor filters): - my $distroName = $self->{engine}->{'distro-name'}; - my $localFilterFile - = "$openslxConfig{'config-path'}/distro-info/$distroName/export-filter"; - my $includeExcludeList = slurpFile($localFilterFile, 1); - $includeExcludeList .= $self->{engine}->{distro}->{'export-filter'}; - $includeExcludeList =~ s[^\s+][]igms; - # remove any leading whitespace, as rsync doesn't like it - return $includeExcludeList; -} - -1; -################################################################################ - -=pod - -=head1 NAME - -OpenSLX::OSExport::ExportType::Base - the base class for all OSExport::ExportTypes - -=head1 SYNOPSIS - - package OpenSLX::OSExport::ExportType::coolnewexporter; - - use vars qw(@ISA $VERSION); - @ISA = ('OpenSLX::OSExport::ExportType::Base'); - $VERSION = 1.01; - - use coolnewexporter; - - sub new - { - my $class = shift; - my $self = {}; - return bless $self, $class; - } - - # override all methods of OpenSLX::OSExport::ExportType::Base in order to - # implement the support for a new export-type - ... - -I> - -=cut diff --git a/installer/OpenSLX/OSExport/ExportType/NBD_Squash.pm b/installer/OpenSLX/OSExport/ExportType/NBD_Squash.pm deleted file mode 100644 index a1ec0c26..00000000 --- a/installer/OpenSLX/OSExport/ExportType/NBD_Squash.pm +++ /dev/null @@ -1,262 +0,0 @@ -# Copyright (c) 2006, 2007 - 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/ -# ----------------------------------------------------------------------------- -# NBD_Squash.pm -# - provides NBD+Squashfs-specific overrides of the OpenSLX::OSExport::ExportType API. -# ----------------------------------------------------------------------------- -package OpenSLX::OSExport::ExportType::NBD_Squash; - -use vars qw($VERSION); -use base qw(OpenSLX::OSExport::ExportType::Base); -$VERSION = 1.01; # API-version . implementation-version - -use strict; -use Carp; -use File::Basename; -use OpenSLX::Basics; -use OpenSLX::ConfigDB qw(:support); -use OpenSLX::OSExport::ExportType::Base 1; -use OpenSLX::Utils; - -################################################################################ -### interface methods -################################################################################ -sub new -{ - my $class = shift; - my $self = { - 'name' => 'NBD_Squash', - }; - return bless $self, $class; -} - -sub exportVendorOS -{ - my $self = shift; - my $source = shift; - my $target = shift; - - my $includeExcludeList = $self->determineIncludeExcludeList(); - # in order to do the filtering as part of mksquashfs, we need to map - # our internal (rsync-)filter format to regexes: - $includeExcludeList - = mapRsyncFilter2Regex($source, $includeExcludeList); - vlog 1, _tr("using include-exclude-filter:\n%s\n", $includeExcludeList); - $self->createSquashFS($source, $target, $includeExcludeList); -} - -sub purgeExport -{ - my $self = shift; - my $target = shift; - - if (system("rm $target")) { - vlog 0, _tr("unable to remove export '%s'!", $target); - return 0; - } - 1; -} - -sub checkRequirements -{ - my $self = shift; - my $vendorOSPath = shift; - my $kernel = shift || 'vmlinuz'; - my $info = shift; - - $kernel = basename(followLink("$vendorOSPath/boot/$kernel")); - if ($kernel !~ m[-(.+)$]) { - die _tr("unable to determine version of kernel '%s'!", $kernel); - } - my $kernelVer = $1; - my $nbdMod = locateKernelModule( - $vendorOSPath, - 'nbd.ko', - ["$vendorOSPath/lib/modules/$kernelVer/kernel/drivers/block"] - ); - if (!defined $nbdMod) { - warn _tr("unable to find nbd-module for kernel version '%s'.", - $kernelVer); - return undef; - } - my $squashfsMod = locateKernelModule( - $vendorOSPath, - 'squashfs.ko', - ["$vendorOSPath/lib/modules/$kernelVer/kernel/fs/squashfs", - "$vendorOSPath/lib/modules/$kernelVer/kernel/fs"] - ); - if (!defined $squashfsMod) { - warn _tr("unable to find squashfs-module for kernel version '%s'.", - $kernelVer); - return undef; - } - if (defined $info) { - $info->{'kernel-mods'} = [ $nbdMod, $squashfsMod ]; - }; - return 1; -} - -sub addExportToConfigDB -{ - my $self = shift; - my $export = shift; - my $openslxDB = shift; - - $export->{port} - = $openslxDB->incrementGlobalCounter('next-nbd-server-port'); - - my $res = $openslxDB->addExport($export); - return $res; -} - -sub generateExportURI -{ - my $self = shift; - my $export = shift; - my $vendorOS = shift; - - my $server - = length($export->{server_ip}) - ? $export->{server_ip} - : generatePlaceholderFor('serverip'); - $server .= ":$export->{port}" if length($export->{port}); - - return "nbd://$server/squashfs"; -} - -sub requiredFSMods -{ - my $self = shift; - - return 'nbd squashfs'; -} - -sub showExportConfigInfo -{ - my $self = shift; - my $export = shift; - - print (('#' x 80)."\n"); - print _tr("Please make sure you start a corresponding nbd-server:\n\t%s\n", - "nbd-server $export->{port} $self->{engine}->{'export-path'} -r"); - print (('#' x 80)."\n"); -} - -################################################################################ -### implementation methods -################################################################################ - -sub createSquashFS -{ - my $self = shift; - my $source = shift; - my $target = shift; - my $includeExcludeList = shift; - - system("rm -f $target"); - # mksquasfs isn't significantly faster if fs already exists, but it - # causes the filesystem to grow somewhat, so we remove it in order to - # get the smallest FS-file possible. - - my $baseDir = dirname($target); - if (!-e $baseDir) { - if (system("mkdir -p $baseDir")) { - die _tr("unable to create directory '%s', giving up! (%s)\n", - $baseDir, $!); - } - } - - # dump filter to a file ... - my $filterFile = "/tmp/slx-nbdsquash-filter-$$"; - open(FILTERFILE,"> $filterFile") - or die _tr("unable to create tmpfile '%s' (%s)", $filterFile, $!); - print FILTERFILE $includeExcludeList; - close(FILTERFILE); - - # ... invoke mksquashfs ... - vlog 0, _tr("invoking mksquashfs..."); - my $mksquashfsBinary - = "$openslxConfig{'base-path'}/share/squashfs/mksquashfs"; - my $res = system("$mksquashfsBinary $source $target -ff $filterFile"); - unlink($filterFile); - # ... remove filter file if done - if ($res) { - die _tr("unable to create squashfs for source '%s' as target '%s', giving up! (%s)", - $source, $target, $!); - } -} - -sub mapRsyncFilter2Regex -{ - my $sourcePath = shift; - - return - join "\n", - map { - if ($_ =~ m[^([-+]\s*)(.+?)\s*$]) { - my $action = $1; - my $regex = $2; - $regex =~ s[\*\*][.+]g; - # '**' matches everything - $regex =~ s[\*][[^/]+]g; - # '*' matches anything except slashes - $regex =~ s[\?][[^/]?]g; - # '*' matches any single char except slash - $regex =~ s[\?][[^/]?]g; - # '*' matches any single char except slash - $regex =~ s[\.][\\.]g; - # escape any dots - if (substr($regex, 0, 1) eq '/') { - # absolute path given, need to extend by source-path: - "$action^$sourcePath$regex\$"; - } else { - # filename pattern given, need to anchor to the end only: - "$action$regex\$"; - } - } else { - $_; - } - } - split "\n", shift; -} - -sub locateKernelModule -{ - my $vendorOSPath = shift; - my $moduleName = shift; - my $defaultPaths = shift; - - vlog 1, _tr("locating kernel-module '%s'", $moduleName); - # check default paths first: - foreach my $defPath (@$defaultPaths) { - vlog 2, "trying $defPath/$moduleName"; - my $target = followLink("$defPath/$moduleName", $vendorOSPath); - return $target unless !-e $target; - } - # use brute force to search for the newest incarnation of the module: - use File::Find; - my $location; - my $locationAge = 9999999; - vlog 2, "searching in $vendorOSPath/lib/modules"; - find sub { - return unless $_ eq $moduleName; - if (-M _ < $locationAge) { - $locationAge = -M _; - $location = $File::Find::name; - vlog 2, "located at $location (age=$locationAge days)"; - } - }, "$vendorOSPath/lib/modules"; - if (defined $location) { - return followLink($location, $vendorOSPath); - } - return undef; -} - -1; diff --git a/installer/OpenSLX/OSExport/ExportType/NFS.pm b/installer/OpenSLX/OSExport/ExportType/NFS.pm deleted file mode 100644 index 12fa4bfc..00000000 --- a/installer/OpenSLX/OSExport/ExportType/NFS.pm +++ /dev/null @@ -1,123 +0,0 @@ -# Copyright (c) 2006, 2007 - 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/ -# ----------------------------------------------------------------------------- -# NFS.pm -# - provides NFS-specific overrides of the OpenSLX::OSExport::ExportType API. -# ----------------------------------------------------------------------------- -package OpenSLX::OSExport::ExportType::NFS; - -use vars qw($VERSION); -use base qw(OpenSLX::OSExport::ExportType::Base); -$VERSION = 1.01; # API-version . implementation-version - -use strict; -use Carp; -use File::Basename; -use OpenSLX::Basics; -use OpenSLX::ConfigDB qw(:support); -use OpenSLX::Utils; -use OpenSLX::OSExport::ExportType::Base 1; - -################################################################################ -### interface methods -################################################################################ -sub new -{ - my $class = shift; - my $self = { - 'name' => 'NFS', - }; - return bless $self, $class; -} - -sub exportVendorOS -{ - my $self = shift; - my $source = shift; - my $target = shift; - - $self->copyViaRsync($source, $target); -} - -sub purgeExport -{ - my $self = shift; - my $target = shift; - - if (system("rm -r $target")) { - vlog 0, _tr("unable to remove export '%s'!", $target); - return 0; - } - 1; -} - -sub generateExportURI -{ - my $self = shift; - my $export = shift; - my $vendorOS = shift; - - my $server - = length($export->{server_ip}) - ? $export->{server_ip} - : generatePlaceholderFor('serverip'); - $server .= ":$export->{port}" if length($export->{port}); - - my $exportPath = "$openslxConfig{'public-path'}/export"; - return "nfs://$server/$exportPath/nfs/$vendorOS->{name}"; -} - -sub requiredFSMods -{ - my $self = shift; - - return 'nfs'; -} - -sub showExportConfigInfo -{ - my $self = shift; - my $export = shift; - - print (('#' x 80)."\n"); - print _tr("Please make sure the following line is contained in /etc/exports\nin order to activate the NFS-export of this vendor-OS:\n\t%s\n", - "$self->{engine}->{'export-path'}\t*(ro,no_root_squash,async,no_subtree_check)"); - print (('#' x 80)."\n"); - -# TODO : add something a bit more clever here... -# my $exports = slurpFile("/etc/exports"); -} - -################################################################################ -### implementation methods -################################################################################ -sub copyViaRsync -{ - my $self = shift; - my $source = shift; - my $target = shift; - - if (system("mkdir -p $target")) { - die _tr("unable to create directory '%s', giving up! (%s)\n", - $target, $!); - } - my $includeExcludeList = $self->determineIncludeExcludeList(); - vlog 1, _tr("using include-exclude-filter:\n%s\n", $includeExcludeList); - open(RSYNC, "| rsync -av --delete --exclude-from=- $source/ $target") - or die _tr("unable to start rsync for source '%s', giving up! (%s)", - $source, $!); - print RSYNC $includeExcludeList; - if (!close(RSYNC)) { - die _tr("unable to export to target '%s', giving up! (%s)", - $target, $!); - } -} - -1; diff --git a/installer/OpenSLX/OSExport/FileSystem/Base.pm b/installer/OpenSLX/OSExport/FileSystem/Base.pm new file mode 100644 index 00000000..bb6f42d3 --- /dev/null +++ b/installer/OpenSLX/OSExport/FileSystem/Base.pm @@ -0,0 +1,81 @@ +# Copyright (c) 2006, 2007 - 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/ +# ----------------------------------------------------------------------------- +# Base.pm +# - provides empty base of the OpenSLX OSExport::FileSystem API. +# ----------------------------------------------------------------------------- +package OpenSLX::OSExport::FileSystem::Base; + +use vars qw($VERSION); +$VERSION = 1.01; # API-version . implementation-version + +use strict; +use Carp; + +use OpenSLX::Basics; +use OpenSLX::Utils; + +################################################################################ +### interface methods +################################################################################ +sub new +{ + confess "Creating OpenSLX::OSExport::FileSystem::Base-objects directly makes no sense!"; +} + +sub initialize +{ +} + +sub exportVendorOS +{ +} + +sub purgeExport +{ +} + +sub checkRequirements +{ + return 1; +} + +sub addExportToConfigDB +{ + my $self = shift; + my $export = shift; + my $openslxDB = shift; + + return $openslxDB->addExport($export); +} + +sub generateExportURI +{ +} + +sub requiredFSMods +{ +} + +sub showExportConfigInfo +{ +} + +1; + +################################################################################ + +=pod + +=head1 NAME + +OpenSLX::OSExport::FileSystem::Base - the base class for all OSExport::FileSystems + +=cut diff --git a/installer/OpenSLX/OSExport/FileSystem/NFS.pm b/installer/OpenSLX/OSExport/FileSystem/NFS.pm new file mode 100644 index 00000000..36926d61 --- /dev/null +++ b/installer/OpenSLX/OSExport/FileSystem/NFS.pm @@ -0,0 +1,150 @@ +# Copyright (c) 2006, 2007 - 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/ +# ----------------------------------------------------------------------------- +# NFS.pm +# - provides NFS-specific overrides of the OpenSLX::OSExport::FileSystem API. +# ----------------------------------------------------------------------------- +package OpenSLX::OSExport::FileSystem::NFS; + +use vars qw($VERSION); +use base qw(OpenSLX::OSExport::FileSystem::Base); +$VERSION = 1.01; # API-version . implementation-version + +use strict; +use Carp; +use File::Basename; +use OpenSLX::Basics; +use OpenSLX::ConfigDB qw(:support); +use OpenSLX::Utils; +use OpenSLX::OSExport::FileSystem::Base 1; + +################################################################################ +### interface methods +################################################################################ +sub new +{ + my $class = shift; + my $self = { + 'name' => 'nfs', + }; + return bless $self, $class; +} + +sub initialize +{ + my $self = shift; + my $engine = shift; + + $self->{'engine'} = $engine; + my $exportBasePath = "$openslxConfig{'public-path'}/export"; + $self->{'export-path'} = "$exportBasePath/nfs/$engine->{'vendor-os-name'}"; +} + +sub exportVendorOS +{ + my $self = shift; + my $source = shift; + + my $target = $self->{'export-path'}; + $self->_copyViaRsync($source, $target); +} + +sub purgeExport +{ + my $self = shift; + + my $target = $self->{'export-path'}; + if (system("rm -r $target")) { + vlog(0, _tr("unable to remove export '%s'!", $target)); + return 0; + } + return 1; +} + +sub generateExportURI +{ + my $self = shift; + my $export = shift; + my $vendorOS = shift; + + my $server + = length($export->{server_ip}) + ? $export->{server_ip} + : generatePlaceholderFor('serverip'); + $server .= ":$export->{port}" if length($export->{port}); + + my $exportPath = "$openslxConfig{'public-path'}/export"; + return "nfs://$server/$exportPath/nfs/$vendorOS->{name}"; +} + +sub requiredFSMods +{ + my $self = shift; + + return 'nfs'; +} + +sub showExportConfigInfo +{ + my $self = shift; + my $export = shift; + + print (('#' x 80)."\n"); + print _tr("Please make sure the following line is contained in /etc/exports\nin order to activate the NFS-export of this vendor-OS:\n\t%s\n", + "$self->{engine}->{'export-path'}\t*(ro,no_root_squash,async,no_subtree_check)"); + print (('#' x 80)."\n"); + +# TODO : add something a bit more clever here... +# my $exports = slurpFile("/etc/exports"); +} + +################################################################################ +### implementation methods +################################################################################ +sub _copyViaRsync +{ + my $self = shift; + my $source = shift; + my $target = shift; + + if (system("mkdir -p $target")) { + die _tr("unable to create directory '%s', giving up! (%s)\n", + $target, $!); + } + my $includeExcludeList = $self->_determineIncludeExcludeList(); + vlog(1, _tr("using include-exclude-filter:\n%s\n", $includeExcludeList)); + open(RSYNC, "| rsync -av --delete --exclude-from=- $source/ $target") + or die _tr("unable to start rsync for source '%s', giving up! (%s)", + $source, $!); + print RSYNC $includeExcludeList; + if (!close(RSYNC)) { + die _tr("unable to export to target '%s', giving up! (%s)", + $target, $!); + } +} + +sub _determineIncludeExcludeList +{ + my $self = shift; + + # Rsync uses a first match strategy, so we mix the local specifications + # in front of the filterset given by the package (as the local filters + # should always overrule the vendor filters): + my $distroName = $self->{engine}->{'distro-name'}; + my $localFilterFile + = "$openslxConfig{'config-path'}/distro-info/$distroName/export-filter"; + my $includeExcludeList = slurpFile($localFilterFile, 1); + $includeExcludeList .= $self->{engine}->{distro}->{'export-filter'}; + $includeExcludeList =~ s[^\s+][]igms; + # remove any leading whitespace, as rsync doesn't like it + return $includeExcludeList; +} + +1; diff --git a/installer/OpenSLX/OSExport/FileSystem/SquashFS.pm b/installer/OpenSLX/OSExport/FileSystem/SquashFS.pm new file mode 100644 index 00000000..5983e2c2 --- /dev/null +++ b/installer/OpenSLX/OSExport/FileSystem/SquashFS.pm @@ -0,0 +1,323 @@ +# Copyright (c) 2006, 2007 - 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/ +# ----------------------------------------------------------------------------- +# SquashFS.pm +# - provides SquashFS-specific overrides of the OpenSLX::OSExport::ExportType +# API. +# ----------------------------------------------------------------------------- +package OpenSLX::OSExport::FileSystem::SquashFS; + +use vars qw($VERSION); +use base qw(OpenSLX::OSExport::FileSystem::Base); +$VERSION = 1.01; # API-version . implementation-version + +use strict; +use Carp; +use File::Basename; +use OpenSLX::Basics; +use OpenSLX::ConfigDB qw(:support); +use OpenSLX::OSExport::FileSystem::Base 1; +use OpenSLX::Utils; + +################################################################################ +### interface methods +################################################################################ +sub new +{ + my $class = shift; + my $self = { + 'name' => 'sqfs', + }; + return bless $self, $class; +} + +sub initialize +{ + my $self = shift; + my $engine = shift; + my $blockDevice = shift || confess('need to pass in block-device!'); + + $self->{'engine'} = $engine; + $self->{'block-device'} = $blockDevice; + my $exportBasePath = "$openslxConfig{'public-path'}/export"; + $self->{'export-path'} + = "$exportBasePath/sqfs/$engine->{'vendor-os-name'}"; +} + +sub exportVendorOS +{ + my $self = shift; + my $source = shift; + + my $includeExcludeList = $self->_determineIncludeExcludeList(); + # in order to do the filtering as part of mksquashfs, we need to map + # our internal (rsync-)filter format to regexes: + $includeExcludeList + = $self->_mapRsyncFilter2Regex($source, $includeExcludeList); + vlog(1, _tr("using include-exclude-filter:\n%s\n", $includeExcludeList)); + my $target = $self->{'export-path'}; +# $self->_createSquashFS($source, $target, $includeExcludeList); + $self->_addBlockDeviceTagToExport($target); +} + +sub purgeExport +{ + my $self = shift; + + my $target = $self->{'export-path'}; + if ($self->_removeBlockDeviceTagFromExport($target)) { + # no more tags, we can remove the image: + if (slxsystem("rm $target")) { + vlog(0, _tr("unable to remove export '%s'!", $target)); + return 0; + } + } + return 1; +} + +sub checkRequirements +{ + my $self = shift; + my $vendorOSPath = shift; + my $kernel = shift || 'vmlinuz'; + my $info = shift; + + $kernel = basename(followLink("$vendorOSPath/boot/$kernel")); + if ($kernel !~ m[-(.+)$]) { + die _tr("unable to determine version of kernel '%s'!", $kernel); + } + my $kernelVer = $1; + my @blockMods; + my @blockModNames = $self->{'block-device'}->requiredBlockDeviceModules(); + foreach my $blockModName (@blockModNames) { + my $blockMod = $self->_locateKernelModule( + $vendorOSPath, + "$blockModName.ko", + ["$vendorOSPath/lib/modules/$kernelVer/kernel/drivers/block"] + ); + if (!defined $blockMod) { + warn _tr("unable to find blockdevice-module '%s' for kernel version '%s'.", + $blockModName, $kernelVer); + return undef; + } + push @blockMods, $blockMod; + } + my $squashfsMod = $self->_locateKernelModule( + $vendorOSPath, + 'squashfs.ko', + ["$vendorOSPath/lib/modules/$kernelVer/kernel/fs/squashfs", + "$vendorOSPath/lib/modules/$kernelVer/kernel/fs"] + ); + if (!defined $squashfsMod) { + warn _tr("unable to find squashfs-module for kernel version '%s'.", + $kernelVer); + return undef; + } + push @blockMods, $squashfsMod; + if (defined $info) { + $info->{'kernel-mods'} = \@blockMods; + }; + return 1; +} + +sub addExportToConfigDB +{ + my $self = shift; + my $export = shift; + my $openslxDB = shift; + + $export->{port} = $self->{'block-device'}->getExportPort($openslxDB); + + my $res = $openslxDB->addExport($export); + return $res; +} + +sub generateExportURI +{ + my $self = shift; + my $export = shift; + my $vendorOS = shift; + + my $URI = $self->{'block-device'}->generateExportURI($export); + $URI .= '/squashfs'; + return $URI; +} + +sub requiredFSMods +{ + my $self = shift; + + my @mods = $self->{'block-device'}->requiredBlockDeviceModules(); + push @mods, 'squashfs '; + return join ' ', @mods; +} + +sub showExportConfigInfo +{ + my $self = shift; + my $export = shift; + + $self->{'block-device'}->showExportConfigInfo($export); +} + +################################################################################ +### implementation methods +################################################################################ + +sub _createSquashFS +{ + my $self = shift; + my $source = shift; + my $target = shift; + my $includeExcludeList = shift; + + system("rm -f $target"); + # mksquasfs isn't significantly faster if fs already exists, but it + # causes the filesystem to grow somewhat, so we remove it in order to + # get the smallest FS-file possible. + + my $baseDir = dirname($target); + if (!-e $baseDir) { + if (system("mkdir -p $baseDir")) { + die _tr("unable to create directory '%s', giving up! (%s)\n", + $baseDir, $!); + } + } + + # dump filter to a file ... + my $filterFile = "/tmp/slx-nbdsquash-filter-$$"; + open(FILTERFILE,"> $filterFile") + or die _tr("unable to create tmpfile '%s' (%s)", $filterFile, $!); + print FILTERFILE $includeExcludeList; + close(FILTERFILE); + + # ... invoke mksquashfs ... + vlog(0, _tr("invoking mksquashfs...")); + my $mksquashfsBinary + = "$openslxConfig{'base-path'}/share/squashfs/mksquashfs"; + my $res = system("$mksquashfsBinary $source $target -ff $filterFile"); + unlink($filterFile); + # ... remove filter file if done + if ($res) { + die _tr("unable to create squashfs for source '%s' as target '%s', giving up! (%s)", + $source, $target, $!); + } +} + +sub _determineIncludeExcludeList +{ + my $self = shift; + + # Rsync uses a first match strategy, so we mix the local specifications + # in front of the filterset given by the package (as the local filters + # should always overrule the vendor filters): + my $distroName = $self->{engine}->{'distro-name'}; + my $localFilterFile + = "$openslxConfig{'config-path'}/distro-info/$distroName/export-filter"; + my $includeExcludeList = slurpFile($localFilterFile, 1); + $includeExcludeList .= $self->{engine}->{distro}->{'export-filter'}; + $includeExcludeList =~ s[^\s+][]igms; + # remove any leading whitespace, as rsync doesn't like it + return $includeExcludeList; +} + +sub _mapRsyncFilter2Regex +{ + my $self = shift; + my $sourcePath = shift; + + return + join "\n", + map { + if ($_ =~ m[^([-+]\s*)(.+?)\s*$]) { + my $action = $1; + my $regex = $2; + $regex =~ s[\*\*][.+]g; + # '**' matches everything + $regex =~ s[\*][[^/]+]g; + # '*' matches anything except slashes + $regex =~ s[\?][[^/]?]g; + # '*' matches any single char except slash + $regex =~ s[\?][[^/]?]g; + # '*' matches any single char except slash + $regex =~ s[\.][\\.]g; + # escape any dots + if (substr($regex, 0, 1) eq '/') { + # absolute path given, need to extend by source-path: + "$action^$sourcePath$regex\$"; + } else { + # filename pattern given, need to anchor to the end only: + "$action$regex\$"; + } + } else { + $_; + } + } + split "\n", shift; +} + +sub _locateKernelModule +{ + my $self = shift; + my $vendorOSPath = shift; + my $moduleName = shift; + my $defaultPaths = shift; + + vlog(1, _tr("locating kernel-module '%s'", $moduleName)); + # check default paths first: + foreach my $defPath (@$defaultPaths) { + vlog(2, "trying $defPath/$moduleName"); + my $target = followLink("$defPath/$moduleName", $vendorOSPath); + return $target unless !-e $target; + } + # use brute force to search for the newest incarnation of the module: + use File::Find; + my $location; + my $locationAge = 9999999; + vlog(2, "searching in $vendorOSPath/lib/modules"); + find sub { + return unless $_ eq $moduleName; + if (-M _ < $locationAge) { + $locationAge = -M _; + $location = $File::Find::name; + vlog(2, "located at $location (age=$locationAge days)"); + } + }, "$vendorOSPath/lib/modules"; + if (defined $location) { + return followLink($location, $vendorOSPath); + } + return undef; +} + +sub _addBlockDeviceTagToExport +{ + my $self = shift; + my $target = shift; + + my $tagName = "$target".'@'.lc($self->{'block-device'}->{name}); + linkFile(basename($target), $tagName); +} + +sub _removeBlockDeviceTagFromExport +{ + my $self = shift; + my $target = shift; + + my $tagName = "$target".'@'.lc($self->{'block-device'}->{name}); + slxsystem("rm $tagName"); + # now find out whether or not there are any other tags left: + my $vendorOSName = basename($target); + opendir(DIR, dirname($target)); + my @tags = grep { /^vendorOSName\@/ } readdir(DIR); + return @tags ? 0 : 1; + # return 1 if no more tags (i.e. it is safe to remove the image) +} + +1; diff --git a/installer/OpenSLX/OSSetup/Engine.pm b/installer/OpenSLX/OSSetup/Engine.pm index 6064ce6f..1bfdcbaf 100644 --- a/installer/OpenSLX/OSSetup/Engine.pm +++ b/installer/OpenSLX/OSSetup/Engine.pm @@ -87,7 +87,7 @@ sub DESTROY # we are the master process, so we clean up all the servers that we # have started: while(my ($localURL, $pid) = each %{$self->{'local-http-servers'}}) { - vlog 1, _tr("stopping local HTTP-server for URL '%s'.", $localURL); + vlog(1, _tr("stopping local HTTP-server for URL '%s'.", $localURL)); kill TERM => $pid; } } @@ -165,7 +165,7 @@ sub initialize $self->{'vendor-os-path'} = "$openslxConfig{'private-path'}/stage1/$self->{'vendor-os-name'}"; - vlog 1, "vendor-OS path is '$self->{'vendor-os-path'}'"; + vlog(1, "vendor-OS path is '$self->{'vendor-os-path'}'"); if ($actionType ne 'clone') { $self->createPackager(); @@ -187,7 +187,7 @@ sub installVendorOS my $baseSystemFile = "$self->{'vendor-os-path'}/.openslx-base-system"; if (-e $baseSystemFile) { - vlog 0, _tr("found existing base system, continuing...\n"); + vlog(0, _tr("found existing base system, continuing...\n")); } else { # basic setup, stage1a-c: $self->setupStage1A(); @@ -213,8 +213,8 @@ sub installVendorOS close(INFO); slxsystem("rm $baseSystemFile"); # no longer needed, we have a full system now - vlog 0, _tr("Vendor-OS '%s' installed succesfully.\n", - $self->{'vendor-os-name'}); + vlog(0, _tr("Vendor-OS '%s' installed succesfully.\n", + $self->{'vendor-os-name'})); $self->addInstalledVendorOSToConfigDB(); } @@ -275,11 +275,11 @@ sub cloneVendorOS close CLONE_INFO; } if ($isReClone) { - vlog 0, _tr("Vendor-OS '%s' has been re-cloned succesfully.\n", - $self->{'vendor-os-name'}); + vlog(0, _tr("Vendor-OS '%s' has been re-cloned succesfully.\n", + $self->{'vendor-os-name'})); } else { - vlog 0, _tr("Vendor-OS '%s' has been cloned succesfully.\n", - $self->{'vendor-os-name'}); + vlog(0, _tr("Vendor-OS '%s' has been cloned succesfully.\n", + $self->{'vendor-os-name'})); } $self->addInstalledVendorOSToConfigDB(); @@ -300,8 +300,8 @@ sub updateVendorOS $self->changePersonalityIfNeeded(); $self->updateStage1D(); }); - vlog 0, _tr("Vendor-OS '%s' updated succesfully.\n", - $self->{'vendor-os-name'}); + vlog(0, _tr("Vendor-OS '%s' updated succesfully.\n", + $self->{'vendor-os-name'})); } sub startChrootedShellForVendorOS @@ -319,20 +319,20 @@ sub startChrootedShellForVendorOS $self->changePersonalityIfNeeded(); $self->startChrootedShellInStage1D(); }); - vlog 0, _tr("Chrooted shell for vendor-OS '%s' has been closed.\n", - $self->{'vendor-os-name'}); + vlog(0, _tr("Chrooted shell for vendor-OS '%s' has been closed.\n", + $self->{'vendor-os-name'})); } sub removeVendorOS { my $self = shift; - vlog 0, _tr("removing vendor-OS folder '%s'...", $self->{'vendor-os-path'}); + vlog(0, _tr("removing vendor-OS folder '%s'...", $self->{'vendor-os-path'})); if (system("rm -r $self->{'vendor-os-path'}")) { - vlog 0, _tr("* unable to remove vendor-OS '%s'!", $self->{'vendor-os-path'}); + vlog(0, _tr("* unable to remove vendor-OS '%s'!", $self->{'vendor-os-path'})); } else { - vlog 0, _tr("Vendor-OS '%s' removed succesfully.\n", - $self->{'vendor-os-name'}); + vlog(0, _tr("Vendor-OS '%s' removed succesfully.\n", + $self->{'vendor-os-name'})); } $self->removeVendorOSFromConfigDB(); } @@ -356,11 +356,11 @@ sub addInstalledVendorOSToConfigDB $openslxDB->changeVendorOS($vendorOS->{id}, { 'clone_source' => $self->{'clone-source'}, }); - vlog 0, _tr("Vendor-OS '%s' has been updated in OpenSLX-database.\n", - $vendorOSName); + vlog(0, _tr("Vendor-OS '%s' has been updated in OpenSLX-database.\n", + $vendorOSName)); } else { - vlog 0, _tr("No need to change vendor-OS '%s' in OpenSLX-database.\n", - $vendorOSName); + vlog(0, _tr("No need to change vendor-OS '%s' in OpenSLX-database.\n", + $vendorOSName)); } } else { my $data = { @@ -371,8 +371,8 @@ sub addInstalledVendorOSToConfigDB } my $id = $openslxDB->addVendorOS($data); - vlog 0, _tr("Vendor-OS '%s' has been added to DB (ID=%s).\n", - $vendorOSName, $id); + vlog(0, _tr("Vendor-OS '%s' has been added to DB (ID=%s).\n", + $vendorOSName, $id)); } $openslxDB->disconnect(); @@ -389,8 +389,8 @@ sub removeVendorOSFromConfigDB my $vendorOS = $openslxDB->fetchVendorOSByFilter({ 'name' => $vendorOSName }); if (!defined $vendorOS) { - vlog 0, _tr("Vendor-OS '%s' didn't exist in OpenSLX-database.\n", - $vendorOSName); + vlog(0, _tr("Vendor-OS '%s' didn't exist in OpenSLX-database.\n", + $vendorOSName)); } else { # remove all exports (and systems) using this vendor-OS and then # remove the vendor-OS itself: @@ -400,14 +400,14 @@ sub removeVendorOSFromConfigDB foreach my $export (@exports) { my $osExportEngine = instantiateClass("OpenSLX::OSExport::Engine"); $osExportEngine->initializeFromExisting($export->{name}); - vlog 0, _tr("purging export '%s', since it belongs to the vendor-OS being deleted...", - $export->{name}); + vlog(0, _tr("purging export '%s', since it belongs to the vendor-OS being deleted...", + $export->{name})); $osExportEngine->purgeExport(); } $openslxDB->removeVendorOS($vendorOS->{id}); - vlog 0, _tr("Vendor-OS '%s' has been removed from DB!\n", - $vendorOSName); + vlog(0, _tr("Vendor-OS '%s' has been removed from DB!\n", + $vendorOSName)); } $openslxDB->disconnect(); @@ -420,7 +420,7 @@ sub readDistroInfo { my $self = shift; - vlog 1, "reading configuration info for $self->{'vendor-os-name'}..."; + vlog(1, "reading configuration info for $self->{'vendor-os-name'}..."); # merge user-provided configuration distro defaults... my %repository = %{$self->{distro}->{config}->{repository}}; my %selection = %{$self->{distro}->{config}->{selection}}; @@ -437,7 +437,7 @@ sub readDistroInfo = $self->{distro}->{config}->{'metapackager-packages'}; my $file = "$self->{'config-distro-info-dir'}/settings"; if (-e $file) { - vlog 2, "reading configuration file $file..."; + vlog(2, "reading configuration file $file..."); my $config = slurpFile($file); if (!eval $config && length($@)) { die _tr("error in config-file '%s' (%s)", $file, $@)."\n"; @@ -466,23 +466,23 @@ sub readDistroInfo if ($openslxConfig{'verbose-level'} >= 2) { # dump distro-info, if asked for: foreach my $r (sort keys %repository) { - vlog 2, "repository '$r':"; + vlog(2, "repository '$r':"); foreach my $k (sort keys %{$repository{$r}}) { - vlog 3, "\t$k = '$repository{$r}->{$k}'"; + vlog(3, "\t$k = '$repository{$r}->{$k}'"); } } foreach my $s (sort keys %selection) { my @selLines = split "\n", $selection{$s}; - vlog 2, "selection '$s':"; + vlog(2, "selection '$s':"); foreach my $sl (@selLines) { - vlog 3, "\t$sl"; + vlog(3, "\t$sl"); } } foreach my $e (sort keys %excludes) { my @exclLines = split "\n", $excludes{$e}; - vlog 2, "excludes for '$e':"; + vlog(2, "excludes for '$e':"); foreach my $excl (@exclLines) { - vlog 3, "\t$excl"; + vlog(3, "\t$excl"); } } } @@ -578,13 +578,13 @@ try_next_url: push @contFlags, '-c' if ($url =~ m[^ftp]); # continuing is only supported with FTP, but not with HTTP foreach my $file (split '\s+', $fileVariantStr) { - vlog 2, "fetching <$file>..."; + vlog(2, "fetching <$file>..."); if (slxsystem("wget", @contFlags, "$url/$file") == 0) { $foundFile = basename($file); last; } elsif ($! == 17) { my $basefile = basename($file); - vlog 2, "removing left-over '$basefile' and trying again..."; + vlog(2, "removing left-over '$basefile' and trying again..."); unlink $basefile; } } @@ -593,8 +593,8 @@ try_next_url: $tryCount++; $self->{'baseURL-index'} = ($self->{'baseURL-index'}+1) % scalar(@URLs); - vlog 0, _tr("switching to mirror '%s'.", - $URLs[$self->{'baseURL-index'}]); + vlog(0, _tr("switching to mirror '%s'.", + $URLs[$self->{'baseURL-index'}])); goto try_next_url; } die _tr("unable to fetch '%s' from any source!\n", @@ -631,7 +631,7 @@ sub startLocalURLServersAsNeeded '-h', '/', '-f' ); - vlog 1, _tr("started local HTTP-server for URL '%s'.", $localURL); + vlog(1, _tr("started local HTTP-server for URL '%s'.", $localURL)); $self->{'local-http-servers'}->{$localURL} = $pid; } } @@ -641,7 +641,7 @@ sub setupStage1A { my $self = shift; - vlog 1, "setting up stage1a for $self->{'vendor-os-name'}..."; + vlog(1, "setting up stage1a for $self->{'vendor-os-name'}..."); # specify individual paths for the respective substages: $self->{stage1aDir} = "$self->{'vendor-os-path'}/stage1a"; @@ -667,7 +667,7 @@ sub stage1A_createBusyboxEnvironment my $self = shift; # copy busybox and all required binaries into stage1a-dir: - vlog 1, "creating busybox-environment..."; + vlog(1, "creating busybox-environment..."); my $busyboxName = $self->hostIs64Bit() ? 'busybox.x86_64' @@ -676,20 +676,20 @@ sub stage1A_createBusyboxEnvironment "$self->{stage1aDir}/bin", 'busybox'); # determine all required libraries and copy those, too: - vlog 1, _tr("calling slxldd for $busyboxName"); + vlog(1, _tr("calling slxldd for $busyboxName")); my $slxlddCmd = "slxldd $openslxConfig{'base-path'}/share/busybox/$busyboxName"; - vlog 2, "executing: $slxlddCmd"; + vlog(2, "executing: $slxlddCmd"); my $requiredLibsStr = `$slxlddCmd`; if ($?) { die _tr("slxldd couldn't determine the libs required by busybox! (%s)", $?); } chomp $requiredLibsStr; - vlog 2, "slxldd results:\n$requiredLibsStr"; + vlog(2, "slxldd results:\n$requiredLibsStr"); my $libcFolder; foreach my $lib (split "\n", $requiredLibsStr) { - vlog 3, "copying lib '$lib'"; + vlog(3, "copying lib '$lib'"); my $libDir = dirname($lib); copyFile($lib, "$self->{stage1aDir}$libDir"); if ($lib =~ m[/libc.so.\d\s*$]) { @@ -740,7 +740,7 @@ sub stage1A_copyPrerequiredFiles return unless -d "$self->{'shared-distro-info-dir'}/prereqfiles"; - vlog 2, "copying folder with pre-required files..."; + vlog(2, "copying folder with pre-required files..."); my $stage1cDir = "$self->{'stage1aDir'}/$self->{'stage1bSubdir'}/$self->{'stage1cSubdir'}"; my $cmd = qq[ @@ -758,7 +758,7 @@ sub stage1A_copyTrustedPackageKeys { my $self = shift; - vlog 2, "copying folder with trusted package keys..."; + vlog(2, "copying folder with trusted package keys..."); my $stage1bDir = "$self->{'stage1aDir'}/$self->{'stage1bSubdir'}"; foreach my $folder ( @@ -789,7 +789,7 @@ sub stage1A_createRequiredFiles { my $self = shift; - vlog 2, "creating required files..."; + vlog(2, "creating required files..."); # fake all files required by stage1b (by creating them empty): my $stage1bDir = "$self->{'stage1aDir'}/$self->{'stage1bSubdir'}"; @@ -814,7 +814,7 @@ sub setupStage1B { my $self = shift; - vlog 1, "setting up stage1b for $self->{'vendor-os-name'}..."; + vlog(1, "setting up stage1b for $self->{'vendor-os-name'}..."); $self->stage1B_chrootAndBootstrap(); } @@ -855,7 +855,7 @@ sub setupStage1C { my $self = shift; - vlog 1, "setting up stage1c for $self->{'vendor-os-name'}..."; + vlog(1, "setting up stage1c for $self->{'vendor-os-name'}..."); $self->stage1C_chrootAndInstallBasicVendorOS(); } @@ -909,7 +909,7 @@ sub setupStage1D { my $self = shift; - vlog 1, "setting up stage1d for $self->{'vendor-os-name'}..."; + vlog(1, "setting up stage1d for $self->{'vendor-os-name'}..."); chrootInto($self->{'vendor-os-path'}); @@ -922,7 +922,7 @@ sub updateStage1D { my $self = shift; - vlog 1, "updating $self->{'vendor-os-name'}..."; + vlog(1, "updating $self->{'vendor-os-name'}..."); chrootInto($self->{'vendor-os-path'}); @@ -933,10 +933,10 @@ sub startChrootedShellInStage1D { my $self = shift; - vlog 0, "starting chrooted shell for $self->{'vendor-os-name'}"; - vlog 0, "---------------------------------------"; - vlog 0, "- please type 'exit' if you are done! -"; - vlog 0, "---------------------------------------"; + vlog(0, "starting chrooted shell for $self->{'vendor-os-name'}"); + vlog(0, "---------------------------------------"); + vlog(0, "- please type 'exit' if you are done! -"); + vlog(0, "---------------------------------------"); chrootInto($self->{'vendor-os-path'}); @@ -951,14 +951,14 @@ sub stage1D_setupPackageSources() { my $self = shift; - vlog 1, "setting up package sources for meta packager..."; + vlog(1, "setting up package sources for meta packager..."); my $selectionName = $self->{'selection-name'}; my $pkgExcludes = $self->{'distro-info'}->{excludes}->{$selectionName}; my $excludeList = join ' ', string2Array($pkgExcludes); $self->{'meta-packager'}->initPackageSources(); my ($rk, $repo); while(($rk, $repo) = each %{$self->{'distro-info'}->{repository}}) { - vlog 2, "setting up package source $rk..."; + vlog(2, "setting up package source $rk..."); $self->{'meta-packager'}->setupPackageSource($rk, $repo, $excludeList); } } @@ -967,7 +967,7 @@ sub stage1D_updateBasicVendorOS() { my $self = shift; - vlog 1, "updating basic vendor-os..."; + vlog(1, "updating basic vendor-os..."); $self->{'meta-packager'}->startSession(); $self->{'meta-packager'}->updateBasicVendorOS(); $self->{'distro'}->updateDistroConfig(); @@ -980,7 +980,7 @@ sub stage1D_installPackageSelection my $selectionName = $self->{'selection-name'}; - vlog 1, "installing package selection <$selectionName>..."; + vlog(1, "installing package selection <$selectionName>..."); my $pkgSelection = $self->{'distro-info'}->{selection}->{$selectionName}; my @pkgs = string2Array($pkgSelection); my @installedPkgs = $self->{'packager'}->getInstalledPackages(); @@ -988,15 +988,15 @@ sub stage1D_installPackageSelection = grep { my $pkg = $_; if (grep { $_ eq $pkg; } @installedPkgs) { - vlog 1, "package '$pkg' filtered, it is already installed."; + vlog(1, "package '$pkg' filtered, it is already installed."); 0; } else { 1; } } @pkgs; - vlog 0, _tr("No packages listed for selection '%s', nothing to do.", - $selectionName); - vlog 1, "installing these packages:\n".join("\n\t", @pkgs); + vlog(0, _tr("No packages listed for selection '%s', nothing to do.", + $selectionName)); + vlog(1, "installing these packages:\n".join("\n\t", @pkgs)); $self->{'meta-packager'}->startSession(); if (scalar(@pkgs) > 0) { $self->{'meta-packager'}->installSelection(join " ", @pkgs); @@ -1010,13 +1010,13 @@ sub clone_fetchSource my $self = shift; my $source = shift; - vlog 0, _tr("Cloning vendor-OS from '%s' to '%s'...\n", $source, - $self->{'vendor-os-path'}); + vlog(0, _tr("Cloning vendor-OS from '%s' to '%s'...\n", $source, + $self->{'vendor-os-path'})); my $excludeIncludeList = $self->clone_determineIncludeExcludeList(); - vlog 1, "using exclude-include-filter:\n$excludeIncludeList\n"; + vlog(1, "using exclude-include-filter:\n$excludeIncludeList\n"); my $rsyncCmd = "rsync -av --delete --exclude-from=- $source $self->{'vendor-os-path'}"; - vlog 2, "executing: $rsyncCmd\n"; + vlog(2, "executing: $rsyncCmd\n"); open(RSYNC, "| $rsyncCmd") or die _tr("unable to start rsync for source '%s', giving up! (%s)\n", $source, $!); @@ -1085,7 +1085,7 @@ sub chrootInto { my $osDir = shift; - vlog 2, "chrooting into $osDir..."; + vlog(2, "chrooting into $osDir..."); chdir $osDir or die _tr("unable to chdir into '%s' (%s)\n", $osDir, $!); # ...do chroot diff --git a/installer/OpenSLX/OSSetup/Packager/rpm.pm b/installer/OpenSLX/OSSetup/Packager/rpm.pm index 12093501..a792cffe 100644 --- a/installer/OpenSLX/OSSetup/Packager/rpm.pm +++ b/installer/OpenSLX/OSSetup/Packager/rpm.pm @@ -40,7 +40,7 @@ sub unpackPackages my $pkgs = shift; foreach my $pkg (@$pkgs) { - vlog 2, "unpacking package $pkg..."; + vlog(2, "unpacking package $pkg..."); if (slxsystem("ash", "-c", "rpm2cpio $pkg | cpio -i -d -u")) { warn _tr("unable to unpack package <%s> (%s)", $pkg, $!); # TODO: change this back to die() if cpio-ing fedora6-glibc @@ -58,7 +58,7 @@ sub importTrustedPackageKeys return unless defined $keyFiles; foreach my $keyFile (@$keyFiles) { - vlog 2, "importing package key $keyFile..."; + vlog(2, "importing package key $keyFile..."); if (slxsystem("rpm", "--root=$finalPath", "--import", "$keyFile")) { die _tr("unable to import package key <%s> (%s)\n", $keyFile, $!); } diff --git a/installer/slxos-export b/installer/slxos-export index a29f2b4e..cdf37672 100755 --- a/installer/slxos-export +++ b/installer/slxos-export @@ -27,30 +27,26 @@ use lib "$FindBin::RealBin"; use lib "$FindBin::RealBin/../lib"; use lib "$FindBin::RealBin/../config-db"; - # development path to config-db +# development path to config-db use OpenSLX::Basics; use OpenSLX::OSExport::Engine; -my ( - $helpReq, - $manReq, - $verbose, - $versionReq, -); +my ($helpReq, $manReq, $verbose, $versionReq,); GetOptions( - 'help|?' => \$helpReq, - 'man' => \$manReq, + 'help|?' => \$helpReq, + 'man' => \$manReq, 'verbose' => \$verbose, 'version' => \$versionReq, -) or pod2usage(2); + ) + or pod2usage(2); pod2usage(-msg => $abstract, -verbose => 0, -exitval => 1) if $helpReq; if ($manReq) { $ENV{LANG} = 'en_EN'; - # avoid dubious problem with perldoc in combination with UTF-8 that - # leads to strange dashes and single-quotes being used - pod2usage(-verbose => 2) + # avoid dubious problem with perldoc in combination with UTF-8 that + # leads to strange dashes and single-quotes being used + pod2usage(-verbose => 2); } if ($versionReq) { system('slxversion'); @@ -63,46 +59,56 @@ my $action = shift @ARGV; if ($action =~ m[^list-ex]i) { print _tr("List of exported vendor-OSes:\n"); - foreach my $type (sort keys %supportedExportTypes) { - print join('', map { - s[^.+/][]; - "\t$type/$_\n"; - } - grep { - # filter out RSYNC_TMP folders: - $_ !~ m[###]; - } - sort <$openslxConfig{'public-path'}/export/$type/*>); + foreach my $type (sort keys %supportedExportFileSystems) { + my @files = <$openslxConfig{'public-path'}/export/$type/*>; + print join( + '', + map { + s[^.+/][]; + "\t$type/$_\n"; + } + grep { + # filter out RSYNC_TMP folders: + $_ !~ m[###]; + } + sort @files + ); } } elsif ($action =~ m[^list-in]i) { + my @files = <$openslxConfig{'private-path'}/stage1/*>; print _tr("List of installed vendor-OSes:\n"); - print join('', map { - s[^.+/][]; - "\t$_\n"; - } - sort <$openslxConfig{'private-path'}/stage1/*>); + print join( + '', + map { + s[^.+/][]; + "\t$_\n"; + } + sort @files + ); } elsif ($action =~ m[^list-ty]i) { print _tr("List of supported export types:\n\t"); - print join("\n\t", sort keys %supportedExportTypes)."\n"; + print join("\n\t", sort @supportedExportTypes) . "\n"; } elsif ($action =~ m[^export]i) { if (scalar(@ARGV) != 2) { - print STDERR _tr("You need to specify exactly one vendor-os-name and one export-type!\n"); + print STDERR _tr( + "You need to specify exactly one vendor-os-name and one export-type!\n" + ); pod2usage(2); } my $vendorOSName = shift @ARGV; - my $exportType = shift @ARGV; + my $exportType = shift @ARGV; # we chdir into the script's folder such that all relative paths have # a known starting point: chdir($FindBin::RealBin) - or die _tr("can't chdir to script-path <%> (%s)", $FindBin::RealBin, $!); + or die _tr("can't chdir to script-path <%> (%s)", $FindBin::RealBin, $!); # create OSExport-engine for given export type and start it: my $engine = OpenSLX::OSExport::Engine->new; $engine->initializeForNew($vendorOSName, $exportType); if (!-e $engine->{'vendor-os-path'}) { die _tr("vendor-OS '%s' doesn't exist, giving up!\n", - $engine->{'vendor-os-path'}); + $engine->{'vendor-os-path'}); } $engine->exportVendorOS(); } elsif ($action =~ m[^remove]i) { @@ -115,24 +121,24 @@ if ($action =~ m[^list-ex]i) { # we chdir into the script's folder such that all relative paths have # a known starting point: chdir($FindBin::RealBin) - or die _tr("can't chdir to script-path <%> (%s)", $FindBin::RealBin, $!); + or die _tr("can't chdir to script-path <%> (%s)", $FindBin::RealBin, $!); # create OSExport-engine for given export type and start it: my $engine = OpenSLX::OSExport::Engine->new; $engine->initializeFromExisting($exportName); $engine->purgeExport(); } else { - print STDERR _tr("You need to specify exactly one action: + print STDERR _tr( + "You need to specify exactly one action: export list-exported list-installed list-types remove -Try '%s --help' for more info.\n", $0); +Try '%s --help' for more info.\n", $0 + ); } - - =head1 NAME slxos-export - OpenSLX-script to generate an export from a vendor-OS. @@ -192,13 +198,16 @@ in different flavors: NFS (network file system) is a well established networking file system, which is supported by LINUX since long. -=item B< Export Type 'nbd'> +=item B< Export Type 'sqfs-nbd'> -A rather modern concept is the network block device, which basically "transports" -a block device over the network (from server to client), making it possible to -use more or less any file system over the network. In this particular case, -a squash-FS is being used, which is a filesystem providing very good compression, +Squash-FS is a rather modern filesystem providing very good compression, resulting in considerably reduced network traffic during boot (and execution). +However, in order to mount a squash-fs that resides on the server, the client +has to get access to it first. This can be established via a network block +device, which basically "transports" a block device over the network (from +server to client), making it possible to use more or less any file system over +the network. +So, this example translates to 'use a squashfs on a network block device'. =back @@ -247,7 +256,7 @@ resulting NFS-export will live in C. =over 8 -=item B<< slxos-export export ubuntu-6.10 nbd >> +=item B<< slxos-export export ubuntu-6.10 sqfs-nbd >> Exports the installed vendor-OS ubuntu-6.10 via nbd, the resulting Squash-FS will live in C. @@ -288,4 +297,5 @@ which can be used to overrule the OpenSLX settings: Please refer to the C-manpage for a more detailed description of these options. -=cut \ No newline at end of file +=cut + -- cgit v1.2.3-55-g7522