Re: Mappings between CPAN packages and lib.*-perl packages
Colin Watson <cjwatson@debian.org> writes:
> On Sat, Dec 07, 2002 at 01:46:11AM -0500, Lloyd Zusman wrote:
>> Is it correct to assume that any given debian package whose name is of
>> the form lib.*-perl corresponds to one and only one CPAN module,
>
> Not quite, but more or less.
>
>> and that the algorithm for determining the corresponding debian
>> package name from a given CPAN module name is this? ...
>>
>> - Add a leading "lib" and a trailing "-perl" to the CPAN module name.
>>
>> - Replace all occurrences of double colon ('::') with a hyphen ('-').
>>
>> - Convert to lower case.
>
> That's pretty much it, yes, and it works 99% of the time. However, for
> one reason or another it might not always be absolutely reliable:
> occasionally packages have been aggregated or split, or are using an
> older naming scheme, or whatever.
>
> If I wanted something absolutely reliable, I would apply s,::,/,g
> instead and use either 'auto-apt search -f' or 'apt-file search'. (Both
> require an update step as root every so often.)
Yep, got it. Thank you. And here's the first cut of a perl script I
wrote to implement this.
#!/usr/bin/perl
# -*- perl -*-
$0 =~ s:^.*/::;
my $program = $0;
unless (scalar(@ARGV) > 0) {
die "usage: $program perl-module ...\n";
# notreached
}
my $aptFile = '/usr/bin/apt-file';
my %output = ();
foreach my $module (@ARGV) {
$module =~ s|::|/|g;
unless (open(AF, "$aptFile search $module 2>/dev/null |")) {
die "$program: unable to invoke: $aptFile\n";
# notreached
}
while (defined(my $line = <AF>)) {
chomp($line);
unless ($line =~ m/:.*perl.*\.pm/) {
next;
}
$output{$line} = 1;
}
close(AF);
}
foreach my $item (sort keys %output) {
print "$item\n";
}
exit(0);
__END__
> --
> Colin Watson [cjwatson@flatline.org.uk]
--
Lloyd Zusman
ljz@asfast.com
Reply to: