From 102f63c43b0e32622bb5bf83a84cdac67174f539 Mon Sep 17 00:00:00 2001 From: Oliver Tappe Date: Sat, 28 Jul 2007 20:38:11 +0000 Subject: * finished installation support for Debian-etch, Debian-sarge and Ubuntu are nearly done (Ubuntu still missing a kernel ...) * some more refactorings to accommodate Debian-support git-svn-id: http://svn.openslx.org/svn/openslx/trunk@1282 95ad53e4-c205-0410-b2fa-d234c58c8868 --- lib/OpenSLX/Utils.pm | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) (limited to 'lib/OpenSLX/Utils.pm') diff --git a/lib/OpenSLX/Utils.pm b/lib/OpenSLX/Utils.pm index bb24f961..bc57078a 100644 --- a/lib/OpenSLX/Utils.pm +++ b/lib/OpenSLX/Utils.pm @@ -25,7 +25,7 @@ $VERSION = 1.01; @EXPORT = qw( copyFile fakeFile linkFile copyBinaryWithRequiredLibs - slurpFile spitFile + slurpFile spitFile appendFile followLink unshiftHereDoc string2Array @@ -125,6 +125,21 @@ sub spitFile return; } +sub appendFile +{ + my $fileName = shift || croak 'need to pass in a fileName!'; + my $content = shift; + + my $fh; + open($fh, '>>', $fileName) + or croak _tr("unable to create file '%s' (%s)\n", $fileName, $!); + print $fh $content + or croak _tr("unable to print to file '%s' (%s)\n", $fileName, $!); + close($fh) + or croak _tr("unable to close file '%s' (%s)\n", $fileName, $!); + return; +} + sub followLink { my $path = shift || croak 'need to pass in a path!'; @@ -171,7 +186,7 @@ sub copyBinaryWithRequiredLibs { foreach my $lib (split "\n", $requiredLibsStr) { my $libDir = dirname($lib); my $targetLib = "$params->{libTargetFolder}$libDir"; -# next if -e $targetLib; + next if -e "$targetLib/$lib"; vlog(3, "copying lib '$lib'"); copyFile($lib, $targetLib); } @@ -182,11 +197,9 @@ sub unshiftHereDoc { my $content = shift; return $content unless $content =~ m{^(\s+)}; - my $shift = length($1); - return - join "\n", - map { substr($_, $shift); } - split m{\n}, $content; + my $shiftStr = $1; + $content =~ s[^$shiftStr][]gms; + return $content; } sub string2Array -- cgit v1.2.3-55-g7522