Changeset 14032


Ignore:
Timestamp:
2007-04-30T16:48:18+12:00 (17 years ago)
Author:
xiao
Message:

Changes made to look for collectionConfig.xml in gs3 mode and collect.cfg in gs2 mode, rather than presumably only for the file collect.cfg in the modelcol directory and copy to a specific collection etc directory. When using this script on the command line in greenstone 3 mode, an option '-gs3mode' MUST be provided, along with the option '-collectdir <collection directory name>'.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gsdl/bin/script/mkcol.pl

    r13186 r14032  
    7575    'type' => "string",
    7676    'reqd' => "no" },
     77      { 'name' => "gs3mode",
     78    'desc' => "",
     79    'type' => "flag",
     80    'reqd' => "no" },
    7781      { 'name' => "collectdir",
    7882    'desc' => "{mkcol.collectdir}",
    7983    'type' => "string",
    80     'deft' => &util::filename_cat ($ENV{'GSDLHOME'}, "collect"),
    81     'reqd' => "no" },
     84    'reqd' => "no" }, # For gs3, this collectdir must be provided.
    8285      { 'name' => "public",
    8386    'desc' => "{mkcol.public}",
     
    129132
    130133# options
    131 my ($creator, $optionfile, $maintainer, $collectdir, $public,
     134my ($creator, $optionfile, $maintainer, $gs3mode, $collectdir, $public,
    132135    $title, $about, $plugin, $quiet, $language, $win31compat, $gli);
    133136
     
    140143sub traverse_dir
    141144{
    142     my ($modeldir, $coldir) = @_;
     145    my ($modeldir, $coldir, $gs3) = @_;
    143146    my ($newfile, @filetext);
    144147
    145148    if (!(-e $coldir)) {
     149   
    146150
    147151    my $store_umask = umask(0002);
     
    163167    {
    164168    my $thisfile = &util::filename_cat ($modeldir, $file);
     169
    165170    if (-d $thisfile) {
    166171        my $colfiledir = &util::filename_cat ($coldir, $file);
    167         traverse_dir ($thisfile, $colfiledir);
     172        traverse_dir ($thisfile, $colfiledir, $gs3);
    168173
    169174    } else {
     175
     176        # There are only two configuration files in modelcol directory:
     177        # collect.cfg and collectionConfig.xml.
     178        # If it is gs2, copy collect.cfg file; if gs3, copy collectionConfig.xml.
     179      if ( ($gs3 && $file =~ /collect\.cfg/) || (!$gs3 && $file =~ /collectionConfig\.xml/) ) {
     180         
     181        next;
     182      }
    170183        my $destfile = $file;
    171184        $destfile =~ s/^modelcol/$collection/;
     
    188201        $line =~ s/\*\*title\*\*/$title/g;
    189202        $line =~ s/\*\*about\*\*/$about/g;
    190         $line =~ s/\*\*plugins\*\*/$pluginstring/g;
     203        if (!$gs3) {
     204           $line =~ s/\*\*plugins\*\*/$pluginstring/g;
     205         }
    191206
    192207        print OUTFILE $line;
     
    204219    my $xml = 0;
    205220   
     221
    206222    my $hashParsingResult = {};
    207223    my $intArgLeftinAfterParsing = parse2::parse(\@ARGV,$arguments,$hashParsingResult,"allow_extra_options");
     
    324340    $cdir = &util::filename_cat ($collectdir, $collection);
    325341    } else {
     342      if (!$gs3mode) {
    326343    $cdir = &util::filename_cat ($ENV{'GSDLHOME'}, "collect", $collection);
     344      }else {
     345        &gsprintf(STDOUT, "{mkcol.no_collectdir}\n");
     346        die "In gs3mode, '-collectdir <directory>' must be specified.\n";
     347      }
    327348    }
    328349
     
    339360    &gsprintf(STDOUT, "\n{mkcol.creating_col}...\n", $collection)
    340361    unless $quiet;
    341     &traverse_dir ($mdir, $cdir);
     362
     363    &traverse_dir ($mdir, $cdir, $gs3mode);
    342364    &gsprintf(STDOUT, "\n{mkcol.success}\n", $cdir)
    343365    unless $quiet;
Note: See TracChangeset for help on using the changeset viewer.