X-Git-Url: http://git.rot13.org/?p=BackupPC.git;a=blobdiff_plain;f=lib%2FBackupPC%2FLib.pm;h=6e1fe8ffb45ca281a1a4018dcc143239adefd3ce;hp=dafa09b058c36d86acc46cb039868e1e22703f4f;hb=71e7c4f845cb4cfb0c81391d0dab71f2d634796d;hpb=9cf3998c4ef71332dea96ff3115daf8b9f722acb diff --git a/lib/BackupPC/Lib.pm b/lib/BackupPC/Lib.pm index dafa09b..6e1fe8f 100644 --- a/lib/BackupPC/Lib.pm +++ b/lib/BackupPC/Lib.pm @@ -29,7 +29,7 @@ # #======================================================================== # -# Version 3.2.0beta0, released 5 April 2009. +# Version 3.2.0, released 31 Jul 2010. # # See http://backuppc.sourceforge.net. # @@ -96,7 +96,7 @@ sub new # Whether to use filesystem hierarchy standard for file layout. # If set, text config files are below /etc/BackupPC. # - my $useFHS = 0; + my $useFHS = 1; my $paths; # @@ -105,6 +105,8 @@ sub new $topDir = '/data/BackupPC' if ( $topDir eq "" ); $installDir = '/usr/local/BackupPC' if ( $installDir eq "" ); + $confDir = '/etc/BackupPC'; # FIXME remove this! XXX + # # Pick some initial defaults. For FHS the only critical # path is the ConfDir, since we get everything else out @@ -130,7 +132,7 @@ sub new my $bpc = bless { %$paths, - Version => '3.2.0beta0', + Version => '3.2.0', }, $class; $bpc->{storage} = BackupPC::Storage->new($paths); @@ -364,9 +366,9 @@ sub ConfigRead # Read host config file # if ( $host ne "" ) { - ($mesg, $config) = $bpc->{storage}->ConfigDataRead($host); + ($mesg, $config) = $bpc->{storage}->ConfigDataRead($host, $config); return $mesg if ( defined($mesg) ); - $bpc->{Conf} = { %{$bpc->{Conf}}, %$config }; + $bpc->{Conf} = $config; } # @@ -1236,19 +1238,24 @@ sub cmdVarSubstitute # Merge variables into @cmd # foreach my $arg ( @$template ) { + # + # Replace $VAR with ${VAR} so that both types of variable + # substitution are supported + # + $arg =~ s[\$(\w+)]{\${$1}}g; # # Replace scalar variables first # - $arg =~ s{\$(\w+)(\+?)}{ + $arg =~ s[\${(\w+)}(\+?)]{ exists($vars->{$1}) && ref($vars->{$1}) ne "ARRAY" ? ($2 eq "+" ? $bpc->shellEscape($vars->{$1}) : $vars->{$1}) - : "\$$1$2" + : "\${$1}$2" }eg; # # Now replicate any array arguments; this just works for just one # array var in each argument. # - if ( $arg =~ m{(.*)\$(\w+)(\+?)(.*)} && ref($vars->{$2}) eq "ARRAY" ) { + if ( $arg =~ m[(.*)\${(\w+)}(\+?)(.*)] && ref($vars->{$2}) eq "ARRAY" ) { my $pre = $1; my $var = $2; my $esc = $3;