3 # makeDist: Build a BackupPC distribution
7 # This script should be run with no arguments to build a
8 # distribution. The $Version and $ReleaseDate should be
9 # edited below to specify the version name and the release
10 # date. The distribution is createede in the sub-directory
11 # dist. The dsitribution is in the file name:
13 # dist/BackupPC-$Version.tar.gz.
16 # Craig Barratt <cbarratt@users.sourceforge.net>
19 # Copyright (C) 2001-2003 Craig Barratt
21 # This program is free software; you can redistribute it and/or modify
22 # it under the terms of the GNU General Public License as published by
23 # the Free Software Foundation; either version 2 of the License, or
24 # (at your option) any later version.
26 # This program is distributed in the hope that it will be useful,
27 # but WITHOUT ANY WARRANTY; without even the implied warranty of
28 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
29 # GNU General Public License for more details.
31 # You should have received a copy of the GNU General Public License
32 # along with this program; if not, write to the Free Software
33 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
35 #========================================================================
44 my $Version = "2.0.0beta1";
45 my $ReleaseDate = "30 Mar 2003";
46 my $DistDir = "dist/BackupPC-$Version";
54 bin/BackupPC_sendEmail
55 bin/BackupPC_serverMesg
56 bin/BackupPC_trashClean
57 bin/BackupPC_tarExtract
58 bin/BackupPC_tarCreate
59 bin/BackupPC_compressPool
60 bin/BackupPC_zipCreate
62 lib/BackupPC/Attrib.pm
63 lib/BackupPC/FileZIO.pm
65 lib/BackupPC/Lang/en.pm
66 lib/BackupPC/Lang/fr.pm
67 lib/BackupPC/Lang/es.pm
68 lib/BackupPC/PoolWrite.pm
70 lib/BackupPC/Xfer/Smb.pm
71 lib/BackupPC/Xfer/Tar.pm
72 lib/BackupPC/Xfer/Rsync.pm
73 lib/BackupPC/Xfer/RsyncFileIO.pm
74 lib/BackupPC/Zip/FileMember.pm
75 cgi-bin/BackupPC_Admin
79 # Check config parameters
84 $errCnt += CheckConfigParams("conf/config.pl", $ConfVars, 0);
85 $ConfVars->{BackupPCUser} = 2;
86 $ConfVars->{CgiDir} = 2;
87 $ConfVars->{InstallDir} = 2;
88 $ConfVars->{CgiImageDir} = 2;
89 foreach my $file ( @PerlSrc ) {
90 $errCnt += CheckConfigParams($file, $ConfVars, 1);
92 $errCnt += CheckLangUsage();
93 exit(1) if ( $errCnt );
95 foreach my $var ( sort(keys(%$ConfVars) ) ) {
96 next if ( $ConfVars->{$var} >= 2 || $var =~ /^\$/ );
97 printf("Unused config parameter $var\n");
100 exit(1) if ( $errCnt );
102 rmtree($DistDir, 0, 0);
103 mkpath($DistDir, 0, 0777);
105 foreach my $dir ( qw(bin lib/BackupPC/Xfer lib/BackupPC/Zip lib/BackupPC/Lang
106 doc conf images init.d/src cgi-bin) ) {
107 mkpath("$DistDir/$dir", 0, 0777);
111 my $ConfPod = config2pod();
113 mkpath("doc", 0, 0777);
114 InstallFile("doc-src/BackupPC.pod", "doc/BackupPC.pod");
117 pod2html("doc/BackupPC.pod",
118 "--backlink=Back to Top",
121 "--outfile=doc/BackupPC.html");
123 foreach my $file ( (@PerlSrc,
129 init.d/src/debian-backuppc
130 init.d/src/linux-backuppc
131 init.d/src/solaris-backuppc
139 InstallFile("$file", "$DistDir/$file");
142 system("cd dist ; tar zcf BackupPC-$Version.tar.gz BackupPC-$Version");
143 print("Distribution written to dist/BackupPC-$Version.tar.gz\n");
144 unlink("pod2htmd.x~~");
145 unlink("pod2htmi.x~~");
147 ###########################################################################
149 ###########################################################################
153 my($file, $dest) = @_;
155 unlink($dest) if ( -d $dest );
156 if ( $file =~ /\.gif/ ) {
157 die("can't copy($file, $dest)\n") unless copy($file, $dest);
159 open(FILE, $file) || die("can't open $file for reading\n");
160 open(OUT, ">$dest") || die("can't open $dest for writing\n");
162 s/^# *Version \d+\.\d+[\.\w]*, released \d+ \w+ \d{4}\.?/# Version __VERSION__, released __RELEASEDATE__./;
163 s/__VERSION__/$Version/g;
164 s/__RELEASEDATE__/$ReleaseDate/g;
165 if ( $file =~ /BackupPC\.html$/ && !/A NAME="item_%24Conf/ ) {
167 defined($ConfName{$1})
168 ? "<A HREF=\"#$ConfName{$1}\">\$Conf{$1}<\/A>"
171 if ( /__CONFIGPOD__/ ) {
173 } elsif ( /^use lib ".*BackupPC\/lib";/
174 || /^use lib "\/home\/pcbackup\/install\/lib";/ ) {
175 print OUT "use lib \"__INSTALLDIR__/lib\";\n";
176 } elsif ( $file =~ /Lib.pm/ && /(.*TopDir *=> .*)'.*',/ ) {
177 print OUT "$1'__TOPDIR__',\n";
178 } elsif ( $file =~ /Lib.pm/ && /(.*Version *=> .*)'[\w\d\.]+',/ ) {
179 print OUT "$1'$Version',\n";
180 } elsif ( $file =~ /Lib.pm/ && /(.*BinDir *=> .*)'.*',/ ) {
181 print OUT "$1'__INSTALLDIR__',\n";
182 } elsif ( $file =~ /Lib.pm/ && /(.*LibDir *=> .*)'.*',/ ) {
183 print OUT "$1'__INSTALLDIR__',\n";
200 open(C, "conf/config.pl") || die("can't open conf/config.pl");
201 my($str, $out, $getHdr, @conf);
206 if ( /^#########################/ ) {
209 $out .= "=back\n\n" if ( !$first );
210 $out .= "=head2 $str\n\n=over 4\n\n";
219 next if ( $str eq "" && /^$/ );
221 $str .= "\n" if ( $str =~ /examples?:\n$/i );
222 } elsif ( /^\$Conf{([^}]*)/ ) {
226 if ( !s/\[$/[ ... ];/ && !s/<<'EOF'/.../ ) {
227 s/([^;])\s*$/$1 .../;
232 $text =~ s{(\W)}{sprintf("%%%02X", ord($1) )}gxe;
233 $text = substr($text, 0, 50);
234 $ConfName{$var} = "item_$text";
236 if ( $str ne "" && @conf ) {
237 $out .= "=item " . join("\n\n=item ", @conf) . "\n\n";
239 $out .= "\n" if ( $str !~ /\n$/ );
245 if ( $str ne "" && @conf ) {
246 $out .= "=item " . join("\n\n=item ", @conf) . "\n\n";
248 $out .= "\n" if ( $str !~ /\n$/ );
250 $out .= "=back\n\n" if ( !$first );
254 sub CheckConfigParams
256 my($file, $vars, $check) = @_;
259 open(F, $file) || die("can't open $file\n");
262 s/\$(self|bpc)->{Conf}{([^}\$]+)}/if ( !defined($vars->{$2}) ) {
263 print("Unexpected Conf var $2 in $file\n");
268 s/\$[Cc]onf(?:->)?{([^}\$]+)}/if ( !defined($vars->{$1}) ) {
269 print("Unexpected Conf var $1 in $file\n");
274 s/UserCommandRun\("([^"]*)"\)/if ( !defined($vars->{$1}) ) {
275 print("Unexpected Conf var $1 in $file\n");
283 s/^[^#]*\$self->{Conf}{([^}]*)/$vars->{$1} = 1;/eg;
284 s/^[^#]*\$Conf{([^}]*)/$vars->{$1} = 1;/eg;
292 # Make sure that every lang variable in cgi-bin/BackupPC_Admin matches
293 # the strings in each lib/BackupPC/Lang/*.pm file. This makes sure
294 # we didn't miss any translations in any of the languages.
301 foreach my $file ( qw(cgi-bin/BackupPC_Admin bin/BackupPC_sendEmail) ) {
302 open(F, $file) || die("can't open $file");
304 s/\$Lang->{([^}]*)}/$vars->{$1} = 1;/eg;
308 foreach my $f ( <lib/BackupPC/Lang/*.pm> ) {
310 open(F, $f) || die("can't open $f\n");
315 next if ( $var =~ m{^(Reason_|Status_)} );
316 if ( !defined($vars->{$var}) ) {
317 print("Unexpected Lang var $var in $f\n");
324 foreach my $v ( keys(%$vars) ) {
326 # skip "variables" with "$", since they are like expressions
328 next if ( $v =~ /\$/ );
329 if ( !defined($done->{$v}) ) {
330 print("Lang var $v missing from $f\n");