Changeset 29108 for main/trunk
- Timestamp:
- 2014-06-26T10:34:58+12:00 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/trunk/greenstone2/bin/script/full-rebuild.pl
r26913 r29108 28 28 29 29 # 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) 33 34 34 35 BEGIN { … … 41 42 use util; 42 43 43 44 # This subroutine has been replaced by a call to activate.pl in sub main45 sub full_replace46 {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 status85 &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 status94 &util::mv($build_dir,$index_dir);95 }96 97 44 sub main 98 45 { … … 103 50 104 51 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"; 108 53 print STDERR "\n"; 109 54 print STDERR "Usage: $progname [options]| collection\n"; 55 print STDERR "\n"; 110 56 print STDERR " If a minus option is shared between import.pl and buildcol.pl then it can appear\n"; 111 57 print STDERR " as is, such as -verbosity 5. This value will be passed to both programs.\n"; 112 58 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"; 116 63 print STDERR "\n"; 117 64 118 65 exit(-1); 119 66 } 120 121 122 my $collect = pop @argv;123 124 67 125 68 my @import_argv = (); 126 69 my @buildcol_argv = (); 127 70 my @activate_argv = (); 128 71 129 72 my $site = undef; … … 190 133 } 191 134 } 192 193 135 194 136 my $quoted_import_argv = join(" ", map { "\"$_\"" } @import_argv); 195 137 my $quoted_buildcol_argv = join(" ", map { "\"$_\"" } @buildcol_argv); 196 138 my $quoted_activate_argv = join(" ", map { "\"$_\"" } @activate_argv); 197 139 198 140 my $final_status = 0; 199 141 200 142 # need to ensure that the path to perl is quoted (in case there's spaces in it) 201 143 my $launch_cmd = "\"".&util::get_perl_exec()."\" -S "; 202 144 … … 206 148 print "************************\n"; 207 149 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"; 209 151 210 152 my $import_status = system($import_cmd)/256; … … 216 158 print "************************\n"; 217 159 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"; 219 161 my $buildcol_status = system($buildcol_cmd)/256; 220 162 221 163 if ($buildcol_status == 0) { 222 164 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; 228 168 } 229 169 else {
Note:
See TracChangeset
for help on using the changeset viewer.