greenstone.org greenstone wiki greenstone trac planet greenstone

Changeset 16385

Show
Ignore:
Timestamp:
2008-07-14 14:41:00 (3 months ago)
Author:
ak19
Message:

Processes new fedorahome and fedoraversion variables if these have been set in the gsdlsite.cfg files. Otherwise, if FEDORA_HOME env var has been set, it uses this to set either FEDORA2_HOME or FEDORA3_HOME as is needed by the Fedora import and build scripts. Additional minor (cosmetic) changes.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • greenstone3/trunk/web/WEB-INF/cgi/gsdlCGI.pm

    r16327 r16385  
    205205sub get_config_info { 
    206206    my $self = shift @_; 
    207     my ($infotype, $ignore) = @_; 
     207    my ($infotype, $optional) = @_; 
    208208 
    209209    my $site_filename = $self->{'site_filename'}; 
     
    221221 
    222222    if ((!defined $loc) || ($loc =~ m/^\s*$/)) { 
    223         if((!defined $ignore) || (!$ignore)) { 
     223        if((!defined $optional) || (!$optional)) { 
    224224            $self->generate_error("$infotype is not set in $site_filename"); 
    225225        } 
     
    264264sub get_java_home { 
    265265    my $self = shift @_; 
     266    my ($optional) = @_; 
    266267     
    267268    if (defined $self->{'javahome'}) { 
     
    269270    } 
    270271 
    271     my $javahome = $self->get_config_info("javahome"); 
    272  
    273     $javahome =~ s/(\/|\\)$//; # remove trailing slash 
    274  
     272    my $javahome = $self->get_config_info("javahome", $optional); 
     273    if(defined $javahome) { 
     274        $javahome =~ s/(\/|\\)$//; # remove trailing slash 
     275        $self->{'javahome'} = $javahome; 
     276    } 
    275277    return $javahome; 
    276278} 
     
    285287    my $perlpath = $self->get_config_info("perlpath"); 
    286288 
    287     $perlpath =~ s/(\/|\\)$//; # remove trailing slash 
    288  
     289    if(defined $perlpath) { 
     290        $perlpath =~ s/(\/|\\)$//; # remove trailing slash 
     291        $self->{'perlpath'} = $perlpath; 
     292    } 
    289293    return $perlpath; 
    290294} 
     
    317321    } 
    318322 
    319     my $ignore = 1; # ignore absence of gwcgi if not found 
    320     my $library_url = $self->get_config_info("gwcgi", $ignore); 
     323    my $optional = 1; # ignore absence of gwcgi if not found 
     324    my $library_url = $self->get_config_info("gwcgi", $optional); 
    321325    if(defined $library_url) { 
    322326        $library_url =~ s/(\/|\\)$//; # remove trailing slash 
     
    337341        } 
    338342    } 
    339          
     343 
     344    $self->{'library_url_suffix'} = $library_url; 
    340345    return $library_url; 
     346} 
     347 
     348sub setup_fedora_homes { 
     349    my $self = shift @_; 
     350    my ($optional) = @_; 
     351 
     352    # The following will still allow the ENV FEDORA_HOME variables to have been set outside  
     353    # the gsdlsite.cfg file. Existing env vars are only overwritten if they've *also* been 
     354    # defined in gsdlsite.cfg. 
     355    if(!defined $self->{'fedora_home'} && !defined $self->{'fedora_version'})  
     356    { 
     357        # Can look for any fedorahome properties defined in the gsdlsite.cfg file 
     358        $self->{'fedora_home'} = $self->get_config_info("fedorahome", $optional); 
     359        $self->{'fedora_version'} = $self->get_config_info("fedoraversion", $optional); 
     360         
     361        if(defined $self->{'fedora_home'} && defined $self->{'fedora_version'})  
     362        { 
     363            # need to set $ENV{FEDORA2_HOME} or $ENV{FEDORA3_HOME} *and* $ENV{FEDORA_HOME} 
     364            my $env_name = "FEDORA".$self->{'fedora_version'}."_HOME"; 
     365            $ENV{$env_name} = $self->{'fedora_home'}; 
     366            $ENV{'FEDORA_HOME'} = $self->{'fedora_home'};  
     367        }  
     368 
     369        # if none were specified in the file, use the ENV vars if FEDORA_HOME is already set there 
     370        elsif(defined $ENV{'FEDORA_HOME'})  
     371        {  
     372            $self->{'fedora_home'} = $ENV{'FEDORA_HOME'}; 
     373            if(defined $ENV{'FEDORA2_HOME'} && ($ENV{'FEDORA_HOME'} eq $ENV{'FEDORA2_HOME'}))  
     374            { 
     375                $self->{'fedora_version'} = 2; 
     376            }  
     377            else # try defaulting to Fedora 3 
     378            {  
     379                print STDERR "Setting FEDORA3_HOME env variable to FEDORA_HOME (".$ENV{'FEDORA_HOME'}.").\n"; 
     380                $self->{'fedora_version'} = 3;  
     381                $ENV{'FEDORA3_HOME'} = $ENV{'FEDORA_HOME'}; 
     382            } 
     383        } 
     384    } 
    341385} 
    342386 
     
    374418        } 
    375419    } 
    376      
    377     # Uncomment these lines if you want to read the "javahome" and "perlpath" properties  
    378     # from values you have set in the gsdl(3)site.cfg config file 
    379     #my $javahome = $self->get_java_home();      
    380     #$ENV{'JAVA_HOME'} = $javahome; 
     420 
     421    # Uncomment these lines if you want to read the "perlpath" property from 
     422    # the gsdl(3)site.cfg config file into PATH 
    381423    #if(!defined $perl_bin_dir) { 
    382424        #$perl_bin_dir = $self->get_perl_path(); 
    383425        #&util::envvar_append("PATH", $perl_bin_dir); 
    384426    #} 
     427     
     428    # gsdl(3)site.cfg can specify JAVA_HOME and FEDORA_HOME along with Fedora's version. Both 
     429    # are needed (by scripts g2f-import and g2f-buildcol) when using Greenstone 2 with Fedora. 
     430    my $optional = 1; # ignore absence of these properties in gsdl(3)site.cfg if not found 
     431 
     432    if(!defined $ENV{'JAVA_HOME'}) { 
     433        $ENV{'JAVA_HOME'} = $self->get_java_home($optional); 
     434    } 
     435 
     436    $self->setup_fedora_homes($optional); 
    385437} 
    386438