Changeset 130 for trunk/gsdl/bin/script


Ignore:
Timestamp:
1999-02-02T22:47:47+13:00 (25 years ago)
Author:
rjmcnab
Message:

Made more configurable.

Location:
trunk/gsdl/bin/script
Files:
3 edited

Legend:

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

    r8 r130  
    1010}
    1111
     12use colcfg;
    1213use parsargv;
    1314use util;
     
    3738
    3839    # get and check the collection
    39     ($collection) = @ARGV;
    40     if (!defined ($collection)) {
     40    if (($collection = &util::use_collection(@ARGV)) eq "") {
    4141    &print_usage();
    4242    die "\n";
    4343    }
    44     if (!-e "$ENV{'GSDLHOME'}/collect/$collection") {
    45     die "Invalid collection name ($collection).\n";
     44
     45    # read the configuration file
     46    $textindex = "section:text";
     47    $configfilename = &util::filename_cat ($ENV{'GSDLCOLLECTDIR'}, "etc/collect.cfg");
     48    if (-e $configfilename) {
     49    $collectcfg = &colcfg::read_collect_cfg ($configfilename);
     50    if (defined $collectcfg->{'archivedir'} && $archivedir eq "") {
     51        $archivedir = $collectcfg->{'archivedir'};
     52    }
     53    if (defined $collectcfg->{'cachedir'} && $cachedir eq "") {
     54        $cachedir = $collectcfg->{'cachedir'};
     55    }
     56    if (defined $collectcfg->{'builddir'} && $builddir eq "") {
     57        $builddir = $collectcfg->{'builddir'};
     58    }
     59    if (defined $collectcfg->{'textindex'}) {
     60        $textindex = $collectcfg->{'textindex'};
     61    }
     62    } else {
     63    die "Couldn't find the configuration file $configfilename\n";
    4664    }
    47 
     65   
    4866    # fill in the default archives and building directories if none
    4967    # were supplied, turn all \ into / and remove trailing /
    50     $archivedir = "$ENV{'GSDLHOME'}/collect/$collection/archives" if $archivedir eq "";
     68    $archivedir = "$ENV{'GSDLCOLLECTDIR'}/archives" if $archivedir eq "";
    5169    $archivedir =~ s/[\\\/]+/\//g;
    5270    $archivedir =~ s/\/$//;
    53     $builddir = "$ENV{'GSDLHOME'}/collect/$collection/building" if $builddir eq "";
     71    $builddir = "$ENV{'GSDLCOLLECTDIR'}/building" if $builddir eq "";
    5472    $builddir =~ s/[\\\/]+/\//g;
    5573    $builddir =~ s/\/$//;
     
    8098    # if a builder class has been created for this collection, use it
    8199    # otherwise, use the mg builder
    82     if (-e "$ENV{'GSDLHOME'}/collect/$collection/perllib/${collection}builder.pm") {
    83     $builderdir = "$ENV{'GSDLHOME'}/collect/$collection/perllib";
     100    if (-e "$ENV{'GSDLCOLLECTDIR'}/perllib/${collection}builder.pm") {
     101    $builderdir = "$ENV{'GSDLCOLLECTDIR'}/perllib";
    84102    $buildertype = "${collection}builder";
    85103    } else {
     
    95113
    96114    $builder->init();
    97     $builder->compress_text();
     115    $builder->compress_text($textindex);
    98116    $builder->build_indexes();
    99117    $builder->make_infodatabase();
  • trunk/gsdl/bin/script/gettext.pl

    r117 r130  
    1313use plugin;
    1414use colcfg;
     15use util;
    1516
    1617sub print_usage {
    1718    print STDERR "\n  usage: $0 collection-name\n";
    1819    print STDERR "  options:\n";
     20    print STDERR "   -archivedir directory Where the archives live\n";
    1921    print STDERR "   -index index   The index to output\n\n";
    2022}
     
    2628
    2729    if (!parsargv::parse(\@ARGV,
     30             'archivedir/.*/', \$archivedir,
    2831             'index/.*/section:text', \$index,
    2932             'mode/.*/text', \$mode)) {
     
    3336
    3437    # get and check the collection name
    35     ($collection) = @ARGV;
    36 
    37     if (!defined($collection)) {
     38   if (($collection = &util::use_collection(@ARGV)) eq "") {
    3839    &print_usage();
    3940    die "\n";
     
    4142   
    4243    # get the list of plugins for this collection
    43     @plugins = ("RecPlug", "HTMLPlug", "TXTPlug");
    44     if (-e "$ENV{'GSDLHOME'}/collect/$collection/etc/collect.cfg") {
    45     $collectcfg = &colcfg::read_collect_cfg ("$ENV{'GSDLHOME'}/collect/$collection/etc/collect.cfg");
     44    @plugins = ();
     45    $configfilename = &util::filename_cat ($ENV{'GSDLCOLLECTDIR'}, "etc/collect.cfg");
     46    if (-e $configfilename) {
     47    $collectcfg = &colcfg::read_collect_cfg ($configfilename);
    4648    if (defined $collectcfg->{'plugins'}) {
    4749        @plugins = @{$collectcfg->{'plugins'}};
    4850    }
     51    if (defined $collectcfg->{'archivedir'} && $archivedir eq "") {
     52        $archivedir = $collectcfg->{'archivedir'};
     53    }
     54    } else {
     55    die "Couldn't find the configuration file $configfilename\n";
    4956    }
    50    
     57
     58    # fill in the default archives directories if none
     59    # was supplied, turn all \ into / and remove trailing /
     60    $archivedir = "$ENV{'GSDLCOLLECTDIR'}/archives" if $archivedir eq "";
     61    $archivedir =~ s/[\\\/]+/\//g;
     62    $archivedir =~ s/\/$//;
    5163
    5264    # load all the plugins
     
    6072    # if a buildproc class has been created for this collection, use it
    6173    # otherwise, use the mg buildproc
     74    # if a builder class has been created for this collection, use it
     75    # otherwise, use the mg builder
     76    # load up the document processor for building
     77    # if a buildproc class has been created for this collection, use it
     78    # otherwise, use the mg buildproc
    6279    my ($buildprocdir, $buildproctype);
    63     if (-e "$ENV{'GSDLHOME'}/collect/$collection/perllib/${collection}buildproc.pm") {
    64     $buildprocdir = "$ENV{'GSDLHOME'}/collect/$collection/perllib";
     80    if (-e "$ENV{'GSDLCOLLECTDIR'}/perllib/${collection}buildproc.pm") {
     81    $buildprocdir = "$ENV{'GSDLCOLLECTDIR'}/perllib";
    6582    $buildproctype = "${collection}buildproc";
    6683    } else {
     
    7087    require "$buildprocdir/$buildproctype.pm";
    7188
    72     my $source_dir = "$ENV{'GSDLHOME'}/collect/$collection/archives";
    73     my $build_dir = "$ENV{'GSDLHOME'}/collect/$collection/building";
    74     my $verbosity = 1;
    75 
    7689    eval("\$buildproc = new $buildproctype(\$collection, " .
    77      "\$source_dir, \$build_dir, \$verbosity)");
     90     "\$archivedir, \"\$ENV{'GSDLCOLLECTDIR'}/building\", 1)");
    7891    die "$@" if $@;
    7992
     
    8699
    87100    # process the import directory
    88     &plugin::read ($pluginfo, $source_dir,
     101    &plugin::read ($pluginfo, $archivedir,
    89102           "", {}, $buildproc);
    90103
  • trunk/gsdl/bin/script/import.pl

    r98 r130  
    1414use plugin;
    1515use docsave;
    16 
     16use util;
     17use parsargv;
    1718
    1819sub print_usage {
    19     print STDERR "\n  usage: $0 collection-name\n";
     20    print STDERR "\n  usage: $0 [options] collection-name\n\n";
     21    print STDERR "  options:\n";
     22    print STDERR "   -importdir directory   Where the original material lives\n";
     23    print STDERR "   -archivedir directory  Where the converted material ends up\n";
     24    print STDERR "   -keepold               Will not destroy the current contents of the\n";
     25    print STDERR "                          archives directory (the default)\n";
     26    print STDERR "   -removeold             Will remove the old contents of the archives\n";
     27    print STDERR "                          directory -- use with care\n\n";
    2028}
    2129
     
    2432
    2533sub main {
    26     # get and check the collection name
    27     ($collection) = @ARGV;
    28     if (!defined($collection)) {
     34    if (!parsargv::parse(\@ARGV,
     35             'importdir/.*/', \$importdir,
     36             'archivedir/.*/', \$archivedir,
     37             'keepold', \$keepold,
     38             'removeold', \$removeold)) {
    2939    &print_usage();
    3040    die "\n";
    3141    }
    32    
    33     if ($collection eq "modelcol") {
    34     print STDERR "You can't import documents into modelcol.\n";
     42
     43    # set removeold to false if it has been defined
     44    $removeold = 0 if ($keepold);
     45
     46    # get and check the collection name
     47    if (($collection = &util::use_collection(@ARGV)) eq "") {
     48    &print_usage();
    3549    die "\n";
    3650    }
    37    
     51
    3852    # get the list of plugins for this collection
    39     @plugins = ("HTMLPlug", "TXTPlug", "RecPlug");
    40     if (-e "$ENV{'GSDLHOME'}/collect/$collection/etc/collect.cfg") {
    41     $collectcfg = &colcfg::read_collect_cfg ("$ENV{'GSDLHOME'}/collect/$collection/etc/collect.cfg");
     53    @plugins = ();
     54    $configfilename = &util::filename_cat ($ENV{'GSDLCOLLECTDIR'}, "etc/collect.cfg");
     55    if (-e $configfilename) {
     56    $collectcfg = &colcfg::read_collect_cfg ($configfilename);
    4257    if (defined $collectcfg->{'plugins'}) {
    4358        @plugins = @{$collectcfg->{'plugins'}};
    4459    }
     60    if (defined $collectcfg->{'importdir'} && $importdir eq "") {
     61        $importdir = $collectcfg->{'importdir'};
     62    }
     63    if (defined $collectcfg->{'archivedir'} && $archivedir eq "") {
     64        $archivedir = $collectcfg->{'archivedir'};
     65    }
     66    if (defined $collectcfg->{'removeold'}) {
     67        if ($collectcfg->{'removeold'} =~ /^true$/i && !$keepold) {
     68        $removeold = 1;
     69        }
     70        if ($collectcfg->{'removeold'} =~ /^false$/i && !$removeold) {
     71        $removeold = 0;
     72        }
     73    }
    4574    } else {
    46     print STDERR "WARNING - couldn't find collection configuration file\n";
    47     print STDERR "          using default plugins\n";
     75    die "Couldn't find the configuration file $configfilename\n";
    4876    }
    4977   
     78    # fill in the default import and archives directories if none
     79    # were supplied, turn all \ into / and remove trailing /
     80    $importdir = "$ENV{'GSDLCOLLECTDIR'}/import" if $importdir eq "";
     81    $importdir =~ s/[\\\/]+/\//g;
     82    $importdir =~ s/\/$//;
     83    $archivedir = "$ENV{'GSDLCOLLECTDIR'}/archives" if $archivedir eq "";
     84    $archivedir =~ s/[\\\/]+/\//g;
     85    $archivedir =~ s/\/$//;
    5086
    5187    # load all the plugins
     
    5692    }
    5793   
     94    # remove the old contents of the archives directory if needed
     95    if ($removeold && -e $archivedir) {
     96    print STDERR "Warning - removing current contents of the archives directory\n";
     97    print STDERR "          in preparation for the import\n";
     98    sleep(5); # just in case...
     99    &util::rm_r ($archivedir);
     100    }
     101
    58102    # read the archive information file
    59     $archive_info_filename = "$ENV{'GSDLHOME'}/collect/$collection/archives/archives.inf";
     103    $archive_info_filename = &util::filename_cat ($archivedir, "archives.inf");
    60104    $archive_info = new arcinfo ();
    61105    $archive_info->load_info ($archive_info_filename);
     
    63107    # create a docsave object to process the documents
    64108    $processor = new docsave ($collection, $archive_info);
     109    $processor->setarchivedir ($archivedir);
    65110
    66111    # process the import directory
    67     &plugin::read ($pluginfo, "$ENV{'GSDLHOME'}/collect/$collection/import/",
     112    &plugin::read ($pluginfo, $importdir,
    68113           "", {}, $processor);
    69114   
Note: See TracChangeset for help on using the changeset viewer.