Name
CatalystX::Usul::Build - M::B utility methods
Version
0.3.$Revision: 624 $
Synopsis
use CatalystX::Usul::Build;
use Class::C3;
my $builder = q(CatalystX::Usul::Build);
my $class = $builder->subclass( class => 'Bob', code => <<'EOB' );
sub ACTION_install {
my $self = shift;
$self->next::method();
# Your application specific post installation code goes here
return;
}
EOB
Description
Subclasses Module::Build. Ask questions during the build phase and stores the answers for use during the install phase. The answers to the questions determine where the application will be installed and which additional actions will take place. Should be generic enough for any web application
Subroutines/Methods
ACTION_build
When called by it's subclass this method prompts the user for information about how this installation is to be performed. User responses are saved to the build.xml file. The "config_attributes" method returns the list of questions to ask
ACTION_install
When called from it's subclass this method performs the sequence of actions required to install the application. Configuration options are read from the file build.xml. The "actions" method returns the list of steps required to install the application
ACTION_installdeps
Iterates over the requires attributes calling CPAN each time to install the dependent module
actions
$current_list_of_actions = $builder->actions( $new_list_of_actions );
This accessor/mutator method defaults to the list defined in the $ACTIONS
package variable
cli
$cli = $builder->cli;
Returns an instance of CatalystX::Usul::Programs, the command line interface object
config_attributes
$current_list_of_attrs = $builder->config_attributes( $new_list_of_attrs );
This accessor/mutator method defaults to the list defined in the $ATTRS
package variable
post_install
$builder->post_install( $config );
Executes the custom post installation commands
process_files
$builder->process_files( $source, $destination );
Handles the processing of files other than library modules and programs. Uses the Bob::skip_pattern defined in the subclass to select only those files that should be processed. Copies files from source to destination, creating the destination directories as required. Source can be a single file or a directory. The destination is optional and defaults to blib
replace
$builder->replace( $this, $that, $path );
Substitutes $this
string for $that
string in the file $path
repository
Return the URI of the SVN repository for this project
skip_pattern
$regexp = $builder->skip_pattern( $new_regexp );
Accessor/mutator method. Used by "_copy_file" to skip processing files that match this pattern. Set to false to not have a skip list
Questions
All question methods are passed $config
and return the new value for one of it's attributes
get_apache_user
Prompts for the userid of the web server process owner. This user will be added to the group that owns the application files and directories. This will allow the web server processes to read and write these files
get_ask
Ask if questions should be asked in future runs of the build process
get_built
Always returns true. This dummy question is used to trigger the suppression of any further questions once the build phase is complete
get_create_schema
Should a database schema be created? If yes then the database connection information must be entered. The database must be available at install time
get_create_ugrps
Create the application user and group that owns the files and directories in the application
get_credentials
Get the database connection information
get_make_default
When installed should this installation become the default for this host? Causes the symbolic link (that hides the version directory from the PATH
environment variable) to be deleted and recreated pointing to this installation
get_new_prefix
If the installation style is normal, then prompt for the installation prefix. This default to /opt. The application name and version directory are automatically appended
get_phase
The phase number represents the reason for the installation. It is encoded into the name of the application home directory. At runtime the application will load some configuration data that is dependent upon this value
get_restart_apache
When the application is mostly installed, should the web server be restarted?
get_run_cmd
Run the post installation commands? These may take a long time to complete
get_setuid_root
Enable the setuid
root wrapper?
get_style
Which installation layout? Either perl or normal
- normal
-
Modules, programs, and the var directory tree are installed to a user selectable path. Defaults to /opt/<appname>
- perl
-
Will install modules and programs in their usual Config locations. The var directory tree will be install to /var/<appname>
get_ver
Dummy question returns the version part of the installation directory
Actions
All action methods are passed $config
copy_files
Copies files as defined in the $config->{copy_files}
attribute. Each item in this list is a hash ref containing from and to keys
create_dirs
Create the directory paths specified in the list $config->{create_dirs}
if they do not exist
create_files
Create the files specified in the list $config->{create_files}
if they do not exist
create_schema
Creates a database then deploys and populates the schema
create_ugrps
Creates the user and group to own the application files
link_files
Creates some symbolic links
make_default
Makes this installation the default for this server
restart_apache
Restarts the web server
set_owner
Set the ownership of the installed files and directories
set_permissions
Set the permissions on the installed files and directories
Private Methods
_abs_path
$absolute_path = $builder->_abs_path( $base, $path );
Prepends $base to $path unless $path is an absolute path
_copy_file
$builder->_copy_file( $source, $destination );
Called by "process_files". Copies the $source
file to the $destination
directory
_edit_credentials
$builder->_edit_credentials( $config, $dbname );
Writes the database login information stored in the $config
to the application config file in the var/etc directory. Called from "create_schema"
_get_arrays_from_dtd
$list_of_arrays = $builder->_get_arrays_from_dtd( $dtd );
Parses the $dtd
data and returns the list of element names which are interpolated into arrays. Called from "_get_connect_info"
_get_config
$config = $builder->_get_config( $path );
Reads the configuration information from $path using XML::Simple. The package variable $ARRAYS
is passed to XML::Simple as the ForceArray attribute. Called by "ACTION_build" and ACTION_install
_get_connect_info
($info, $dtd) = $builder->_get_connect_info( $path );
Reads database connection information from $path using XML::Simple. The ForceArray attribute passed to XML::Simple is obtained by parsing the DTD elements in the file. Called by the "get_credentials" question and _edit_credentials
_set_base
$base = $builder->_set_base( $config );
Uses the $config->{style}
attribute to set the Module::Build install_base attribute to the base directory for this installation. Returns that path. Also sets; bin, lib, and var directory paths as appropriate. Called from ACTION_install
_set_config
$config = $builder->_set_config( $path, $config );
Writes the $config
hash to the $path file for later use by the install action. Called from ACTION_build
Diagnostics
None
Configuration and Environment
Edits and stores config information in the file build.xml
Dependencies
Incompatibilities
There are no known incompatibilities in this module
Bugs and Limitations
There are no known bugs in this module. Please report problems to the address below. Patches are welcome
Author
Peter Flanigan, <Support at RoxSoft.co.uk>
License and Copyright
Copyright (c) 2008 Peter Flanigan. All rights reserved
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See perlartistic
This program is distributed in the hope that it will be useful, but WITHOUT WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE