Changeset 28560 for main


Ignore:
Timestamp:
2013-10-30T20:54:49+13:00 (10 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
Files:
13 edited

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone2/bin/script/explode_metadata_database.pl

    r27901 r28560  
    1414use encodings;
    1515use extrametautil;
     16use util;
     17use FileUtils;
    1618use printusage;
    1719use parse2;
     
    8789    'type' => "string",
    8890    # parsearg left "" as default
    89     #'deft' => &util::filename_cat ($ENV{'GSDLHOME'}, "collect"),
     91    #'deft' => &FileUtils::filenameConcatenate($ENV{'GSDLHOME'}, "collect"),
    9092    'deft' => "",
    9193    'reqd' => "no",
     
    349351
    350352    # Explode means just that: the original file is deleted
    351     &util::rm($filename);
     353    &FileUtils::removeFiles($filename);
    352354    $plugobj->clean_up_after_exploding();
    353355
     
    364366    die "Error: document directory $documents_directory already exists (bailing).\n";
    365367    }
    366     &util::mk_dir($documents_directory);
    367 
    368     my $documents_metadata_xml_file = &util::filename_cat($documents_directory, "metadata.xml");
     368    &FileUtils::makeDirectory($documents_directory);
     369
     370    my $documents_metadata_xml_file = &FileUtils::filenameConcatenate($documents_directory, "metadata.xml");
    369371    if (-e $documents_metadata_xml_file) {
    370372    die "Error: documents metadata.xml file $documents_metadata_xml_file already exists (bailing).\n";
     
    427429            # by first of all stripping any trailing slash and then always ensuring one is used through filename_cat
    428430            $document_prefix =~ s/(\/|\\)$//;
    429             $document_file_full = &util::filename_cat($document_prefix, "$value$document_suffix");
     431            $document_file_full = &FileUtils::filenameConcatenate($document_prefix, "$value$document_suffix");
    430432        } else { # the doc prefix may also contain the prefix of the actual *filename* following the directory
    431433            $document_file_full = $document_prefix . $value . $document_suffix;
     
    560562    $document_file_full =~ /([^\/]+)$/;
    561563    $document_file_name = $1;
    562     $local_document_file = &util::filename_cat($documents_directory, $document_file_name);
     564    $local_document_file = &FileUtils::filenameConcatenate($documents_directory, $document_file_name);
     565
     566    # the wget binary is dependent on the gnomelib_env (particularly lib/libiconv2.dylib) being set, particularly on Mac Lions (android too?)
     567    &util::set_gnomelib_env(); # this will set the gnomelib env once for each subshell launched, by first checking if GEXTGNOME is not already set
    563568
    564569    my $wget_options = "--quiet";
     
    576581    else {
    577582    # convert the dirseps in filepath to correct dir sep for OS
    578     $document_file_full = &util::filename_cat($document_file_full);
     583    $document_file_full = &FileUtils::filenameConcatenate($document_file_full);
    579584    my $dir_sep = &util::get_os_dirsep();
    580585
     
    588593    if (!$is_absolute) {
    589594        $document_file_full
    590         = &util::filename_cat($orig_base_dir,$document_file_full);
    591     }
    592 
    593     $local_document_file = &util::filename_cat($documents_directory, $document_file_name);
     595        = &FileUtils::filenameConcatenate($orig_base_dir,$document_file_full);
     596    }
     597
     598    $local_document_file = &FileUtils::filenameConcatenate($documents_directory, $document_file_name);
    594599
    595600    if (-e $document_file_full) {
    596         &util::cp($document_file_full, $documents_directory);
     601        &FileUtils::copyFiles($document_file_full, $documents_directory);
    597602    }
    598603   
     
    606611        # file local to metadata record
    607612        # => copy has been made successfully, so remove original
    608         &util::rm($document_file_full);
     613        &FileUtils::removeFiles($document_file_full);
    609614        }
    610615    }
  • main/trunk/greenstone2/bin/script/grab_collection.pl

    r2671 r28560  
    11#!/usr/bin/perl -w
    22
     3use util;
    34
    45# Both this script and its associated process_html.pl were written by
     
    550551    }
    551552   
     553    # the wget binary is dependent on the gnomelib_env (particularly lib/libiconv2.dylib) being set, particularly on Mac Lions (android too?)
     554    &util::set_gnomelib_env(); # this will set the gnomelib env once for each subshell launched, by first checking if GEXTGNOME is not already set
     555
    552556    # wget is set to 'q - quiet' and 'nc - dont clobber existing files'
    553557    $kommand = $wget.' -qnc --directory-prefix='.$temp_outputdir.$image_dir.' "'.$found.'"';
  • main/trunk/greenstone2/bin/script/gsWget.pl

    r2304 r28560  
    3636
    3737use util;
     38use FileUtils;
    3839
    3940# wget should live in the Greenstone directory structure
    4041# we'll bail if we can't find it
    4142my $exe = &util::get_os_exe ();
    42 my $cmd = &util::filename_cat ($ENV{'GSDLHOME'}, "bin", $ENV{'GSDLOS'}, "wget");
     43my $cmd = &FileUtils::filenameConcatenate($ENV{'GSDLHOME'}, "bin", $ENV{'GSDLOS'}, "wget");
    4344$cmd .= $exe;
    4445if (! -e "$cmd") {
     
    5253    $cmd = "wget";
    5354}
     55
     56# the wget binary is dependent on the gnomelib_env (particularly lib/libiconv2.dylib) being set, particularly on Mac Lions (android too?)
     57&util::set_gnomelib_env(); # this will set the gnomelib env once for each subshell launched, by first checking if GEXTGNOME is not already set
    5458
    5559# command-line parameters
  • main/trunk/greenstone2/bin/script/importfrom.pl

    r17198 r28560  
    4040use colcfg;
    4141use util;
     42use FileUtils;
    4243use parsargv;
    4344use FileHandle;
     
    6263    print STDERR "   -debug                 Print imported text to STDOUT\n";
    6364    print STDERR "   -collectdir directory  Collection directory (defaults to " .
    64     &util::filename_cat ($ENV{'GSDLHOME'}, "collect") . ")\n";
     65    &FileUtils::filenameConcatenate($ENV{'GSDLHOME'}, "collect") . ")\n";
    6566    print STDERR "   -out                   Filename or handle to print output status to.\n";
    6667    print STDERR "                          The default is STDERR\n\n";
     
    9697{
    9798    my ($wget_cmd,$out,$verbosity) = @_;
     99
     100    # the wget binary is dependent on the gnomelib_env (particularly lib/libiconv2.dylib) being set, particularly on Mac Lions (android too?)
     101    &util::set_gnomelib_env(); # this will set the gnomelib env once for each subshell launched, by first checking if GEXTGNOME is not already set
    98102
    99103    if ($verbosity>2) {
     
    210214    print $out "Getting document $doc_url\n";
    211215
    212     &util::mk_dir($output_dir)  if (!-e "$output_dir");
    213 
    214     my $full_id_fname = &util::filename_cat($output_dir,$id_fname);
     216    &FileUtils::makeDirectory($output_dir)  if (!-e "$output_dir");
     217
     218    my $full_id_fname = &FileUtils::filenameConcatenate($output_dir,$id_fname);
    215219
    216220    my $wget_cmd = "wget $wgetopt --quiet -O \"$full_id_fname\" \"$doc_url\"";
     221
     222    # the wget binary is dependent on the gnomelib_env (particularly lib/libiconv2.dylib) being set, particularly on Mac Lions (android too?)
     223    &util::set_gnomelib_env(); # this will set the gnomelib env once for each subshell launched, by first checking if GEXTGNOME is not already set
    217224
    218225    if (system($wget_cmd)!=0) {
     
    245252    my $i_os = $i; #convert OAI set separators (:) to OS dir sep
    246253    $i_os =~ s/:/$ds/g;
    247     my $file_i = &util::filename_cat($output_dir,"$i_os.oai");
     254    my $file_i = &FileUtils::filenameConcatenate($output_dir,"$i_os.oai");
    248255
    249256    # obtain record
    250257    my $wget_cmd = "wget $wgetopt -q -O - \"$url\"";
     258
     259    # the wget binary is dependent on the gnomelib_env (particularly lib/libiconv2.dylib) being set, particularly on Mac Lions (android too?)
     260    &util::set_gnomelib_env(); # this will set the gnomelib env once for each subshell launched, by first checking if GEXTGNOME is not already set
    251261
    252262    open (OAIIN,"$wget_cmd|")
     
    267277    my ($i_dir,$unused) = dir_file_split($file_i_url);
    268278
    269     &util::mk_all_dir($i_dir);
     279    &FileUtils::makeAllDirectories($i_dir);
    270280
    271281    # look out for identifier tag in metadata section
     
    286296##          $revised_doc_url =~ s/hdl\.handle\.net/mcgonagall.cs.waikato.ac.nz:8080\/dspace\/handle/;
    287297           
    288             my $srcdocs_dir = &util::filename_cat($i_dir,"srcdocs");
     298            my $srcdocs_dir = &FileUtils::filenameConcatenate($i_dir,"srcdocs");
    289299
    290300            if (get_oai_document($revised_doc_url,$srcdocs_dir, $out)) {               
     
    360370    # get acquire list
    361371    my $acquire = [];
    362     $configfilename = &util::filename_cat ($ENV{'GSDLCOLLECTDIR'}, "etc", "collect.cfg");
     372    $configfilename = &FileUtils::filenameConcatenate($ENV{'GSDLCOLLECTDIR'}, "etc", "collect.cfg");
    363373    if (-e $configfilename) {
    364374    $collectcfg = &colcfg::read_collect_cfg ($configfilename);
     
    383393    # fill in the default import directory if none
    384394    # were supplied, turn all \ into / and remove trailing /
    385     $importdir = &util::filename_cat ($ENV{'GSDLCOLLECTDIR'}, "import") if $importdir eq "";
     395    $importdir = &FileUtils::filenameConcatenate($ENV{'GSDLCOLLECTDIR'}, "import") if $importdir eq "";
    386396    $importdir =~ s/[\\\/]+/\//g;
    387397    $importdir =~ s/\/$//;
     
    391401    print $out "Warning - removing current contents of the import directory\n";
    392402    print $out "          in preparation for the acquire\n";
    393     &util::rm_r ($importdir);
     403    &FileUtils::removeFilesRecursive($importdir);
    394404    }
    395405
  • main/trunk/greenstone2/bin/script/mirror.pl

    r24362 r28560  
    8484
    8585    # get the etc directory
    86     $etcdir = &util::filename_cat ($ENV{'GSDLCOLLECTDIR'}, "etc");
     86    $etcdir = &FileUtils::filenameConcatenate($ENV{'GSDLCOLLECTDIR'}, "etc");
    8787   
    8888    # check the collection configuration file for options
    8989    my $interval = 0;
    90     $configfilename = &util::filename_cat ($ENV{'GSDLCOLLECTDIR'},
     90    $configfilename = &FileUtils::filenameConcatenate($ENV{'GSDLCOLLECTDIR'},
    9191                       "etc", "collect.cfg");
    9292    if (-e $configfilename) {
     
    107107    # make sure there is an import directory
    108108    if (! -e "$importdir") {
    109     &util::mk_dir($importdir);
     109    &FileUtils::makeDirectory($importdir);
    110110    }
    111111
  • 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.