Changeset 24747

Show
Ignore:
Timestamp:
11.10.2011 11:22:53 (8 years ago)
Author:
davidb
Message:

Tidied up support for -site in full-rebuild.pl and incremental-rebuild.pl plug more consistent handling of import.pl/buildcol.pl specific arguments. Tweaked wording printed out when switching from incremental to full building

Location:
main/trunk/greenstone2/bin/script
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone2/bin/script/full-rebuild.pl

    r24362 r24747  
    4343 
    4444 
     45sub full_replace 
     46{ 
     47    my ($site,$collect_dir,$collect,$build_dir,$index_dir) = @_; 
     48 
     49 
     50    if (!defined $build_dir) { 
     51    if (defined $collect_dir) { 
     52        $build_dir = &util::filename_cat($collect_dir,$collect, "building"); 
     53    } 
     54    else { 
     55        if (defined $site) { 
     56        $build_dir = &util::filename_cat($ENV{'GSDL3HOME'},"sites",$site,"collect",$collect, "building"); 
     57        } 
     58        else { 
     59        $build_dir = &util::filename_cat($ENV{'GSDLHOME'},"collect",$collect, "building"); 
     60        } 
     61    } 
     62    } 
     63     
     64    if (!defined $index_dir) { 
     65    if (defined $collect_dir) { 
     66        $index_dir = &util::filename_cat($collect_dir,$collect, "index"); 
     67    } 
     68    else { 
     69        if (defined $site) { 
     70        $index_dir = &util::filename_cat($ENV{'GSDL3HOME'},"sites",$site,"collect",$collect, "index"); 
     71        } 
     72        else { 
     73        $index_dir = &util::filename_cat($ENV{'GSDLHOME'},"collect",$collect, "index"); 
     74        } 
     75    } 
     76    } 
     77     
     78    if (-e $index_dir) { 
     79    print "\n"; 
     80    print "************************\n"; 
     81    print "* Removing \"index\"\n"; 
     82    print "************************\n"; 
     83 
     84    # An improvement would be to check on error status 
     85    &util::rm_r($index_dir); 
     86    } 
     87     
     88    print "\n"; 
     89    print "************************\n"; 
     90    print "* Moving \"building\" -> \"index\"\n"; 
     91    print "************************\n"; 
     92     
     93    # An improvement would be to check on error status 
     94    &util::mv($build_dir,$index_dir);     
     95} 
     96 
    4597sub main 
    4698{ 
     
    51103 
    52104    print STDERR "\n"; 
     105    print STDERR "This program runs import.pl followed by buildcol.pl (in both cases removing any previously\n"; 
     106    print STDERR "  generated files in 'archives' or 'building'), and then replaces the content of collection's\n"; 
     107    print STDERR "  'index' directory with 'building'."; 
     108    print STDERR "\n"; 
    53109    print STDERR "Usage: $progname [option shared between import.pl and buildcol.pl] collection\n"; 
    54110    print STDERR "\n"; 
     
    61117 
    62118 
    63     my @filtered_argv = (); 
    64  
     119    my @import_argv = (); 
     120    my @buildcol_argv = (); 
     121 
     122    my $site        = undef; 
    65123    my $collect_dir = undef; 
    66     my $build_dir  = undef; 
     124    my $build_dir   = undef; 
     125    my $index_dir   = undef; 
    67126 
    68127    while (my $arg = shift @argv) { 
    69     if ($arg eq "-collectdir") { 
     128    if ($arg eq "-site") { 
     129        $site = shift @argv; 
     130        push(@import_argv,$arg,$site); 
     131        push(@buildcol_argv,$arg,$site); 
     132    } 
     133    elsif ($arg eq "-collectdir") { 
    70134        $collect_dir = shift @argv; 
    71         push(@filtered_argv,$arg,$collect_dir); 
     135        push(@import_argv,$arg,$collect_dir); 
     136        push(@buildcol_argv,$arg,$collect_dir); 
     137    } 
     138    elsif ($arg eq "-importdir") { 
     139        # only makes sense in import.pl 
     140        my $import_dir = shift @argv; 
     141        push(@import_argv,$arg,$import_dir); 
    72142    } 
    73143    elsif ($arg eq "-builddir") { 
     144        # only makes sense in buildcol.pl 
    74145        $build_dir = shift @argv; 
    75         push(@filtered_argv,$arg,$build_dir); 
    76     } 
    77     else { 
    78         push(@filtered_argv,$arg); 
    79     } 
    80     } 
    81  
    82  
    83     if (!defined $collect_dir) { 
    84     $collect_dir = &util::filename_cat($ENV{'GSDLHOME'},"collect"); 
    85     } 
    86     my $this_collect_dir = &util::filename_cat($collect_dir,$collect); 
    87  
    88     if (!-d $this_collect_dir) { 
    89     print STDERR "Error: $collect_dir does not exist\n"; 
    90     exit(-1); 
    91     } 
    92  
    93  
    94     if (!defined $build_dir) { 
    95     $build_dir = &util::filename_cat($this_collect_dir,"building"); 
    96     push(@filtered_argv,"-builddir",$build_dir); 
    97     } 
    98  
    99      
    100     my $quoted_argv = join(" ", map { "\"$_\"" } @argv); 
     146        push(@buildcol_argv,$arg,$build_dir); 
     147    } 
     148    elsif ($arg eq "-indexdir") { 
     149        # only makes sense in buildcol.pl 
     150        $index_dir = shift @argv; 
     151        push(@buildcol_argv,$arg,$index_dir); 
     152    } 
     153    else { 
     154        push(@import_argv,$arg); 
     155        push(@buildcol_argv,$arg); 
     156    } 
     157    } 
     158 
     159     
     160    my $quoted_import_argv = join(" ", map { "\"$_\"" } @import_argv); 
     161    my $quoted_buildcol_argv = join(" ", map { "\"$_\"" } @buildcol_argv); 
    101162     
    102163    my $final_status = 0; 
     
    110171    print "************************\n"; 
    111172 
    112     my $import_cmd = $launch_cmd . "full-import.pl $quoted_argv \"$collect\""; 
     173    my $import_cmd = $launch_cmd . "full-import.pl $quoted_import_argv \"$collect\""; 
    113174 
    114175    my $import_status = system($import_cmd)/256; 
     
    120181    print "************************\n"; 
    121182     
    122     my $buildcol_cmd = $launch_cmd . "full-buildcol.pl $quoted_argv \"$collect\""; 
     183    my $buildcol_cmd = $launch_cmd . "full-buildcol.pl $quoted_buildcol_argv \"$collect\""; 
    123184    my $buildcol_status = system($buildcol_cmd)/256; 
     185 
    124186    if ($buildcol_status == 0) { 
    125         my $index_dir = &util::filename_cat($this_collect_dir,"index"); 
    126          
    127         if (-e $index_dir) { 
    128         print "\n"; 
    129         print "************************\n"; 
    130         print "* Removing \"index\"\n"; 
    131         print "************************\n"; 
    132          
    133         &util::rm_r($index_dir); 
    134         } 
    135  
    136         print "\n"; 
    137         print "************************\n"; 
    138         print "* Moving \"building\" -> \"index\"\n"; 
    139         print "************************\n"; 
    140  
    141         &util::mv($build_dir,$index_dir); 
    142  
     187 
     188        full_replace($site,$collect_dir,$collect,$build_dir,$index_dir); 
    143189    } 
    144190    else { 
  • main/trunk/greenstone2/bin/script/incremental-buildcol.pl

    r24362 r24747  
    125125    if ($buildcfg->{'buildtype'} ne $collectcfg->{'buildtype'}) { 
    126126        print STDERR "*****\n"; 
    127         print STDERR "* Change of indexer detected. Switching to full buildcol.pl.\n"; 
     127        print STDERR "* Change of indexer detected. Switching to full buildcol.pl (with -removeold).\n"; 
    128128        print STDERR "*****\n"; 
    129129        $buildcol_cmd .= " -removeold"; 
     
    137137    # build.cfg doesn't exit 
    138138    print STDERR "*****\n"; 
    139     print STDERR "* First time built. Switching to full buildcol.pl.\n"; 
     139    print STDERR "* First time built. Switching to full buildcol.pl (with -removeold).\n"; 
    140140    print STDERR "*****\n"; 
    141141    $buildcol_cmd .= " -removeold"; 
  • main/trunk/greenstone2/bin/script/incremental-rebuild.pl

    r24362 r24747  
    5050 
    5151    print STDERR "\n"; 
     52    print STDERR "This program runs -- incrementally where possible -- import.pl followed by buildcol.pl (retaining any\n"; 
     53    print STDERR "  previously generated files in 'archives' or 'index').  The import.pl script can always be run\n"; 
     54        print STDERR "  incrementally in Greenstone, however buildcol.pl will default to a full rebuild if the indexer\n"; 
     55        print STDERR "  the collection uses (such as mg, or mgpp) does not support incremental indexing.\n"; 
     56    print STDERR "\n"; 
    5257    print STDERR "Usage: $progname [shared import.pl and buildcol.pl options] collection\n"; 
    5358    print STDERR "\n"; 
     
    6267    my @buildcol_argv = (); 
    6368 
    64     my $a; 
    65     while ($a = shift @argv) { 
    66     if ($a eq "-manifest") { 
    67         push(@import_argv,$a); 
     69    while (my $arg = shift @argv) { 
    6870 
    69         my $af = shift(@argv); 
    70         push(@import_argv,$af); 
     71    if ($arg eq "-manifest") { 
     72        # only makes sense in import.pl 
     73        my $manifest = shift(@argv); 
     74        push(@import_argv,$arg,$manifest); 
     75    } 
     76    elsif ($arg eq "-importdir") { 
     77        # only makes sense in import.pl 
     78        my $import_dir = shift @argv; 
     79        push(@import_argv,$arg,$import_dir); 
     80    } 
     81    elsif ($arg eq "-builddir") { 
     82        # only makes sense in build.pl 
     83        my $build_dir = shift @argv; 
     84        push(@buildcol_argv,$arg,$build_dir); 
     85    } 
     86    elsif ($arg eq "-indexdir") { 
     87        # only makes sense in build.pl 
     88        my $index_dir = shift @argv; 
     89        push(@buildcol_argv,$arg,$index_dir); 
    7190    } 
    7291    else { 
    73         push(@import_argv,$a); 
    74         push(@buildcol_argv,$a); 
     92        push(@import_argv,$arg); 
     93        push(@buildcol_argv,$arg); 
    7594    } 
    7695 
     
    91110     
    92111    my $import_cmd = $launch_cmd . "incremental-import.pl $quoted_import_argv \"$collect\""; 
    93  
    94     print STDERR "***** import cmd = $import_cmd\n"; 
    95112 
    96113    my $import_status = system($import_cmd)/256;