[Lxr-commits] CVS: lxr/scripts recreatedb.pl,1.8,1.9
Brought to you by:
ajlittoz
From: Andre-Littoz <ajl...@us...> - 2013-11-17 15:50:24
|
Update of /cvsroot/lxr/lxr/scripts In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv9872/scripts Modified Files: recreatedb.pl Log Message: scripts/recreatedb.pl: fix various bugs Fix erroneous extension of output script Insert missing symbols into global dictionary Output in a fresh file (not adding at end) Make possible a customised DB engine per tree Index: recreatedb.pl =================================================================== RCS file: /cvsroot/lxr/lxr/scripts/recreatedb.pl,v retrieving revision 1.8 retrieving revision 1.9 diff -u -d -r1.8 -r1.9 --- recreatedb.pl 2 Sep 2013 17:07:51 -0000 1.8 +++ recreatedb.pl 17 Nov 2013 15:50:21 -0000 1.9 @@ -192,10 +192,13 @@ # If lxr-ctx not given, use default companion filename if (! $lxrctx) { $lxrctx = $lxrconf; - $lxrctx =~ s/\.[^.]*$//; # Remove extension - $lxrctxdft =~ s/^[^.]*//; # Context file extension - $lxrctx =~ s/$/$lxrctxdft/; # Insert correct extension - if ($lxrctx !~ m!/!) { + my $extpos = rindex($lxrctx, '.'); + if (0 <= $extpos) { # Remove the extension + $lxrctx = substr($lxrctx, 0, $extpos); + } + $extpos = rindex($lxrctxdft, '.'); # Default extension + $lxrctx .= substr($lxrctxdft, $extpos); # Insert correct extension + if (0 >= index($lxrctx, '/')) { $lxrctx = $confdir . '/' . $lxrctx; } } @@ -375,10 +378,15 @@ , '%_nodbuser%' => $nodbuser , '%_nodbprefix%' => $nodbprefix , '%_shell%' => 1 - ); -my $sample; -$markers{'%LXRroot%'} = $rootdir; + # Global parameters: directories, server URL + # (may be overwritten, but not recommended!) + , '%LXRconfUser%' => getlogin # OS-user running configuration + , '%LXRroot%' => $rootdir + , '%LXRtmpldir%' => $tmpldir + , '%LXRovrdir%' => $ovrdir + , '%LXRconfdir%' => $confdir + ); $markers{'%DB_name%'} = $dbname if $dbname; $markers{'%DB_user%'} = $dbuser if $dbuser; @@ -394,8 +402,9 @@ ############################################################## unlink "${confdir}/${scriptout}"; -open(DEST, '>>', "${confdir}/${scriptout}") +open(DEST, '>', "${confdir}/${scriptout}") or die("${VTred}ERROR:${VTnorm} couldn't open output file \"${confdir}/$scriptout\"\n"); +print DEST "#!/bin/sh\n"; if ($verbose) { print "\n"; @@ -451,9 +460,9 @@ $dbengine_seen{$treedbengine} = 1; } - my $input = $ovrdir . "/initdb/initdb-${dbengine}-template.sql"; + my $input = $ovrdir . "/initdb/initdb-${treedbengine}-template.sql"; if (! -e $input) { - $input = $tmpldir . "/initdb/initdb-${dbengine}-template.sql"; + $input = $tmpldir . "/initdb/initdb-${treedbengine}-template.sql"; } open(SOURCE, '<', $input) or die("${VTred}ERROR:${VTnorm} couldn't open script template file \"${input}\"\n"); |