source: gsdl/trunk/bin/script/incremental-import.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.0 KB
Line 
1#!/usr/bin/perl -w
2
3###########################################################################
4#
5# full-import.pl -- runs import.pl with -incremental option on
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 is designed to support incremental building of Greenstone
30# Runs: import.pl -incremental ...
31
32
33
34BEGIN {
35 die "GSDLHOME not set\n" unless defined $ENV{'GSDLHOME'};
36 die "GSDLOS not set\n" unless defined $ENV{'GSDLOS'};
37 unshift (@INC, "$ENV{'GSDLHOME'}/perllib");
38
39 # for windows, need PERLPATH in order to launch Perl
40 if($ENV{'GSDLOS'} =~ m/windows/) {
41 die "PERLPATH, which is required for Windows, is not set.\n" unless defined $ENV{'PERLPATH'};
42 }
43}
44
45
46use strict;
47
48use util;
49
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
59 print STDERR "\n";
60 print STDERR "Usage: $progname [import.pl options] collection\n";
61 print STDERR "\n";
62
63 exit(-1);
64 }
65
66
67 my $collect = pop @argv;
68
69 my @filtered_argv = ();
70
71 my $collect_dir = undef;
72 my $archive_dir = undef;
73
74 while (my $arg = shift @argv) {
75 # No actual filtering happens at the moment (@filterd_argv == @argv)
76 # Useful to do it this way if we want incremental-import.pl
77 # to start accepting its own arguments that are different to import.pl
78
79 if ($arg eq "-collectdir") {
80 $collect_dir = shift @argv;
81 push(@filtered_argv,$arg,$collect_dir);
82 }
83 elsif ($arg eq "-archivedir") {
84 $archive_dir = shift @argv;
85 push(@filtered_argv,$arg,$archive_dir);
86 }
87 else {
88 push(@filtered_argv,$arg);
89 }
90 }
91
92 if (!defined $collect_dir) {
93 $collect_dir = &util::filename_cat($ENV{'GSDLHOME'},"collect");
94 }
95 my $this_collect_dir = &util::filename_cat($collect_dir,$collect);
96
97 if (!-d $this_collect_dir) {
98 print STDERR "Error: $this_collect_dir does not exist\n";
99 exit(-1);
100 }
101
102
103 if (!defined $archive_dir) {
104 $archive_dir = &util::filename_cat($this_collect_dir,"archives");
105 }
106
107 my $archiveinf_doc = &util::filename_cat($archive_dir,"archiveinf-doc");
108 &util::rename_gdbm_file($archiveinf_doc); # ensure gdb
109 $archiveinf_doc .= ".gdb";
110 my $quoted_argv = join(" ", map { "\"$_\"" } @filtered_argv);
111
112
113 my $import_cmd = "import.pl";
114 if($ENV{'GSDLOS'} =~ m/windows/) {
115 $import_cmd = "$ENV{'PERLPATH'}\\Perl.exe -S $import_cmd";
116 #$import_cmd = "perl -S $import_cmd";
117 }
118 if (-e $archiveinf_doc) {
119 $import_cmd .= " -incremental";
120
121 }
122 else {
123### print STDERR "$archiveinf_doc does not exist.\n";
124 print STDERR "*****\n";
125 print STDERR "First time built. Switching to full import.pl.\n";
126 print STDERR "*****\n";
127 $import_cmd .= " -removeold";
128 }
129
130 $import_cmd .= " $quoted_argv \"$collect\"";
131
132
133 my $import_status = system($import_cmd)/256;
134
135 if ($import_status != 0) {
136 print STDERR "Error: Failed to run: $import_cmd\n";
137 print STDERR " $!\n" if ($! ne "");
138 exit(-1);
139 }
140}
141
142&main(scalar(@ARGV),@ARGV);
Note: See TracBrowser for help on using the repository browser.