Changeset 29371

Show
Ignore:
Timestamp:
16.10.2014 11:25:27 (5 years ago)
Author:
kjdon
Message:

changing the deprecated util methods to newer FileUtils? methods

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone2/bin/script/build

    r24362 r29371  
    6060use parsargv; 
    6161use util; 
     62use FileUtils; 
    6263use cfgread; 
    6364use colcfg; 
     
    7273my $path_separator = ":"; 
    7374$path_separator = ";" if $ENV{'GSDLOS'} =~ /^windows$/; 
    74 $ENV{'PATH'} = &util::filename_cat($ENV{'GSDLHOME'}, "bin", $ENV{'GSDLOS'}) . 
    75     $path_separator . &util::filename_cat($ENV{'GSDLHOME'}, "bin", "script") . 
     75$ENV{'PATH'} = &FileUtils::filenameConcatenate($ENV{'GSDLHOME'}, "bin", $ENV{'GSDLOS'}) . 
     76    $path_separator . &FileUtils::filenameConcatenate($ENV{'GSDLHOME'}, "bin", "script") . 
    7677    $path_separator . $ENV{'PATH'}; 
    7778 
     
    111112{ 
    112113    die "GSDL3HOME not set." unless $ENV{'GSDL3HOME'}; 
    113     $cdir = &util::filename_cat ($ENV{'GSDL3HOME'}, "sites", $site, "collect") unless $collectdir =~ /\w/; 
     114    $cdir = &FileUtils::filenameConcatenate ($ENV{'GSDL3HOME'}, "sites", $site, "collect") unless $collectdir =~ /\w/; 
    114115    $gs_mode = "gs3"; 
    115116} 
    116117else 
    117118{ 
    118     $cdir = &util::filename_cat ($ENV{'GSDLHOME'}, "collect") unless $collectdir =~ /\w/; 
     119    $cdir = &FileUtils::filenameConcatenate ($ENV{'GSDLHOME'}, "collect") unless $collectdir =~ /\w/; 
    119120    $gs_mode = "gs2"; 
    120121} 
    121122 
    122 my $importdir = &util::filename_cat ($cdir, $collection, "import"); 
    123 my $archivedir = &util::filename_cat ($cdir, $collection, "archives"); 
    124 my $buildingdir = &util::filename_cat ($cdir, $collection, "building"); 
    125 my $indexdir = &util::filename_cat ($cdir, $collection, "index"); 
    126 my $etcdir = &util::filename_cat ($cdir, $collection, "etc"); 
    127 my $bindir = &util::filename_cat ($ENV{'GSDLHOME'}, "bin"); 
     123my $importdir = &FileUtils::filenameConcatenate ($cdir, $collection, "import"); 
     124my $archivedir = &FileUtils::filenameConcatenate ($cdir, $collection, "archives"); 
     125my $buildingdir = &FileUtils::filenameConcatenate ($cdir, $collection, "building"); 
     126my $indexdir = &FileUtils::filenameConcatenate ($cdir, $collection, "index"); 
     127my $etcdir = &FileUtils::filenameConcatenate ($cdir, $collection, "etc"); 
     128my $bindir = &FileUtils::filenameConcatenate ($ENV{'GSDLHOME'}, "bin"); 
    128129 
    129130my $use_out = 0; 
     
    134135     
    135136    # delete any existing .final file 
    136     &util::rm ("$outfile.final") if -e "$outfile.final"; 
     137    &FileUtils::removeFiles ("$outfile.final") if -e "$outfile.final"; 
    137138 
    138139    $use_out = 1; 
     
    141142 
    142143# delete any .kill file left laying around from a previously aborted build 
    143 if (-e &util::filename_cat ($cdir, $collection, ".kill")) { 
    144     &util::rm (&util::filename_cat ($cdir, $collection, ".kill")); 
     144if (-e &FileUtils::filenameConcatenate ($cdir, $collection, ".kill")) { 
     145    &FileUtils::removeFiles (&FileUtils::filenameConcatenate ($cdir, $collection, ".kill")); 
    145146} 
    146147 
    147148# get maintainer email address from main.cfg 
    148149my $maintainer = "NULL"; 
    149 my $main_cfg = &util::filename_cat ($ENV{'GSDLHOME'}, "etc", "main.cfg"); 
     150my $main_cfg = &FileUtils::filenameConcatenate ($ENV{'GSDLHOME'}, "etc", "main.cfg"); 
    150151my $cfgdata = &cfgread::read_cfg_file ($main_cfg, "maintainer"); 
    151152if (defined $cfgdata->{'maintainer'} && $cfgdata->{'maintainer'} =~ /\w/) { 
     
    166167    my ($final_etcdir); 
    167168    if ($dontinstall) { 
    168     $final_etcdir = &util::filename_cat($collectdir, "etc", "build.log"); 
     169    $final_etcdir = &FileUtils::filenameConcatenate($collectdir, "etc", "build.log"); 
    169170    } else { 
    170     $final_etcdir = &util::filename_cat($ENV{'GSDLHOME'}, "collect", $collection, "etc", "build.log"); 
     171    $final_etcdir = &FileUtils::filenameConcatenate($ENV{'GSDLHOME'}, "collect", $collection, "etc", "build.log"); 
    171172    } 
    172173     
    173     &util::cp($outfile, $final_etcdir); 
     174    &FileUtils::copyFiles($outfile, $final_etcdir); 
    174175} 
    175176 
     
    204205    print STDOUT "                           a -download option is supplied\n"; 
    205206    print STDOUT "   -collectdir directory   Collection directory (defaults to " . 
    206     &util::filename_cat($ENV{'GSDLHOME'}). "collect for Greenstone2;\n"; 
     207    &FileUtils::filenameConcatenate($ENV{'GSDLHOME'}). "collect for Greenstone2;\n"; 
    207208    print STDOUT"                            for Greenstone3 use -site option and then collectdir default will be\n"; 
    208209    print STDOUT "                            set to the collect folder within that site.)\n"; 
     
    225226    print STDOUT "                           etc.) to event_log_file\n"; 
    226227    print STDOUT "   -event_log_file file    File to append important events to (defaults to\n"; 
    227     print STDOUT "                           " . &util::filename_cat ($ENV{'GSDLHOME'}, "etc", "events.txt") . "\n"; 
     228    print STDOUT "                           " . &FileUtils::filenameConcatenate ($ENV{'GSDLHOME'}, "etc", "events.txt") . "\n"; 
    228229    print STDOUT "   -email_events addr      Comma separated list of email addresses to mail\n"; 
    229230    print STDOUT "                           details of important collection building events\n"; 
     
    242243    if ($save_archives && -d $archivedir) { 
    243244    print $out "caching original archives to ${archivedir}.org\n"; 
    244     &util::cp_r ($archivedir, "${archivedir}.org"); 
     245    &FileUtils::copyFilesRecursive ($archivedir, "${archivedir}.org"); 
    245246    } 
    246247 
     
    250251    if (&has_content ($importdir)) { 
    251252        #print $out "build: WARNING: removing contents of $importdir\n"; 
    252         #&util::rm_r ($importdir); 
     253        #&FileUtils::removeFilesRecursive ($importdir); 
    253254    } 
    254255     
     
    294295            next if $file =~ /^\.\.?$/; 
    295296            if ($file =~ /^robots.txt$/i) { 
    296                 &util::rm (&util::filename_cat ($importdir, $file)); 
     297                &FileUtils::removeFiles (&FileUtils::filenameConcatenate ($importdir, $file)); 
    297298                last; 
    298299            } else { 
    299                 $file = &util::filename_cat ($importdir, $file); 
     300                $file = &FileUtils::filenameConcatenate ($importdir, $file); 
    300301                if (-d $file) { 
    301302                if (opendir (DIR, $file)) { 
     
    304305                    foreach my $file2 (@files2) { 
    305306                    if ($file2 =~ /^robots.txt$/i) { 
    306                         &util::rm (&util::filename_cat ($file, $file2)); 
     307                        &FileUtils::removeFiles (&FileUtils::filenameConcatenate ($file, $file2)); 
    307308                        last; 
    308309                    } 
     
    352353    my $col_cfg_file; 
    353354    if ($gs_mode eq "gs3") { 
    354     $col_cfg_file = &util::filename_cat($etcdir, "collectionConfig.xml"); 
     355    $col_cfg_file = &FileUtils::filenameConcatenate($etcdir, "collectionConfig.xml"); 
    355356    } else { 
    356     $col_cfg_file = &util::filename_cat($etcdir, "collect.cfg"); 
     357    $col_cfg_file = &FileUtils::filenameConcatenate($etcdir, "collect.cfg"); 
    357358    } 
    358359 
     
    415416        if ((defined $site) && ($site ne "")) 
    416417        { 
    417         $install_collectdir = &util::filename_cat ($ENV{'GSDL3HOME'}, "sites", $site, "collect"); 
     418        $install_collectdir = &FileUtils::filenameConcatenate ($ENV{'GSDL3HOME'}, "sites", $site, "collect"); 
    418419        } 
    419420        else  
     
    428429    else 
    429430    { 
    430         $install_collectdir = &util::filename_cat ($ENV{'GSDLHOME'}, "collect"); 
     431        $install_collectdir = &FileUtils::filenameConcatenate ($ENV{'GSDLHOME'}, "collect"); 
    431432    } 
    432433 
     
    435436        # install collection to gsdl/collect 
    436437        print $out "installing the $collection collection\n"; 
    437         my $newdir = &util::filename_cat ($install_collectdir, $collection); 
    438         my $olddir = &util::filename_cat ($collectdir, $collection); 
     438        my $newdir = &FileUtils::filenameConcatenate ($install_collectdir, $collection); 
     439        my $olddir = &FileUtils::filenameConcatenate ($collectdir, $collection); 
    439440        if (-d $newdir) { 
    440441        my $msg = "build: Could not install collection as $newdir\n" . 
     
    494495    if ($remove_import) { 
    495496        print $out "removing import directory ($importdir)\n"; 
    496         &util::rm_r ($importdir); 
     497        &FileUtils::removeFilesRecursive ($importdir); 
    497498    } 
    498499    } else { 
     
    540541    my $build_ok = 0; 
    541542    foreach my $db_ext (@db_exts) { 
    542     if ($removeold && (-e &util::filename_cat ($buildingdir, "text", "$collection$db_ext"))) { 
     543    if ($removeold && (-e &FileUtils::filenameConcatenate ($buildingdir, "text", "$collection$db_ext"))) { 
    543544        $build_ok = 1; 
    544545        last; 
    545546    } 
    546     if (($removeold==0) && (-e &util::filename_cat ($indexdir, "text", "$collection$db_ext"))) { 
     547    if (($removeold==0) && (-e &FileUtils::filenameConcatenate ($indexdir, "text", "$collection$db_ext"))) { 
    547548        $build_ok = 1; 
    548549        last; 
     
    554555    if ($remove_archives) { 
    555556        print $out "removing archives directory ($archivedir)\n"; 
    556         &util::rm_r ($archivedir); 
     557        &FileUtils::removeFilesRecursive ($archivedir); 
    557558    } 
    558559    } else { 
     
    568569    if (&has_content ($indexdir)) { 
    569570        print $out "removing old indexes\n"; 
    570         &util::rm_r ($indexdir); 
     571        &FileUtils::removeFilesRecursive ($indexdir); 
    571572    } 
    572573    rmdir ($indexdir) if -d $indexdir; 
     
    579580    # remove the cached archives 
    580581    if ($save_archives && -d "${archivedir}.org") { 
    581     &util::rm_r ("${archivedir}.org"); 
     582    &FileUtils::removeFilesRecursive ("${archivedir}.org"); 
    582583    } 
    583584} 
     
    611612    $/ = "\n"; 
    612613    close FILE; 
    613     &util::rm ($file); 
     614    &FileUtils::removeFiles ($file); 
    614615} 
    615616 
     
    652653    if ($event_log_file eq "" || !open (LOG, ">>$event_log_file")) { 
    653654        # log file defaults to $GSDLHOME/etc/events.txt 
    654         $event_log_file = &util::filename_cat ($ENV{'GSDLHOME'}, "etc", "events.txt"); 
     655        $event_log_file = &FileUtils::filenameConcatenate ($ENV{'GSDLHOME'}, "etc", "events.txt"); 
    655656        if (!open (LOG, ">>$event_log_file")) { 
    656657        print $out "build: ERROR: Couldn't open event log file $event_log_file\n"; 
     
    724725    if ($make_writable) { 
    725726    # chmod a+rw new collection 
    726     my $installed_collection = &util::filename_cat($ENV{'GSDLHOME'}, "collect", $collection); 
     727    my $installed_collection = &FileUtils::filenameConcatenate($ENV{'GSDLHOME'}, "collect", $collection); 
    727728    &recursive_chmod($installed_collection); 
    728729 
    729730    # chmod a+rw anything we've left laying about in the tmp directory 
    730731    if (($collectdir ne "") &&   
    731         (!&util::filenames_equal ($collectdir, &util::filename_cat($ENV{'GSDLHOME'}, "collect")))) { 
     732        (!&util::filenames_equal ($collectdir, &FileUtils::filenameConcatenate($ENV{'GSDLHOME'}, "collect")))) { 
    732733        &recursive_chmod($collectdir); 
    733734    } 
     
    751752    foreach my $file (@files) { 
    752753        next if $file =~ /^\.\.?$/; 
    753         $file = &util::filename_cat($dir, $file); 
     754        $file = &FileUtils::filenameConcatenate($dir, $file); 
    754755        if (-d $file) { 
    755756        &recursive_chmod ($file);