[18470] | 1 | #!/usr/bin/perl -w
|
---|
| 2 |
|
---|
| 3 | ###########################################################################
|
---|
| 4 | #
|
---|
| 5 | # incremental-rebuild.pl --
|
---|
| 6 | # A component of the Greenstone digital library software
|
---|
| 7 | # from the New Zealand Digital Library Project at the
|
---|
| 8 | # University of Waikato, New Zealand.
|
---|
| 9 | #
|
---|
| 10 | # Copyright (C) 2009 New Zealand Digital Library Project
|
---|
| 11 | #
|
---|
| 12 | # This program is free software; you can redistribute it and/or modify
|
---|
| 13 | # it under the terms of the GNU General Public License as published by
|
---|
| 14 | # the Free Software Foundation; either version 2 of the License, or
|
---|
| 15 | # (at your option) any later version.
|
---|
| 16 | #
|
---|
| 17 | # This program is distributed in the hope that it will be useful,
|
---|
| 18 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
| 19 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
| 20 | # GNU General Public License for more details.
|
---|
| 21 | #
|
---|
| 22 | # You should have received a copy of the GNU General Public License
|
---|
| 23 | # along with this program; if not, write to the Free Software
|
---|
| 24 | # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
---|
| 25 | #
|
---|
| 26 | ###########################################################################
|
---|
| 27 |
|
---|
| 28 |
|
---|
| 29 | # This program will incrementally rebuild a collection
|
---|
| 30 | # Runs: incremental-import.pl -incremental ...
|
---|
| 31 | # Followed by: incremental-buildcol.pl -incremental -builddir index ...
|
---|
| 32 | # (assumming import.pl did not end with an error)
|
---|
| 33 |
|
---|
| 34 |
|
---|
| 35 | BEGIN {
|
---|
| 36 | die "GSDLHOME not set\n" unless defined $ENV{'GSDLHOME'};
|
---|
| 37 | die "GSDLOS not set\n" unless defined $ENV{'GSDLOS'};
|
---|
| 38 | unshift (@INC, "$ENV{'GSDLHOME'}/perllib");
|
---|
| 39 | }
|
---|
| 40 |
|
---|
| 41 | use strict;
|
---|
| 42 | use util;
|
---|
| 43 |
|
---|
| 44 | sub main
|
---|
| 45 | {
|
---|
| 46 | my ($argc,@argv) = @_;
|
---|
| 47 |
|
---|
| 48 | if (($argc==0) || (($argc==1) && ($argv[0] =~ m/^--?h(elp)?$/))) {
|
---|
[20606] | 49 | my ($progname) = ($0 =~ m/^.*[\/|\\](.*?)$/);
|
---|
[18470] | 50 |
|
---|
| 51 | print STDERR "\n";
|
---|
| 52 | print STDERR "Usage: $progname [shared import.pl and buildcol.pl options] collection\n";
|
---|
| 53 | print STDERR "\n";
|
---|
| 54 |
|
---|
| 55 | exit(-1);
|
---|
| 56 | }
|
---|
| 57 |
|
---|
| 58 |
|
---|
| 59 | my $collect = pop @argv;
|
---|
| 60 |
|
---|
[20606] | 61 | my @import_argv = ();
|
---|
| 62 | my @buildcol_argv = ();
|
---|
| 63 |
|
---|
| 64 | my $a;
|
---|
| 65 | while ($a = shift @argv) {
|
---|
| 66 | if ($a eq "-manifest") {
|
---|
| 67 | push(@import_argv,$a);
|
---|
| 68 |
|
---|
| 69 | my $af = shift(@argv);
|
---|
| 70 | push(@import_argv,$af);
|
---|
| 71 | }
|
---|
| 72 | else {
|
---|
| 73 | push(@import_argv,$a);
|
---|
| 74 | push(@buildcol_argv,$a);
|
---|
| 75 | }
|
---|
| 76 |
|
---|
| 77 | }
|
---|
| 78 |
|
---|
| 79 | my $quoted_import_argv = join(" ", map { "\"$_\"" } @import_argv);
|
---|
| 80 | my $quoted_buildcol_argv = join(" ", map { "\"$_\"" } @buildcol_argv);
|
---|
[18470] | 81 |
|
---|
| 82 | my $final_status = 0;
|
---|
| 83 |
|
---|
[20925] | 84 | # need to ensure that the path to perl is quoted (in case there's spaces in it)
|
---|
[24362] | 85 | my $launch_cmd = "\"".&util::get_perl_exec()."\" -S ";
|
---|
[19409] | 86 |
|
---|
[23192] | 87 | print STDERR "\n";
|
---|
| 88 | print STDERR "************************\n";
|
---|
| 89 | print STDERR "* Running Import Stage\n";
|
---|
| 90 | print STDERR "************************\n";
|
---|
[18470] | 91 |
|
---|
[20606] | 92 | my $import_cmd = $launch_cmd . "incremental-import.pl $quoted_import_argv \"$collect\"";
|
---|
[23192] | 93 |
|
---|
| 94 | print STDERR "***** import cmd = $import_cmd\n";
|
---|
| 95 |
|
---|
[18470] | 96 | my $import_status = system($import_cmd)/256;
|
---|
| 97 |
|
---|
| 98 | if ($import_status == 0) {
|
---|
[23192] | 99 | print STDERR "\n";
|
---|
| 100 | print STDERR "************************\n";
|
---|
| 101 | print STDERR "* Running Buildcol Stage\n";
|
---|
| 102 | print STDERR "************************\n";
|
---|
[18470] | 103 |
|
---|
| 104 |
|
---|
[20606] | 105 | my $buildcol_cmd = $launch_cmd . "incremental-buildcol.pl $quoted_buildcol_argv \"$collect\"";
|
---|
[18470] | 106 | my $buildcol_status = system($buildcol_cmd)/256;
|
---|
| 107 | if ($buildcol_status != 0) {
|
---|
| 108 | $final_status = $buildcol_status;
|
---|
| 109 | }
|
---|
| 110 | }
|
---|
| 111 | else {
|
---|
| 112 | $final_status = $import_status;
|
---|
| 113 | }
|
---|
| 114 |
|
---|
| 115 | exit($final_status);
|
---|
| 116 | }
|
---|
| 117 |
|
---|
| 118 | &main(scalar(@ARGV),@ARGV);
|
---|
| 119 |
|
---|