/[BackupPC]/trunk/bin/BackupPC_burnArchiveCLI
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_burnArchiveCLI

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

revision 334 by dpavlin, Mon Jan 30 17:45:25 2006 UTC revision 335 by dpavlin, Wed Mar 1 12:11:23 2006 UTC
# Line 394  foreach my $arc (@archives_to_burn) { Line 394  foreach my $arc (@archives_to_burn) {
394          my $volumes = $#volumes + 1;          my $volumes = $#volumes + 1;
395          my $volume_nr = 1;          my $volume_nr = 1;
396    
397          foreach my $v (@volumes) {          my $copies = $Conf{BurnMultipleCopies} || 1;
398    
399                  #print Dumper($v);          foreach my $copy_nr ( 1 .. $copies ) {
400    
401                  my $iso_size = 0;                  foreach my $v (@volumes) {
                 my $disk_name = $dvd_nr;  
                 # suffix added to multi-volume archives  
                 my $volume_suffix = '';  
402    
403                  if ($volumes > 1) {                          #print Dumper($v);
                         $volume_suffix = '_' . $volume_nr;  
                         $disk_name .= ' ' . $volume_nr . '/' . $volumes;  
                 }  
404    
405                  print "Processing DVD #$dvd_nr, volume $volume_nr/$volumes\n";                          my $iso_size = 0;
406                            my $disk_name = $dvd_nr;
407                            # suffix added to multi-volume archives
408                            my $volume_suffix = '';
409    
410                  my $iso_file = my $xml_file = my $stage =                          if ($volumes > 1) {
411                          "${iso_dir}/${dvd_nr}";                                  $volume_suffix = '_' . $volume_nr;
412                                    $disk_name .= ' ' . $volume_nr . '/' . $volumes;
413                            }
414    
415                  $iso_file .= $volume_suffix . '.iso';                          print "Processing DVD #$dvd_nr, volume $volume_nr/$volumes\n";
                 $xml_file .= '.xml';  
416    
417                  $stage .= $volume_suffix . '.stage';                          my $iso_file = my $xml_file = my $stage =
418                                    "${iso_dir}/${dvd_nr}";
419    
420                  my $md5_file = "${stage}/${dvd_nr}${volume_suffix}.md5";                          $iso_file .= $volume_suffix . '.iso';
421                            $xml_file .= '.xml';
422    
423                  #                          $stage .= $volume_suffix . '.stage';
                 # check if ISO file exists  
                 #  
424    
425                  if (! -e $iso_file) {                          my $md5_file = "${stage}/${dvd_nr}${volume_suffix}.md5";
426    
427                          # create stage directory                          #
428                          if (-e $stage) {                          # check if ISO file exists
429                                  rmtree($stage) || die "can't remove $stage: $!";                          #
                         }  
                         mkpath($stage);  
430    
431                          # open file for md5sums                          if (! -e $iso_file) {
                         open(my $md5, "> $md5_file") || skip "can't open $md5_file: $!";  
432    
433                          my $parts_on_this_volume = 0;                                  # create stage directory
434                                    if (-e $stage) {
435                                            rmtree($stage) || die "can't remove $stage: $!";
436                                    }
437                                    mkpath($stage);
438    
439                          foreach my $p (@{ $v->{parts} }) {                                  # open file for md5sums
440                                  my $tar_file = $p->{filename} || die "no filename in part", Dumper($p);                                  open(my $md5, "> $md5_file") || skip "can't open $md5_file: $!";
                                 my $rel_path = $tar_file;  
441    
442                                  if (-d "$tar_dir/$rel_path") {                                  my $parts_on_this_volume = 0;
                                         mkpath("$stage/$rel_path") unless (-d "$stage/$rel_path");  
                                         $rel_path .= '/' . $p->{part_nr};  
                                 }  
                                 $rel_path .= '.tar.gz';  
443    
444                                  skip "can't find increment $rel_path: $!" unless (-r "$tar_dir/$rel_path");                                  foreach my $p (@{ $v->{parts} }) {
445                                            my $tar_file = $p->{filename} || die "no filename in part", Dumper($p);
446                                            my $rel_path = $tar_file;
447    
448                                  add_symlink("$tar_dir/$rel_path", "$stage/$rel_path");                                          if (-d "$tar_dir/$rel_path") {
449                                                    mkpath("$stage/$rel_path") unless (-d "$stage/$rel_path");
450                                                    $rel_path .= '/' . $p->{part_nr};
451                                            }
452                                            $rel_path .= '.tar.gz';
453    
454                                  my $md5sum = $p->{md5} || die "no md5 in part ", Dumper($p);                                          skip "can't find increment $rel_path: $!" unless (-r "$tar_dir/$rel_path");
                                 chomp($md5sum);  
                                 print $md5 "$md5sum  $rel_path\n" || die "can't write md5sum: $!";  
455    
456                                  $parts_on_this_volume++;                                          add_symlink("$tar_dir/$rel_path", "$stage/$rel_path");
                         }  
457    
458                          # add file list and note in xml                                          my $md5sum = $p->{md5} || die "no md5 in part ", Dumper($p);
459                          dumpArchive2XML($dbh, $dvd_nr, $xml_file) unless (-f $xml_file);                                          chomp($md5sum);
460                                            print $md5 "$md5sum  $rel_path\n" || die "can't write md5sum: $!";
461    
462                          add_symlink($xml_file, "$stage/${dvd_nr}.xml");                                          $parts_on_this_volume++;
463                                    }
464    
465                          # add css file for archive                                  # add file list and note in xml
466                          my $css_file = $Conf{CgiImageDir} . '/archive.css';                                  dumpArchive2XML($dbh, $dvd_nr, $xml_file) unless (-f $xml_file);
                         if (-r $css_file) {  
                                 add_symlink($css_file, "$stage/archive.css");  
                         } else {  
                                 print "WARNING: missing $css_file, not added to iso image!\n";  
                         }  
467    
468                          print "Running mkisofs now for $parts_on_this_volume increments, disk $disk_name\n";                                  add_symlink($xml_file, "$stage/${dvd_nr}.xml");
469    
470                          my $cmd = $bin->{'mkisofs'} . qq{ -A BackupPC -gui -J -r -T --input-charset ISO-8859-2 -V "$disk_name" -o ${iso_file}.tmp -f $stage };                                  # add css file for archive
471                                    my $css_file = $Conf{CgiImageDir} . '/archive.css';
472                                    if (-r $css_file) {
473                                            add_symlink($css_file, "$stage/archive.css");
474                                    } else {
475                                            print "WARNING: missing $css_file, not added to iso image!\n";
476                                    }
477    
478                          system($cmd) == 0 or skip "can't run $cmd: $?";                                  print "Running mkisofs now for $parts_on_this_volume increments, disk $disk_name\n";
479    
480                          rename $iso_file.'.tmp', $iso_file || skip "can't rename $iso_file: $!";                                  my $cmd = $bin->{'mkisofs'} . qq{ -A BackupPC -gui -J -r -T --input-charset ISO-8859-2 -V "$disk_name" -o ${iso_file}.tmp -f $stage };
481    
482                          $iso_size = (stat($iso_file))[7];                                  system($cmd) == 0 or skip "can't run $cmd: $?";
483    
484                          print "Created $iso_file [$iso_size bytes] in ", fmt_time(time() - $t), "\n";                                  rename $iso_file.'.tmp', $iso_file || skip "can't rename $iso_file: $!";
485    
486                          rmtree($stage) || warn "can't remove stage directory $stage: $!";                                  $iso_size = (stat($iso_file))[7];
487    
488                  } else {                                  print "Created $iso_file [$iso_size bytes] in ", fmt_time(time() - $t), "\n";
                         print "ISO $iso_file allready exists\n";  
                 }  
489    
490                  my $copies = $Conf{BurnMultipleCopies} || 1;                                  rmtree($stage) || warn "can't remove stage directory $stage: $!";
491    
492                  foreach my $copy_nr ( 1 .. $copies ) {                          } else {
493                                    print "ISO $iso_file allready exists\n";
494                            }
495    
496                          print "\nREADY TO BURN MEDIA $disk_name copy $copy_nr\n\nPlease insert blank media and press ENTER\n\n";                          print "\nREADY TO BURN MEDIA $disk_name copy $copy_nr\n\nPlease insert blank media and press ENTER\n\n";
497    

Legend:
Removed from v.334  
changed lines
  Added in v.335

  ViewVC Help
Powered by ViewVC 1.1.26