Thread: [Lxr-commits] CVS: lxr/scripts recreatedb.pl,1.7,1.8
Brought to you by:
ajlittoz
From: Andre-Littoz <ajl...@us...> - 2013-09-02 17:07:54
|
Update of /cvsroot/lxr/lxr/scripts In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv25390/scripts Modified Files: recreatedb.pl Log Message: scripts/recreatedb.pl: synchronise with configuration wizard Index: recreatedb.pl =================================================================== RCS file: /cvsroot/lxr/lxr/scripts/recreatedb.pl,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- recreatedb.pl 22 Jan 2013 16:59:52 -0000 1.7 +++ recreatedb.pl 2 Sep 2013 17:07:51 -0000 1.8 @@ -27,18 +27,20 @@ use Fcntl; use Getopt::Long; use IO::Handle; -use File::MMagic; use File::Path qw(make_path); -use LXR::Files; -use LXR::Index; -use LXR::Common; - use ContextMgr; use LCLInterpreter; -use QuestionAnswer; use VTescape; +# The following use statements are written only to allow to eval +# without error the lxr.conf file is the event it contains sub +# definitions for 'range' with references to allbranches, +# allreleases, allrevisions or alltags functions defined in Files. +# These function calls may use LXR global $pathname defined in Common. +use LXR::Files; +use LXR::Common; + ############################################################## # @@ -46,14 +48,9 @@ # ############################################################## -# This is a nasty trick to fool Perl into accepting the CVS -# revision tag without trying to make sense with a supposed -# variable (sigils may be separated from the variable name -# by spaces! Not documented of course!) -$_ = ''; # Calm down Perl ardour -my $version ="\$Revision$_"; -$version =~ s/Revision: (.*) $/$1/; -$version =~ s/\$//; +my $version = '$Revision$'; +$version =~ s/Revision: (.*) /$1/; +$version =~ s/\$//g; # Who am I? Strip directory path. my $cmdname = $0; @@ -77,6 +74,7 @@ chomp($rootdir); my ($scriptdir) = $0 =~ m!([^/]+)/[^/]+$!; my $tmpldir = 'templates'; +my $ovrdir = 'custom.d/templates'; my $verbose; my $scriptout = 'initdb.sh'; my $lxrconf = 'lxr.conf'; @@ -89,6 +87,7 @@ , 'root-dir=s' => \$rootdir , 'script-out=s'=> \$scriptout , 'tmpl-dir=s' => \$tmpldir + , 'tmpl-ovr=s' => \$ovrdir , 'verbose|v' => \$verbose , 'version' ) @@ -123,6 +122,9 @@ --tmpl-dir=directory Define template directory (default: $tmpldir) + --tmpl-ovr=directory + Define template user-override directory + (default: $ovrdir) -v, --verbose Explain what is being done --version Print version information and quit @@ -139,7 +141,7 @@ if ($option{'version'}) { print <<END_VERSION; ${cmdname} version $version -(C) 2012 A. J. Littoz +(C) 2012-2013 A. J. Littoz This is free software under GPL v3 (or higher) licence. There is NO warranty, not even for MERCHANTABILITY nor FITNESS FOR A PARICULAR PURPOSE to the extent permitted by law. @@ -153,6 +155,7 @@ # "Canonise" directory names $confdir =~ s:/*$::; $tmpldir =~ s:/*$::; +$ovrdir =~ s:/*$::; $rootdir =~ s:/*$::; # Check LXR environment @@ -196,29 +199,41 @@ $lxrctx = $confdir . '/' . $lxrctx; } } -if (! -e "$lxrctx") { +if (! -e $lxrctx) { print "${VTred}ERROR:${VTnorm} configuration context file" . " ${VTred}$lxrctx${VTnorm} does not exist!\n"; } -if (! -e "$tmpldir/initdb/initdb-m-template.sql") { +if ( ! -e $tmpldir.'/initdb/initdb-m-template.sql' + && ! -e $ovrdir .'/initdb/initdb-m-template.sql' + ) { print "${VTred}ERROR:${VTnorm} template file" - . " ${VTred}$tmpldir/initdb/initdb-m-template.sql{VTnorm} does not exist!\n"; + . " ${VTred}initdb/initdb-m-template.sql{VTnorm}" + . " exists neither in override nor in templates directory!\n"; $error = 1; } -if (! -e "$tmpldir/initdb/initdb-o-template.sql") { +if ( ! -e $tmpldir.'/initdb/initdb-o-template.sql' + && ! -e $ovrdir .'/initdb/initdb-o-template.sql' + ) { print "${VTred}ERROR:${VTnorm} template file" - . " ${VTred}$tmpldir/initdb/initdb-o-template.sql{VTnorm} does not exist!\n"; + . " ${VTred}initdb/initdb-o-template.sql{VTnorm}" + . " exists neither in override nor in templates directory!\n"; $error = 1; } -if (! -e "$tmpldir/initdb/initdb-p-template.sql") { +if ( ! -e $tmpldir.'/initdb/initdb-p-template.sql' + && ! -e $ovrdir .'/initdb/initdb-p-template.sql' + ) { print "${VTred}ERROR:${VTnorm} template file" - . " ${VTred}$tmpldir/initdb/initdb-p-template.sql{VTnorm} does not exist!\n"; + . " ${VTred}initdb/initdb-p-template.sql{VTnorm}" + . " exists neither in override nor in templates directory!\n"; $error = 1; } -if (! -e "$tmpldir/initdb/initdb-s-template.sql") { +if ( ! -e $tmpldir.'/initdb/initdb-s-template.sql' + && ! -e $ovrdir .'/initdb/initdb-s-template.sql' + ) { print "${VTred}ERROR:${VTnorm} template file" - . " ${VTred}$tmpldir/initdb/initdb-s-template.sql{VTnorm} does not exist!\n"; + . " ${VTred}initdb/initdb-s-template.sql{VTnorm}" + . " exists neither in override nor in templates directory!\n"; $error = 1; } @@ -331,10 +346,10 @@ if (exists($config[0]{'dbprefix'})) { $dbprefix = $config[0]{'dbprefix'}; } -if (exists($config->{'dbname'})) { - $config->{'dbname'} =~ m/dbi:(.)/; +if (exists($config[0]{'dbname'})) { + $config[0]{'dbname'} =~ m/dbi:(.)/; $dbengine = lc($1); - if ($config->{'dbname'} =~ m/dbname=([^;]+)/) { + if ($config[0]{'dbname'} =~ m/dbname=([^;]+)/) { $dbname = $1; } } @@ -430,29 +445,19 @@ } if ( $dbenginechanged - || $treedbengine ne $dbengine && !$dbengine_seen{$treedbengine} + || $treedbengine ne $dbengine && !$dbengine_seen{$treedbengine} ) { $markers{'%_createglobals%'} = 1; $dbengine_seen{$treedbengine} = 1; } - open(SOURCE, '<', "${tmpldir}/initdb/initdb-${treedbengine}-template.sql") - or die("${VTred}ERROR:${VTnorm} couldn't open script template file \"${tmpldir}/initdb/initdb-${dbengine}-template.sql\"\n"); + my $input = $ovrdir . "/initdb/initdb-${dbengine}-template.sql"; + if (! -e $input) { + $input = $tmpldir . "/initdb/initdb-${dbengine}-template.sql"; + } + open(SOURCE, '<', $input) + or die("${VTred}ERROR:${VTnorm} couldn't open script template file \"${input}\"\n"); - # NOTE: - # The design of the configuration process left the possibility - # to expand the SQL templates without interspersing the results - # with shell commands (so that the result would be a sequence - # of SQL commands only). - # Initially, the sub expand_slash_star was intended to be a script - # to which others would connect through a pipe. - # A shell expander would pass --shell to expand_slash_star to enable - # shell commands, while an SQL expander script would not pass - # this option. - # This is why the 'shell' pseudo-option is created. - # Of course, this statement would be better outside the loop, - # but this comment would be far from expand_slash_star invocation. - $markers{'%_shell%'} = 1; # Expand script model expand_slash_star ( sub{ <SOURCE> } , \*DEST |