1 package CPANPLUS::Dist::Base;
5 use vars qw[@ISA $VERSION];
6 @ISA = qw[CPANPLUS::Dist];
11 CPANPLUS::Dist::Base - Base class for custom distribution classes
15 package CPANPLUS::Dist::MY_IMPLEMENTATION
17 use base 'CPANPLUS::Dist::Base';
22 ### do the 'standard' things
23 $dist->SUPER::prepare( @_ ) or return;
25 ### do MY_IMPLEMENTATION specific things
28 ### don't forget to set the status!
29 return $dist->status->prepared( $SUCCESS ? 1 : 0 );
35 CPANPLUS::Dist::Base functions as a base class for all custom
36 distribution implementations. It does all the mundane work
37 CPANPLUS would have done without a custom distribution, so you
38 can override just the parts you need to make your own implementation
43 Below is a brief outline when and in which order methods in this
46 $Class->format_available; # can we use this class on this system?
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
53 $dist->uninstall; # remove the distribution (OPTIONAL)
60 =head2 $bool = $Class->format_available
62 This method is called when someone requests a module to be installed
63 via the superclass. This gives you the opportunity to check if all
64 the needed requirements to build and install this distribution have
67 For example, you might need a command line program, or a certain perl
68 module installed to do your job. Now is the time to check.
70 Simply return true if the request can proceed and false if it can not.
72 The C<CPANPLUS::Dist::Base> implementation always returns true.
76 sub format_available { return 1 }
79 =head2 $bool = $dist->init
81 This method is called just after the new dist object is set up and
82 before the C<prepare> method is called. This is the time to set up
83 the object so it can be used with your class.
85 For example, you might want to add extra accessors to the C<status>
86 object, which you might do as follows:
88 $dist->status->mk_accessors( qw[my_implementation_accessor] );
90 The C<status> object is implemented as an instance of the
91 C<Object::Accessor> class. Please refer to it's documentation for
94 Return true if the initialization was successul, and false if it was
97 The C<CPANPLUS::Dist::Base> implementation does not alter your object
98 and always returns true.
102 sub init { return 1; }
104 =head2 $bool = $dist->prepare
106 This runs the preparation step of your distribution. This step is meant
107 to set up the environment so the C<create> step can create the actual
109 A C<prepare> call in the standard C<ExtUtils::MakeMaker> distribution
110 would, for example, run C<perl Makefile.PL> to find the dependencies
111 for a distribution. For a C<debian> distribution, this is where you
112 would write all the metafiles required for the C<dpkg-*> tools.
114 The C<CPANPLUS::Dist::Base> implementation simply calls the underlying
115 distribution class (Typically C<CPANPLUS::Dist::MM> or
116 C<CPANPLUS::Dist::Build>).
118 Sets C<< $dist->status->prepared >> to the return value of this function.
119 If you override this method, you should make sure to set this value.
124 ### just in case you already did a create call for this module object
125 ### just via a different dist object
127 my $self = $dist->parent;
128 my $dist_cpan = $self->status->dist_cpan;
130 my $cb = $self->parent;
131 my $conf = $cb->configure_object;
133 $dist->status->prepared( $dist_cpan->prepare( @_ ) );
136 =head2 $bool = $dist->create
138 This runs the creation step of your distribution. This step is meant
139 to follow up on the C<prepare> call, that set up your environment so
140 the C<create> step can create the actual distribution(file).
141 A C<create> call in the standard C<ExtUtils::MakeMaker> distribution
142 would, for example, run C<make> and C<make test> to build and test
143 a distribution. For a C<debian> distribution, this is where you
144 would create the actual C<.deb> file using C<dpkg>.
146 The C<CPANPLUS::Dist::Base> implementation simply calls the underlying
147 distribution class (Typically C<CPANPLUS::Dist::MM> or
148 C<CPANPLUS::Dist::Build>).
150 Sets C<< $dist->status->dist >> to the location of the created
152 If you override this method, you should make sure to set this value.
154 Sets C<< $dist->status->created >> to the return value of this function.
155 If you override this method, you should make sure to set this value.
160 ### just in case you already did a create call for this module object
161 ### just via a different dist object
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;
168 my $cb = $self->parent;
169 my $conf = $cb->configure_object;
170 my $format = ref $dist;
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;
177 $dist->status->created( $dist_cpan->create(prereq_format => $format, @_) );
180 =head2 $bool = $dist->install
182 This runs the install step of your distribution. This step is meant
183 to follow up on the C<create> call, which prepared a distribution(file)
185 A C<create> call in the standard C<ExtUtils::MakeMaker> distribution
186 would, for example, run C<make install> to copy the distribution files
187 to their final destination. For a C<debian> distribution, this is where
188 you would run C<dpkg --install> on the created C<.deb> file.
190 The C<CPANPLUS::Dist::Base> implementation simply calls the underlying
191 distribution class (Typically C<CPANPLUS::Dist::MM> or
192 C<CPANPLUS::Dist::Build>).
194 Sets C<< $dist->status->installed >> to the return value of this function.
195 If you override this method, you should make sure to set this value.
200 ### just in case you already did a create call for this module object
201 ### just via a different dist object
203 my $self = $dist->parent;
204 my $dist_cpan = $self->status->dist_cpan;
206 my $cb = $self->parent;
207 my $conf = $cb->configure_object;
209 $dist->status->installed( $dist_cpan->install( @_ ) );
212 =head2 $bool = $dist->uninstall
214 This runs the uninstall step of your distribution. This step is meant
215 to remove the distribution from the file system.
216 A C<uninstall> call in the standard C<ExtUtils::MakeMaker> distribution
217 would, for example, run C<make uninstall> to remove the distribution
218 files the file system. For a C<debian> distribution, this is where you
219 would run C<dpkg --uninstall PACKAGE>.
221 The C<CPANPLUS::Dist::Base> implementation simply calls the underlying
222 distribution class (Typically C<CPANPLUS::Dist::MM> or
223 C<CPANPLUS::Dist::Build>).
225 Sets C<< $dist->status->uninstalled >> to the return value of this function.
226 If you override this method, you should make sure to set this value.
231 ### just in case you already did a create call for this module object
232 ### just via a different dist object
234 my $self = $dist->parent;
235 my $dist_cpan = $self->status->dist_cpan;
237 my $cb = $self->parent;
238 my $conf = $cb->configure_object;
240 $dist->status->uninstalled( $dist_cpan->uninstall( @_ ) );
246 # c-indentation-style: bsd
248 # indent-tabs-mode: nil
250 # vim: expandtab shiftwidth=4: