source: gsdl/trunk/bin/script/full-rebuild.pl@ 18470

Last change on this file since 18470 was 18470, checked in by davidb, 15 years ago

Additions scripts to support full (re)building and incremental (re)building

  • Property svn:executable set to *
File size: 3.4 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 ...
31# Followed by: full-buildcol.pl -removeold ...
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
41
42use strict;
43
44use util;
45
46sub main
47{
48 my ($argc,@argv) = @_;
49
50 if (($argc==0) || (($argc==1) && ($argv[0] =~ m/^--?h(elp)?$/))) {
51 my ($progname) = ($0 =~ m/^.*\/(.*?)$/);
52
53 print STDERR "\n";
54 print STDERR "Usage: $progname [option shared between import.pl and buildcol.pl] collection\n";
55 print STDERR "\n";
56
57 exit(-1);
58 }
59
60
61 my $collect = pop @argv;
62
63 my $collect_dir = &util::filename_cat($ENV{'GSDLHOME'},"collect",$collect);
64 if (!-d $collect_dir) {
65 print STDERR "Error: $collect_dir does not exist\n";
66 exit(-1);
67 }
68
69
70
71 my $quoted_argv = join(" ", map { "\"$_\"" } @argv);
72
73 my $final_status = 0;
74
75 print "\n";
76 print "************************\n";
77 print "* Running Import Stage\n";
78 print "************************\n";
79
80 my $import_cmd = "full-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 my $buildcol_cmd = "full-buildcol.pl $quoted_argv \"$collect\"";
91 my $buildcol_status = system($buildcol_cmd)/256;
92 if ($buildcol_status == 0) {
93 my $building_dir = &util::filename_cat($collect_dir,"building");
94 my $index_dir = &util::filename_cat($collect_dir,"index");
95
96 print "\n";
97 print "************************\n";
98 print "* Removing \"index\"\n";
99 print "************************\n";
100
101 &util::rm_r($index_dir);
102
103 print "\n";
104 print "************************\n";
105 print "* Moving \"building\" -> \"index\"\n";
106 print "************************\n";
107
108 &util::mv($building_dir,$index_dir);
109
110 }
111 else {
112 $final_status = $buildcol_status;
113 }
114 }
115 else {
116 $final_status = $import_status;
117 }
118
119 exit($final_status);
120}
121
122&main(scalar(@ARGV),@ARGV);
123
Note: See TracBrowser for help on using the repository browser.