source: main/trunk/greenstone2/bin/script/incremental-rebuild.pl@ 24747

Last change on this file since 24747 was 24747, checked in by davidb, 9 years ago

Tidied up support for -site in full-rebuild.pl and incremental-rebuild.pl plug more consistent handling of import.pl/buildcol.pl specific arguments. Tweaked wording printed out when switching from incremental to full building

  • Property svn:executable set to *
File size: 4.3 KB
Line 
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
35BEGIN {
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
41use strict;
42use util;
43
44sub main
45{
46 my ($argc,@argv) = @_;
47
48 if (($argc==0) || (($argc==1) && ($argv[0] =~ m/^--?h(elp)?$/))) {
49 my ($progname) = ($0 =~ m/^.*[\/|\\](.*?)$/);
50
51 print STDERR "\n";
52 print STDERR "This program runs -- incrementally where possible -- import.pl followed by buildcol.pl (retaining any\n";
53 print STDERR " previously generated files in 'archives' or 'index'). The import.pl script can always be run\n";
54 print STDERR " incrementally in Greenstone, however buildcol.pl will default to a full rebuild if the indexer\n";
55 print STDERR " the collection uses (such as mg, or mgpp) does not support incremental indexing.\n";
56 print STDERR "\n";
57 print STDERR "Usage: $progname [shared import.pl and buildcol.pl options] collection\n";
58 print STDERR "\n";
59
60 exit(-1);
61 }
62
63
64 my $collect = pop @argv;
65
66 my @import_argv = ();
67 my @buildcol_argv = ();
68
69 while (my $arg = shift @argv) {
70
71 if ($arg eq "-manifest") {
72 # only makes sense in import.pl
73 my $manifest = shift(@argv);
74 push(@import_argv,$arg,$manifest);
75 }
76 elsif ($arg eq "-importdir") {
77 # only makes sense in import.pl
78 my $import_dir = shift @argv;
79 push(@import_argv,$arg,$import_dir);
80 }
81 elsif ($arg eq "-builddir") {
82 # only makes sense in build.pl
83 my $build_dir = shift @argv;
84 push(@buildcol_argv,$arg,$build_dir);
85 }
86 elsif ($arg eq "-indexdir") {
87 # only makes sense in build.pl
88 my $index_dir = shift @argv;
89 push(@buildcol_argv,$arg,$index_dir);
90 }
91 else {
92 push(@import_argv,$arg);
93 push(@buildcol_argv,$arg);
94 }
95
96 }
97
98 my $quoted_import_argv = join(" ", map { "\"$_\"" } @import_argv);
99 my $quoted_buildcol_argv = join(" ", map { "\"$_\"" } @buildcol_argv);
100
101 my $final_status = 0;
102
103 # need to ensure that the path to perl is quoted (in case there's spaces in it)
104 my $launch_cmd = "\"".&util::get_perl_exec()."\" -S ";
105
106 print STDERR "\n";
107 print STDERR "************************\n";
108 print STDERR "* Running Import Stage\n";
109 print STDERR "************************\n";
110
111 my $import_cmd = $launch_cmd . "incremental-import.pl $quoted_import_argv \"$collect\"";
112
113 my $import_status = system($import_cmd)/256;
114
115 if ($import_status == 0) {
116 print STDERR "\n";
117 print STDERR "************************\n";
118 print STDERR "* Running Buildcol Stage\n";
119 print STDERR "************************\n";
120
121
122 my $buildcol_cmd = $launch_cmd . "incremental-buildcol.pl $quoted_buildcol_argv \"$collect\"";
123 my $buildcol_status = system($buildcol_cmd)/256;
124 if ($buildcol_status != 0) {
125 $final_status = $buildcol_status;
126 }
127 }
128 else {
129 $final_status = $import_status;
130 }
131
132 exit($final_status);
133}
134
135&main(scalar(@ARGV),@ARGV);
136
Note: See TracBrowser for help on using the repository browser.