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

use strict;

use base    qw[CPANPLUS::Dist];
use vars    qw[$VERSION];
$VERSION =  $CPANPLUS::Internals::VERSION = $CPANPLUS::Internals::VERSION;


=head1 NAME

CPANPLUS::Dist::Base - Base class for custom distribution classes

=head1 SYNOPSIS

    package CPANPLUS::Dist::MY_IMPLEMENTATION

    use base 'CPANPLUS::Dist::Base';

    sub prepare {
        my $dist = shift;
        
        ### do the 'standard' things
        $dist-&gt;SUPER::prepare( @_ ) or return;
    
        ### do MY_IMPLEMENTATION specific things
        ...
        
        ### don't forget to set the status!
        return $dist-&gt;status-&gt;prepared( $SUCCESS ? 1 : 0 );
    }


=head1 DESCRIPTION

CPANPLUS::Dist::Base functions as a base class for all custom
distribution implementations. It does all the mundane work 
CPANPLUS would have done without a custom distribution, so you
can override just the parts you need to make your own implementation
work.

=head1 FLOW

Below is a brief outline when and in which order methods in this
class are called:

    $Class-&gt;format_available;   # can we use this class on this system?

    $dist-&gt;init;                # set up custom accessors, etc
    $dist-&gt;prepare;             # find/write meta information
    $dist-&gt;create;              # write the distribution file
    $dist-&gt;install;             # install the distribution file
    
    $dist-&gt;uninstall;           # remove the distribution (OPTIONAL)

=head1 METHODS

=cut

=head2 @subs = $Class-&gt;methods

Returns a list of methods that this class implements that you can
override.

=cut

sub methods { 
    return qw[format_available init prepare create install uninstall] 
}

=head2 $bool = $Class-&gt;format_available

This method is called when someone requests a module to be installed
via the superclass. This gives you the opportunity to check if all
the needed requirements to build and install this distribution have
been met.

For example, you might need a command line program, or a certain perl
module installed to do your job. Now is the time to check.

Simply return true if the request can proceed and false if it can not.

The C&lt;CPANPLUS::Dist::Base&gt; implementation always returns true.

=cut 

sub format_available { return 1 }


=head2 $bool = $dist-&gt;init

This method is called just after the new dist object is set up and
before the C&lt;prepare&gt; method is called. This is the time to set up
the object so it can be used with your class. 

For example, you might want to add extra accessors to the C&lt;status&gt;
object, which you might do as follows:

    $dist-&gt;status-&gt;mk_accessors( qw[my_implementation_accessor] );

The C&lt;status&gt; object is implemented as an instance of the 
C&lt;Object::Accessor&gt; class. Please refer to its documentation for 
details.

Return true if the initialization was successful, and false if it was
not.

The C&lt;CPANPLUS::Dist::Base&gt; implementation does not alter your object 
and always returns true.

=cut

sub init { return 1; }

=head2 $bool = $dist-&gt;prepare

This runs the preparation step of your distribution. This step is meant
to set up the environment so the C&lt;create&gt; step can create the actual
distribution(file). 
A C&lt;prepare&gt; call in the standard C&lt;ExtUtils::MakeMaker&gt; distribution 
would, for example, run C&lt;perl Makefile.PL&gt; to find the dependencies
for a distribution. For a C&lt;debian&gt; distribution, this is where you 
would write all the metafiles required for the C&lt;dpkg-*&gt; tools.

The C&lt;CPANPLUS::Dist::Base&gt; implementation simply calls the underlying
distribution class (Typically C&lt;CPANPLUS::Dist::MM&gt; or 
C&lt;CPANPLUS::Dist::Build&gt;).

Sets C&lt;&lt; $dist-&gt;status-&gt;prepared &gt;&gt; to the return value of this function.
If you override this method, you should make sure to set this value.

=cut

sub prepare { 
    ### just in case you already did a create call for this module object
    ### just via a different dist object
    my $dist        = shift;
    my $self        = $dist-&gt;parent;
    my $dist_cpan   = $self-&gt;status-&gt;dist_cpan;

    my $cb   = $self-&gt;parent;
    my $conf = $cb-&gt;configure_object;

    $dist-&gt;status-&gt;prepared( $dist_cpan-&gt;prepare( @_ ) );
}

=head2 $bool = $dist-&gt;create

This runs the creation step of your distribution. This step is meant
to follow up on the C&lt;prepare&gt; call, that set up your environment so 
the C&lt;create&gt; step can create the actual distribution(file). 
A C&lt;create&gt; call in the standard C&lt;ExtUtils::MakeMaker&gt; distribution 
would, for example, run C&lt;make&gt; and C&lt;make test&gt; to build and test
a distribution. For a C&lt;debian&gt; distribution, this is where you 
would create the actual C&lt;.deb&gt; file using C&lt;dpkg&gt;.

The C&lt;CPANPLUS::Dist::Base&gt; implementation simply calls the underlying
distribution class (Typically C&lt;CPANPLUS::Dist::MM&gt; or 
C&lt;CPANPLUS::Dist::Build&gt;).

Sets C&lt;&lt; $dist-&gt;status-&gt;dist &gt;&gt; to the location of the created 
distribution.
If you override this method, you should make sure to set this value.

Sets C&lt;&lt; $dist-&gt;status-&gt;created &gt;&gt; to the return value of this function.
If you override this method, you should make sure to set this value.

=cut

sub create { 
    ### just in case you already did a create call for this module object
    ### just via a different dist object
    my $dist        = shift;
    my $self        = $dist-&gt;parent;
    my $dist_cpan   = $self-&gt;status-&gt;dist_cpan;
    $dist           = $self-&gt;status-&gt;dist   if      $self-&gt;status-&gt;dist;
    $self-&gt;status-&gt;dist( $dist )            unless  $self-&gt;status-&gt;dist;

    my $cb      = $self-&gt;parent;
    my $conf    = $cb-&gt;configure_object;
    my $format  = ref $dist;

    ### make sure to set this variable, if the caller hasn't yet
    ### just so we have some clue where the dist left off.
    $dist-&gt;status-&gt;dist( $dist_cpan-&gt;status-&gt;distdir )
        unless defined $dist-&gt;status-&gt;dist;

    $dist-&gt;status-&gt;created( $dist_cpan-&gt;create(prereq_format =&gt; $format, @_) );
}

=head2 $bool = $dist-&gt;install

This runs the install step of your distribution. This step is meant
to follow up on the C&lt;create&gt; call, which prepared a distribution(file)
to install.
A C&lt;create&gt; call in the standard C&lt;ExtUtils::MakeMaker&gt; distribution 
would, for example, run C&lt;make install&gt; to copy the distribution files
to their final destination. For a C&lt;debian&gt; distribution, this is where 
you would run C&lt;dpkg --install&gt; on the created C&lt;.deb&gt; file.

The C&lt;CPANPLUS::Dist::Base&gt; implementation simply calls the underlying
distribution class (Typically C&lt;CPANPLUS::Dist::MM&gt; or 
C&lt;CPANPLUS::Dist::Build&gt;).

Sets C&lt;&lt; $dist-&gt;status-&gt;installed &gt;&gt; to the return value of this function.
If you override this method, you should make sure to set this value.

=cut

sub install { 
    ### just in case you already did a create call for this module object
    ### just via a different dist object
    my $dist        = shift;
    my $self        = $dist-&gt;parent;
    my $dist_cpan   = $self-&gt;status-&gt;dist_cpan;    

    my $cb   = $self-&gt;parent;
    my $conf = $cb-&gt;configure_object;

    $dist-&gt;status-&gt;installed( $dist_cpan-&gt;install( @_ ) );
}

=head2 $bool = $dist-&gt;uninstall

This runs the uninstall step of your distribution. This step is meant
to remove the distribution from the file system. 
A C&lt;uninstall&gt; call in the standard C&lt;ExtUtils::MakeMaker&gt; distribution 
would, for example, run C&lt;make uninstall&gt; to remove the distribution 
files the file system. For a C&lt;debian&gt; distribution, this is where you 
would run C&lt;dpkg --uninstall PACKAGE&gt;.

The C&lt;CPANPLUS::Dist::Base&gt; implementation simply calls the underlying
distribution class (Typically C&lt;CPANPLUS::Dist::MM&gt; or 
C&lt;CPANPLUS::Dist::Build&gt;).

Sets C&lt;&lt; $dist-&gt;status-&gt;uninstalled &gt;&gt; to the return value of this function.
If you override this method, you should make sure to set this value.

=cut

sub uninstall { 
    ### just in case you already did a create call for this module object
    ### just via a different dist object
    my $dist        = shift;
    my $self        = $dist-&gt;parent;
    my $dist_cpan   = $self-&gt;status-&gt;dist_cpan;    

    my $cb   = $self-&gt;parent;
    my $conf = $cb-&gt;configure_object;

    $dist-&gt;status-&gt;uninstalled( $dist_cpan-&gt;uninstall( @_ ) );
}

1;              

# Local variables:
# c-indentation-style: bsd
# c-basic-offset: 4
# indent-tabs-mode: nil
# End:
# vim: expandtab shiftwidth=4:
</pre></body></html>