<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">package DhMakePerl;

use warnings;
use strict;
use 5.010;    # we use smart matching

use base 'Class::Accessor';

__PACKAGE__-&gt;mk_accessors( qw( cfg apt_contents ) );

=head1 NAME

DhMakePerl - create Debian source package from CPAN dist

=head1 VERSION

Version 0.80

=cut

our $VERSION = '0.80';

=head1 SYNOPSIS

    use DhMakePerl;

    DhMakePerl-&gt;run;

=head1 ACCESSORS

=over

=item apt_contents

Stores the cached copy of L&lt;Debian::AptContents&gt;.

=item cfg

Stores the configuration, an instance of L&lt;DhMakePerl::Config&gt;

=back

=head1 CLASS METHODS

=over

=cut

use Debian::AptContents ();
use DhMakePerl::Config;
use version          ();

=item run( I&lt;%init&gt; )

Runs DhMakePerl.

Unless the %init contains an I&lt;cfg&gt; member, constructs and instance of
L&lt;DhMakePerl::Config&gt; and assigns it to I&lt;$init{cfg}&gt;.

Then determines the dh-make-perl command requested (via cfg-&gt;command), loads
the appropriate I&lt;DhMakePerl::Command::$command&gt; class, constructs an instance
of it and calls its I&lt;execute&gt; method.

=cut

sub run {
    my ( $class, %c ) = @_;

    unless ( $c{cfg} ) {
        my $cfg = DhMakePerl::Config-&gt;new;
        $cfg-&gt;parse_command_line_options;
        $cfg-&gt;parse_config_file;
        $c{cfg} = $cfg;
    }

    my $cmd_mod = $c{cfg}-&gt;command;
    $cmd_mod =~ s/-/_/g;
    require "DhMakePerl/Command/$cmd_mod.pm";

    $cmd_mod =~ s{/}{::}g;
    $cmd_mod = "DhMakePerl::Command::$cmd_mod";

    my $self = $cmd_mod-&gt;new( \%c );

    return $self-&gt;execute;
}

=item get_apt_contents

Returns (possibly cached) instance of L&lt;Debian::AptContents&gt;.

=cut

sub get_apt_contents {
    my $self = shift;

    return $self-&gt;apt_contents
        if $self-&gt;apt_contents;

    my $apt_c = Debian::AptContents-&gt;new(
        {   homedir      =&gt; $self-&gt;cfg-&gt;home_dir,
            dist         =&gt; $self-&gt;cfg-&gt;dist,
            sources      =&gt; $self-&gt;cfg-&gt;sources_list,
            verbose      =&gt; $self-&gt;cfg-&gt;verbose,
            contents_dir =&gt; $self-&gt;cfg-&gt;apt_contents_dir,
        }
    );

    undef $apt_c unless $apt_c-&gt;cache;

    return $self-&gt;apt_contents($apt_c);
}

=back

=head1 COPYRIGHT &amp; LICENSE

=over

=item Copyright (C) 2009, 2010 Damyan Ivanov &lt;dmn@debian.org&gt;

=back

This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License version 2 as published by the Free
Software Foundation.

This program is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE.  See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with
this program; if not, write to the Free Software Foundation, Inc., 51 Franklin
Street, Fifth Floor, Boston, MA 02110-1301 USA.

=cut

1; # End of DhMakePerl
</pre></body></html>