r8516@llin: dpavlin | 2005-10-14 12:59:08 +0200
authordpavlin <dpavlin@8392b6e1-25fa-0310-8288-cc32f8e212ea>
Fri, 14 Oct 2005 14:02:51 +0000 (14:02 +0000)
committerdpavlin <dpavlin@8392b6e1-25fa-0310-8288-cc32f8e212ea>
Fri, 14 Oct 2005 14:02:51 +0000 (14:02 +0000)
 use File::Which to find binaries

git-svn-id: svn+ssh://llin/home/dpavlin/private/svn/BackupPC/trunk@201 8392b6e1-25fa-0310-8288-cc32f8e212ea

bin/BackupPC_burnArchiveCLI
bin/BackupPC_incPartsUpdate

index 763cbff..cc3bc0b 100755 (executable)
@@ -91,7 +91,8 @@ sub dumpArchive2XML($$$)
                        backups.date AS date,
                        shares.name  AS share,
                        backups.size AS backup_size,
-                       backups.inc_size AS compress_size
+                       backups.inc_size AS compress_size,
+                       backups.parts AS parts
                FROM backups, archive_backup, hosts, shares
                WHERE archive_backup.backup_id = backups.id
                        AND hosts.id=backups.hostid
@@ -170,15 +171,20 @@ sub fmt_archive($) {
        $row->{'copies'} =~ s/^\s*0+\s*$/no/;
        $row->{'total_size'} /= (1024*1024);
 
-       my $copies = 'copies';
-       $copies = 'copy' if ($row->{'copies'} == 1);
+       my $copies = $row->{'copies'};
+       if ($row->{'parts'} > 1) {
+               $copies .= '/' . $row->{'parts'};
+       }
+
+       my $copies_dest = 'copies';
+       $copies_dest = 'copy' if ($row->{'copies'} == 1);
 
        return
                sprintf("%d by %s on %s, %s %s [%.2f Mb]",
                        $row->{'dvd_nr'},
                        $row->{'username'},
                        $row->{'date'},
-                       $row->{'copies'}, $copies,
+                       $copies, $copies_dest,
                        $row->{'total_size'},
                );
 }
index b9f30aa..272dd83 100755 (executable)
@@ -11,6 +11,7 @@ use Time::HiRes qw/time/;
 use POSIX qw/strftime/;
 use BackupPC::SearchLib;
 use Cwd qw/abs_path/;
+use File::Which;
 
 my $path = abs_path($0);
 $path =~ s#/[^/]+$#/#;
@@ -18,6 +19,12 @@ my $tarIncCreate = $path .= 'BackupPC_tarIncCreate';
 
 die "can't find $tarIncCreate: $!\n" unless (-x $tarIncCreate);
 
+my $bin;
+foreach my $c (qw/gzip split/) {
+       $bin->{$c} = which($c) || die "$0 needs $c, install it\n";
+}
+
+
 my $debug = 0;
 $|=1;
 
@@ -94,7 +101,7 @@ while (my $row = $sth->fetchrow_hashref) {
 
        # re-create archive?
        if ($row->{'inc_size'} == -1 || $size == -1 || $row->{'inc_size'} != $size) {
-               my $cmd = qq{rm -Rf $tar_dir/$tar_file && $tarIncCreate -h "$row->{'host'}" -s "$row->{'share'}" -n $row->{'num'} | gzip -9 > $tar_dir/$tar_file};
+               my $cmd = qq{rm -Rf $tar_dir/$tar_file && $tarIncCreate -h "$row->{'host'}" -s "$row->{'share'}" -n $row->{'num'} | $bin->{'gzip'} -9 > $tar_dir/$tar_file};
                print STDERR "## $cmd\n" if ($debug);
 
                system($cmd) == 0 or die "failed: $?";
@@ -127,7 +134,7 @@ while (my $row = $sth->fetchrow_hashref) {
                        mkdir $in || die "can't mkdir $in: $!";
 
                        my $suffix_len = length("$parts");
-                       system("split -d -b $max_size -a $suffix_len $out $in/part") == 0 or die "can't split $out: $?";
+                       system("$bin->{'split'} -d -b $max_size -a $suffix_len $out $in/part") == 0 or die "can't split $out: $?";
                        unlink $out || die "can't unlink $out: $!";
                }