samtregar has asked for the wisdom of the Perl Monks concerning the following question:

Hello all. A little background: I'm building an installer for Bricolage. One of the things the installer does is install modules automatically from CPAN.

My problem is that CPAN.pm is picking the .zip versions of modules that have .tar.gz versions. This works fine on my Redhat test systems since Redhat comes with unzip. On FreeBSD this causes my installation run to fail since unzip is unavailable. The irritating thing is that the module in question has a .tar.gz version.

Here's the core nugget of my CPAN.pm driving code:

# installs a single module from CPAN, following dependencies sub install_module { my ($name, $req_version) = @_; # push onto the queue. This keeps everything simpler below CPAN::Queue->new($name); # process the queue while (my $q = CPAN::Queue->first) { # get a module object one way or another my $m = ref $q ? $q : CPAN::Shell->expandany($q); hard_fail(<<END) unless $m; Couldn't find $q on CPAN. Your CPAN.pm installation may be broken. To debug manually, run: perl -MCPAN -e 'install $q' END print "Found ", $m->id, ". Installing...\n"; # need to force? my $key = $m->isa('CPAN::Distribution') ? $m->called_for : $m->id; $m->force('install') if $flags{$key} and $flags{$key} & FORCE; # need PG env vars? if ($flags{$key} and $flags{$key} & PG_ENV) { $ENV{POSTGRES_INCLUDE} = $PG->{include_dir}; $ENV{POSTGRES_LIB} = $PG->{lib_dir}; } # do the install. If prereqs are found they'll get put on the # Queue and processed in turn. $m->install; # I don't understand why this is necessary but CPAN.pm does it # when it walks the queue and not doing it results in failures # in some modules installs (SOAP::Lite, MIME::Lite). $m->undelay; # remove self from the queue CPAN::Queue->delete_first($q); } # check to make sure it worked print "Checking $name installation...\n"; # try loading the module eval "require $name"; hard_fail(<<END) if $@; Installation of $name failed. Your CPAN.pm installation may be broken. To debug manually, run (as root): perl -MCPAN -e shell Then at the "cpan>" prompt: look $name You can then attempt to install the module manually with: perl Makefile.PL make test make install END if (defined $req_version) { eval { $name->VERSION($req_version) }; hard_fail(<<END) if $@; Installation of $name version $req_version failed. Your CPAN.pm installation may be broken. To debug manually, run (as root): perl -MCPAN -e shell Then at the "cpan>" prompt: look $name You can then attempt to install the module manually with: perl Makefile.PL make test make install END } # all done. print "$name installed successfully.\n"; }

Replies are listed 'Best First'.
Re: Can I tell CPAN.pm to prefer .tar.gz over .zip?
by JayBonci (Curate) on Apr 24, 2002 at 11:04 UTC
    Hmm, good one. I'm going to take a stab at it, but I'm really not sure what it might be.
    • On the BSD box, rearrange the CPAN servers. What are you using as your first one? Try one of the ones from your RedHat machine.
    • Try to wget the file manually, ala http://www.cpan.org/authors/id/ANDK/CPAN-1.60b.tar.gz. Does that come up?
    • Make sure you have the latest CPAN on that machine
    • What does CPAN debugging say. At the cpan> prompt, type:
      o debug #for a list of choices, but you'll probably want o debug cpan o debug ftp
    • You might be able to cheat CPAN. If you use LWP to get the file, then you can choose which one you want. Then pick up in the get() function from CPAN.pm where it leaves off.
    I can't see a preference anywhere for .zip or .gz files, and all the docs I see say that .zip is deprecated or for Windows machines, so I'm thinking it might be the CPAN server. Check which mirrors you're using first.

        --jb
      Thanks for the suggestions. Both test machines are using the same mirror, and it's on I administer (cpan.thepirtgroup.com). I don't think the problem is there but I'll try a few others and see if that helps. I'll also looking into the debug options.

      -sam