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"; }

In reply to Can I tell CPAN.pm to prefer .tar.gz over .zip? by samtregar

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.