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 |
|
---|
42 | use strict;
|
---|
43 |
|
---|
44 | use Config; # for getting the perlpath in the recommended way
|
---|
45 | use util;
|
---|
46 |
|
---|
47 | sub main
|
---|
48 | {
|
---|
49 | my ($argc,@argv) = @_;
|
---|
50 |
|
---|
51 | if (($argc==0) || (($argc==1) && ($argv[0] =~ m/^--?h(elp)?$/))) {
|
---|
52 | my ($progname) = ($0 =~ m/^.*[\/|\\](.*?)$/);
|
---|
53 |
|
---|
54 | print STDERR "\n";
|
---|
55 | print STDERR "Usage: $progname [shared import.pl and buildcol.pl options] collection\n";
|
---|
56 | print STDERR "\n";
|
---|
57 |
|
---|
58 | exit(-1);
|
---|
59 | }
|
---|
60 |
|
---|
61 |
|
---|
62 | my $collect = pop @argv;
|
---|
63 |
|
---|
64 | my @import_argv = ();
|
---|
65 | my @buildcol_argv = ();
|
---|
66 |
|
---|
67 | my $a;
|
---|
68 | while ($a = shift @argv) {
|
---|
69 | if ($a eq "-manifest") {
|
---|
70 | push(@import_argv,$a);
|
---|
71 |
|
---|
72 | my $af = shift(@argv);
|
---|
73 | push(@import_argv,$af);
|
---|
74 | }
|
---|
75 | else {
|
---|
76 | push(@import_argv,$a);
|
---|
77 | push(@buildcol_argv,$a);
|
---|
78 | }
|
---|
79 |
|
---|
80 | }
|
---|
81 |
|
---|
82 | my $quoted_import_argv = join(" ", map { "\"$_\"" } @import_argv);
|
---|
83 | my $quoted_buildcol_argv = join(" ", map { "\"$_\"" } @buildcol_argv);
|
---|
84 |
|
---|
85 | my $final_status = 0;
|
---|
86 |
|
---|
87 | my $launch_cmd = "";
|
---|
88 | if($ENV{'PERLPATH'}) {
|
---|
89 | # need to ensure that the path to perl is quoted (in case there's spaces in it)
|
---|
90 | if($ENV{'GSDLOS'} =~ m/windows/) {
|
---|
91 | $launch_cmd = "\"$ENV{'PERLPATH'}\\Perl.exe\" -S ";
|
---|
92 | } else {
|
---|
93 | $launch_cmd = "\"$ENV{'PERLPATH'}/perl\" -S ";
|
---|
94 | }
|
---|
95 | } else {
|
---|
96 | #Config{perlpath}, like $^X, is a special variable containing the full path to the current perl executable we are in
|
---|
97 | $launch_cmd = "\"$Config{perlpath}\" -S ";
|
---|
98 | }
|
---|
99 |
|
---|
100 | print STDERR "\n";
|
---|
101 | print STDERR "************************\n";
|
---|
102 | print STDERR "* Running Import Stage\n";
|
---|
103 | print STDERR "************************\n";
|
---|
104 |
|
---|
105 | my $import_cmd = $launch_cmd . "incremental-import.pl $quoted_import_argv \"$collect\"";
|
---|
106 |
|
---|
107 | print STDERR "***** import cmd = $import_cmd\n";
|
---|
108 |
|
---|
109 | my $import_status = system($import_cmd)/256;
|
---|
110 |
|
---|
111 | if ($import_status == 0) {
|
---|
112 | print STDERR "\n";
|
---|
113 | print STDERR "************************\n";
|
---|
114 | print STDERR "* Running Buildcol Stage\n";
|
---|
115 | print STDERR "************************\n";
|
---|
116 |
|
---|
117 |
|
---|
118 | my $buildcol_cmd = $launch_cmd . "incremental-buildcol.pl $quoted_buildcol_argv \"$collect\"";
|
---|
119 | my $buildcol_status = system($buildcol_cmd)/256;
|
---|
120 | if ($buildcol_status != 0) {
|
---|
121 | $final_status = $buildcol_status;
|
---|
122 | }
|
---|
123 | }
|
---|
124 | else {
|
---|
125 | $final_status = $import_status;
|
---|
126 | }
|
---|
127 |
|
---|
128 | exit($final_status);
|
---|
129 | }
|
---|
130 |
|
---|
131 | &main(scalar(@ARGV),@ARGV);
|
---|
132 |
|
---|