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

Last change on this file since 19409 was 19409, checked in by ak19, 15 years ago

Getting the incremental build scripts to work on Windows (it already works on the Vista here, but only because .pl files were associated with Perl).

  • Property svn:executable set to *
File size: 4.3 KB
RevLine 
[18470]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");
[19409]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 }
[18470]44}
45
46
47use strict;
48
49use util;
50
51sub 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 [option shared between import.pl and buildcol.pl] collection\n";
60 print STDERR "\n";
61
62 exit(-1);
63 }
64
65
66 my $collect = pop @argv;
67
[18510]68
69 my @filtered_argv = ();
70
71 my $collect_dir = undef;
72 my $build_dir = undef;
73
74 while (my $arg = shift @argv) {
75 if ($arg eq "-collectdir") {
76 $collect_dir = shift @argv;
77 push(@filtered_argv,$arg,$collect_dir);
78 }
79 elsif ($arg eq "-builddir") {
80 $build_dir = shift @argv;
81 push(@filtered_argv,$arg,$build_dir);
82 }
83 else {
84 push(@filtered_argv,$arg);
85 }
86 }
87
88
89 if (!defined $collect_dir) {
90 $collect_dir = &util::filename_cat($ENV{'GSDLHOME'},"collect");
91 }
92 my $this_collect_dir = &util::filename_cat($collect_dir,$collect);
93
94 if (!-d $this_collect_dir) {
[18470]95 print STDERR "Error: $collect_dir does not exist\n";
96 exit(-1);
97 }
98
99
[18510]100 if (!defined $build_dir) {
101 $build_dir = &util::filename_cat($this_collect_dir,"building");
102 push(@filtered_argv,"-builddir",$build_dir);
103 }
104
[18470]105
106 my $quoted_argv = join(" ", map { "\"$_\"" } @argv);
107
108 my $final_status = 0;
[19409]109
110 my $launch_cmd = "";
111 $launch_cmd = "$ENV{'PERLPATH'}\\Perl.exe -S " if($ENV{'GSDLOS'} =~ m/windows/);
[18470]112
113 print "\n";
114 print "************************\n";
115 print "* Running Import Stage\n";
116 print "************************\n";
[19409]117
118 my $import_cmd = $launch_cmd . "full-import.pl $quoted_argv \"$collect\"";
119
[18470]120 my $import_status = system($import_cmd)/256;
121
122 if ($import_status == 0) {
123 print "\n";
124 print "************************\n";
125 print "* Running Buildcol Stage\n";
126 print "************************\n";
127
[19409]128 my $buildcol_cmd = $launch_cmd . "full-buildcol.pl $quoted_argv \"$collect\"";
[18470]129 my $buildcol_status = system($buildcol_cmd)/256;
130 if ($buildcol_status == 0) {
[18529]131 my $index_dir = &util::filename_cat($this_collect_dir,"index");
[18527]132
133 if (-e $index_dir) {
134 print "\n";
135 print "************************\n";
136 print "* Removing \"index\"\n";
137 print "************************\n";
138
139 &util::rm_r($index_dir);
140 }
[18470]141
142 print "\n";
143 print "************************\n";
144 print "* Moving \"building\" -> \"index\"\n";
145 print "************************\n";
146
[18510]147 &util::mv($build_dir,$index_dir);
[18470]148
149 }
150 else {
151 $final_status = $buildcol_status;
152 }
153 }
154 else {
155 $final_status = $import_status;
156 }
157
158 exit($final_status);
159}
160
161&main(scalar(@ARGV),@ARGV);
162
Note: See TracBrowser for help on using the repository browser.