Search code examples
perldebianpackage-managers

How to find (Debian/Ubuntu/...) packages that provide required Perl modules


I found that installing native Debian or Ubuntu Perl packages, such is often more reliable and convenient than "manually" installing Perl modules via cpanm (especially for XS-Modules). Is there an easy way to find these modules given a list of required Perl modules? The most convenient way would be to map a cpanfile, such as

requires 'XML::LibXSLT', '1.78';

to a list of distributions and packages that provide the modules for different target platforms:

XML::LibXSLT, Ubuntu 13.04, libxml-libxslt-perl, 1.78
XML::LibXSLT, Ubuntu 13.10, libxml-libxslt-perl, 1.78
XML::LibXSLT, Ubuntu 14.04, libxml-libxslt-perl, 1.84
XML::LibXSLT, Debian squeeze, libxml-libxslt-perl, 1.70
XML::LibXSLT, Debian wheezy, libxml-libxslt-perl, 1.77
XML::LibXSLT, Debian jessie, libxml-libxslt-perl, 1.92
XML::LibXSLT, Debian sid, libxml-libxslt-perl, 1.92

P.S.: I guess the information can somehow be looked up from the package repositories of each distribution, e.g. http://packages.ubuntu.com/ and https://packages.debian.org but is there a scriptable solution that already does this lookup?


Solution

  • On Debian-based systems, install the dh-make-perl package and try

    dh-make-perl locate XML::LibXSLT
    

    On my LMDE box, it outputs:

    == dh-make-perl 0.80 ==
    Using cached Contents from Thu Sep 18 13:23:19 2014
    XML::LibXSLT is in libxml-libxslt-perl package
    

    For mapping this package name to other Linux distros, you could use distromatch. It also seems to support Perl (CPAN) and Python package names. Unfortunately, distromatch seems to be unmaintained and does not work out-of-the-box now. Recently I did manage to make it work well enough for translating Debian to openSUSE package names.