/[BackupPC]/trunk/bin/BackupPC_tarIncCreate
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /trunk/bin/BackupPC_tarIncCreate

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 169 by dpavlin, Mon Oct 10 14:12:33 2005 UTC revision 254 by dpavlin, Mon Dec 12 16:07:27 2005 UTC
# Line 1  Line 1 
1  #!/usr/bin/perl  #!/usr/bin/perl -w
2  #============================================================= -*-perl-*-  #============================================================= -*-perl-*-
3  #  #
4  # BackupPC_tarIncCreate: create a tar archive of an existing incremental dump  # BackupPC_tarIncCreate: create a tar archive of an existing incremental dump
# Line 72  use BackupPC::View; Line 72  use BackupPC::View;
72  use BackupPC::SearchLib;  use BackupPC::SearchLib;
73  use Time::HiRes qw/time/;  use Time::HiRes qw/time/;
74  use POSIX qw/strftime/;  use POSIX qw/strftime/;
75    use File::Which;
76    use File::Path;
77    use File::Slurp;
78  use Data::Dumper;       ### FIXME  use Data::Dumper;       ### FIXME
79    
80  die("BackupPC::Lib->new failed\n") if ( !(my $bpc = BackupPC::Lib->new) );  die("BackupPC::Lib->new failed\n") if ( !(my $bpc = BackupPC::Lib->new) );
81  my $TopDir = $bpc->TopDir();  my $TopDir = $bpc->TopDir();
82  my $BinDir = $bpc->BinDir();  my $BinDir = $bpc->BinDir();
83  my %Conf   = $bpc->Conf();  my %Conf   = $bpc->Conf();
84    %BackupPC::SearchLib::Conf = %Conf;
85  my %opts;  my %opts;
86  my $in_backup_increment;  my $in_backup_increment;
87    
88    
89  if ( !getopts("th:n:p:r:s:b:w:v", \%opts) ) {  if ( !getopts("th:n:p:r:s:b:w:vdf", \%opts) ) {
90      print STDERR <<EOF;      print STDERR <<EOF;
91  usage: $0 [options]  usage: $0 [options]
92    Required options:    Required options:
# Line 98  usage: $0 [options] Line 102  usage: $0 [options]
102       -p pathAdd      new path prefix       -p pathAdd      new path prefix
103       -b BLOCKS       BLOCKS x 512 bytes per record (default 20; same as tar)       -b BLOCKS       BLOCKS x 512 bytes per record (default 20; same as tar)
104       -w writeBufSz   write buffer size (default 1048576 = 1MB)       -w writeBufSz   write buffer size (default 1048576 = 1MB)
105         -f              overwrite existing parts
106       -v              verbose output       -v              verbose output
107         -d              debug output
108  EOF  EOF
109      exit(1);      exit(1);
110  }  }
111    
112  if ( $opts{h} !~ /^([\w\.\s-]+)$/ ) {  if ( $opts{h} !~ /^([\w\.\s-]+)$/ ) {
113      print(STDERR "$0: bad host name '$opts{h}'\n");      die "$0: bad host name '$opts{h}'\n";
     exit(1);  
114  }  }
115  my $Host = $opts{h};  my $Host = $opts{h};
116    
117  if ( $opts{n} !~ /^(-?\d+)$/ ) {  if ( $opts{n} !~ /^(-?\d+)$/ ) {
118      print(STDERR "$0: bad dump number '$opts{n}'\n");      die "$0: bad dump number '$opts{n}'\n";
     exit(1);  
119  }  }
120  my $Num = $opts{n};  my $Num = $opts{n};
121    
122    my $bin;
123    foreach my $c (qw/gzip md5sum tee/) {
124            $bin->{$c} = which($c) || die "$0 needs $c, install it\n";
125    }
126    
127  my @Backups = $bpc->BackupInfoRead($Host);  my @Backups = $bpc->BackupInfoRead($Host);
128  my $FileCnt = 0;  my $FileCnt = 0;
129  my $ByteCnt = 0;  my $ByteCnt = 0;
130  my $DirCnt = 0;  my $DirCnt = 0;
131  my $SpecialCnt = 0;  my $SpecialCnt = 0;
132  my $ErrorCnt = 0;  my $ErrorCnt = 0;
133    my $current_tar_size = 0;
134    my $total_increment_size = 0;
135    
136  my $i;  my $i;
137  $Num = $Backups[@Backups + $Num]{num} if ( -@Backups <= $Num && $Num < 0 );  $Num = $Backups[@Backups + $Num]{num} if ( -@Backups <= $Num && $Num < 0 );
# Line 128  for ( $i = 0 ; $i < @Backups ; $i++ ) { Line 139  for ( $i = 0 ; $i < @Backups ; $i++ ) {
139      last if ( $Backups[$i]{num} == $Num );      last if ( $Backups[$i]{num} == $Num );
140  }  }
141  if ( $i >= @Backups ) {  if ( $i >= @Backups ) {
142      print(STDERR "$0: bad backup number $Num for host $Host\n");      die "$0: bad backup number $Num for host $Host\n";
     exit(1);  
143  }  }
144    
145  my $PathRemove = $1 if ( $opts{r} =~ /(.+)/ );  my $PathRemove = $1 if ( $opts{r} =~ /(.+)/ );
146  my $PathAdd    = $1 if ( $opts{p} =~ /(.+)/ );  my $PathAdd    = $1 if ( $opts{p} =~ /(.+)/ );
147  if ( $opts{s} !~ /^([\w\s\.\/\$-]+)$/ && $opts{s} ne "*" ) {  if ( $opts{s} !~ /^([\w\s\.\/\$-]+)$/ && $opts{s} ne "*" ) {
148      print(STDERR "$0: bad share name '$opts{s}'\n");      die "$0: bad share name '$opts{s}'\n";
     exit(1);  
149  }  }
150  our $ShareName = $opts{s};  our $ShareName = $opts{s};
151  our $view = BackupPC::View->new($bpc, $Host, \@Backups);  our $view = BackupPC::View->new($bpc, $Host, \@Backups);
152    
153    # database
154    
155    my $dsn = $Conf{SearchDSN};
156    my $db_user = $Conf{SearchUser} || '';
157    
158    my $dbh = DBI->connect($dsn, $db_user, "", { RaiseError => 1, AutoCommit => 0} );
159    
160    my $sth_inc_size = $dbh->prepare(qq{
161            update backups set
162                    inc_size = ?,
163                    parts = ?,
164                    inc_deleted = false
165            where id = ?
166    });
167    my $sth_backup_parts = $dbh->prepare(qq{
168            insert into backup_parts (
169                    backup_id,
170                    part_nr,
171                    tar_size,
172                    size,
173                    md5,
174                    items
175            ) values (?,?,?,?,?,?)
176    });
177    
178  #  #
179  # This constant and the line of code below that uses it are borrowed  # This constant and the line of code below that uses it are borrowed
180  # from Archive::Tar.  Thanks to Calle Dybedahl and Stephen Zander.  # from Archive::Tar.  Thanks to Calle Dybedahl and Stephen Zander.
# Line 163  my(%HardLinkExtraFiles, @HardLinks); Line 197  my(%HardLinkExtraFiles, @HardLinks);
197  #  #
198  # Write out all the requested files/directories  # Write out all the requested files/directories
199  #  #
200  binmode(STDOUT);  
201  my $fh = *STDOUT;  my $max_file_size = $Conf{'MaxArchiveFileSize'} || die "problem with MaxArchiveFileSize parametar";
202    $max_file_size *= 1024;
203    
204    my $tar_dir = $Conf{InstallDir}.'/'.$Conf{GzipTempDir};
205    die "problem with $tar_dir, check GzipTempDir in configuration\n" unless (-d $tar_dir && -w $tar_dir);
206    
207    my $tar_file = BackupPC::SearchLib::getGzipName($Host, $ShareName, $Num) || die "can't getGzipName($Host, $ShareName, $Num)";
208    
209    my $tar_path_final = $tar_dir . '/' . $tar_file;
210    my $tar_path = $tar_path_final . '.tmp';
211    
212    $tar_path =~ s#//#/#g;
213    
214    my $sth = $dbh->prepare(qq{
215            SELECT
216                    backups.id
217            FROM backups
218                    JOIN shares on shares.id = shareid
219                    JOIN hosts on hosts.id = shares.hostid
220            WHERE hosts.name = ? and shares.name = ? and backups.num = ?
221    });
222    $sth->execute($Host, $ShareName, $Num);
223    my ($backup_id) = $sth->fetchrow_array;
224    $sth->finish;
225    
226    print STDERR "backup_id: $backup_id working dir: $tar_dir, max uncompressed size $max_file_size bytes, tar $tar_file\n" if ($opts{d});
227    
228    if (-e $tar_path_final) {
229            if ($opts{f}) {
230                    rmtree $tar_path_final || die "can't remove $tar_path_final: $!";
231            } else {
232                    die "$tar_path_final allready exists\n";
233            }
234    }
235    
236    my $fh;
237    my $part = 0;
238    my $no_files = 0;
239    my $items_in_part = 0;
240    
241    sub new_tar_part {
242            my $arg = {@_};
243    
244            if ($fh) {
245                    return if ($current_tar_size == 0);
246    
247                    print STDERR " $part";
248    
249                    #
250                    # Finish with two null 512 byte headers,
251                    # and then round out a full block.
252                    #
253                    my $data = "\0" x ($tar_header_length * 2);
254                    TarWrite($fh, \$data);
255                    TarWrite($fh, undef);
256    
257                    close($fh) || die "can't close archive part $part: $!";
258    
259                    my $file = $tar_path . '/' . $part;
260    
261                    my $md5 = read_file( $file . '.md5' ) || die "can't read md5sum file ${file}.md5";
262                    $md5 =~ s/\s.*$//;
263    
264                    my $size = (stat( $file . '.tar.gz' ))[7] || die "can't stat ${file}.tar.gz";
265    
266                    $sth_backup_parts->execute(
267                            $backup_id,
268                            $part,
269                            $current_tar_size,
270                            $size,
271                            $md5,
272                            $items_in_part,
273                    );
274    
275                    $total_increment_size += $size;
276    
277                    if ($arg->{close}) {
278    
279                            sub move($$) {
280                                    my ($from,$to) = @_;
281                                    print STDERR "# rename $from -> $to\n" if ($opts{d});
282                                    rename $from, $to || die "can't move $from -> $to: $!\n";
283                            }
284    
285                            if ($part == 1) {
286                                    print STDERR " single" if ($opts{v});
287                                    move("${tar_path}/1.tar.gz", "${tar_path_final}.tar.gz");
288                                    move("${tar_path}/1.md5", "${tar_path_final}.md5");
289                                    rmtree $tar_path or die "can't remove temporary dir $tar_path: $!";
290                            } else {
291                                    print STDERR " [last]" if ($opts{v});
292                                    move("${tar_path}", "${tar_path_final}");
293                            }
294    
295                            $sth_inc_size->execute(
296                                    $total_increment_size,
297                                    $part,
298                                    $backup_id
299                            );
300    
301                            print STDERR ", $total_increment_size bytes\n" if ($opts{v});
302    
303                            return;
304                    }
305    
306            }
307    
308            $part++;
309    
310            # if this is first part, create directory
311    
312            if ($part == 1) {
313                    if (-e $tar_path) {
314                            print STDERR "# deleting existing $tar_path\n" if ($opts{d});
315                            rmtree($tar_path);
316                    }
317                    mkdir($tar_path) || die "can't create directory $tar_path: $!";
318    
319                    sub abort_cleanup {
320                            print STDERR "ABORTED: cleanup temp dir";
321                            rmtree($tar_path);
322                            $dbh->rollback;
323                            exit 1;
324                    }
325    
326                    $SIG{'INT'}  = \&abort_cleanup;
327                    $SIG{'QUIT'} = \&abort_cleanup;
328                    $SIG{'__DIE__'} = \&abort_cleanup;
329    
330            }
331    
332            my $file = $tar_path . '/' . $part;
333    
334            #
335            # create comprex pipe which will pass output through gzip
336            # for compression, create file on disk using tee
337            # and pipe same output to md5sum to create checksum
338            #
339    
340            my $cmd = '| ' . $bin->{'gzip'}   . ' ' . $Conf{GzipLevel} .      ' ' .
341                      '| ' . $bin->{'tee'}    . ' ' . $file . '.tar.gz' . ' ' .
342                      '| ' . $bin->{'md5sum'} . ' - > ' . $file . '.md5';
343    
344            print STDERR "## $cmd\n" if ($opts{d});
345    
346            open($fh, $cmd) or die "can't open $cmd: $!";
347            binmode($fh);
348    
349            $current_tar_size = 0;
350            $items_in_part = 0;
351    }
352    
353    new_tar_part();
354    
355  if (seedCache($Host, $ShareName, $Num)) {  if (seedCache($Host, $ShareName, $Num)) {
356          archiveWrite($fh, '/');          archiveWrite($fh, '/');
357          archiveWriteHardLinks($fh);          archiveWriteHardLinks($fh);
358            new_tar_part( close => 1 );
359  } else {  } else {
360          print STDERR "NOTE: no files found for $Host:$ShareName, increment $Num\n" if ($opt{v});          print STDERR "NOTE: no files found for $Host:$ShareName, increment $Num\n" if ($opts{v});
361            # remove temporary files if there are no files
362            rmtree($tar_path);
363  }  }
364    
365  #  #
 # Finish with two null 512 byte headers, and then round out a full  
 # block.  
 #  
 my $data = "\0" x ($tar_header_length * 2);  
 TarWrite($fh, \$data);  
 TarWrite($fh, undef);  
   
 #  
366  # print out totals if requested  # print out totals if requested
367  #  #
368  if ( $opts{t} ) {  if ( $opts{t} ) {
# Line 193  if ( $ErrorCnt && !$FileCnt && !$DirCnt Line 374  if ( $ErrorCnt && !$FileCnt && !$DirCnt
374      # Got errors, with no files or directories; exit with non-zero      # Got errors, with no files or directories; exit with non-zero
375      # status      # status
376      #      #
377      exit(1);      die "got errors or no files\n";
378  }  }
379  exit(0);  
380    $sth_inc_size->finish;
381    $sth_backup_parts->finish;
382    
383    $dbh->commit || die "can't commit changes to database";
384    $dbh->disconnect();
385    
386    exit;
387    
388  ###########################################################################  ###########################################################################
389  # Subroutines  # Subroutines
# Line 260  sub TarWrite Line 448  sub TarWrite
448  {  {
449      my($fh, $dataRef) = @_;      my($fh, $dataRef) = @_;
450    
451    
452      if ( !defined($dataRef) ) {      if ( !defined($dataRef) ) {
453          #          #
454          # do flush by padding to a full $WriteBufSz          # do flush by padding to a full $WriteBufSz
# Line 267  sub TarWrite Line 456  sub TarWrite
456          my $data = "\0" x ($WriteBufSz - length($WriteBuf));          my $data = "\0" x ($WriteBufSz - length($WriteBuf));
457          $dataRef = \$data;          $dataRef = \$data;
458      }      }
459    
460        # poor man's tell :-)
461        $current_tar_size += length($$dataRef);
462    
463      if ( length($WriteBuf) + length($$dataRef) < $WriteBufSz ) {      if ( length($WriteBuf) + length($$dataRef) < $WriteBufSz ) {
464          #          #
465          # just buffer and return          # just buffer and return
# Line 277  sub TarWrite Line 470  sub TarWrite
470      my $done = $WriteBufSz - length($WriteBuf);      my $done = $WriteBufSz - length($WriteBuf);
471      if ( syswrite($fh, $WriteBuf . substr($$dataRef, 0, $done))      if ( syswrite($fh, $WriteBuf . substr($$dataRef, 0, $done))
472                                  != $WriteBufSz ) {                                  != $WriteBufSz ) {
473          print(STDERR "Unable to write to output file ($!)\n");          die "Unable to write to output file ($!)\n";
         exit(1);  
474      }      }
475      while ( $done + $WriteBufSz <= length($$dataRef) ) {      while ( $done + $WriteBufSz <= length($$dataRef) ) {
476          if ( syswrite($fh, substr($$dataRef, $done, $WriteBufSz))          if ( syswrite($fh, substr($$dataRef, $done, $WriteBufSz))
477                              != $WriteBufSz ) {                              != $WriteBufSz ) {
478              print(STDERR "Unable to write to output file ($!)\n");              die "Unable to write to output file ($!)\n";
             exit(1);  
479          }          }
480          $done += $WriteBufSz;          $done += $WriteBufSz;
481      }      }
# Line 389  sub TarWriteFileInfo Line 580  sub TarWriteFileInfo
580  sub seedCache($$$) {  sub seedCache($$$) {
581          my ($host, $share, $dumpNo) = @_;          my ($host, $share, $dumpNo) = @_;
582    
583          my $dsn = $Conf{SearchDSN};          print STDERR curr_time(), "$host:$share #$dumpNo" if ($opts{v});
         my $db_user = $Conf{SearchUser} || '';  
           
         print STDERR curr_time(), "getting files for $host:$share increment $dumpNo..." if ($opts{v});  
584          my $sql = q{          my $sql = q{
585                  SELECT path                  SELECT path,size
586                  FROM files                  FROM files
587                          JOIN shares on shares.id = shareid                          JOIN shares on shares.id = shareid
588                          JOIN hosts on hosts.id = shares.hostid                          JOIN hosts on hosts.id = shares.hostid
589                  WHERE hosts.name = ? and shares.name = ? and backupnum = ?                  WHERE hosts.name = ? and shares.name = ? and backupnum = ?
590          };          };
591    
         my $dbh = DBI->connect($dsn, $db_user, "", { RaiseError => 1, AutoCommit => 1} );        
592          my $sth = $dbh->prepare($sql);            my $sth = $dbh->prepare($sql);  
593          $sth->execute($host, $share, $dumpNo);          $sth->execute($host, $share, $dumpNo);
594          my $count = $sth->rows;          my $count = $sth->rows;
595          print STDERR " found $count items\n" if ($opts{v});          print STDERR " $count items, parts:" if ($opts{v});
596          while (my $row = $sth->fetchrow_arrayref) {          while (my $row = $sth->fetchrow_arrayref) {
597  #print STDERR "+ ", $row->[0],"\n";  #print STDERR "+ ", $row->[0],"\n";
598                  $in_backup_increment->{ $row->[0] }++;                  $in_backup_increment->{ $row->[0] } = $row->[1];
599          }          }
600                    
601          $sth->finish();          $sth->finish();
         $dbh->disconnect();  
602    
603          return $count;          return $count;
604  }  }
605    
606    #
607    # calculate overhad for one file in tar
608    #
609    sub tar_overhead($) {
610            my $name = shift || '';
611    
612            # header, padding of file and two null blocks at end
613            my $len = 4 * $tar_header_length;
614    
615            # if filename is longer than 99 chars subtract blocks for
616            # long filename
617            if ( length($name) > 99 ) {
618                    $len += int( ( length($name) + $tar_header_length ) / $tar_header_length ) * $tar_header_length;
619            }
620    
621            return $len;
622    }
623    
624  my $Attr;  my $Attr;
625  my $AttrDir;  my $AttrDir;
626    
# Line 429  sub TarWriteFile Line 633  sub TarWriteFile
633    
634      $tarPath =~ s{//+}{/}g;      $tarPath =~ s{//+}{/}g;
635    
636  #print STDERR "? $tarPath\n";      #print STDERR "? $tarPath\n" if ($opts{d});
637      return unless ($in_backup_increment->{$tarPath});      my $size = $in_backup_increment->{$tarPath};
638  #print STDERR "A $tarPath\n";      return unless (defined($size));
639    
640        # is this file too large to fit into MaxArchiveFileSize?
641    
642        if ( ($current_tar_size + tar_overhead($tarPath) + $size) > $max_file_size ) {
643            print STDERR "# tar file $current_tar_size + $tar_header_length + $size > $max_file_size, splitting\n" if ($opts{d});
644            new_tar_part();
645        }
646    
647        #print STDERR "A $tarPath [$size] tell: $current_tar_size\n" if ($opts{d});
648        $items_in_part++;
649    
650      if ( defined($PathRemove)      if ( defined($PathRemove)
651              && substr($tarPath, 0, length($PathRemove)) eq $PathRemove ) {              && substr($tarPath, 0, length($PathRemove)) eq $PathRemove ) {
# Line 445  sub TarWriteFile Line 659  sub TarWriteFile
659          #          #
660          # Directory: just write the header          # Directory: just write the header
661          #          #
           
                   
662          $hdr->{name} .= "/" if ( $hdr->{name} !~ m{/$} );          $hdr->{name} .= "/" if ( $hdr->{name} !~ m{/$} );
663          TarWriteFileInfo($fh, $hdr);          TarWriteFileInfo($fh, $hdr);
664          $DirCnt++;          $DirCnt++;
# Line 460  sub TarWriteFile Line 672  sub TarWriteFile
672              $ErrorCnt++;              $ErrorCnt++;
673              return;              return;
674          }          }
675          TarWriteFileInfo($fh, $hdr);          # do we need to split file?
676          my($data, $size);          if ($hdr->{size} < $max_file_size) {
677          while ( $f->read(\$data, $BufSize) > 0 ) {                  TarWriteFileInfo($fh, $hdr);
678              TarWrite($fh, \$data);                  my($data, $size);
679              $size += length($data);                  while ( $f->read(\$data, $BufSize) > 0 ) {
680          }                      TarWrite($fh, \$data);
681          $f->close;                      $size += length($data);
682          TarWritePad($fh, $size);                  }
683                    $f->close;
684                    TarWritePad($fh, $size);
685                  $FileCnt++;                  $FileCnt++;
686                  $ByteCnt += $size;                  $ByteCnt += $size;
687            } else {
688                    my $full_size = $hdr->{size};
689                    my $orig_name = $hdr->{name};
690                    my $max_part_size = $max_file_size - tar_overhead($hdr->{name});
691    
692                    my $parts = int(($full_size + $max_part_size - 1) / $max_part_size);
693                    print STDERR "# splitting $orig_name [$full_size bytes] into $parts parts\n" if ($opts{d});
694                    foreach my $subpart ( 1 .. $parts ) {
695                            new_tar_part();
696                            if ($subpart < $parts) {
697                                    $hdr->{size} = $max_part_size;
698                            } else {
699                                    $hdr->{size} = $full_size % $max_part_size;
700                            }
701                            $hdr->{name} = $orig_name . '/' . $subpart;
702                            print STDERR "## creating part $subpart ",$hdr->{name}, " [", $hdr->{size}," bytes]\n";
703    
704                            TarWriteFileInfo($fh, $hdr);
705                            my($data, $size);
706    if (0) {
707                            for ( 1 .. int($hdr->{size} / $BufSize) ) {
708                                    my $r_size = $f->read(\$data, $BufSize);
709                                    die "expected $BufSize bytes read, got $r_size bytes!" if ($r_size != $BufSize);
710                                    TarWrite($fh, \$data);
711                                    $size += length($data);
712                            }
713    }
714                            my $size_left = $hdr->{size} % $BufSize;
715                            my $r_size = $f->read(\$data, $size_left);
716                            die "expected $size_left bytes last read, got $r_size bytes!" if ($r_size != $size_left);
717    
718                            TarWrite($fh, \$data);
719                            $size += length($data);
720                            TarWritePad($fh, $size);
721    
722                            $items_in_part++;
723                    }
724                    $f->close;
725                    $FileCnt++;
726                    $ByteCnt += $full_size;
727                    new_tar_part();
728            }
729      } elsif ( $hdr->{type} == BPC_FTYPE_HARDLINK ) {      } elsif ( $hdr->{type} == BPC_FTYPE_HARDLINK ) {
730          #          #
731          # Hardlink file: either write a hardlink or the complete file          # Hardlink file: either write a hardlink or the complete file
732                  # depending upon whether the linked-to file will be written          # depending upon whether the linked-to file will be written
733                  # to the archive.          # to the archive.
734          #          #
735                  # Start by reading the contents of the link.          # Start by reading the contents of the link.
736                  #          #
737          my $f = BackupPC::FileZIO->open($hdr->{fullPath}, 0, $hdr->{compress});          my $f = BackupPC::FileZIO->open($hdr->{fullPath}, 0, $hdr->{compress});
738          if ( !defined($f) ) {          if ( !defined($f) ) {
739              print(STDERR "Unable to open file $hdr->{fullPath}\n");              print(STDERR "Unable to open file $hdr->{fullPath}\n");
# Line 488  sub TarWriteFile Line 744  sub TarWriteFile
744          while ( $f->read(\$data, $BufSize) > 0 ) {          while ( $f->read(\$data, $BufSize) > 0 ) {
745              $hdr->{linkname} .= $data;              $hdr->{linkname} .= $data;
746          }          }
747                  $f->close;          $f->close;
748                  my $done = 0;          my $done = 0;
749                  my $name = $hdr->{linkname};          my $name = $hdr->{linkname};
750                  $name =~ s{^\./}{/};          $name =~ s{^\./}{/};
751                  if ( $HardLinkExtraFiles{$name} ) {          if ( $HardLinkExtraFiles{$name} ) {
752                      #              #
753                      # Target file will be or was written, so just remember              # Target file will be or was written, so just remember
754                      # the hardlink so we can dump it later.              # the hardlink so we can dump it later.
755                      #              #
756                      push(@HardLinks, $hdr);              push(@HardLinks, $hdr);
757                      $SpecialCnt++;              $SpecialCnt++;
758                  } else {          } else {
759                      #              #
760                      # Have to dump the original file.  Just call the top-level              # Have to dump the original file.  Just call the top-level
761                      # routine, so that we save the hassle of dealing with              # routine, so that we save the hassle of dealing with
762                      # mangling, merging and attributes.              # mangling, merging and attributes.
763                      #              #
764                      $HardLinkExtraFiles{$hdr->{linkname}} = 1;              $HardLinkExtraFiles{$hdr->{linkname}} = 1;
765                      archiveWrite($fh, $hdr->{linkname}, $hdr->{name});              archiveWrite($fh, $hdr->{linkname}, $hdr->{name});
766                  }          }
767      } elsif ( $hdr->{type} == BPC_FTYPE_SYMLINK ) {      } elsif ( $hdr->{type} == BPC_FTYPE_SYMLINK ) {
768          #          #
769          # Symbolic link: read the symbolic link contents into the header          # Symbolic link: read the symbolic link contents into the header

Legend:
Removed from v.169  
changed lines
  Added in v.254

  ViewVC Help
Powered by ViewVC 1.1.26