* Major changes from Ryan Kucera to add style sheets to the CGI
[BackupPC.git] / makeDist
index d4d5c81..8c547a4 100755 (executable)
--- a/makeDist
+++ b/makeDist
@@ -1,6 +1,38 @@
 #!/bin/perl
 #
-# Build a BackupPC distribution
+# makeDist: Build a BackupPC distribution
+#
+# DESCRIPTION
+#
+#   This script should be run with no arguments to build a
+#   distribution.  The $Version and $ReleaseDate should be
+#   edited below to specify the version name and the release
+#   date.  The distribution is createede in the sub-directory
+#   dist.  The dsitribution is in the file name:
+#
+#           dist/BackupPC-$Version.tar.gz.
+#
+# AUTHOR
+#   Craig Barratt <cbarratt@users.sourceforge.net>
+#
+# COPYRIGHT
+#   Copyright (C) 2001-2003  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
+#   the Free Software Foundation; either version 2 of the License, or
+#   (at your option) any later version.
+#
+#   This program is distributed in the hope that it will be useful,
+#   but WITHOUT ANY WARRANTY; without even the implied warranty of
+#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#   GNU General Public License for more details.
+#
+#   You should have received a copy of the GNU General Public License
+#   along with this program; if not, write to the Free Software
+#   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+#
+#========================================================================
 #
 
 use strict;
@@ -9,12 +41,15 @@ use File::Copy;
 
 umask(0022);
 
