summaryrefslogtreecommitdiffstats
path: root/installer/OpenSLX/OSExport/FileSystem
diff options
context:
space:
mode:
authorOliver Tappe2007-07-01 22:28:50 +0200
committerOliver Tappe2007-07-01 22:28:50 +0200
commit6974fa8b0419bbd0711f79c8b78e07a9543810dd (patch)
tree25141f0f4d20ca8fdb1c845edf5b9ce4b24a6e98 /installer/OpenSLX/OSExport/FileSystem
parentTried to add Ubuntu 7.04 to the list of cloneable systems. (diff)
downloadcore-6974fa8b0419bbd0711f79c8b78e07a9543810dd.tar.gz
core-6974fa8b0419bbd0711f79c8b78e07a9543810dd.tar.xz
core-6974fa8b0419bbd0711f79c8b78e07a9543810dd.zip
* activated 'use warnings' to all modules and adjusted all occurences of
'use of uninitialized values', a couple of which might still show up * adjusted all code with respect to passing perlcritic level 4 and 5 git-svn-id: http://svn.openslx.org/svn/openslx/trunk@1207 95ad53e4-c205-0410-b2fa-d234c58c8868
Diffstat (limited to 'installer/OpenSLX/OSExport/FileSystem')
-rw-r--r--installer/OpenSLX/OSExport/FileSystem/Base.pm10
-rw-r--r--installer/OpenSLX/OSExport/FileSystem/NFS.pm35
-rw-r--r--installer/OpenSLX/OSExport/FileSystem/SquashFS.pm27
3 files changed, 33 insertions, 39 deletions
diff --git a/installer/OpenSLX/OSExport/FileSystem/Base.pm b/installer/OpenSLX/OSExport/FileSystem/Base.pm
index bb6f42d3..0822c458 100644
--- a/installer/OpenSLX/OSExport/FileSystem/Base.pm
+++ b/installer/OpenSLX/OSExport/FileSystem/Base.pm
@@ -13,14 +13,12 @@
# -----------------------------------------------------------------------------
package OpenSLX::OSExport::FileSystem::Base;
-use vars qw($VERSION);
-$VERSION = 1.01; # API-version . implementation-version
-
use strict;
-use Carp;
+use warnings;
+
+our $VERSION = 1.01; # API-version . implementation-version
-use OpenSLX::Basics;
-use OpenSLX::Utils;
+use Carp qw(confess);
################################################################################
### interface methods
diff --git a/installer/OpenSLX/OSExport/FileSystem/NFS.pm b/installer/OpenSLX/OSExport/FileSystem/NFS.pm
index ffeaeffd..0073d55c 100644
--- a/installer/OpenSLX/OSExport/FileSystem/NFS.pm
+++ b/installer/OpenSLX/OSExport/FileSystem/NFS.pm
@@ -13,17 +13,15 @@
# -----------------------------------------------------------------------------
package OpenSLX::OSExport::FileSystem::NFS;
-use vars qw($VERSION);
+use strict;
+use warnings;
+
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
@@ -74,11 +72,11 @@ sub generateExportURI
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 $serverIP = $export->{server_ip} || '';
+ my $server
+ = length($serverIP) ? $serverIP : generatePlaceholderFor('serverip');
+ my $port = $export->{port} || '';
+ $server .= ":$port" if length($port);
my $exportPath = "$openslxConfig{'public-path'}/export";
return "nfs://$server$exportPath/nfs/$vendorOS->{name}";
@@ -98,7 +96,7 @@ sub showExportConfigInfo
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)");
+ "$self->{'export-path'}\t*(ro,no_root_squash,async,no_subtree_check)");
print (('#' x 80)."\n");
# TODO : add something a bit more clever here...
@@ -120,14 +118,14 @@ sub _copyViaRsync
}
my $includeExcludeList = $self->_determineIncludeExcludeList();
vlog(1, _tr("using include-exclude-filter:\n%s\n", $includeExcludeList));
- open(RSYNC, "| rsync -av --delete --exclude-from=- $source/ $target")
+ my $rsyncFH;
+ open($rsyncFH, '|-', "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, $!);
- }
+ print $rsyncFH $includeExcludeList;
+ close($rsyncFH)
+ or die _tr("unable to export to target '%s', giving up! (%s)",
+ $target, $!);
}
sub _determineIncludeExcludeList
@@ -140,7 +138,8 @@ sub _determineIncludeExcludeList
my $distroName = $self->{engine}->{'distro-name'};
my $localFilterFile
= "$openslxConfig{'config-path'}/distro-info/$distroName/export-filter";
- my $includeExcludeList = slurpFile($localFilterFile, 1);
+ my $includeExcludeList
+ = slurpFile($localFilterFile, { failIfMissing => 0 });
$includeExcludeList .= $self->{engine}->{distro}->{'export-filter'};
$includeExcludeList =~ s[^\s+][]igms;
# remove any leading whitespace, as rsync doesn't like it
diff --git a/installer/OpenSLX/OSExport/FileSystem/SquashFS.pm b/installer/OpenSLX/OSExport/FileSystem/SquashFS.pm
index 48efb45b..6aeb9cd2 100644
--- a/installer/OpenSLX/OSExport/FileSystem/SquashFS.pm
+++ b/installer/OpenSLX/OSExport/FileSystem/SquashFS.pm
@@ -14,12 +14,11 @@
# -----------------------------------------------------------------------------
package OpenSLX::OSExport::FileSystem::SquashFS;
-use vars qw($VERSION);
+use strict;
+use warnings;
+
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);
@@ -61,11 +60,11 @@ sub exportVendorOS
vlog(1, _tr("using include-exclude-filter:\n%s\n", $includeExcludeList));
my $target = $self->{'export-path'};
- my $sourceTime = (stat($source))[9];
- my $targetTime = (stat($target))[9];
+ my $sourceTime = (stat($source))[9] || 0;
+ my $targetTime = (stat($target))[9] || 0;
vlog(2, "source-time=$sourceTime target-time=$targetTime");
- if (defined $targetTime && $sourceTime < $targetTime) {
+ if ($targetTime && $sourceTime < $targetTime) {
vlog(
0,
"!!! creation of squashfs skipped, as vendor-OS hasn't changed since last export!\n"
@@ -115,7 +114,7 @@ sub checkRequirements
"unable to find blockdevice-module '%s' for kernel version '%s'.",
$blockModName, $kernelVer
);
- return undef;
+ return;
}
push @blockMods, $blockMod;
}
@@ -130,7 +129,7 @@ sub checkRequirements
if (!defined $squashfsMod) {
warn _tr("unable to find squashfs-module for kernel version '%s'.",
$kernelVer);
- return undef;
+ return;
}
push @blockMods, $squashfsMod;
if (defined $info) {
@@ -205,10 +204,7 @@ sub _createSquashFS
# 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);
+ spitFile($filterFile, $includeExcludeList);
# ... invoke mksquashfs ...
vlog(0, _tr("invoking mksquashfs..."));
@@ -234,7 +230,8 @@ sub _determineIncludeExcludeList
my $distroName = $self->{engine}->{'distro-name'};
my $localFilterFile =
"$openslxConfig{'config-path'}/distro-info/$distroName/export-filter";
- my $includeExcludeList = slurpFile($localFilterFile, 1);
+ my $includeExcludeList
+ = slurpFile($localFilterFile, { failIfMissing => 0 });
$includeExcludeList .= $self->{engine}->{distro}->{'export-filter'};
$includeExcludeList =~ s[^\s+][]igms;
# remove any leading whitespace, as rsync doesn't like it
@@ -310,7 +307,7 @@ sub _locateKernelModule
if (defined $location) {
return followLink($location, $vendorOSPath);
}
- return undef;
+ return;
}
sub _addBlockDeviceTagToExport