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/bin/script
Files:
5 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
Note: See TracChangeset for help on using the changeset viewer.