X-Git-Url: http://git.rot13.org/?p=BackupPC.git;a=blobdiff_plain;f=lib%2FBackupPC%2FStorage%2FText.pm;h=e1d31cccbe07d4607fa106efda5abfeffd7db8ea;hp=18f59136cd061f1802c9778e005d2810d10517fd;hb=ee969a9445a5439cf94a516c7d882e12b1bdf945;hpb=5b3e6091d542c2e7445d5dd511cdf6e20aec8b8d diff --git a/lib/BackupPC/Storage/Text.pm b/lib/BackupPC/Storage/Text.pm index 18f5913..e1d31cc 100644 --- a/lib/BackupPC/Storage/Text.pm +++ b/lib/BackupPC/Storage/Text.pm @@ -30,7 +30,7 @@ # #======================================================================== # -# Version 3.0.0alpha, released 23 Jan 2006. +# Version 3.0.0beta2, released 18 Nov 2006. # # See http://backuppc.sourceforge.net. # @@ -247,11 +247,13 @@ sub ConfigPath return "$s->{ConfDir}/config.pl" if ( !defined($host) ); if ( $s->{useFHS} ) { - return "$s->{ConfDir}/host/$host.pl"; + return "$s->{ConfDir}/pc/$host.pl"; } else { + return "$s->{TopDir}/pc/$host/config.pl" + if ( -f "$s->{TopDir}/pc/$host/config.pl" ); return "$s->{ConfDir}/$host.pl" if ( $host ne "config" && -f "$s->{ConfDir}/$host.pl" ); - return "$s->{TopDir}/pc/$host/config.pl"; + return "$s->{ConfDir}/pc/$host.pl"; } } @@ -287,6 +289,23 @@ sub ConfigDataRead $conf->{$param} = { "*" => $conf->{$param} }; } + # + # Handle backward compatibility with defunct BlackoutHourBegin, + # BlackoutHourEnd, and BlackoutWeekDays parameters. + # + if ( defined($conf->{BlackoutHourBegin}) ) { + push(@{$conf->{BlackoutPeriods}}, + { + hourBegin => $conf->{BlackoutHourBegin}, + hourEnd => $conf->{BlackoutHourEnd}, + weekDays => $conf->{BlackoutWeekDays}, + } + ); + delete($conf->{BlackoutHourBegin}); + delete($conf->{BlackoutHourEnd}); + delete($conf->{BlackoutWeekDays}); + } + return (undef, $conf); } @@ -311,10 +330,7 @@ sub ConfigFileMerge { my($s, $inFile, $newConf) = @_; local(*C); - my($contents, $out); - my $comment = 1; - my $skipVar = 0; - my $endLine = undef; + my($contents, $skipExpr, $fakeVar); my $done = {}; if ( -f $inFile ) { @@ -326,12 +342,10 @@ sub ConfigFileMerge binmode(C); while ( ) { - if ( $comment && /^\s*#/ ) { - $out .= $_; - } elsif ( /^\s*\$Conf\{([^}]*)\}\s*=/ ) { + if ( /^\s*\$Conf\{([^}]*)\}\s*=(.*)/ ) { my $var = $1; - if ( exists($newConf->{$var}) ) { - $contents .= $out; + $skipExpr = "\$fakeVar = $2\n"; + if ( exists($newConf->{$var}) ) { my $d = Data::Dumper->new([$newConf->{$var}], [*value]); $d->Indent(1); $d->Terse(1); @@ -340,27 +354,24 @@ sub ConfigFileMerge $contents .= "\$Conf{$var} = " . $value; $done->{$var} = 1; } - $endLine = $1 if ( /^\s*\$Conf\{[^}]*} *= *<<(.*);/ ); - $endLine = $1 if ( /^\s*\$Conf\{[^}]*} *= *<<'(.*)';/ ); - $out = ""; - $skipVar = 1; - } elsif ( $skipVar ) { - if ( !defined($endLine) && (/^\s*[\r\n]*$/ || /^\s*#/) ) { - $skipVar = 0; - $comment = 1; - $out .= $_; - } - if ( defined($endLine) && /^\Q$endLine\E[\n\r]*$/ ) { - $endLine = undef; - $skipVar = 0; - $comment = 1; - } + } elsif ( defined($skipExpr) ) { + $skipExpr .= $_; } else { - $out .= $_; + $contents .= $_; + } + if ( defined($skipExpr) + && ($skipExpr =~ /^\$fakeVar = *<