I solve another big set of problems for MyCPAN

I knocked off another big chunks of distributions that MyCPAN didn't like. I worked on the 700 or so dists that it couldn't unpack, and that number is now down to about 30. The changes to my method weren't that dramatic, but it clears up a bunch of the problem dists.

First, I was stopping too soon. Many archives unpack just fine even if they give warnings. Now I'll just record the warnings and wait to see if I get a directory with some files in it.

Second, I was using an HFS case-insensitive file system (stupid, but it's the default). Many distributions did not like that. Moving everything to a case-sensitive file system solved many of those problems. Once I find out why Foo-Bar-0.01.tar.gz doesn't unpack, I usually solve the problem for all Foo-Bar-* series which probably had the same problem.

The remaining 30 or so dists are unpackable with the tars that I tried. That's not a huge number out of the 140,000 total, so I'm not so worried. Maybe they unpack with different tar implementations. I'm not that worried about it.

Here's the short script I used to go through all the distros once I had them on a new filesystem:

use Archive::Extract;
use Cwd;
use File::Path qw( remove_tree );
use Test::More 'no_plan';

my $start_dir = cwd();

remove_tree( grep { ! /\.tar\.gz\z/ } glob ('*') );

$SIG{__WARN__} = sub { 1 }; # ignore warnings
foreach my $file ( glob( "*.tar.gz" ) ) {
    chdir $start_dir or die "Could not start at the right place: $!\n";

    eval {
        my $extractor = Archive::Extract->new( archive => $file );
        ok( $extractor->extract, "Extracts $file" );

        my $new_dir = $extractor->extract_path;
        ok( $new_dir && chdir $new_dir, "Changed to $new_dir for $file" );

        ok( 
            ( -d $new_dir ) && ( my $count = () = glob('*') ), 
            "[$file] $new_dir has at least one file" 
            );

        remove_tree( $new_dir );
        }

    }

2 Comments

Hi brian

But why are you only checking for *.tar.gz and not *.tgz, which is what I and a few other authors use?

Leave a comment

About brian d foy

user-pic I'm the author of Mastering Perl, and the co-author of Learning Perl (6th Edition), Intermediate Perl, Programming Perl (4th Edition) and Effective Perl Programming (2nd Edition).