+ if ($volumes > 1) {
+ $volume_suffix = '_' . $volume_nr;
+ $disk_name .= ' ' . $volume_nr . '/' . $volumes;
+ }
+
+ print "Processing DVD #$dvd_nr, volume $volume_nr/$volumes [", fmt_mb($v->{size}), "]\n";
+
+ my $iso_file = my $xml_file = my $stage =
+ "${iso_dir}/${dvd_nr}";
+
+ $iso_file .= $volume_suffix . '.iso';
+ $xml_file .= '.xml';
+
+ $stage .= $volume_suffix . '.stage';
+
+ my $md5_file = "${stage}/${dvd_nr}${volume_suffix}.md5";
+
+ #
+ # check if ISO file exists
+ #
+
+ if (! -e $iso_file) {
+
+ # create stage directory
+ if (-e $stage) {
+ rmtree($stage) || die "can't remove $stage: $!";
+ }
+ mkpath($stage);
+
+ # open file for md5sums
+ open(my $md5, "> $md5_file") || skip "can't open $md5_file: $!";
+
+ my $parts_on_this_volume = 0;
+
+ foreach my $p (@{ $v->{parts} }) {
+ my $tar_file = $p->{filename} || die "no filename in part", Dumper($p);
+ my $rel_path = $tar_file;
+
+ if (-d "$tar_dir/$rel_path") {
+ mkpath("$stage/$rel_path") unless (-d "$stage/$rel_path");
+ $rel_path .= '/' . $p->{part_nr};
+ }
+ $rel_path .= '.tar.gz';
+
+ skip "can't find increment $rel_path: $!" unless (-r "$tar_dir/$rel_path");
+
+ add_symlink("$tar_dir/$rel_path", "$stage/$rel_path");
+
+ my $md5sum = $p->{md5} || die "no md5 in part ", Dumper($p);
+ chomp($md5sum);
+ print $md5 "$md5sum $rel_path\n" || die "can't write md5sum: $!";
+
+ $parts_on_this_volume++;
+ }
+
+ # add file list and note in xml
+ dumpArchive2XML($dbh, $dvd_nr, $xml_file) unless (-f $xml_file);
+
+ add_symlink($xml_file, "$stage/${dvd_nr}.xml");
+
+ # add css file for archive
+ my $css_file = $Conf{CgiImageDir} . '/archive.css';
+ if (-r $css_file) {
+ add_symlink($css_file, "$stage/archive.css");
+ } else {
+ print "WARNING: missing $css_file, not added to iso image!\n";
+ }
+
+ print "Running mkisofs now for $parts_on_this_volume increments, disk $disk_name\n";
+
+ 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 };
+
+ system($cmd) == 0 or skip "can't run $cmd: $?";
+
+ rename $iso_file.'.tmp', $iso_file || skip "can't rename $iso_file: $!";
+
+ $iso_size = (stat($iso_file))[7];
+
+ print "Created $iso_file [$iso_size bytes] in ", fmt_time(time() - $t), "\n";
+
+ rmtree($stage) || warn "can't remove stage directory $stage: $!";
+
+ } else {
+ $iso_size = (stat($iso_file))[7];
+ print "ISO $iso_file allready exists [$iso_size bytes]\n";
+ }
+
+ print "\nREADY TO BURN MEDIA $disk_name copy $copy_nr\n\nPlease insert blank media and press ENTER\n\n";
+
+ system($bin->{'eject'}.' '.$eject_opts) == 0 or skip "can't run eject: $?";
+
+ my $wait = <STDIN>;
+
+ my $cmd = $bin->{'cdrecord'} . ' ' . $cdr_opts . ' ' . $iso_file;
+
+ # FIXME
+ print "## $cmd\n";
+ system($cmd) == 0 or skip "can't run $cmd: $?";
+
+ print "\n\nPLEASE REMOVE DVD MEDIA AND LABEL IT WITH $disk_name\n\n";
+
+ $sth_archive_burned->execute($dvd_nr, $iso_size, $volume_nr, $copy_nr);
+
+ print "Media burn for $disk_name copy $copy_nr recorded\n";
+
+ if ($copy_nr >= $copies) {
+ print STDERR "erasing temporary files, have $copy_nr copies (> $copies)\n";
+ foreach my $f (( $xml_file, $iso_file )) {
+ print STDERR "\t$f ";
+ unlink $f || die "can't remove $f: $!";
+ print STDERR "removed\n";
+ }
+ }
+
+ $volume_nr++;
+ }
+
+ }