NAME
Mail::Toaster::Perl - Perl specific functions for Mail Toaster
SYNOPSIS
Perl functions for loading, installing and testing perl modules.
DESCRIPTION
Mail::Toaster::Perl is a few frequently used functions that make dealing with perl and perl modules a little more managable. The following methods are available:
check - checks perl version
install - installs perl
module_load - loads a perl module (attempts to install if missing)
See the description for each method below.
METHODS
- new
-
To use a a method in this class, you must first request a Mail::Toaster::Perl object:
use Mail::Toaster::Perl; my $perl = Mail::Toaster::Perl->new();
You can then call subsequent methods with $perl->method();
- check
-
Checks perl to make sure the version is higher than a minimum (supplied) value.
$perl->check( min=>'5.006001' ); arguments required: min - defaults to 5.6.1 (5.006001). arguments optional: timer - default 60 seconds debug usage: $perl->check( min=>5.006001 );
returns 1 for success, 0 for failure.
- has_module
-
Checks to see if a perl module is installed.
if ( $perl->has_module("Date::Format") ) { print "yay!\n"; }; arguments required: module - the name of the perl module arguments optional: version - minimum version
- module_install
-
Downloads and installs a perl module from sources.
The arguments get concatenated to a url like this: $site/$url/$module.tar.gz
Once downloaded, we expand the archive and attempt to build it. If not set, the default targets are: make, make test, and make install. After install, we clean up the sources and exit.
This method builds from sources only. Compare to module_load which will attempt to build from FreeBSD ports, CPAN, and then finally resort to sources if all else fails.
usage: $perl->module_install( module=>"Params::Validate", conf=>$conf ); Example: $perl->module_install( module => 'Mail-Toaster', archive => 'Mail-Toaster-4.01.tar.gz', site => 'http://www.tnpi.net', url => '/internet/mail/toaster/src', targets => ['perl Makefile.PL', 'make install'], ); arguments required: module - module name (CGI) site - site to download from url - path to downloads on site arguments optional: archive - archived module name (CGI-1.35.tar.gz) targets - build targets: conf - $conf is toaster-watcher.conf settings, (barely) optional. result: 1 - success 0 - failure.
- module_load
-
$perl->module_load( module=>'Net::DNS' );
Loads a required Perl module. If the load fails, we attempt to install the required module (rather than failing gracelessly).
arguments required: module - the name of the module: (ie. LWP::UserAgent) arguments optional: port_name - is the name of the FreeBSD port port_group - is is the ports group ( "ls /usr/ports" to see groups) warn - if set, we warn instead of dying upon failure timer - how long (in seconds) to wait for user input (default 60) site - site to download sources from url - url at site (see module_install) archive - downloadable archive name (module-1.03.tar.gz)
returns 1 for success, 0 for failure.
- perl_install
-
$perl->perl_install( version=>"perl-5.8.5" );
currently only works on FreeBSD and Darwin (Mac OS X)
input is a hashref with the following values:
version - perl version to install options - compile flags to set (comma separated list)
On FreeBSD, version is the directory name such as "perl5.8" derived from /usr/ports/lang/perl5.8. Ex: $perl->perl_install( version=>"perl5.8" );
On Darwin, it's the directory name of the port in Darwin Ports. Ex: $perl->perl_install( {version=>"perl-5.8"} ) because perl is installed from /usr/ports/dports/lang/perl5.8. Otherwise, it's the exact version to download and install, ex: "perl-5.8.5".
Example with option:
$perl->perl_install( version=>"perl-5.8.5", options=>"ENABLE_SUIDPERL" );
AUTHOR
Matt Simerson (matt@tnpi.net)
BUGS
None known. Report any to author.
TODO
SEE ALSO
The following are all man/perldoc pages:
Mail::Toaster
Mail::Toaster::Conf
toaster.conf
toaster-watcher.conf
http://www.tnpi.net/internet/mail/toaster/
COPYRIGHT AND LICENSE
Copyright (c) 2003-2006, The Network People, Inc. All Rights Reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
Neither the name of the The Network People, Inc. nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.