+ # 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';
+
+
+ unless (-r "$tar_dir/$rel_path") {
+ print "WARNING: can't find increment $rel_path , trying to recreate it using BackupPC_tarIncCreate...\n";
+ my $host = $p->{host};
+ my $share = $p->{share};
+ my $dump = $p->{num};
+ my $currUser = getlogin();
+ my $otherUser = "";
+ if ($currUser eq "agi") {
+ $otherUser = "backuppc-agi";
+ } elsif ($currUser eq "qc") {
+ $otherUser = "backuppc-qc";
+ }
+ if ($otherUser ne "") {
+ my $cmd = "sudo -u $otherUser ".$tarIncCreate. " -h $host -s $share -n $dump";
+ print "$cmd ";
+ if (system($cmd) != 0) {
+ print " FAILED.\n";
+ } else {
+ print " done.\n";
+ }
+ }
+ }
+
+ skip "can't find increment $rel_path, recreateing obviously did not work: $!" 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 };