Changeset 2355


Ignore:
Timestamp:
2001-05-03T13:59:37+12:00 (23 years ago)
Author:
sjboddie
Message:

All options to import.pl and buildcol.pl may now be specified from
within a collect.cfg file

Location:
trunk/gsdl
Files:
3 edited

Legend:

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

    r2336 r2355  
    8585    $create_images, $collectdir, $out, $buildtype, $textindex,
    8686    $no_strip_html, $no_text);
     87
     88    # note that no defaults are passed for most options as they're set
     89    # later (after we check the collect.cfg file)
    8790    if (!parsargv::parse(\@ARGV,
    88              'verbosity/\d+/2', \$verbosity,
     91             'verbosity/\d+/', \$verbosity,
    8992             'archivedir/.*/', \$archivedir,
    9093             'cachedir/.*/', \$cachedir,
    9194             'builddir/.*/', \$builddir,
    92              'maxdocs/^\-?\d+/-1', \$maxdocs,
     95             'maxdocs/^\-?\d+/', \$maxdocs,
    9396             'debug', \$debug,
    94              'mode/^(all|compress_text|build_index|infodb)$/all', \$mode,
     97             'mode/^(all|compress_text|build_index|infodb)$/', \$mode,
    9598             'index/.*/', \$indexname,
    9699             'no_text', \$no_text,
     
    122125
    123126    # read the configuration file
    124 
    125127    $configfilename = &util::filename_cat ($ENV{'GSDLCOLLECTDIR'}, "etc", "collect.cfg");
    126128    if (-e $configfilename) {
    127129    $collectcfg = &colcfg::read_collect_cfg ($configfilename);
    128130
     131    if ($verbosity !~ /\d+/) {
     132        if (defined $collectcfg->{'verbosity'} && $collectcfg->{'verbosity'} =~ /\d+/) {
     133        $verbosity = $collectcfg->{'verbosity'};
     134        } else {
     135        $verbosity = 2; # the default
     136        }
     137    }
    129138    if (defined $collectcfg->{'buildtype'} && $buildtype eq "") {
    130139        $buildtype = $collectcfg->{'buildtype'};
     
    142151        $builddir = $collectcfg->{'builddir'};
    143152    }
    144     if (defined $collectcfg->{'collectdir'} && $collectdir eq "") {
    145         $collectdir = $collectcfg->{'collectdir'};
     153    if ($maxdocs !~ /\-?\d+/) {
     154        if (defined $collectcfg->{'maxdocs'} && $collectcfg->{'maxdocs'} =~ /\-?\d+/) {
     155        $maxdocs = $collectcfg->{'maxdocs'};
     156        } else {
     157        $maxdocs = -1; # the default
     158        }
     159    }
     160    if (defined $collectcfg->{'debug'} && $collectcfg->{'debug'} =~ /^true$/i) {
     161        $debug = 1;
     162    }
     163    if ($mode !~ /^(all|compress_text|build_index|infodb)$/) {
     164        if (defined $collectcfg->{'mode'} && $collectcfg->{'mode'} =~ /^(all|compress_text|build_index|infodb)$/) {
     165        $mode = $collectcfg->{'mode'};
     166        } else {
     167        $mode = "all"; # the default
     168        }
     169    }
     170    if (defined $collectcfg->{'index'} && $indexname eq "") {
     171        $indexname = $collectcfg->{'index'};
    146172    }
    147173    if (defined $collectcfg->{'no_text'} && $no_text == 0) {
    148         if ($collectcfg->{'no_text'} =~ /^true$/) {
     174        if ($collectcfg->{'no_text'} =~ /^true$/i) {
    149175        $no_text = 1;
    150176        }
    151177    }
    152178    if (defined $collectcfg->{'allclassifications'} && $allclassifications == 0) {
    153         if ($collectcfg->{'allclassifications'} =~ /^true$/) {
     179        if ($collectcfg->{'allclassifications'} =~ /^true$/i) {
    154180        $allclassifications = 1;
    155181        }
     182    }
     183    if (defined $collectcfg->{'keepold'} && $collectcfg->{'keepold'} =~ /^true$/i) {
     184        $keepold = 1;
     185    }
     186    if (defined $collectcfg->{'create_images'} && $collectcfg->{'create_images'} =~ /^true$/i) {
     187        $create_images = 1;
    156188    }
    157189    if ($buildtype eq "mgpp" && defined $collectcfg->{'textcompress'}) {
  • trunk/gsdl/bin/script/import.pl

    r2328 r2355  
    9292    $pluginfo, $sortmeta, $archive_info_filename,
    9393    $archive_info, $processor, $out, $collectdir);
    94     if (!parsargv::parse(\@ARGV,
    95              'verbosity/\d+/2', \$verbosity,
     94
     95    # note that no defaults are passed for most options as they're set
     96    # later (after we check the collect.cfg file)
     97    if (!parsargv::parse(\@ARGV,
     98             'verbosity/\d+/', \$verbosity,
    9699             'importdir/.*/', \$importdir,
    97              'archivedir/.*/', \$archivedir,
    98              'keepold', \$keepold,
    99              'removeold', \$removeold,
    100              'gzip', \$gzip,
    101              'groupsize/\d+/1', \$groupsize,
    102              'OIDtype/^(hash|incremental)$/hash', \$OIDtype,
    103              'sortmeta/.*/', \$sortmeta,
     100             'archivedir/.*/', \$archivedir, 
     101             'keepold', \$keepold, 
     102             'removeold', \$removeold, 
     103             'gzip', \$gzip, 
     104             'groupsize/\d+/', \$groupsize,
     105             'OIDtype/^(hash|incremental)$/', \$OIDtype,
     106             'sortmeta/.*/', \$sortmeta, 
    104107             'debug', \$debug,
    105              'maxdocs/^\-?\d+/-1', \$maxdocs,
     108             'maxdocs/^\-?\d+/', \$maxdocs,
    106109             'collectdir/.*/', \$collectdir,
    107110             'out/.*/STDERR', \$out)) {
     
    142145
    143146
    144     # get the list of plugins for this collection
     147    # get the list of plugins for this collection and set any options that
     148    # were specified in the collect.cfg (all import.pl options except
     149    # -collectdir and -out may be specified in the collect.cfg (these
     150    # options must be known before we read the collect.cfg))
    145151    my $plugins = [];
    146152    $configfilename = &util::filename_cat ($ENV{'GSDLCOLLECTDIR'}, "etc", "collect.cfg");
     
    150156        $plugins = $collectcfg->{'plugin'};
    151157    }
     158
     159    if ($verbosity !~ /\d+/) {
     160        if (defined $collectcfg->{'verbosity'} && $collectcfg->{'verbosity'} =~ /\d+/) {
     161        $verbosity = $collectcfg->{'verbosity'};
     162        } else {
     163        $verbosity = 2; # the default
     164        }
     165    }
    152166    if (defined $collectcfg->{'importdir'} && $importdir eq "") {
    153167        $importdir = $collectcfg->{'importdir'};
     
    164178        }
    165179    }
     180    if (defined $collectcfg->{'keepold'}) {
     181        if ($collectcfg->{'keepold'} =~ /^false$/i && !$keepold) {
     182        $removeold = 1;
     183        }
     184    }
     185    if (defined $collectcfg->{'gzip'} && !$gzip) {
     186        if ($collectcfg->{'gzip'} =~ /^true$/i) {
     187        $gzip = 1;
     188        }
     189    }
     190    if ($maxdocs !~ /\-?\d+/) {
     191        if (defined $collectcfg->{'maxdocs'} && $collectcfg->{'maxdocs'} =~ /\-?\d+/) {
     192        $maxdocs = $collectcfg->{'maxdocs'};
     193        } else {
     194        $maxdocs = -1; # the default
     195        }
     196    }
     197    if ($groupsize !~ /\d+/) {
     198        if (defined $collectcfg->{'groupsize'} && $collectcfg->{'groupsize'} =~ /\d+/ && $groupsize !~ /\d+/) {
     199        $groupsize = $collectcfg->{'groupsize'};
     200        } else {
     201        $groupsize = 1; # the default
     202        }
     203    }
     204    if ($OIDtype !~ /^(hash|incremental)$/) {
     205        if (defined $collectcfg->{'OIDtype'} && $collectcfg->{'OIDtype'} =~ /^(hash|incremental)$/) {
     206        $OIDtype = $collectcfg->{'OIDtype'};
     207        } else {
     208        $OIDtype = "hash"; # the default
     209        }
     210    }
     211    if (defined $collectcfg->{'sortmeta'} && $sortmeta eq "") {
     212        $sortmeta = $collectcfg->{'sortmeta'};
     213    }
     214    if (defined $collectcfg->{'debug'} && $collectcfg->{'debug'} =~ /^true$/i) {
     215        $debug = 1;
     216    }
     217
    166218    } else {
    167219    die "Couldn't find the configuration file $configfilename\n";
  • trunk/gsdl/perllib/colcfg.pm

    r2336 r2355  
    6767                    q/^(creator|public|beta|defaultindex|importdir|/ .
    6868                    q/archivedir|cachedir|builddir|removeold|/ .
    69                     q/textcompress|buildtype|collectdir|no_text|allclassifications)$/,
     69                    q/textcompress|buildtype|no_text|keepold|gzip/ .
     70                    q/verbosity|allclassifications|OIDtype|maxdocs|/ .
     71                    q/groupsize|sortmeta|debug|mode|create_images)$/,
    7072                    q/(maintainer|languages|indexsubcollections|/ .
    7173                       q/indexes|dontbuild|dontgdbm|mirror|phind|levels)$/,
Note: See TracChangeset for help on using the changeset viewer.