Ignore:
Timestamp:
2013-10-30T20:54:49+13:00 (11 years ago)
Author:
ak19
Message:
  1. New subroutine util::set_gnomelib_env that sets the environment for gnomelib needed for running hashfile, suffix and wget which are dependent on the libiconv dll in ext/gnome-lib(-minimal). It's particularly the Mac Lions that need libiconv.2.dylib. 2. Updated the call to hashfile in doc.pm, the call to suffix in Phind.pm and the calls to wget in several perl scripts and modules to call util::set_gnomelib_env, though this will only set the environment once for each subshell.
Location:
main/trunk/greenstone2/perllib
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone2/perllib/classify/Phind.pm

    r27905 r28560  
    167167
    168168    # Ensure the Phind generate scripts are in place
     169
     170    # the suffix binary is dependent on the gnomelib_env (particularly lib/libiconv2.dylib) being set, particularly on Mac Lions (android too?)
     171    &util::set_gnomelib_env(); # this will set the gnomelib env once for each subshell launched, by first checking if GEXTGNOME is not already set
     172
    169173    my $file1 = &FileUtils::filenameConcatenate($ENV{'GSDLHOME'}, "bin", $ENV{'GSDLOS'}, "suffix");
    170174    $file1 .= ".exe" if $ENV{'GSDLOS'} =~ /^windows$/;
  • main/trunk/greenstone2/perllib/doc.pm

    r27538 r28560  
    373373    my $hashfile_exe = &FileUtils::filenameConcatenate($ENV{'GSDLHOME'},"bin",
    374374                       $ENV{'GSDLOS'},"hashfile$osexe");
     375
     376    &util::set_gnomelib_env(); # gnomelib_env (particularly lib/libiconv2.dylib) required to run the hashfile executable on Mac Lions
     377    # The subroutine will set the gnomelib env once for each subshell launched, by first testing if GEXTGNOME is not already set
    375378
    376379    my $result = "NULL";
  • main/trunk/greenstone2/perllib/downloaders/WgetDownload.pm

    r28250 r28560  
    3535use strict;
    3636use Cwd;
     37use util;
    3738use IPC::Open3;
    3839use IO::Select;
     
    139140
    140141    my $self = new BaseDownload($getlist,$inputargs,$hashArgOptLists);
     142
     143    # the wget binary is dependent on the gnomelib_env (particularly lib/libiconv2.dylib) being set, particularly on Mac Lions (android too?)
     144    &util::set_gnomelib_env(); # this will set the gnomelib env once for each subshell launched, by first checking if GEXTGNOME is not already set
    141145
    142146    return bless $self, $class;
  • main/trunk/greenstone2/perllib/g2futil.pm

    r26440 r28560  
    99    }
    1010
    11     my $fedora_client_bin = &util::filename_cat($ENV{'FEDORA_HOME'},"client","bin");
     11    my $fedora_client_bin = &FileUtils::filenameConcatenate($ENV{'FEDORA_HOME'},"client","bin");
    1212    &util::envvar_append("PATH",$fedora_client_bin);
    1313}
     
    1515use strict;
    1616use util;
     17use FileUtils;
    1718
    1819sub run_cmd_old
     
    186187    #$ENV{'fgsPassword'} = $options->{'password'};   
    187188
    188     #my $prog = &util::filename_cat($ENV{'FEDORA_GSEARCH'}, "runRESTClient.sh");
    189     my $prog = &util::filename_cat($fedoragsearch_webapp, "client", "runRESTClient.sh");
     189    #my $prog = &FileUtils::filenameConcatenate($ENV{'FEDORA_GSEARCH'}, "runRESTClient.sh");
     190    my $prog = &FileUtils::filenameConcatenate($fedoragsearch_webapp, "client", "runRESTClient.sh");
    190191
    191192    my $gsearch_commands = "updateIndex deletePid"; # deletePID
     
    214215    #$ENV{'fgsPassword'} = $options->{'password'};   
    215216
    216     #my $prog = &util::filename_cat($ENV{'FEDORA_GSEARCH'}, "runRESTClient.sh");
    217     my $prog = &util::filename_cat($fedoragsearch_webapp, "client", "runRESTClient.sh");
     217    #my $prog = &FileUtils::filenameConcatenate($ENV{'FEDORA_GSEARCH'}, "runRESTClient.sh");
     218    my $prog = &FileUtils::filenameConcatenate($fedoragsearch_webapp, "client", "runRESTClient.sh");
    218219   
    219220    my $gsearch_commands = "updateIndex fromPid"; # fromPID
     
    231232    # if GS3, first look for a fedoragsearch webapp installed in Greenstone's tomcat
    232233    if(defined $ENV{'GSDL3SRCHOME'}) {
    233     $fedoragsearch_webapp = &util::filename_cat($ENV{'GSDL3SRCHOME'},"packages","tomcat","webapps","fedoragsearch");   
    234     return $fedoragsearch_webapp if (&util::dir_exists($fedoragsearch_webapp));
     234    $fedoragsearch_webapp = &FileUtils::filenameConcatenate($ENV{'GSDL3SRCHOME'},"packages","tomcat","webapps","fedoragsearch");   
     235    return $fedoragsearch_webapp if (&FileUtils::directoryExists($fedoragsearch_webapp));
    235236    }
    236237
    237238    # next look for a fedoragsearch webapp installed in Fedora's tomcat
    238239    if(defined $ENV{'FEDORA_HOME'}) {
    239     $fedoragsearch_webapp =  &util::filename_cat($ENV{'FEDORA_HOME'},"tomcat","webapps","fedoragsearch");
    240     return $fedoragsearch_webapp if (&util::dir_exists($fedoragsearch_webapp));
     240    $fedoragsearch_webapp =  &FileUtils::filenameConcatenate($ENV{'FEDORA_HOME'},"tomcat","webapps","fedoragsearch");
     241    return $fedoragsearch_webapp if (&FileUtils::directoryExists($fedoragsearch_webapp));
    241242    }
    242243
     
    287288
    288289    if (opendir(DIR, $full_dir)) {
    289     my @sub_dirs = grep { ($_ !~ /^\./) && (-d &util::filename_cat($full_dir,$_)) } readdir(DIR);
     290    my @sub_dirs = grep { ($_ !~ /^\./) && (-d &FileUtils::filenameConcatenate($full_dir,$_)) } readdir(DIR);
    290291    closedir DIR;
    291292
     
    294295   
    295296    foreach my $hd (@hash_dirs) {
    296         my $full_hash_dir = &util::filename_cat($full_dir,$hd);
     297        my $full_hash_dir = &FileUtils::filenameConcatenate($full_dir,$hd);
    297298        push(@$all_dirs,$full_hash_dir);
    298299    }
    299300
    300301    foreach my $rd (@rec_dirs) {
    301         my $full_rec_dir = &util::filename_cat($full_dir,$rd);
     302        my $full_rec_dir = &FileUtils::filenameConcatenate($full_dir,$rd);
    302303        rec_get_all_hash_dirs($full_rec_dir,$all_dirs);
    303304    }       
     
    329330    my $hash_id = undef;
    330331
    331     my $docmets_filename = &util::filename_cat($hash_dir,"docmets.xml");
     332    my $docmets_filename = &FileUtils::filenameConcatenate($hash_dir,"docmets.xml");
    332333
    333334    if (open(DIN,"<$docmets_filename"))
     
    372373    # to temporarily set CATALINA_HOME to fedora's tomcat. (Catalina is undefined for GS2.)
    373374    my $gs_catalina_home = $ENV{'CATALINA_HOME'} if defined $ENV{'CATALINA_HOME'};
    374     $ENV{'CATALINA_HOME'} = &util::filename_cat($ENV{'FEDORA_HOME'}, "tomcat");
     375    $ENV{'CATALINA_HOME'} = &FileUtils::filenameConcatenate($ENV{'FEDORA_HOME'}, "tomcat");
    375376   
    376377    # 1. Find out which folder to write to: fedora_host or localhost
    377378    # whichever contains fedora.xml is the one we want (if none, exit with error value?)
    378379    my $fedora_home = $ENV{'FEDORA_HOME'};
    379     my $base_path = &util::filename_cat($fedora_home, "tomcat", "conf", "Catalina");
    380 
    381     my $host_path = &util::filename_cat($base_path, $fedora_host);
    382     my $xmlFile = &util::filename_cat($host_path, "fedora.xml");
     380    my $base_path = &FileUtils::filenameConcatenate($fedora_home, "tomcat", "conf", "Catalina");
     381
     382    my $host_path = &FileUtils::filenameConcatenate($base_path, $fedora_host);
     383    my $xmlFile = &FileUtils::filenameConcatenate($host_path, "fedora.xml");
    383384    if (!-e $xmlFile) {
    384385    # check if the folder localhost contains fedoraXML
    385     $host_path = &util::filename_cat($base_path, "localhost");
    386     $xmlFile = &util::filename_cat($host_path, "fedora.xml");
     386    $host_path = &FileUtils::filenameConcatenate($base_path, "localhost");
     387    $xmlFile = &FileUtils::filenameConcatenate($host_path, "fedora.xml");
    387388    if(!-e $xmlFile) {
    388389        # try putting gsdl in this folder, but still print a warning
     
    405406    # 3. If there is already a gsdl.xml file in host_path, compare the string we
    406407    # want to write with what is already in there. If they're the same, we can return
    407     $xmlFile = &util::filename_cat($host_path, "gsdl.xml");
     408    $xmlFile = &FileUtils::filenameConcatenate($host_path, "gsdl.xml");
    408409    if(-e $xmlFile) {
    409410    # such a file exists, so read the contents
     
    428429    # a. First stop the fedora server
    429430    my $script_ext = ($ENV{'GSDLOS'} =~ m/^windows/) ? ".bat" : ".sh";
    430     my $stop_tomcat = &util::filename_cat($fedora_home, "tomcat", "bin", "shutdown".$script_ext);
     431    my $stop_tomcat = &FileUtils::filenameConcatenate($fedora_home, "tomcat", "bin", "shutdown".$script_ext);
    431432    # execute the command
    432433    $! = 0; # does this initialise the return value?
     
    447448
    448449    # c. Restart the fedora server
    449     my $start_tomcat = &util::filename_cat($fedora_home, "tomcat", "bin", "startup".$script_ext);
     450    my $start_tomcat = &FileUtils::filenameConcatenate($fedora_home, "tomcat", "bin", "startup".$script_ext);
    450451    $! = 0;
    451452    $status = system($start_tomcat);
     
    458459    $ENV{'CATALINA_HOME'} = $gs_catalina_home if defined $gs_catalina_home;
    459460   
     461    # the wget binary is dependent on the gnomelib_env (particularly lib/libiconv2.dylib) being set, particularly on Mac Lions (android too?)
     462    &util::set_gnomelib_env(); # this will set the gnomelib env once for each subshell launched, by first checking if GEXTGNOME is not already set
     463
    460464    # Starting up the Fedora server takes a long time. We need to wait for the server to be
    461465    # ready before import can continue, because g2f-import relies on an up-and-running Fedora
  • main/trunk/greenstone2/perllib/giget.pm

    r24601 r28560  
    8080   
    8181    if ((!-e $downloadto_fname) || (-z $downloadto_fname)) {
     82
     83    # the wget binary is dependent on the gnomelib_env (particularly lib/libiconv2.dylib) being set, particularly on Mac Lions (android too?)
     84    &util::set_gnomelib_env(); # this will set the gnomelib env once for each subshell launched, by first checking if GEXTGNOME is not already set
     85
    8286    my $cmd = "wget -nv -T 10 -nc -U \"Mozilla\" -O \"$downloadto_fname\" \"$full_url\"";
    8387##  print STDERR "*** wget cmd:\n $cmd\n";
  • main/trunk/greenstone2/perllib/plugins/LOMPlugin.pm

    r24971 r28560  
    3737use MetadataRead;
    3838use util;
     39use FileUtils;
    3940use XMLParser;
    4041use Cwd;
     
    582583    my $output_dir = $self->{'output_dir'};
    583584
    584     $output_dir = &util::filename_cat($output_dir,"_gsdldown.all");
     585    $output_dir = &FileUtils::filenameConcatenate($output_dir,"_gsdldown.all");
    585586
    586587    if (! -d $output_dir) {
     
    596597    $file_url .= "index.html" if ($file_url =~ m/\/$/);
    597598
    598     my $full_file_url = &util::filename_cat($output_dir,$file_url);
     599    my $full_file_url = &FileUtils::filenameConcatenate($output_dir,$file_url);
    599600    # the path to srcdoc will be used later in extrametadata to associate
    600601    # the lom metadata with the document. Needs to be relative to current
    601602    # directory.
    602     my $srcdoc_path = &util::filename_cat("_gsdldown.all", $file_url);
     603    my $srcdoc_path = &FileUtils::filenameConcatenate("_gsdldown.all", $file_url);
    603604    my $check_timestamp = $self->{'check_timestamp'};
    604605    my $status;
     
    628629    }
    629630    ##print STDERR "**** wget = $wget_cmd\n";
    630 
     631   
     632    # the wget binary is dependent on the gnomelib_env (particularly lib/libiconv2.dylib) being set, particularly on Mac Lions (android too?)
     633    &util::set_gnomelib_env(); # this will set the gnomelib env once for each subshell launched, by first checking if GEXTGNOME is not already set
    631634   
    632635    $status = system($wget_cmd);
  • main/trunk/greenstone2/perllib/plugins/MediaWikiPlugin.pm

    r19123 r28560  
    3535use HTMLPlugin;
    3636use unicode;
     37use util;
     38use FileUtils;
    3739
    3840use strict; # every perl program should have this!
     
    218220        $css_files[$css_file_count++] = $2 if defined $2;
    219221    }
     222
     223    # Set the env for wget once, outside the for loop
     224    # the wget binary is dependent on the gnomelib_env (particularly lib/libiconv2.dylib) being set, particularly on Mac Lions (android too?)
     225    &util::set_gnomelib_env(); # this will set the gnomelib env once for each subshell launched, by first checking if GEXTGNOME is not already set
    220226       
    221227    # download the stylesheets if we haven't downloaded them yet
     
    238244        $css_file =~ s/\?(.+)$//isg; 
    239245       
    240             my $css_file_path = &util::filename_cat($base_dir, $css_file);     
     246            my $css_file_path = &FileUtils::filenameConcatenate($base_dir, $css_file);     
    241247       
    242248        # do nothing if we have already downloaded the css files
     
    251257        mkdir($path_check) if (! -d $path_check );
    252258         }
    253          
     259
    254260             # NOTE: wget needs configuration to directly access Internet
    255261             # These files should already downloaded if we used the MediaWikiDownload             
     
    293299            $style_dir =~ s/import$/style/;
    294300            $css_file =~ m/(.*)\/(.*)$/;
    295             $style_dir = &util::filename_cat($style_dir, $2);           
     301            $style_dir = &FileUtils::filenameConcatenate($style_dir, $2);           
    296302           
    297303            if(open(OUTPUT, ">$style_dir")){   
     
    477483        my $macro_path = $base_dir;
    478484        $macro_path =~ s/import$/macros/;       
    479         my $extradm_file = &util::filename_cat($macro_path, "extra.dm");       
     485        my $extradm_file = &FileUtils::filenameConcatenate($macro_path, "extra.dm");       
    480486       
    481487        my $extra_dm = "";
     
    644650    my $self = shift(@_);
    645651
    646   my $about_macro_file = &util::filename_cat($ENV{'GSDLHOME'}, "macros", "about.dm");
     652  my $about_macro_file = &FileUtils::filenameConcatenate($ENV{'GSDLHOME'}, "macros", "about.dm");
    647653  my $about_page_content = "";
    648654  if (open(INPUT, "<$about_macro_file")){
  • main/trunk/greenstone2/perllib/util.pm

    r28460 r28560  
    16501650}
    16511651
     1652# Sets the gnomelib_env. Based on the logic in wvware.pl which can perhaps be replaced with a call to this function in future
     1653sub set_gnomelib_env
     1654{
     1655    ## SET THE ENVIRONMENT AS DONE IN SETUP.BASH/BAT OF GNOME-LIB
     1656    # Though this is only needed for darwin Lion at this point (and android, though that is untested)
     1657
     1658    my $env_vars="";
     1659
     1660    my $libext = "so";
     1661    if ($ENV{'GSDLOS'} =~ m/^windows$/i) {
     1662    #return $env_vars;
     1663    return;
     1664    } elsif ($ENV{'GSDLOS'} =~ m/^darwin$/i) {
     1665    $libext = "dylib";
     1666    }
     1667
     1668    if (!defined $ENV{'GEXTGNOME'}) {
     1669        ##print STDERR "@@@ Setting GEXTGNOME env\n";
     1670
     1671    my $gnome_dir = &FileUtils::filenameConcatenate($ENV{'GSDLHOME'},"ext","gnome-lib-minimal");
     1672
     1673    if(! -d $gnome_dir) {
     1674        $gnome_dir = &FileUtils::filenameConcatenate($ENV{'GSDLHOME'},"ext","gnome-lib");
     1675
     1676        if(! -d $gnome_dir) {
     1677        $gnome_dir = "";
     1678        }
     1679    }
     1680   
     1681    # now set other the related env vars,
     1682    # IF we've found the gnome-lib dir installed in the ext folder 
     1683
     1684    if ($gnome_dir ne "" && -f &FileUtils::filenameConcatenate($gnome_dir, $ENV{'GSDLOS'}, "lib", "libiconv.$libext")) {
     1685        $ENV{'GEXTGNOME'} = $gnome_dir;
     1686        $ENV{'GEXTGNOME_INSTALLED'}=&FileUtils::filenameConcatenate($ENV{'GEXTGNOME'}, $ENV{'GSDLOS'});
     1687       
     1688        my $gnomelib_bin = &FileUtils::filenameConcatenate($ENV{'GEXTGNOME_INSTALLED'}, "bin");
     1689        if(-d $gnomelib_bin) { # no bin subfolder in GS binary's cutdown gnome-lib-minimal folder
     1690        &util::envvar_prepend("PATH", $gnomelib_bin);
     1691        #$env_vars = "export PATH=".$ENV{'PATH'}.";";
     1692        }
     1693
     1694        # util's prepend will create LD/DYLD_LIB_PATH if it doesn't exist yet
     1695        my $gextlib = &FileUtils::filenameConcatenate($ENV{'GEXTGNOME_INSTALLED'}, "lib");
     1696
     1697        if($ENV{'GSDLOS'} eq "linux") {
     1698        &util::envvar_prepend("LD_LIBRARY_PATH", $gextlib);
     1699        #$env_vars .= "export LD_LIBRARY_PATH=".$ENV{'LD_LIBRARY_PATH'};
     1700        }
     1701        elsif ($ENV{'GSDLOS'} eq "darwin") {
     1702        #&util::envvar_prepend("DYLD_LIBRARY_PATH", $gextlib);
     1703        &util::envvar_prepend("DYLD_FALLBACK_LIBRARY_PATH", $gextlib);
     1704        #$env_vars .= "export DYLD_FALLBACK_LIBRARY_PATH=".$ENV{'DYLD_FALLBACK_LIBRARY_PATH'};
     1705        }
     1706    }
     1707   
     1708    # Above largely mimics the setup.bash of the gnome-lib-minimal.
     1709    # Not doing the devel-srcpack that gnome-lib-minimal's setup.bash used to set
     1710    # Not exporting GSDLEXTS variable either
     1711    }
     1712
     1713#    print STDERR "@@@@@ GEXTGNOME: ".$ENV{'GEXTGNOME'}."\n\tINSTALL".$ENV{'GEXTGNOME_INSTALLED'}."\n";
     1714#    print STDERR "\tPATH".$ENV{'PATH'}."\n";
     1715#    print STDERR "\tLD_LIB_PATH".$ENV{'LD_LIBRARY_PATH'}."\n" if $ENV{'LD_LIBRARY_PATH};
     1716#    print STDERR "\tDYLD_FALLBACK_LIB_PATH".$ENV{'DYLD_FALLBACK_LIBRARY_PATH'}."\n" if $ENV{'DYLD_FALLBACK_LIBRARY_PATH};
     1717
     1718    # if no GEXTGNOME, maybe users didn't need gnome-lib to run gnomelib/libiconv dependent binaries like hashfile, suffix, wget
     1719    # (wvware is launched in a gnomelib env from its own script, but could possibly go through this script in future)
     1720
     1721    #return $env_vars; #print STDOUT $env_vars;
     1722}
     1723
     1724
    16521725
    16531726## @function augmentINC()
Note: See TracChangeset for help on using the changeset viewer.