-my $Version     = "1.5.0";
-my $ReleaseDate = "2 Aug 2002";
+my $Version     = "2.1.0_CVS";
+my $ReleaseDate = "3 Jul 2003";
 my $DistDir     = "dist/BackupPC-$Version";
 
 my @PerlSrc = qw(
     bin/BackupPC
+    bin/BackupPC_archive
+    bin/BackupPC_archivecd
+    bin/BackupPC_archivetape
     bin/BackupPC_dump
     bin/BackupPC_link
     bin/BackupPC_nightly
@@ -30,11 +65,37 @@ my @PerlSrc = qw(
     lib/BackupPC/Attrib.pm
     lib/BackupPC/FileZIO.pm
     lib/BackupPC/Lib.pm
+    lib/BackupPC/PoolWrite.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/EmailSummary.pm
+    lib/BackupPC/CGI/GeneralInfo.pm
+    lib/BackupPC/CGI/HostInfo.pm
+    lib/BackupPC/CGI/Lib.pm
+    lib/BackupPC/CGI/LOGlist.pm
+    lib/BackupPC/CGI/Queue.pm
+    lib/BackupPC/CGI/ReloadServer.pm
+    lib/BackupPC/CGI/RestoreFile.pm
+    lib/BackupPC/CGI/RestoreInfo.pm
+    lib/BackupPC/CGI/Restore.pm
+    lib/BackupPC/CGI/StartServer.pm
+    lib/BackupPC/CGI/StartStopBackup.pm
+    lib/BackupPC/CGI/StopServer.pm
+    lib/BackupPC/CGI/Summary.pm
+    lib/BackupPC/CGI/View.pm
+    lib/BackupPC/Lang/de.pm
     lib/BackupPC/Lang/en.pm
+    lib/BackupPC/Lang/es.pm
     lib/BackupPC/Lang/fr.pm
-    lib/BackupPC/PoolWrite.pm
+    lib/BackupPC/Xfer/Archive.pm
     lib/BackupPC/Xfer/Smb.pm
     lib/BackupPC/Xfer/Tar.pm
+    lib/BackupPC/Xfer/Rsync.pm
+    lib/BackupPC/Xfer/RsyncFileIO.pm
     lib/BackupPC/Zip/FileMember.pm
     cgi-bin/BackupPC_Admin
 );
@@ -43,15 +104,20 @@ my @PerlSrc = qw(
 # Check config parameters
 #
 my $ConfVars = {};
-CheckConfigParams("conf/config.pl", $ConfVars, 0);
+my $errCnt;
+
+$errCnt += CheckConfigParams("conf/config.pl", $ConfVars, 0);
 $ConfVars->{BackupPCUser} = 2;
 $ConfVars->{CgiDir} = 2;
 $ConfVars->{InstallDir} = 2;
 $ConfVars->{CgiImageDir} = 2;
 foreach my $file ( @PerlSrc ) {
-    CheckConfigParams($file, $ConfVars, 1);
+    $errCnt += CheckConfigParams($file, $ConfVars, 1);
 }
-my $errCnt;
+$errCnt += CheckLangUsage();
+exit(1) if ( $errCnt );
+
+$errCnt = 0;
 foreach my $var ( sort(keys(%$ConfVars) ) ) {
     next if ( $ConfVars->{$var} >= 2 || $var =~ /^\$/ );
     printf("Unused config parameter $var\n");
@@ -62,8 +128,12 @@ exit(1) if ( $errCnt );
 rmtree($DistDir, 0, 0);
 mkpath($DistDir, 0, 0777);
 
-foreach my $dir ( qw(bin lib/BackupPC/Xfer lib/BackupPC/Zip doc conf
-                    images init.d/src cgi-bin) ) {
+foreach my $dir ( qw(bin doc conf images init.d/src cgi-bin
+                    lib/BackupPC/CGI
+                    lib/BackupPC/Lang
+                    lib/BackupPC/Xfer
+                    lib/BackupPC/Zip
+               ) ) {
     mkpath("$DistDir/$dir", 0, 0777);
 }
 
@@ -86,8 +156,12 @@ foreach my $file ( (@PerlSrc,
                conf/config.pl
                conf/hosts
                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/solaris-backuppc
+               init.d/src/suse-backuppc
                doc/BackupPC.pod
                doc/BackupPC.html
                README
@@ -99,6 +173,9 @@ foreach my $file ( (@PerlSrc,
 }
 rmtree("doc", 0, 0);
 system("cd dist ; tar zcf BackupPC-$Version.tar.gz BackupPC-$Version");
+print("Distribution written to dist/BackupPC-$Version.tar.gz\n");
+unlink("pod2htmd.x~~");
+unlink("pod2htmi.x~~");
 
 ###########################################################################
 # Subroutines
@@ -114,6 +191,8 @@ sub InstallFile
     } else {
        open(FILE, $file)   || die("can't open $file for reading\n");
        open(OUT, ">$dest") || die("can't open $dest for writing\n");
+       binmode(FILE);
+       binmode(OUT);
        while ( <FILE> ) {
            s/^# *Version \d+\.\d+[\.\w]*, released \d+ \w+ \d{4}\.?/# Version __VERSION__, released __RELEASEDATE__./;
            s/__VERSION__/$Version/g;
@@ -134,9 +213,9 @@ sub InstallFile
            } elsif ( $file =~ /Lib.pm/ && /(.*Version *=> .*)'[\w\d\.]+',/ ) {
                print OUT "$1'$Version',\n";
            } elsif ( $file =~ /Lib.pm/ && /(.*BinDir *=> .*)'.*',/ ) {
-               print OUT "$1'__INSTALLDIR__/bin',\n";
+               print OUT "$1'__INSTALLDIR__',\n";
            } elsif ( $file =~ /Lib.pm/ && /(.*LibDir *=> .*)'.*',/ ) {
-               print OUT "$1'__INSTALLDIR__/lib',\n";
+               print OUT "$1'__INSTALLDIR__',\n";
            } else {
                print OUT;
            }
@@ -154,6 +233,7 @@ sub InstallFile
 sub config2pod
 {
     open(C, "conf/config.pl") || die("can't open conf/config.pl");
+    binmode(C);
     my($str, $out, $getHdr, @conf);
     my $first = 1;
     while ( <C> ) {
@@ -210,19 +290,27 @@ sub config2pod
 sub CheckConfigParams
 {
     my($file, $vars, $check) = @_;
+    my $errors;
 
     open(F, $file) || die("can't open $file\n");
+    binmode(F);
     if ( $check ) {
         while ( <F> ) {
-            s/\$self->{Conf}{([^}\$]+)}/if ( !defined($vars->{$1}) ) {
+            s/\$(self|bpc)->{Conf}{([^}\$]+)}/if ( !defined($vars->{$2}) ) {
+                    print("Unexpected Conf var $2 in $file\n");
+                    $errors++;
+                } else {
+                    $vars->{$2}++;
+                }/eg;
+            s/\$[Cc]onf(?:->)?{([^}\$]+)}/if ( !defined($vars->{$1}) ) {
                     print("Unexpected Conf var $1 in $file\n");
-                    exit(1);
+                    $errors++;
                 } else {
                     $vars->{$1}++;
                 }/eg;
-            s/\$[Cc]onf(?:->)?{([^}\$]+)}/if ( !defined($vars->{$1}) ) {
+            s/UserCommandRun\("([^"]*)"\)/if ( !defined($vars->{$1}) ) {
                     print("Unexpected Conf var $1 in $file\n");
-                    exit(1);
+                    $errors++;
                 } else {
                     $vars->{$1}++;
                 }/eg;
@@ -234,4 +322,61 @@ sub CheckConfigParams
         }
     }
     close(F);
+    return $errors;
+}
+
+#
+# Make sure that every lang variable in cgi-bin/BackupPC_Admin matches
+# the strings in each lib/BackupPC/Lang/*.pm file.  This makes sure
+# we didn't miss any translations in any of the languages.
+#
+sub CheckLangUsage
+{
+    my $errors;
+    my $vars = {};
+
+    foreach my $file ( (
+               qw(cgi-bin/BackupPC_Admin bin/BackupPC_sendEmail),
+               <lib/BackupPC/CGI/*pm>
+           ) ) {
+       open(F, $file) || die("can't open $file");
+       binmode(F);
+       while ( <F> ) {
+           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> ) {
+        my $done = {};
+        open(F, $f) || die("can't open $f\n");
+       binmode(F);
+        while ( <F> ) {
+            s/#.*//g;
+            s/\$Lang{([^}]*)}/
+                   my $var = $1;
+                   next if ( $var =~ m{^(Reason_|Status_|backupType_)} );
+                    if ( !defined($vars->{$var}) ) {
+                        print("Unexpected Lang var $var in $f\n");
+                        $errors++;
+                    } else {
+                        $done->{$var} = 1;
+                    }/eg;
+        }
+        close(F);
+        foreach my $v ( keys(%$vars) ) {
+           #
+           # skip "variables" with "$", since they are like expressions
+           #
+           next if ( $v =~ /\$/ );
+            if ( !defined($done->{$v}) ) {
+                print("Lang var $v missing from $f\n");
+                $errors++;
+            }
+        }
+    }
+    return $errors;
 }