Changeset 1431


Ignore:
Timestamp:
2000-08-20T20:42:28+12:00 (24 years ago)
Author:
sjboddie
Message:

Made a few minor adjustments to perl building code for use with
collectoraction

Location:
trunk/gsdl
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/gsdl/bin/script/build

    r1424 r1431  
    1818
    1919if (!parsargv::parse(\@ARGV,
     20             'append', \$append,
    2021             'remove_archives', \$remove_archives,
    2122             'remove_import', \$remove_import,
     
    5051my $bindir = &util::filename_cat ($ENV{'GSDLHOME'}, "bin");
    5152
    52 my $close_out = 0;
     53my $use_out = 0;
    5354my $outfile = $out;
    5455if ($out !~ /^(STDERR|STDOUT)$/i) {
    5556    open (OUT, ">$out") || die "Couldn't open output file $out\n";
    5657    $out = "OUT";
    57     $close_out = 1;
     58    $use_out = 1;
    5859}
    5960$out->autoflush(1);
     
    6162&main();
    6263
    63 close OUT if $close_out;
     64close OUT if $use_out;
    6465
    6566sub print_usage {
    6667    print STDERR "\n  usage: $0 [options] collection-name\n\n";
    6768    print STDERR "  options:\n";
     69    print STDERR "   -append                 Add new files to existing collection\n";
    6870    print STDERR "   -remove_archives        Remove archives directory after successfully\n";
    6971    print STDERR "                           building the collection.\n";
     
    8991    if (scalar (@download)) {
    9092    # remove any existing import data
    91     &util::rm_r ($importdir) if -d $importdir;
     93    if (&has_content ($importdir)) {
     94        print $out "build: WARNING: removing contents of $importdir\n";
     95        &util::rm_r ($importdir);
     96    }
    9297
    9398    foreach $download_dir (@download) {
     
    107112            # copy download_dir and all it contains to the import directory
    108113            my $download_cmd = "perl " . &util::filename_cat ($bindir, "script", "filecopy.pl");
    109             $download_cmd .= " -out \"$outfile\" \"" . $download_dir . "\" " . $collection;
     114            $download_cmd .= " -out \"$outfile.download\"" if $use_out;
     115            $download_cmd .= " \"" . $download_dir . "\" " . $collection;
    110116            system ($download_cmd);
     117            # if using output directory append the file download output to it
     118            &append_file ($out, "$outfile.download");
    111119        } else {
    112120            print $out "WARNING: $download_dir does not exist\n";
     
    154162    print $out "importing the $collection collection\n\n";
    155163
    156     my $import = &util::filename_cat ($bindir, "script", "import.pl");
    157     system ("perl $import -removeold $maxdocs -out \"$outfile\" $collection");
     164    my $import_cmd = "perl " . &util::filename_cat ($bindir, "script", "import.pl");
     165    $import_cmd .= " -out \"$outfile.import\"" if $use_out;
     166    $import_cmd .= " -removeold" unless $append;
     167    $import_cmd .= " $maxdocs $collection";
     168    system ($import_cmd);
     169    # if using output directory append the import output to it
     170    &append_file ($out, "$outfile.import");
     171
    158172    if (-e &util::filename_cat ($archivedir, "archives.inf")) {
    159173    print $out "$collection collection imported successfully\n\n";
     
    171185    print $out "building the $collection collection\n\n";
    172186
    173     my $buildcol = &util::filename_cat ($bindir, "script", "buildcol.pl");
    174     system ("perl $buildcol $maxdocs -out \"$outfile\" $collection");
     187    my $build_cmd = "perl " . &util::filename_cat ($bindir, "script", "buildcol.pl");
     188    $build_cmd .= " -out \"$outfile.build\"" if $use_out;
     189    $build_cmd .= " $maxdocs $collection";
     190    system ($build_cmd);
     191    # if using output directory append the buildcol output to it
     192    &append_file ($out, "$outfile.build");
     193
    175194    if (-e &util::filename_cat ($buildingdir, "text", "$collection.ldb") ||
    176195    -e &util::filename_cat ($buildingdir, "text", "$collection.bdb")) {
     
    209228    return 0;
    210229}
     230
     231sub append_file {
     232    my ($handle, $file) = @_;
     233
     234    open (FILE, $file) || return;
     235    undef $/;
     236    print $handle <FILE>;
     237    $/ = "\n";
     238    close FILE;
     239    &util::rm ($file);
     240}
  • trunk/gsdl/bin/script/buildcol.pl

    r1424 r1431  
    9191    my $close_out = 0;
    9292    if ($out !~ /^(STDERR|STDOUT)$/i) {
    93     open (OUT, ">>$out") || die "Couldn't open output file $out\n";
     93    open (OUT, ">$out") || die "Couldn't open output file $out\n";
    9494    $out = "buildcol::OUT";
    9595    $close_out = 1;
  • trunk/gsdl/bin/script/filecopy.pl

    r1424 r1431  
    151151    my $close_out = 0;
    152152    if ($out !~ /^(STDERR|STDOUT)$/i) {
    153     open (OUT, ">>$out") || die "Couldn't open output file $out\n";
    154     $out = "MAIN::OUT";
     153    open (OUT, ">$out") || die "Couldn't open output file $out\n";
     154    $out = OUT;
    155155    $close_out = 1;
    156156    }
  • trunk/gsdl/bin/script/import.pl

    r1424 r1431  
    9494    my $close_out = 0;
    9595    if ($out !~ /^(STDERR|STDOUT)$/i) {
    96     open (OUT, ">>$out") || die "Couldn't open output file $out\n";
     96    open (OUT, ">$out") || die "Couldn't open output file $out\n";
    9797    $out = 'import::OUT';
    9898    $close_out = 1;
  • trunk/gsdl/perllib/plugin.pm

    r1424 r1431  
    2929
    3030sub load_plugins {
    31     my ($plugin_list, $verbosity, $outhandle) = @_;
     31    my ($plugin_list) = shift @_;
     32    ($verbosity, $outhandle) = @_; # globals
    3233    my @plugin_objects = ();
    3334
    3435    $verbosity = 2 unless defined $verbosity;
     36    $outhandle = STDERR unless defined $outhandle;
    3537
    3638    foreach $pluginoptions (@$plugin_list) {
     
    8688    }
    8789   
    88     if (defined $processor->{'verbosity'} && $processor->{'verbosity'} >= 2) {
    89     print STDERR "WARNING - no plugin could process " .
     90    if ($verbosity >= 2) {
     91    print $outhandle "WARNING - no plugin could process " .
    9092        &util::filename_cat($base_dir,$file) . "\n";
    9193    }
  • trunk/gsdl/perllib/plugins/HTMLPlug.pm

    r1424 r1431  
    119119    my $self = shift (@_);
    120120    my ($textref, $pluginfo, $base_dir, $file, $metadata, $doc_obj) = @_;
    121     my $outhandle = $self->{'outhandle'}
    122 
    123     print $outhandle "HTMLPlug: processing $file\n" 
     121    my $outhandle = $self->{'outhandle'};
     122
     123    print $outhandle "HTMLPlug: processing $file\n"
    124124    if $self->{'verbosity'} > 1;
    125125
  • trunk/gsdl/perllib/util.pm

    r1046 r1431  
    555555    # are defined
    556556    $ENV{'GSDLCOLLECTION'} = $collection unless defined $ENV{'GSDLCOLLECTION'};
    557     $ENV{'GSDLCOLLECTDIR'} = "$ENV{'GSDLHOME'}/collect/$collection";
     557    $ENV{'GSDLCOLLECTDIR'} = &filename_cat ($ENV{'GSDLHOME'}, "collect", $collection);
    558558
    559559    # make sure this collection exists
Note: See TracChangeset for help on using the changeset viewer.