Index: /gsdl/trunk/bin/script/full-buildcol.pl
===================================================================
--- /gsdl/trunk/bin/script/full-buildcol.pl	(revision 18470)
+++ /gsdl/trunk/bin/script/full-buildcol.pl	(revision 18470)
@@ -0,0 +1,50 @@
+#!/usr/bin/perl -w
+
+###########################################################################
+#
+# full-buildcol.pl -- runs buildcol.pl with -removeold option on
+# A component of the Greenstone digital library software
+# from the New Zealand Digital Library Project at the 
+# University of Waikato, New Zealand.
+#
+# Copyright (C) 2009 New Zealand Digital Library Project
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+#
+###########################################################################
+
+
+# This program will "buildcol" (or re-"buildcol") a collection from scratch
+# Runs:        buildcol.pl -removeold ...
+
+
+use strict;
+
+my $quoted_argv = join(" ", map { "\"$_\"" } @ARGV);
+
+
+my $buildcol_cmd = "buildcol.pl -removeold $quoted_argv";
+
+my $buildcol_status = system($buildcol_cmd)/256;
+
+if ($buildcol_status != 0) {
+    print STDERR "Error: Failed to run: $buildcol_cmd\n";
+    print STDERR "       $!\n" if ($! ne "");
+    exit(-1);
+}
+
+
+
+
Index: /gsdl/trunk/bin/script/full-import.pl
===================================================================
--- /gsdl/trunk/bin/script/full-import.pl	(revision 18470)
+++ /gsdl/trunk/bin/script/full-import.pl	(revision 18470)
@@ -0,0 +1,47 @@
+#!/usr/bin/perl -w
+
+###########################################################################
+#
+# full-import.pl -- runs import.pl with -removeold option on
+# A component of the Greenstone digital library software
+# from the New Zealand Digital Library Project at the 
+# University of Waikato, New Zealand.
+#
+# Copyright (C) 2009 New Zealand Digital Library Project
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+#
+###########################################################################
+
+
+# This program will import (or re-import) a collection from scratch
+# Runs:        import.pl -removeold ...
+
+
+use strict;
+
+my $quoted_argv = join(" ", map { "\"$_\"" } @ARGV);
+
+
+my $import_cmd = "import.pl -removeold $quoted_argv";
+
+my $import_status = system($import_cmd)/256;
+
+if ($import_status != 0) {
+    print STDERR "Error: Failed to run: $import_cmd\n";
+    print STDERR "       $!\n" if ($! ne "");
+    exit(-1);
+}
+
Index: /gsdl/trunk/bin/script/full-rebuild.pl
===================================================================
--- /gsdl/trunk/bin/script/full-rebuild.pl	(revision 18470)
+++ /gsdl/trunk/bin/script/full-rebuild.pl	(revision 18470)
@@ -0,0 +1,123 @@
+#!/usr/bin/perl -w
+
+###########################################################################
+#
+# full-rebuild.pl --
+# A component of the Greenstone digital library software
+# from the New Zealand Digital Library Project at the 
+# University of Waikato, New Zealand.
+#
+# Copyright (C) 2009 New Zealand Digital Library Project
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+#
+###########################################################################
+
+
+# This program will rebuild a collection from scratch
+# Runs:        full-import.pl -removeold ...
+# Followed by: full-buildcol.pl -removeold ...
+# (assumming import.pl did not end with an error)
+
+
+BEGIN {
+    die "GSDLHOME not set\n" unless defined $ENV{'GSDLHOME'};
+    die "GSDLOS not set\n" unless defined $ENV{'GSDLOS'};
+    unshift (@INC, "$ENV{'GSDLHOME'}/perllib");
+}
+
+
+use strict;
+
+use util;
+
+sub main
+{
+    my ($argc,@argv) = @_;
+
+    if (($argc==0)  || (($argc==1) && ($argv[0] =~ m/^--?h(elp)?$/))) {
+	my ($progname) = ($0 =~ m/^.*\/(.*?)$/);
+
+	print STDERR "\n";
+	print STDERR "Usage: $progname [option shared between import.pl and buildcol.pl] collection\n";
+	print STDERR "\n";
+
+	exit(-1);
+    }
+	
+
+    my $collect = pop @argv;
+
+    my $collect_dir = &util::filename_cat($ENV{'GSDLHOME'},"collect",$collect);
+    if (!-d $collect_dir) {
+	print STDERR "Error: $collect_dir does not exist\n";
+	exit(-1);
+    }
+
+
+    
+    my $quoted_argv = join(" ", map { "\"$_\"" } @argv);
+    
+    my $final_status = 0;
+    
+    print "\n";
+    print "************************\n";
+    print "* Running  Import  Stage\n";
+    print "************************\n";
+    
+    my $import_cmd = "full-import.pl $quoted_argv \"$collect\"";
+    
+    my $import_status = system($import_cmd)/256;
+    
+    if ($import_status == 0) {
+	print "\n";
+	print "************************\n";
+	print "* Running Buildcol Stage\n";
+	print "************************\n";
+	
+	my $buildcol_cmd = "full-buildcol.pl $quoted_argv \"$collect\"";
+	my $buildcol_status = system($buildcol_cmd)/256;
+	if ($buildcol_status == 0) {
+	    my $building_dir = &util::filename_cat($collect_dir,"building");
+	    my $index_dir = &util::filename_cat($collect_dir,"index");
+
+	    print "\n";
+	    print "************************\n";
+	    print "* Removing \"index\"\n";
+	    print "************************\n";
+
+	    &util::rm_r($index_dir);
+
+	    print "\n";
+	    print "************************\n";
+	    print "* Moving \"building\" -> \"index\"\n";
+	    print "************************\n";
+
+	    &util::mv($building_dir,$index_dir);
+
+	}
+	else {
+	    $final_status = $buildcol_status;
+	}
+    }
+    else {
+	$final_status = $import_status;
+    }
+    
+    exit($final_status);
+}
+
+&main(scalar(@ARGV),@ARGV);
+
Index: /gsdl/trunk/bin/script/incremental-buildcol.pl
===================================================================
--- /gsdl/trunk/bin/script/incremental-buildcol.pl	(revision 18470)
+++ /gsdl/trunk/bin/script/incremental-buildcol.pl	(revision 18470)
@@ -0,0 +1,91 @@
+#!/usr/bin/perl -w
+
+###########################################################################
+#
+# incremental-buildcol.pl -- runs buildcol.pl with -incremental on
+# A component of the Greenstone digital library software
+# from the New Zealand Digital Library Project at the 
+# University of Waikato, New Zealand.
+#
+# Copyright (C) 2009 New Zealand Digital Library Project
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+#
+###########################################################################
+
+
+# This program is designed to support incremental building of Greenstone
+# Runs:        buildcol.pl -incremental -builddir GSDLHOME/collect/$collect/index ...
+
+
+BEGIN {
+    die "GSDLHOME not set\n" unless defined $ENV{'GSDLHOME'};
+    die "GSDLOS not set\n" unless defined $ENV{'GSDLOS'};
+    unshift (@INC, "$ENV{'GSDLHOME'}/perllib");
+}
+
+
+use strict;
+
+use util;
+
+
+sub main
+{
+    my ($argc,@argv) = @_;
+
+    if (($argc==0)  || (($argc==1) && ($argv[0] =~ m/^--?h(elp)?$/))) {
+	my ($progname) = ($0 =~ m/^.*\/(.*?)$/);
+
+
+	print STDERR "\n";
+	print STDERR "Usage: $progname [buildcol.pl options] collection\n";
+	print STDERR "\n";
+
+	exit(-1);
+    }
+
+
+    my $collect = pop @argv;
+
+    my $collect_dir = &util::filename_cat($ENV{'GSDLHOME'},"collect",$collect);
+    if (!-d $collect_dir) {
+	print STDERR "Error: $collect_dir does not exist\n";
+	exit(-1);
+    }
+
+    
+    my $index_dir = &util::filename_cat($collect_dir,"index");
+
+
+    my $quoted_argv = join(" ", map { "\"$_\"" } @argv);
+        
+    
+    my $buildcol_cmd = "buildcol.pl -incremental $quoted_argv -builddir \"$index_dir\" \"$collect\"";
+    
+    my $buildcol_status = system($buildcol_cmd)/256;
+    
+    if ($buildcol_status != 0) {
+	print STDERR "Error: Failed to run: $buildcol_cmd\n";
+	print STDERR "       $!\n" if ($! ne "");
+	exit(-1);
+    }
+}
+
+&main(scalar(@ARGV),@ARGV);
+
+
+
+
Index: /gsdl/trunk/bin/script/incremental-import.pl
===================================================================
--- /gsdl/trunk/bin/script/incremental-import.pl	(revision 18470)
+++ /gsdl/trunk/bin/script/incremental-import.pl	(revision 18470)
@@ -0,0 +1,47 @@
+#!/usr/bin/perl -w
+
+###########################################################################
+#
+# full-import.pl -- runs import.pl with -incremental option on
+# A component of the Greenstone digital library software
+# from the New Zealand Digital Library Project at the 
+# University of Waikato, New Zealand.
+#
+# Copyright (C) 2009 New Zealand Digital Library Project
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+#
+###########################################################################
+
+
+# This program is designed to support incremental building of Greenstone
+# Runs:        import.pl -incremental ...
+
+
+use strict;
+
+my $quoted_argv = join(" ", map { "\"$_\"" } @ARGV);
+
+
+my $import_cmd = "import.pl -incremental $quoted_argv";
+
+my $import_status = system($import_cmd)/256;
+
+if ($import_status != 0) {
+    print STDERR "Error: Failed to run: $import_cmd\n";
+    print STDERR "       $!\n" if ($! ne "");
+    exit(-1);
+}
+
Index: /gsdl/trunk/bin/script/incremental-rebuild.pl
===================================================================
--- /gsdl/trunk/bin/script/incremental-rebuild.pl	(revision 18470)
+++ /gsdl/trunk/bin/script/incremental-rebuild.pl	(revision 18470)
@@ -0,0 +1,105 @@
+#!/usr/bin/perl -w
+
+###########################################################################
+#
+# incremental-rebuild.pl --
+# A component of the Greenstone digital library software
+# from the New Zealand Digital Library Project at the 
+# University of Waikato, New Zealand.
+#
+# Copyright (C) 2009 New Zealand Digital Library Project
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+#
+###########################################################################
+
+
+# This program will incrementally rebuild a collection 
+# Runs:        incremental-import.pl -incremental ...
+# Followed by: incremental-buildcol.pl -incremental -builddir index ...
+# (assumming import.pl did not end with an error)
+
+
+BEGIN {
+    die "GSDLHOME not set\n" unless defined $ENV{'GSDLHOME'};
+    die "GSDLOS not set\n" unless defined $ENV{'GSDLOS'};
+    unshift (@INC, "$ENV{'GSDLHOME'}/perllib");
+}
+
+
+use strict;
+
+use util;
+
+sub main
+{
+    my ($argc,@argv) = @_;
+
+    if (($argc==0)  || (($argc==1) && ($argv[0] =~ m/^--?h(elp)?$/))) {
+	my ($progname) = ($0 =~ m/^.*\/(.*?)$/);
+
+	print STDERR "\n";
+	print STDERR "Usage: $progname [shared import.pl and buildcol.pl options] collection\n";
+	print STDERR "\n";
+
+	exit(-1);
+    }
+	
+
+    my $collect = pop @argv;
+
+    my $collect_dir = &util::filename_cat($ENV{'GSDLHOME'},"collect",$collect);
+    if (!-d $collect_dir) {
+	print STDERR "Error: $collect_dir does not exist\n";
+	exit(-1);
+    }
+
+
+    
+    my $quoted_argv = join(" ", map { "\"$_\"" } @argv);
+    
+    my $final_status = 0;
+    
+    print "\n";
+    print "************************\n";
+    print "* Running  Import  Stage\n";
+    print "************************\n";
+    
+    my $import_cmd = "incremental-import.pl $quoted_argv \"$collect\"";
+    
+    my $import_status = system($import_cmd)/256;
+    
+    if ($import_status == 0) {
+	print "\n";
+	print "************************\n";
+	print "* Running Buildcol Stage\n";
+	print "************************\n";
+	
+
+	my $buildcol_cmd = "incremental-buildcol.pl $quoted_argv \"$collect\"";
+	my $buildcol_status = system($buildcol_cmd)/256;
+	if ($buildcol_status != 0) {
+	    $final_status = $buildcol_status;
+	}
+    }
+    else {
+	$final_status = $import_status;
+    }
+    
+    exit($final_status);
+}
+
+&main(scalar(@ARGV),@ARGV);
+
