Thread: [Lxr-commits] CVS: lxr genxref,1.64,1.65
Brought to you by:
ajlittoz
From: Andre-Littoz <ajl...@us...> - 2012-12-04 13:47:16
|
Update of /cvsroot/lxr/lxr In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv9515 Modified Files: genxref Log Message: genxref: improve initial environment tests Index: genxref =================================================================== RCS file: /cvsroot/lxr/lxr/genxref,v retrieving revision 1.64 retrieving revision 1.65 diff -u -d -r1.64 -r1.65 --- genxref 21 Nov 2012 13:33:45 -0000 1.64 +++ genxref 4 Dec 2012 13:47:13 -0000 1.65 @@ -44,10 +44,11 @@ , "help!" , "url=s" , "version=s" - , "allurls!" + , "allurls" , "allversions:s" - , "reindexall!" - , "checkonly!" + , "reindexall" + , "checkonly" + , "accept" ); if ($option{'help'}) { @@ -58,10 +59,10 @@ The genxref program automatically generates LXR database cross-reference tokens for a set of URL configuration blocks and source code versions. These -are both defined in the lxr.conf configuration file. Each "URL" is a separate +are both defined in the $lxrconf configuration file. Each "URL" is a separate source tree; LXR separates and identifies these by their URL. Each "version" is -a different version of the source tree being indexed. See lxr.conf or -lxr.conf.template for configuring URLs and versions. +a different version of the source tree being indexed. See file $lxrconf or +script configure-lxr.pl for configuring URLs and versions. Valid options are: --help Print a summary of the options. @@ -71,6 +72,7 @@ --allversions Generate tokens for all versions of the code (default). --reindexall Purges existing index data --checkonly Verify tools version and stop + --accept Accept parameter suggestions to continue with indexing Report bugs at http://sourceforge.net/projects/lxr/. END_HELP @@ -79,10 +81,6 @@ my $failure = 0; # Cumulative failure indicator -# TODO: implement --allurls -# die("${VTred}Option --allurls not implemented.${VTnorm} Use --url instead.\n") -# if $option{'allurls'}; - if ( !$option{'checkonly'} && !$option{'url'} && !$option{'allurls'} @@ -117,7 +115,7 @@ } else { print "${VTred}ERROR:${VTnorm} could not open configuration file ${VTred}$lxrconf${VTnorm}\n"; exit(1) unless $option{'checkonly'}; - $failure = 1; + $failure |= 1; } @@ -134,30 +132,39 @@ print VTCUU(1), "${VTgreen}[ OK ]${VTnorm}\n"; } else { print VTCUU(1), "${VTred}[${VTslow}FAILED${VTnorm}${VTred}]${VTnorm}\n"; - $failure = 1; + $failure |= 1; } # Check tools version # Return value: -# . -1. OK but conf parm set -# . 0 everything fine -# . 1 software tool not found -# . 2 version too low +# . -2. version too low for forced parm (see 1) +# . -1 version too low +# . 0 software tool not found +# . 1 OK but conf parm set +# . 2 everything fine sub check_tool { my ($tl_param, $tl_name, $tl_option, $tl_version) = @_; my $tool; my $toolloc; - my $toolforced; + my $toolforced = 0; my $version; if ($config && $config->{$tl_param}) { $tool = $config->{$tl_param}; - $toolloc = `command -v $tl_name 2>/dev/null`; - $toolloc =~ s/\n$//s; - if ($tool ne $toolloc) { - print "${VTyellow}'$tl_param' not equal to `command -v $tl_name`${VTnorm}\n"; - print "If this is a non-system copy, ignore this warning\n"; + # Make further tests on designated tool + $toolloc = `command -v $tool 2>/dev/null`; + if ($toolloc !~ s/\n$//s) { + print "${VTred}'$tl_param' does not name an existing $tl_name utility${VTnorm}\n"; + delete $config->{$tl_param}; + } else { + my $systoolloc = `command -v $tl_name 2>/dev/null`; + if ($systoolloc =~ s/\n$//s) { + if ($systoolloc ne $toolloc) { + print "${VTyellow}'$tl_param' not equal to `command -v $tl_name`${VTnorm}\n"; + print "If this is a non-system copy, ignore this warning\n"; + } + } } } else { print("${VTyellow}Parameter '$tl_param' not defined - trying to find $tl_name${VTnorm}\n"); @@ -168,15 +175,18 @@ } if (!$toolloc) { print "${VTred}$tl_name not found,${VTnorm} `command -v $tl_name` returned a null string\n"; - return 1; + if ($config) { + delete $config->{$tl_param}; + } + return 0; } if ($config) { if (!$config->{$tl_param}) { $config->{$tl_param} = $toolloc; - $toolforced = -1; + $toolforced = 1; $tool = $toolloc; print "$tl_name found at ${VTyellow}$toolloc${VTnorm}\n"; - print "Manually update lxr.conf for permanent setting if needed\n"; + print "Manually update $lxrconf for permanent setting if needed\n"; } } else { print "$tl_name found at ${VTyellow}$toolloc${VTnorm}\n"; @@ -200,57 +210,77 @@ ) { print VTCUU(1), "${VTred}[${VTslow}FAILED${VTnorm}${VTred}]${VTnorm}\n"; print "$tl_name version $tl_version or above required, found $version\n"; - return 2; + return -1 - $toolforced; } else { print VTCUU(1), "${VTgreen}[ OK ]${VTnorm}\n"; } } else { print VTCUU(1), "${VTyellow}Checked:${VTnorm}\n"; } - return $toolforced // 0; + return 2 -$toolforced; } my $foundglimpse = 0; my $foundswishe = 0; my $ct = check_tool('ectagsbin', 'ctags', '--version', '5'); -if ($ct > 0) { - if ($ct == 1) { - print "genxref can't index source-tree without ctags\n"; - print "Find its location or install it and fix 'ectagsbin'\n"; - } - $failure = 1; -} -$ct = check_tool('glimpsebin', 'glimpse', '-V', '0'); -if ($ct <= 0) { - $foundglimpse = 2 * $ct + 1; -} -check_tool('glimpseindex', 'glimpseindex', '-V', '0'); -$ct = check_tool('swishbin', 'swish-e', '-V', '2.1'); -if ($ct <= 0) { - $foundswishe = 2 * $ct + 1; +if ($ct == 0) { + print "genxref can't index source-tree without ctags\n"; + print "Find its location or install it and fix 'ectagsbin'\n"; + $failure |= 1; +} elsif ($ct == 1) { + print "ctags fixed for genxref, but LXR browsing will not work\n"; + $failure |= 2; +} elsif ($ct < 0) { + $failure |= 1; } -if ( $foundglimpse == 1 - && $foundswishe == 1 - ) { - print "${VTred}Both 'glimpsebin' and 'swishbin' defined${VTnorm}\n"; - print "Choose one of them by commenting the other in lxr.conf\n"; - $failure = 1; -} +$foundglimpse = check_tool('glimpsebin', 'glimpse', '-V', '0'); +check_tool('glimpseindex', 'glimpseindex', '-V', '0'); +$foundswishe = check_tool('swishbin', 'swish-e', '-V', '2.1'); -if ( $foundglimpse == -1 - && $foundswishe == -1 - ) { +if ($foundglimpse == 0 && $foundswishe == 0) { + # No engine defined - propose to go on without print "${VTyellow}Neither 'glimpsebin' nor 'swishbin' defined${VTnorm}\n"; - if ($foundglimpse) { - print "Using existing ${VTyellow}glimpse${VTnorm}\n"; - print "If you prefer swish-e, configure lxr.conf\n"; - } elsif ($foundswishe){ - print "Using existing ${VTyellow}swish-e${VTnorm}\n"; - print "If you prefer glimpse, configure lxr.conf\n"; - } else { - print "${VTyellow}None found in the system - Free-text search disabled${VTnorm}\n"; + print "${VTyellow}Disabling free-text search${VTnorm}\n"; + if ($config) { + $config->{'glimpsebin'} = '/usr/bin/true'; + } + $failure |= 2; +} elsif ($foundglimpse == 2 && $foundswishe == 2) { + # Both engines defined - do not know what to do + print "${VTred}Both 'glimpsebin' and 'swishbin' defined${VTnorm}\n"; + print "Choose one of them by commenting the other in $lxrconf\n"; + $failure |= 1; +} elsif ($foundglimpse <= 0 && $foundswishe <= 0) { + # Can't use any search engine + # (either not found or version too low) + $failure |= 1 +} elsif ($foundglimpse == 1 && $foundswishe <= 1) { + # glimpse has been forced, but glimpse is prefered if both + print "${VTyellow}Warning:${VTnorm} using existing ${VTbold}glimpse${VTnorm}\n"; + delete $config->{'swishbin'} if ($config); + $failure |= 2; +} elsif ($foundswishe == 1 && $foundglimpse <= 0) { + # swish-e has been forced, but glimpse is prefered if both + print "${VTyellow}Warning:${VTnorm} using existing ${VTbold}swish-e${VTnorm}\n"; + delete $config->{'glimpsebin'} if ($config); + $failure |= 2; +} elsif ($foundglimpse == 2) { + # Standard glimpse selection, but for the case of both + # engines present and swish-e has too low a version + if ($foundswishe == -1) { + print "${VTyellow}Warning:${VTnorm} forcing use of ${VTbold}glimpse${VTnorm}\n"; + delete $config->{'swishbin'} if ($config); + $failure |= 2; + } +} elsif ($foundswishe == 2) { + # Standard swish-e selection, but for the case of both + # engines present and glimpse has too low a version + if ($foundglimpse == -1) { + print "${VTyellow}Warning:${VTnorm} forcing use of ${VTbold}swish-e${VTnorm}\n"; + delete $config->{'glimpsebin'} if ($config); + $failure |= 2; } } @@ -259,6 +289,17 @@ print "${VTyellow}genxref stopped without indexing by --checkonly option${VTnorm}\n"; exit; } +if ($failure > 1) { + if ($option{'accept'}) { + print "\nParameter changes accepted by option --accept without writing them in $lxrconf\n"; + print "Indexing may eventually complete but expect malfunction in LXR browsing\n"; + print "till you fix configuration file $lxrconf\n\n"; + $failure = 0; + } else { + print "\ngenxref suggested changes to your configuration\n"; + print "You can test their effect with option ${VTyellow}--accept${VTnorm}\n"; + } +} if ($failure > 0) { die "${VTred}Aborting due to previous errors${VTnorm}"; } @@ -339,9 +380,9 @@ $autoversionflag = 1; } else { @versions = $config->varrange('v'); - die - "${VTred}Option --allversions cannot be used because no versions found automatically.${VTnorm} Use --version=VERSION or fix lxr.conf.\n" - if scalar @versions <= 0; + die "${VTred}Option --allversions cannot be used because no versions found automatically.${VTnorm}" + . "Use --version=VERSION or fix $lxrconf.\n" + if scalar @versions <= 0; } } else { @versions = $option{'version'}; |