source: main/trunk/greenstone2/bin/script/full-rebuild.pl@ 34128

Last change on this file since 34128 was 34128, checked in by ak19, 4 years ago

When rebuilding the opotiki site today, had noticed that full-rebuild's call to activate was attempting to get the collection in default library to be activated, rather than the collection in the opotiki library. Although activate.pl has a library_name minus option (and one for library_url too) for this purpose when activate.pl is called directly, and although buildcol.pl is set up to pass these 2 options on to activate.pl if buildcol was called with minus-activate, full-rebuild.pl did not yet have code to allow for the library_name and library_url options to be passed through to buildcol and activate. Fixed and tested with a sample collection in the opotiki site on the machine where I built the opotiki collections today. Am committing from this svn version.

  • Property svn:executable set to *
File size: 6.8 KB
Line 
1#!/usr/bin/perl -w
2
3###########################################################################
4#
5# full-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 rebuild a collection from scratch
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)
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 full-import.pl, full-buildcol.pl, activate.pl (in each case removing any previously generated files in 'archives', 'building','index')\n";
53 print STDERR "\n";
54 print STDERR "Usage: $progname [options]| collection\n";
55 print STDERR "\n";
56 print STDERR " If a minus option is shared between import.pl and buildcol.pl then it can appear\n";
57 print STDERR " as is, such as -verbosity 5. This value will be passed to both programs.\n";
58 print STDERR " If a minus option is specific to one of the programs in particular, then prefix\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";
63 print STDERR "\n";
64
65 exit(-1);
66 }
67
68 my @import_argv = ();
69 my @buildcol_argv = ();
70 my @activate_argv = ();
71
72 my $site = undef;
73 my $collect_dir = undef;
74 my $build_dir = undef;
75 my $index_dir = undef;
76 my $verbosity = 2; # same as the default in buildcol.pl
77
78 while (my $arg = shift @argv) {
79 if ($arg eq "-site") {
80 $site = shift @argv;
81 push(@import_argv,$arg,$site);
82 push(@buildcol_argv,$arg,$site);
83 push(@activate_argv,$arg,$site);
84 }
85 elsif ($arg eq "-collectdir") {
86 $collect_dir = shift @argv;
87 push(@import_argv,$arg,$collect_dir);
88 push(@buildcol_argv,$arg,$collect_dir);
89 push(@activate_argv,$arg,$collect_dir);
90 }
91 elsif ($arg eq "-importdir") {
92 # only makes sense in import.pl
93 my $import_dir = shift @argv;
94 push(@import_argv,$arg,$import_dir);
95 }
96 elsif ($arg eq "-builddir") {
97 # only makes sense in buildcol.pl and activate.pl
98 $build_dir = shift @argv;
99 push(@buildcol_argv,$arg,$build_dir);
100 push(@activate_argv,$arg,$build_dir);
101 }
102 elsif ($arg eq "-indexdir") {
103 # only makes sense in buildcol.pl and activate.pl
104 $index_dir = shift @argv;
105 push(@buildcol_argv,$arg,$index_dir);
106 push(@activate_argv,$arg,$index_dir);
107 }
108 elsif ($arg eq "-verbosity") {
109 $verbosity = shift @argv;
110 push(@import_argv,$arg,$verbosity);
111 push(@buildcol_argv,$arg,$verbosity);
112 push(@activate_argv,$arg,$verbosity);
113 }
114 elsif ($arg =~ /-import:(.*)$/) {
115 my $import_arg = "-".$1;
116 my $import_val = shift @argv;
117 push(@import_argv,$import_arg,$import_val);
118 }
119 elsif ($arg =~ /-buildcol:(.*)$/) {
120 my $buildcol_arg = "-".$1;
121 my $buildcol_val = shift @argv;
122 push(@buildcol_argv,$buildcol_arg,$buildcol_val);
123 }
124 elsif ($arg =~ /-activate:(.*)$/) {
125 my $activate_arg = "-".$1;
126 my $activate_val = shift @argv;
127 push(@activate_argv,$activate_arg,$activate_val);
128 }
129 elsif ($arg eq "-library_url" || $arg eq "-library_name") {
130 # only makes sense in buildcol.pl and activate.pl
131 # we want buildcol.pl to send it to activate if running buildcol.pl with -activate
132 # And we want activate.pl to get it if running activate.pl
133 $build_dir = shift @argv;
134 push(@buildcol_argv,$arg,$build_dir);
135 push(@activate_argv,$arg,$build_dir);
136 }
137 elsif ($arg =~ "-OIDtype") {
138 shift @argv; # skip OIDtype (don't pass OIDtype to buildcol.pl. It's not currently accepted.)
139 # this allows us to run full-rebuild.pl -OIDtype filename for instance
140 }
141 else {
142 push(@import_argv,$arg);
143 push(@buildcol_argv,$arg);
144 push(@activate_argv,$arg);
145 }
146 }
147
148 my $quoted_import_argv = join(" ", map { "\"$_\"" } @import_argv);
149 my $quoted_buildcol_argv = join(" ", map { "\"$_\"" } @buildcol_argv);
150 my $quoted_activate_argv = join(" ", map { "\"$_\"" } @activate_argv);
151
152 my $final_status = 0;
153
154 # need to ensure that the path to perl is quoted (in case there's spaces in it)
155 my $launch_cmd = "\"".&util::get_perl_exec()."\" -S ";
156
157 print "\n";
158 print "************************\n";
159 print "* Running Import Stage\n";
160 print "************************\n";
161
162 my $import_cmd = $launch_cmd . "full-import.pl $quoted_import_argv";
163
164 my $import_status = system($import_cmd)/256;
165
166 if ($import_status == 0) {
167 print "\n";
168 print "************************\n";
169 print "* Running Buildcol Stage\n";
170 print "************************\n";
171
172 my $buildcol_cmd = $launch_cmd . "full-buildcol.pl $quoted_buildcol_argv";
173 my $buildcol_status = system($buildcol_cmd)/256;
174
175 if ($buildcol_status == 0) {
176
177 # run activate with -removeold, just like full-buildcol.pl called above runs buildcol.pl
178 my $activatecol_cmd = $launch_cmd . "activate.pl -removeold $quoted_activate_argv";
179 my $activatecol_status = system($activatecol_cmd)/256;
180 }
181 else {
182 $final_status = $buildcol_status;
183 }
184 }
185 else {
186 $final_status = $import_status;
187 }
188
189 exit($final_status);
190}
191
192&main(scalar(@ARGV),@ARGV);
193
Note: See TracBrowser for help on using the repository browser.