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 | # for windows, need PERLPATH in order to launch Perl
|
---|
41 | if($ENV{'GSDLOS'} =~ m/windows/) {
|
---|
42 | die "PERLPATH, which is required for Windows, is not set.\n" unless defined $ENV{'PERLPATH'};
|
---|
43 | }
|
---|
44 | }
|
---|
45 |
|
---|
46 |
|
---|
47 | use strict;
|
---|
48 |
|
---|
49 | use util;
|
---|
50 |
|
---|
51 | sub main
|
---|
52 | {
|
---|
53 | my ($argc,@argv) = @_;
|
---|
54 |
|
---|
55 | if (($argc==0) || (($argc==1) && ($argv[0] =~ m/^--?h(elp)?$/))) {
|
---|
56 | my ($progname) = ($0 =~ m/^.*\/(.*?)$/);
|
---|
57 |
|
---|
58 | print STDERR "\n";
|
---|
59 | print STDERR "Usage: $progname [shared import.pl and buildcol.pl options] collection\n";
|
---|
60 | print STDERR "\n";
|
---|
61 |
|
---|
62 | exit(-1);
|
---|
63 | }
|
---|
64 |
|
---|
65 |
|
---|
66 | my $collect = pop @argv;
|
---|
67 |
|
---|
68 | my $quoted_argv = join(" ", map { "\"$_\"" } @argv);
|
---|
69 |
|
---|
70 | my $final_status = 0;
|
---|
71 |
|
---|
72 | my $launch_cmd = "";
|
---|
73 | $launch_cmd = "$ENV{'PERLPATH'}\\Perl.exe -S " if($ENV{'GSDLOS'} =~ m/windows/);
|
---|
74 |
|
---|
75 | print "\n";
|
---|
76 | print "************************\n";
|
---|
77 | print "* Running Import Stage\n";
|
---|
78 | print "************************\n";
|
---|
79 |
|
---|
80 | my $import_cmd = $launch_cmd . "incremental-import.pl $quoted_argv \"$collect\"";
|
---|
81 |
|
---|
82 | my $import_status = system($import_cmd)/256;
|
---|
83 |
|
---|
84 | if ($import_status == 0) {
|
---|
85 | print "\n";
|
---|
86 | print "************************\n";
|
---|
87 | print "* Running Buildcol Stage\n";
|
---|
88 | print "************************\n";
|
---|
89 |
|
---|
90 |
|
---|
91 | my $buildcol_cmd = $launch_cmd . "incremental-buildcol.pl $quoted_argv \"$collect\"";
|
---|
92 | my $buildcol_status = system($buildcol_cmd)/256;
|
---|
93 | if ($buildcol_status != 0) {
|
---|
94 | $final_status = $buildcol_status;
|
---|
95 | }
|
---|
96 | }
|
---|
97 | else {
|
---|
98 | $final_status = $import_status;
|
---|
99 | }
|
---|
100 |
|
---|
101 | exit($final_status);
|
---|
102 | }
|
---|
103 |
|
---|
104 | &main(scalar(@ARGV),@ARGV);
|
---|
105 |
|
---|