+ my $volumes = $#volumes + 1;
+ my $volume_nr = 1;
+
+ foreach my $v (@volumes) {
+
+ #print Dumper($v);
+
+ my $iso_size = 0;
+ my $disk_name = $dvd_nr;
+ # suffix added to multi-volume archives
+ my $volume_suffix = '';
+
+ 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';