|Perl Monk, Perl Meditation|
Re: Creating modules for installationby andreychek (Parson)
|on Apr 21, 2002 at 17:42 UTC||Need Help??|
If you intend on putting your modules on CPAN, what you're looking to do is fairly straightforward. Your question is well timed -- just the other day, a tutorial was created on How to make a CPAN Module Distribution. I highly recommend checking that out, it will get you started in the right direction.
Regarding your specific points above:
1. Is h2xs sufficient for my needs?
All your requirements that you mentioned, believe it or not, are fairly typical. Using h2xs should be just fine for you, and the previously mentioned tutorial shows you how you can use it properly.
2. Will it handle other modules (e.g. DBI, DBD::mysql) if they are not loaded on the machine?
Sure! The tutorial doesn't really get into this, but the perldoc for ExtUtils::MakeMaker can help you out here. What you need to use is the parameter "PREREQ_PM". Also, be sure to take a peek at how some other modules make use of this, that should really help you out.
3. Does CPAN handle this automatically? I do not want to necessarily include the other modules, just have CPAN know enough to install them as dependencies if they are not already installed.
If you intend on putting your modules on CPAN, then yes, downloading prerequisite modules is handled for you, assuming you put your requirements in the "PREREQ_PM" mentioned above.
If you don't want to put your modules on CPAN for some reason, perhaps you should look into ExtUtils::AutoInstall. From the Description:
ExtUtils::AutoInstall lets module writers to specify a more sophisticated form of dependency information than the PREREQ_PM option offered by ExtUtils::MakeMaker.
Basically, it properly handles installing module dependencies, whether or not you are running under CPAN. Additionally, it allows you the flexibility of having optional features, and it can ask at install-time of your module which dependencies you desire to load.
4. How should I handle versioning of the module collection? Once installed, I want to easily update the files.
Versioning is also handled by a combination of ExtUtils::MakeMaker (or ExtUtils::AutoInstall if you decide to use it), and a package variable in your module. In your Makefile.PL, you could use the "VERSION_FROM" parameter like so:
VERSION_FROM => 'lib/MyModule.pm'
And then, in MyModule.pm, you would need to include this line:
With this setup, CPAN or CPANPLUS will be capable of determining the version of your module, and from that will be able to know whether or not to update it.
I hope that helps!