Remove unused Module::Build tests
[p5sagit/p5-mst-13.2.git] / lib / CPANPLUS / Dist / Base.pm
CommitLineData
6aaee015 1package CPANPLUS::Dist::Base;
2
3use strict;
4
5use vars qw[@ISA $VERSION];
6@ISA = qw[CPANPLUS::Dist];
7$VERSION = '0.01';
8
9=head1 NAME
10
11CPANPLUS::Dist::Base - Base class for custom distribution classes
12
13=head1 SYNOPSIS
14
15 package CPANPLUS::Dist::MY_IMPLEMENTATION
16
17 use base 'CPANPLUS::Dist::Base';
18
19 sub prepare {
20 my $dist = shift;
21
22 ### do the 'standard' things
23 $dist->SUPER::prepare( @_ ) or return;
24
25 ### do MY_IMPLEMENTATION specific things
26 ...
27
28 ### don't forget to set the status!
29 return $dist->status->prepared( $SUCCESS ? 1 : 0 );
30 }
31
32
33=head1 DESCRIPTION
34
35CPANPLUS::Dist::Base functions as a base class for all custom
36distribution implementations. It does all the mundane work
37CPANPLUS would have done without a custom distribution, so you
38can override just the parts you need to make your own implementation
39work.
40
41=head1 FLOW
42
43Below is a brief outline when and in which order methods in this
44class are called:
45
46 $Class->format_available; # can we use this class on this system?
47
48 $dist->init; # set up custom accessors, etc
49 $dist->prepare; # find/write meta information
50 $dist->create; # write the distribution file
51 $dist->install; # install the distribution file
52
53 $dist->uninstall; # remove the distribution (OPTIONAL)
54
55=head1 METHODS
56
57=cut
58
59
60=head2 $bool = $Class->format_available
61
62This method is called when someone requests a module to be installed
63via the superclass. This gives you the opportunity to check if all
64the needed requirements to build and install this distribution have
65been met.
66
67For example, you might need a command line program, or a certain perl
68module installed to do your job. Now is the time to check.
69
70Simply return true if the request can proceed and false if it can not.
71
72The C<CPANPLUS::Dist::Base> implementation always returns true.
73
74=cut
75
76sub format_available { return 1 }
77
78
79=head2 $bool = $dist->init
80
81This method is called just after the new dist object is set up and
82before the C<prepare> method is called. This is the time to set up
83the object so it can be used with your class.
84
85For example, you might want to add extra accessors to the C<status>
86object, which you might do as follows:
87
88 $dist->status->mk_accessors( qw[my_implementation_accessor] );
89
90The C<status> object is implemented as an instance of the
91C<Object::Accessor> class. Please refer to it's documentation for
92details.
93
94Return true if the initialization was successul, and false if it was
95not.
96
97The C<CPANPLUS::Dist::Base> implementation does not alter your object
98and always returns true.
99
100=cut
101
102sub init { return 1; }
103
104=head2 $bool = $dist->prepare
105
106This runs the preparation step of your distribution. This step is meant
107to set up the environment so the C<create> step can create the actual
108distribution(file).
109A C<prepare> call in the standard C<ExtUtils::MakeMaker> distribution
110would, for example, run C<perl Makefile.PL> to find the dependencies
111for a distribution. For a C<debian> distribution, this is where you
112would write all the metafiles required for the C<dpkg-*> tools.
113
114The C<CPANPLUS::Dist::Base> implementation simply calls the underlying
115distribution class (Typically C<CPANPLUS::Dist::MM> or
116C<CPANPLUS::Dist::Build>).
117
118Sets C<< $dist->status->prepared >> to the return value of this function.
119If you override this method, you should make sure to set this value.
120
121=cut
122
123sub prepare {
124 ### just in case you already did a create call for this module object
125 ### just via a different dist object
126 my $dist = shift;
127 my $self = $dist->parent;
128 my $dist_cpan = $self->status->dist_cpan;
129
130 my $cb = $self->parent;
131 my $conf = $cb->configure_object;
132
133 $dist->status->prepared( $dist_cpan->prepare( @_ ) );
134}
135
136=head2 $bool = $dist->create
137
138This runs the creation step of your distribution. This step is meant
139to follow up on the C<prepare> call, that set up your environment so
140the C<create> step can create the actual distribution(file).
141A C<create> call in the standard C<ExtUtils::MakeMaker> distribution
142would, for example, run C<make> and C<make test> to build and test
143a distribution. For a C<debian> distribution, this is where you
144would create the actual C<.deb> file using C<dpkg>.
145
146The C<CPANPLUS::Dist::Base> implementation simply calls the underlying
147distribution class (Typically C<CPANPLUS::Dist::MM> or
148C<CPANPLUS::Dist::Build>).
149
150Sets C<< $dist->status->dist >> to the location of the created
151distribution.
152If you override this method, you should make sure to set this value.
153
154Sets C<< $dist->status->created >> to the return value of this function.
155If you override this method, you should make sure to set this value.
156
157=cut
158
159sub create {
160 ### just in case you already did a create call for this module object
161 ### just via a different dist object
162 my $dist = shift;
163 my $self = $dist->parent;
164 my $dist_cpan = $self->status->dist_cpan;
165 $dist = $self->status->dist if $self->status->dist;
166 $self->status->dist( $dist ) unless $self->status->dist;
167
e3b7d412 168 my $cb = $self->parent;
169 my $conf = $cb->configure_object;
170 my $format = ref $dist;
6aaee015 171
172 ### make sure to set this variable, if the caller hasn't yet
173 ### just so we have some clue where the dist left off.
174 $dist->status->dist( $dist_cpan->status->distdir )
175 unless defined $dist->status->dist;
176
e3b7d412 177 $dist->status->created( $dist_cpan->create(prereq_format => $format, @_) );
6aaee015 178}
179
180=head2 $bool = $dist->install
181
182This runs the install step of your distribution. This step is meant
183to follow up on the C<create> call, which prepared a distribution(file)
184to install.
185A C<create> call in the standard C<ExtUtils::MakeMaker> distribution
186would, for example, run C<make install> to copy the distribution files
187to their final destination. For a C<debian> distribution, this is where
188you would run C<dpkg --install> on the created C<.deb> file.
189
190The C<CPANPLUS::Dist::Base> implementation simply calls the underlying
191distribution class (Typically C<CPANPLUS::Dist::MM> or
192C<CPANPLUS::Dist::Build>).
193
194Sets C<< $dist->status->installed >> to the return value of this function.
195If you override this method, you should make sure to set this value.
196
197=cut
198
199sub install {
200 ### just in case you already did a create call for this module object
201 ### just via a different dist object
202 my $dist = shift;
203 my $self = $dist->parent;
204 my $dist_cpan = $self->status->dist_cpan;
205
206 my $cb = $self->parent;
207 my $conf = $cb->configure_object;
208
209 $dist->status->installed( $dist_cpan->install( @_ ) );
210}
211
212=head2 $bool = $dist->uninstall
213
214This runs the uninstall step of your distribution. This step is meant
215to remove the distribution from the file system.
216A C<uninstall> call in the standard C<ExtUtils::MakeMaker> distribution
217would, for example, run C<make uninstall> to remove the distribution
218files the file system. For a C<debian> distribution, this is where you
219would run C<dpkg --uninstall PACKAGE>.
220
221The C<CPANPLUS::Dist::Base> implementation simply calls the underlying
222distribution class (Typically C<CPANPLUS::Dist::MM> or
223C<CPANPLUS::Dist::Build>).
224
225Sets C<< $dist->status->uninstalled >> to the return value of this function.
226If you override this method, you should make sure to set this value.
227
228=cut
229
230sub uninstall {
231 ### just in case you already did a create call for this module object
232 ### just via a different dist object
233 my $dist = shift;
234 my $self = $dist->parent;
235 my $dist_cpan = $self->status->dist_cpan;
236
237 my $cb = $self->parent;
238 my $conf = $cb->configure_object;
239
240 $dist->status->uninstalled( $dist_cpan->uninstall( @_ ) );
241}
242
2431;
244
245# Local variables:
246# c-indentation-style: bsd
247# c-basic-offset: 4
248# indent-tabs-mode: nil
249# End:
250# vim: expandtab shiftwidth=4: