Changeset 29108

Show
Ignore:
Timestamp:
26.06.2014 10:34:58 (5 years ago)
Author:
kjdon
Message:

no longer taking collect as the last arg in the arg list. If the user has forgotten to put the collection in the command, then you get weird error messages. eg 'full-rebuild.pl -verbosity 5' gives an error about verbosity should be an int, rather than a missing collection name error. Just pass the collection arg to the scripts along with the other ones

Files:
1 modified

Legend:

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

    r26913 r29108  
    2828 
    2929# This program will rebuild a collection from scratch 
    30 # Runs:        full-import.pl -removeold ... 
    31 # Followed by: full-buildcol.pl -removeold ... 
    32 # (assumming import.pl did not end with an error) 
     30# Runs:        full-import.pl -removeold [args] 
     31# Followed by: full-buildcol.pl -removeold [args] 
     32# Followed by: activate.pl -removeold [args] 
     33# (assumming import.pl/buildcol.pl did not end with an error) 
    3334 
    3435BEGIN { 
     
    4142use util; 
    4243 
    43  
    44 # This subroutine has been replaced by a call to activate.pl in sub main 
    45 sub 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  
    9744sub main 
    9845{ 
     
    10350 
    10451    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'.\n"; 
     52    print STDERR "This program runs full-import.pl, full-buildcol.pl, activate.pl (in each case removing any previously generated files in 'archives', 'building','index')\n"; 
    10853    print STDERR "\n"; 
    10954    print STDERR "Usage: $progname [options]| collection\n"; 
     55    print STDERR "\n"; 
    11056    print STDERR "       If a minus option is shared between import.pl and buildcol.pl then it can appear\n"; 
    11157        print STDERR "         as is, such as -verbosity 5.  This value will be passed to both programs.\n"; 
    11258    print STDERR "       If a minus option is specific to one of the programs in particular, then prefix\n"; 
    113     print STDERR "         it with 'import:' or 'buildcol:' respectively, as in '-import:OIDtype hash_on_full_filename'\n"; 
    114     print STDERR "       Run 'import.pl' or 'buildcol.pl' from the command line with no arguments to see the\n"; 
    115         print STDERR "         specific values they take.\n"; 
     59    print STDERR "         it with 'import:', 'buildcol:', or 'activate:' respectively, \n"; 
     60    print STDERR "         as in '-import:OIDtype hash_on_full_filename'\n"; 
     61    print STDERR "       Run '(full-)import.pl -h', '(full-)buildcol.pl -h', 'activate.pl -h' from the \n"; 
     62    print STDERR "         command line to see the specific values they take.\n"; 
    11663    print STDERR "\n"; 
    11764 
    11865    exit(-1); 
    11966    } 
    120      
    121  
    122     my $collect = pop @argv; 
    123  
    12467 
    12568    my @import_argv = (); 
    12669    my @buildcol_argv = (); 
    127     my @activate_argv = (); 
     70    my @activate_argv = (); 
    12871 
    12972    my $site        = undef; 
     
    190133    } 
    191134    } 
    192  
    193135     
    194136    my $quoted_import_argv = join(" ", map { "\"$_\"" } @import_argv); 
    195137    my $quoted_buildcol_argv = join(" ", map { "\"$_\"" } @buildcol_argv); 
    196     my $quoted_activate_argv = join(" ", map { "\"$_\"" } @activate_argv); 
     138    my $quoted_activate_argv = join(" ", map { "\"$_\"" } @activate_argv); 
    197139     
    198140    my $final_status = 0; 
    199141 
    200     # need to ensure that the path to perl is quoted (in case there's spaces in it) 
     142    # need to ensure that the path to perl is quoted (in case there's spaces in it) 
    201143    my $launch_cmd = "\"".&util::get_perl_exec()."\" -S ";     
    202144     
     
    206148    print "************************\n"; 
    207149 
    208     my $import_cmd = $launch_cmd . "full-import.pl $quoted_import_argv \"$collect\""; 
     150    my $import_cmd = $launch_cmd . "full-import.pl $quoted_import_argv"; 
    209151 
    210152    my $import_status = system($import_cmd)/256; 
     
    216158    print "************************\n"; 
    217159     
    218     my $buildcol_cmd = $launch_cmd . "full-buildcol.pl $quoted_buildcol_argv \"$collect\""; 
     160    my $buildcol_cmd = $launch_cmd . "full-buildcol.pl $quoted_buildcol_argv"; 
    219161    my $buildcol_status = system($buildcol_cmd)/256; 
    220162 
    221163    if ($buildcol_status == 0) { 
    222164 
    223         #full_replace($site,$collect_dir,$collect,$build_dir,$index_dir); 
    224          
    225         # run activate with -removeold, just like full-buildcol.pl called above runs buildcol.pl 
    226         my $activatecol_cmd = $launch_cmd . "activate.pl -removeold $quoted_activate_argv \"$collect\""; 
    227         my $activatecol_status = system($activatecol_cmd)/256; 
     165        # run activate with -removeold, just like full-buildcol.pl called above runs buildcol.pl 
     166        my $activatecol_cmd = $launch_cmd . "activate.pl -removeold $quoted_activate_argv"; 
     167        my $activatecol_status = system($activatecol_cmd)/256; 
    228168    } 
    229169    else {