DhMakePerl::Command::locate - dh-make-perl locate implementation


DhMakePerl documentation Contained in the DhMakePerl distribution.

Index


Code Index:

NAME

Top

DhMakePerl::Command::locate - dh-make-perl locate implementation

DESCRIPTION

Top

This module implements the locate command of dh-make-perl(1).

METHODS

Top

execute

Provides locate command implementation.

COPYRIGHT & LICENSE

Top


DhMakePerl documentation Contained in the DhMakePerl distribution.
package DhMakePerl::Command::locate;

use strict; use warnings;

use base 'DhMakePerl';

use DhMakePerl::Utils qw(is_core_module);

sub execute {
    my $self = shift;

    @ARGV == 1
        or die "locate command requires exactly one non-option argument\n";

    my $apt_contents = $self->get_apt_contents;

    unless ($apt_contents) {
        die <<EOF;
Unable to locate module packages, because APT Contents files
are not available on the system.

Install the 'apt-file' package, run 'apt-file update' as root
and retry.
EOF
    }
    my $mod = $ARGV[0];

    if ( defined( my $core_since = is_core_module($mod) ) ) {
        print "$mod is in Perl core (package perl)";
        print $core_since ? " since $core_since\n" : "\n";
        return 0;
    }

    if ( my $pkg = $apt_contents->find_perl_module_package($mod) ) {
        print "$mod is in $pkg package\n";
        return 0;
    }

    print "$mod is not found in any Debian package\n";
    return 1;
}

1;