CPAN PLUS
by Jos Boumans
|
Pages: 1, 2
The Programmer's Interface: 'Backend'
CPANPLUS shells are built upon the CPANPLUS::Backend module. Backend provides generic functions for module management tasks. It is suitable for creating not only shells, but also autonomous programs.
Rather than describe in detail all the available methods, which are documented in the CPANPLUS::Backend pod, I will give a few bits of sample code to show what you can do with Backend.
### Install all modules in the POE:: namespace ###
my $cb = new CPANPLUS::Backend;
my $hr = $cb->search( type => 'module', list => [qw|^POE$ ^POE::.*|] );
my $rv = $cb->install( modules => [ keys %$hr ] );
The variable $rv is a hash reference where the keys are the
names of the modules and the values are exit states. This allows
you to check how the installation went for each module. You can
also get an error object from Backend with a complete history of
what CPANPLUS did while installing these modules.
### Fetch a certain version of LWP ###
my $cb = new CPANPLUS::Backend;
my $rv = $cb->fetch( modules => ['/G/GA/GAAS/libwww-perl-5.62.tar.gz'] );
Once again, $rv is a hash reference, where the key is
the module you tried to fetch and the value is the location on your
disk where it was stored. Some people might not care for the
way searches are handled and would rather roll their own. Backend
allows you to take matters into your own hands:
### Do your own thing ###
my $cb = new CPANPLUS::Backend;
my $mt = $cb->module_tree();
$mt now holds the complete module tree, which is the
same tree CPANPLUS uses internally. For this hash reference, the keys
are the names of modules, and values are CPANPLUS::Internals::Module
objects.
for my $name ( keys %$mt ) {
if ($name =~ /^Acme/) {
my $href = $mt->{$name}->modules();
while ( my ($mod,$obj) = each %$href ) {
print $obj->install()
? "$mod installed succesfully\n"
: "$mod installation failed!\n";
}
}
}
This traverses the module tree, looking for module names that match
the regular expression '/^Acme/' and installing all modules by the
same author.
Why would you want to do this? We all have our reasons, and mine
is that the Acme:: namespace is CPAN's bleeding edge
codebase. Authors who have modules there must be trustworthy!
Merits of the Interfaces
In addition to the modules I've mentioned, there are plenty more:
CPANPLUS currently contains 17 modules. These modules are part of a
three-tiered approach. Underneath everything sits
Internals, which performs the nitty-gritty work;
Backend rests on top of it; and finally
Shell provides a user interface.
The logic beyond the layered structure is that everyone wants
something different from CPANPLUS. Some people just want a working
shell like CPAN.pm provided. Others need a way to write
applications that manage Perl installations. Still others dream of
more elaborate plugins, like CPANTS or an automatic bug ticketing with
RT -- something which is already planned.
The division allows us to stay flexible. There is something for everyone in CPANPLUS -- and if it's not there yet, it can probably be built upon the existing codebase.
Current and Future Developments
CPANPLUS was just released, but we're not resting. There's still a lot of functionality we want to provide.
It's high priority to
create backward compatibility with the current CPAN.pm
so CPANPLUS can eventually be released as CPAN.pm,
possibly taking over its place in the core Perl distribution.
Another development that was already mentioned is automatic bug reporting, which would give authors of modules feedback on the performance of their modules on varying platforms, under various configurations. Of course, there's also CPANTS, the idea that sparked the entire CPANPLUS project. CPANTS is intended to provide automated testing of CPAN modules to make certain they meet minimal standards.
We have thoughts about integrating with known package managers like
PPM, RPM and dpkg.
We also plan to develop more shells, both for the command-line and for the Windows and X environments.
Naturally, we don't want to stop there. There are a million possibilities with CPANPLUS, and hopefully they'll all be explored and developed.
If you have a good idea, then mail us your suggestion; or better yet, join as a developer and contribute!
Support and Contributing
If you have questions or suggestions, or want to join up as a developer, then send mail to: cpanplus-info@lists.sourceforge.net. This is the general mailing list.
Reports of bugs should be sent to: cpanplus-bugs@lists.sourceforge.net Some of the developers are also regulars on the IRC channel #CP on magnet.
Where to Get CPANPLUS
There are two places where you can obtain CPANPLUS. The first is, of course, to check your local CPAN mirror (or look it up on search.cpan.org). The latest stable release will always be there.
If you are interested in development versions, then look at Sourceforge.
More Information
In addition to the documents that come with CPANPLUS, information is available on our Web site. All good things stem from there.
On a side note, I will be giving speeches and tutorials on CPANPLUS at both YAPC::America::North and YAPC::Europe, as well as TPC. Come by and share your ideas!
Credits
Of course, I couldn't end without giving credit to the other developers. Although I started CPANPLUS, it would never have become what it is now without Joshua Boschert and Autrijus Tang. Ann Barcomb wrote all the documentation and Michael Schwern provided tests and just general good ideas. Thanks also goes to everyone who contributed with posts to the development and bug mailing lists.
Conclusion
So here we are, eight months after that first magical gathering. One step closer to the goal. And one step closer to Yet Another Venue. And perhaps there, I'll be standing up, talking about new things, or at least CPANPLUS.
Hopefully I'll be able to meet you there, in a circle of laptops, and we'll continue to make our world a better place!

