# Craig Barratt <cbarratt@users.sourceforge.net>
#
# COPYRIGHT
-# Copyright (C) 2001-2003 Craig Barratt
+# Copyright (C) 2001-2004 Craig Barratt
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
use strict;
use File::Path;
use File::Copy;
+use Getopt::Std;
umask(0022);
-my $Version = "2.1.0_CVS";
-my $ReleaseDate = "3 Jul 2003";
+my $Version = "3.0.0alpha";
+my $ReleaseDate = "23 Jan 2006";
my $DistDir = "dist/BackupPC-$Version";
my @PerlSrc = qw(
bin/BackupPC
bin/BackupPC_archive
- bin/BackupPC_archivecd
- bin/BackupPC_archivetape
+ bin/BackupPC_archiveHost
+ bin/BackupPC_attribPrint
bin/BackupPC_dump
+ bin/BackupPC_fixupBackupSummary
bin/BackupPC_link
bin/BackupPC_nightly
bin/BackupPC_restore
bin/BackupPC_trashClean
bin/BackupPC_tarExtract
bin/BackupPC_tarCreate
+ bin/BackupPC_tarPCCopy
bin/BackupPC_compressPool
bin/BackupPC_zipCreate
bin/BackupPC_zcat
lib/BackupPC/Attrib.pm
+ lib/BackupPC/Config.pm
lib/BackupPC/FileZIO.pm
lib/BackupPC/Lib.pm
lib/BackupPC/PoolWrite.pm
+ lib/BackupPC/Storage.pm
lib/BackupPC/View.pm
lib/BackupPC/CGI/AdminOptions.pm
lib/BackupPC/CGI/Archive.pm
lib/BackupPC/CGI/ArchiveInfo.pm
lib/BackupPC/CGI/Browse.pm
lib/BackupPC/CGI/DirHistory.pm
+ lib/BackupPC/CGI/EditConfig.pm
lib/BackupPC/CGI/EmailSummary.pm
lib/BackupPC/CGI/GeneralInfo.pm
lib/BackupPC/CGI/HostInfo.pm
lib/BackupPC/CGI/StopServer.pm
lib/BackupPC/CGI/Summary.pm
lib/BackupPC/CGI/View.pm
+ lib/BackupPC/Config/Meta.pm
lib/BackupPC/Lang/de.pm
lib/BackupPC/Lang/en.pm
lib/BackupPC/Lang/es.pm
lib/BackupPC/Lang/fr.pm
+ lib/BackupPC/Lang/it.pm
+ lib/BackupPC/Lang/nl.pm
+ lib/BackupPC/Lang/pt_br.pm
+ lib/BackupPC/Storage/Text.pm
lib/BackupPC/Xfer/Archive.pm
lib/BackupPC/Xfer/Smb.pm
lib/BackupPC/Xfer/Tar.pm
lib/BackupPC/Xfer/Rsync.pm
+ lib/BackupPC/Xfer/RsyncDigest.pm
lib/BackupPC/Xfer/RsyncFileIO.pm
lib/BackupPC/Zip/FileMember.pm
cgi-bin/BackupPC_Admin
);
+my %opts;
+if ( !getopts("l", \%opts) || @ARGV != 0 ) {
+ print("usage: $0 [-l]\n");
+ exit(1);
+}
+
#
# Check config parameters
#
my $errCnt;
$errCnt += CheckConfigParams("conf/config.pl", $ConfVars, 0);
+
+$errCnt += CheckConfigParams("doc-src/BackupPC.pod", $ConfVars, 1);
+
+#
+# These config parameters are not used in the code, so ignore them.
+#
$ConfVars->{BackupPCUser} = 2;
-$ConfVars->{CgiDir} = 2;
-$ConfVars->{InstallDir} = 2;
-$ConfVars->{CgiImageDir} = 2;
+$ConfVars->{CgiDir} = 2;
+$ConfVars->{InstallDir} = 2;
+$ConfVars->{CgiImageDir} = 2;
+
+#
+# These config parameters are used in the code to be backward compatible,
+# but are not present in the current config file, so ignore them.
+#
+$ConfVars->{BlackoutHourBegin} = 2;
+$ConfVars->{BlackoutHourEnd} = 2;
+$ConfVars->{BlackoutWeekDays} = 2;
+$ConfVars->{RsyncLogLevel} = 2;
+
foreach my $file ( @PerlSrc ) {
$errCnt += CheckConfigParams($file, $ConfVars, 1);
}
-$errCnt += CheckLangUsage();
-exit(1) if ( $errCnt );
+if ( !$opts{l} ) {
+ $errCnt += CheckLangUsage();
+ $errCnt += CheckLangTags();
+}
+if ( $errCnt ) {
+ print("Exiting because of errors\n");
+ exit(1)
+}
$errCnt = 0;
foreach my $var ( sort(keys(%$ConfVars) ) ) {
printf("Unused config parameter $var\n");
$errCnt++;
}
-exit(1) if ( $errCnt );
+if ( $errCnt ) {
+ print("Exiting because of errors\n");
+ exit(1)
+}
rmtree($DistDir, 0, 0);
mkpath($DistDir, 0, 0777);
foreach my $dir ( qw(bin doc conf images init.d/src cgi-bin
lib/BackupPC/CGI
+ lib/BackupPC/Config
lib/BackupPC/Lang
+ lib/BackupPC/Storage
lib/BackupPC/Xfer
lib/BackupPC/Zip
) ) {
qw(
conf/config.pl
conf/hosts
+ conf/BackupPC_stnd.css
init.d/README
init.d/src/debian-backuppc
init.d/src/gentoo-backuppc
init.d/src/gentoo-backuppc.conf
init.d/src/linux-backuppc
+ init.d/src/slackware-backuppc
init.d/src/solaris-backuppc
init.d/src/suse-backuppc
doc/BackupPC.pod
print("Distribution written to dist/BackupPC-$Version.tar.gz\n");
unlink("pod2htmd.x~~");
unlink("pod2htmi.x~~");
+unlink("pod2htmd.tmp");
+unlink("pod2htmi.tmp");
###########################################################################
# Subroutines
binmode(FILE);
binmode(OUT);
while ( <FILE> ) {
- s/^# *Version \d+\.\d+[\.\w]*, released \d+ \w+ \d{4}\.?/# Version __VERSION__, released __RELEASEDATE__./;
+ s/^([#*\s]+)Version \d+\.\d+[\.\w]*, released \d+ \w+ \d{4}\.?/$1Version __VERSION__, released __RELEASEDATE__./;
s/__VERSION__/$Version/g;
s/__RELEASEDATE__/$ReleaseDate/g;
- if ( $file =~ /BackupPC\.html$/ && !/A NAME="item_%24Conf/ ) {
- s/\$Conf{([^}]*)}/
+ if ( $file =~ /BackupPC\.html$/ ) {
+ #
+ # fixup for perl 5.6.x
+ #
+ if ( !/A NAME="item_(%|_)24Conf/i ) {
+ s/\$Conf{([^}]*)}/
defined($ConfName{$1})
- ? "<A HREF=\"#$ConfName{$1}\">\$Conf{$1}<\/A>"
+ ? "\L<A HREF=\"#$ConfName{$1}\">\E\$Conf{$1}<\/A>"
: "\$Conf{$1}"/eg;
+ }
+ s/<(A NAME="item_(%|_)24Conf(%|_)7B(.*?)(%|_)7D).*?">/\L<A NAME="item_%24Conf%7b$4%7d">/ig;
+ s/^<DD>/<DD><P>/;
+ #
+ # Fixup for perl 5.8.x first one no longer needed after
+ # fix in CSS)
+ #
+# if ( /^<\/dt>/ ) {
+# $_ .= <FILE>;
+# s/^(<\/dt>\n<dd>)/$1<p>/s;
+# }
+ s/^<li><\/li>/<li>/;
}
if ( /__CONFIGPOD__/ ) {
print OUT $ConfPod;
print OUT "$1'__INSTALLDIR__',\n";
} elsif ( $file =~ /Lib.pm/ && /(.*LibDir *=> .*)'.*',/ ) {
print OUT "$1'__INSTALLDIR__',\n";
+ } elsif ( $file =~ /BackupPC_Admin/ && /(my *\$installDir *= *)'.*'/ ) {
+ print OUT "$1'__INSTALLDIR__/lib';\n";
} else {
print OUT;
}
s/([^;])\s*$/$1 .../;
}
push(@conf, $_);
- my $text = $_;
+ my $text = "\$Conf{$var}";
$text =~ s/\s+/_/sg;
$text =~ s{(\W)}{sprintf("%%%02X", ord($1) )}gxe;
$text = substr($text, 0, 50);
} else {
$vars->{$1}++;
}/eg;
- s/UserCommandRun\("([^"]*)"\)/if ( !defined($vars->{$1}) ) {
+ s/UserCommandRun\("([^"]*)"/if ( !defined($vars->{$1}) ) {
print("Unexpected Conf var $1 in $file\n");
$errors++;
} else {
open(F, $file) || die("can't open $file");
binmode(F);
while ( <F> ) {
+ next if ( /^\s*#/ );
s/\$Lang->{([^}]*)}/$vars->{$1} = 1;/eg;
}
close(F);
}
- # CB: disable other lang checks for now
- #
- # foreach my $f ( <lib/BackupPC/Lang/*.pm> ) {
- #
- foreach my $f ( <lib/BackupPC/Lang/en.pm> ) {
+
+ foreach my $f ( <lib/BackupPC/Lang/*.pm> ) {
my $done = {};
open(F, $f) || die("can't open $f\n");
binmode(F);
s/\$Lang{([^}]*)}/
my $var = $1;
next if ( $var =~ m{^(Reason_|Status_|backupType_)} );
+ next if ( $var eq "Documentation" );
if ( !defined($vars->{$var}) ) {
print("Unexpected Lang var $var in $f\n");
$errors++;
}
return $errors;
}
+
+#
+# Pedantically check that all the html tags in each language file
+# match.
+#
+sub CheckLangTags
+{
+ my($en, $enVars) = LangParse("lib/BackupPC/Lang/en.pm");
+ my($errors);
+
+ foreach my $lang ( qw(fr.pm de.pm es.pm it.pm nl.pm) ) {
+ my($d, $dVars) = LangParse("lib/BackupPC/Lang/$lang");
+ foreach my $v1 ( @$en ) {
+ my $v2 = shift(@$d);
+ if ( $v1->{var} ne $v2->{var} ) {
+ print("Botch: got $lang var $v2->{var} vs en.pm $v1->{var}\n");
+ exit;
+ }
+ my $t1 = LangTextStrip($v1->{val});
+ my $t2 = LangTextStrip($v2->{val});
+ if ( $t1 ne $t2 ) {
+ print("$v1->{var}: got en.pm $t1\nvs $lang $t2\n\n");
+ $errors++;
+ }
+ }
+ }
+ return $errors;
+}
+
+sub LangTextStrip
+{
+ my($t) = @_;
+
+ $t = "" if ( $t !~ /<.*>/ );
+ $t =~ s/^[^<]*</</s;
+ $t =~ s/([}>])[^<]*</$1</g;
+ $t =~ s/>[^<]*$/>/;
+ $t =~ s/(value=)"[^"]*"/$1""/sg;
+ $t =~ s/({h[12]\()"[^"]*"/$1""/g;
+ $t =~ s/ENG[\s\n]*//sg;
+ $t =~ s/^(<<EOF;\n)[^<]*/$1/g;
+ return $t;
+}
+
+sub LangParse
+{
+ my($file) = @_;
+ open(C, $file) || die("can't open $file");
+ binmode(C);
+ my($out, @lang, $var);
+ my $comment = 1;
+ my $allVars = {};
+ my $endLine = undef;
+ while ( <C> ) {
+ if ( /^#/ && !defined($endLine) ) {
+ if ( $comment ) {
+ $out .= $_;
+ } else {
+ if ( $out ne "" ) {
+ $allVars->{$var} = @lang if ( defined($var) );
+ push(@lang, {
+ text => $out,
+ var => $var,
+ });
+ }
+ $var = undef;
+ $comment = 1;
+ $out = $_;
+ }
+ } elsif ( /^\s*\$Lang\{([^}]*)/ ) {
+ $comment = 0;
+ if ( defined($var) ) {
+ $allVars->{$var} = @lang if ( defined($var) );
+ push(@lang, {
+ text => $out,
+ var => $var,
+ });
+ $out = $_;
+ } else {
+ $out .= $_;
+ }
+ $var = $1;
+ $endLine = $1 if ( /^\s*\$Lang\{[^}]*} *= *<<(.*);/ );
+ $endLine = $1 if ( /^\s*\$Lang\{[^}]*} *= *<<'(.*)';/ );
+ } else {
+ $endLine = undef if ( defined($endLine) && /^\Q$endLine[\n\r]*$/ );
+ $out .= $_;
+ }
+ }
+ if ( $out ne "" ) {
+ $allVars->{$var} = @lang if ( defined($var) );
+ push(@lang, {
+ text => $out,
+ var => $var,
+ });
+ }
+ close(C);
+ foreach my $v ( @lang ) {
+ if ( $v->{text} =~ /\$Lang{$v->{var}}\s*=\s*(.*)/s ) {
+ $v->{val} = $1;
+ }
+ }
+ return (\@lang, $allVars);
+}