[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Utility to install a perl module via apt with cpan fallback

-=| Brian Cassidy, Thu, Jan 08, 2009 at 02:18:17PM -0400 |=-
> I was recently asked if I was aware of a utility that would allow a
> user to attempt to install module by first checking the apt
> repository, then falling back to a regular CPAN install if that
> failed.
> my( $mod ) = shift;
> ( my $file = "perl5/${mod}.pm" ) =~ s{::}{/}g;
> my $r = `apt-file search $file`;

How about using the Debian::AptContents module living in dh-make-perl? 
That would give you almost instant search results (after constructing 
its cache, once)

> if( $r ) {
>     my( $p ) = split( /:/, $r, 2 );
>     exec "apt-get install $p";

Better leave this to the user.

> }
> else {
>     exec "cpan $mod";

How about exec "dh-make-perl --cpan $mod --build" instead?

> I think many people would want a utility like this, I'll be interested
> to see what you all can come up with.

In sort, instead of doing everything for the user, do only the search 
and leave the package installation to the human.

Heh, perhaps dh-make-perl can be made to check whether the package 
requested to be created already exists :)

dam            JabberID: dam@jabber.minus273.org

Attachment: signature.asc
Description: Digital signature

Reply to: