package votorola::b::Config; # Copyright 2005, 2007, 2009, 2014, Michael Allan. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Votorola Software"), to deal in the Votorola Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicence, and/or sell copies of the Votorola Software, and to permit persons to whom the Votorola Software is furnished to do so, subject to the following conditions: The preceding copyright notice and this permission notice shall be included in all copies or substantial portions of the Votorola Software. THE VOTOROLA SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE VOTOROLA SOFTWARE OR THE USE OR OTHER DEALINGS IN THE VOTOROLA SOFTWARE. use strict; use warnings; =pod =head1 DESCRIPTION Configuration files for build scripts. A build script that cannot locate its configuration will halt with an error, such as: Unable to parse BASEPATH_config.pl: No such file or directory (1) There are two things you must do. First create the missing configuration file. An example is provided in the same directory under the name: BASEPATH_config_example.* Make a copy of the example file, renaming it, and placing it in a separate directory tree on Perl's library search path. For example: /usr/local/lib/perl5/BASEPATH_config.EXT You could also place it in the same directory alongside the example file. It is usually better however to keep config files separate from the source working copies, if only to prevent them being accidently committed to the repo. (2) Then load the new config file into your editor and modify it to suit to your own setup. =head2 When Upgrading or Updating If you have upgraded/updated to a new version of the Votorola codebase, and a build script detects out-of-date configuration, then it will halt with an error such as: Undefined subroutine NAME called at FILE Expecting version N at FILE If there is an associated FILE_config, then it is probably out of date. Update it according to the example configuration supplied with the new code. =head1 EXPORTS =over 4 =cut BEGIN { use Exporter (); our @ISA; @ISA = qw( Exporter ); our @EXPORT_OK; @EXPORT_OK = qw( $auto_deploy config_basepath_from_package do_fail ); } our @EXPORT_OK; =pod =item B( $I ) Returns the relative basepath to the local files for the specified package name. This is the complete relative pathname of the local files, except for their extensions. =cut sub config_basepath_from_package( $ ) { my $basepath = shift; # votorola::foo::Bar $basepath =~ s,::,/,g; # votorola/foo/Bar $basepath .= '_config'; # votorola/foo/Bar_config return $basepath; } =pod =item B( $I ) Handles a failure of 'do', on the specified local path. Dies with an appropriate message. =cut sub do_fail( $ ) { my $config_path = shift; $@ and die "Compile error in $config_path: $@\n"; $! and die "Unable to parse $config_path: $!\n"; die "$config_path did not return a true value\n"; } # =pod # # =item B( $I ) # # Ensures that a config file exists on the specified relative path. # Returns the config file, or dies. # # =cut # # sub ensure_config_file( $ ) # { # my $rel_path = shift; # # my $file; # for my $prefix( @INC ) # { # my $f = "$prefix/$rel_path"; # if( -f $f ) # { # $file = $f; # last; # } # } # defined $file or die "Cannot find $rel_path\n"; # # return $file; # } ### not used =pod =back =cut 1;