atool fails to convert a 7z archive to zip, terminates with an error

Bug #1360259 reported by Scott Pitcher on 2014-08-22
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
atool (Ubuntu)
Undecided
Unassigned

Bug Description

Using arepack Trying to convert 18,000+ 7z archive files to zip format with atool fails part way through with one particular file. This file is astrof.7z from the Mame 0.153 romset. The following is the output from the command which fails ...

=============================================================================
scotty@officepc:~/tmp/Mame-roms/ROMs$ arepack --format=zip -E --each astrof.7z
mkdir Unpack-7757
7z x -oUnpack-7757 astrof.7z

7-Zip 9.20 Copyright (c) 1999-2010 Igor Pavlov 2010-11-18
p7zip Version 9.20 (locale=en_AU.UTF-8,Utf16=on,HugeFiles=on,4 CPUs)

Processing archive: astrof.7z

Extracting 0
Extracting 1a
Extracting 2a
Extracting ke2
Extracting ke3
Extracting ke4
Extracting ke5
Extracting ke6
Extracting ke7
Extracting ke8
Extracting ke9
Extracting kei
Extracting kei0
Extracting kei2
Extracting keii
Extracting 0.bin
Extracting 1.bin
Extracting 10405-0.bin
Extracting 10405-1.bin
Extracting 10405-2.bin
Extracting 10405-3.bin
Extracting 10405-4.bin
Extracting 10405-5.bin
Extracting 10405-6.bin
Extracting 10405-7.bin
Extracting 10405-8.bin
Extracting 10405-9.bin
Extracting 10405-a.bin
Extracting 10405-b.bin
Extracting 2.bin
Extracting 2h-prot.bin
Extracting 3.bin
Extracting 4.bin
Extracting 5.bin
Extracting 6.bin
Extracting 7.bin
Extracting 8.bin
Extracting 8f-clr.bin
Extracting 9.bin
Extracting a.bin
Extracting b.bin
Extracting sidam-4.bin
Extracting sidam-5.bin
Extracting af583.00
Extracting af579.08
Extracting afii.1
Extracting afii.2
Extracting afii.3
Extracting afii.4
Extracting afii.5
Extracting afii.6
Extracting astrf.clr
Extracting 0.rom
Extracting 1.rom
Extracting 5.rom
Extracting 7.rom
Extracting 9.rom
Extracting a.rom

Everything is Ok

Files: 58
Size: 63008
Compressed: 25800
cd Unpack-7757
zip -r ../astrof.zip .
  adding: 9.rom (deflated 21%)
  adding: 10405-5.bin (deflated 19%)
  adding: a.bin (deflated 31%)
  adding: 10405-0.bin (deflated 25%)
  adding: 0 (deflated 25%)
  adding: 10405-8.bin (deflated 19%)
  adding: 7.rom (deflated 13%)
  adding: astrf.clr (stored 0%)
  adding: afii.6 (deflated 32%)
  adding: sidam-4.bin (deflated 23%)
  adding: 0.rom (deflated 26%)
  adding: 0.bin (deflated 25%)
  adding: 10405-6.bin (deflated 26%)
  adding: ke2 (deflated 21%)
  adding: ke9 (deflated 20%)
  adding: 5.rom (deflated 19%)
  adding: afii.3 (deflated 24%)
  adding: 10405-1.bin (deflated 37%)
  adding: 8f-clr.bin (deflated 47%)
  adding: 5.bin (deflated 19%)
  adding: a.rom (deflated 31%)
  adding: 10405-4.bin (deflated 23%)
  adding: sidam-5.bin (deflated 18%)
  adding: 8.bin (deflated 19%)
  adding: 2.bin (deflated 29%)
  adding: ke4 (deflated 21%)
  adding: keii (deflated 30%)
  adding: afii.2 (deflated 23%)
  adding: afii.5 (deflated 24%)
  adding: ke7 (deflated 26%)
  adding: 1.rom (deflated 39%)
  adding: 6.bin (deflated 26%)
  adding: b.bin (deflated 20%)
  adding: 7.bin (deflated 13%)
  adding: 10405-a.bin (deflated 31%)
  adding: ke5 (deflated 22%)
  adding: 10405-9.bin (deflated 21%)
  adding: ke6 (deflated 14%)
  adding: 10405-7.bin (deflated 13%)
  adding: 1a (deflated 37%)
  adding: kei (deflated 69%)
  adding: afii.1 (deflated 46%)
  adding: af579.08 (deflated 20%)
  adding: 2a (deflated 27%)
  adding: afii.4 (deflated 27%)
  adding: kei2 (deflated 21%)
  adding: 10405-2.bin (deflated 26%)
  adding: 1.bin (deflated 38%)
  adding: kei0 (deflated 20%)
  adding: 9.bin (deflated 21%)
  adding: af583.00 (deflated 68%)
  adding: ke8 (deflated 25%)
  adding: 10405-3.bin (deflated 23%)
  adding: ke3 (deflated 21%)
  adding: 3.bin (deflated 23%)
  adding: 10405-b.bin (deflated 20%)
  adding: 4.bin (deflated 23%)
  adding: 2h-prot.bin (stored 0%)
cd ..
rm -r Unpack-7757
arepack: 0: cannot remove - No such file or directory
=============================================================================

I collected the commands in a shell script as follows ....

=========================
#!/bin/sh

mkdir Unpack-7757
7z x -oUnpack-7757 astrof.7z
cd Unpack-7757
zip -r ../astrof.zip .
cd ..
rm -r Unpack-7757
=========================

And these execute with no error.

Scott Pitcher (scottypitcher) wrote :

Thank you for taking the time to report this bug and helping to make Ubuntu better. Please execute the following command, as it will automatically gather debugging information, in a terminal:

  apport-collect BUGNUMBER

When reporting bugs in the future please use apport by using 'ubuntu-bug' and the name of the package affected. You can learn more about this functionality at https://wiki.ubuntu.com/ReportingBugs.

Changed in atool (Ubuntu):
status: New → Incomplete
Scott Pitcher (scottypitcher) wrote :

I'm not a perl programmer I work with C and TCL, but I had a look at /usr/bin/atool.

The problem is in the unlink_directory subroutine ...

====================================================================
sub unlink_directory($) {
  my ($dir) = @_;
  die "$::basename: internal error 1 - please report this bug\n"
    if ($dir eq '/' || $dir eq $ENV{HOME});
# chmod 0700, $dir || die "$::basename: cannot chmod `".quote($dir)."': $!\n";
  chdir $dir || die "$::basename: ".quote($dir).": cannot change to - $!\n";
  opendir(DIR, $::cur) || die "$::basename: ".quote($dir).": cannot list - $!\n";
  my @files = readdir(DIR);
  closedir(DIR);
  foreach my $file (@files) {
    next if $file eq $::cur || $file eq $::up;
    if (-d $file && !-l $file) {
      unlink_directory($file);
    } else {
      unlink $file || die "$::basename: ".quote($file).": cannot remove - $!\n";
    }
  }
  chdir $::up || die "$::basename: $::up: cannot change to - $!\n";
  rmdir $dir || die "$::basename: ".quote($dir).": cannot remove - $!\n";
}
====================================================================

Line 1677 reads: unlink $file || die "$::basename: ".quote($file).": cannot remove - $!\n";

if I change the unlink $file to unlink "./$file" then the error goes away. The file which is generating the error is named "0" (without quotes), so perl must has some issue with the statement "unlink 0".

I can't do anymore but this is a workaround for me.

Changed in atool (Ubuntu):
status: Incomplete → New
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers

Bug attachments