Index: /main/trunk/greenstone2/bin/script/full-rebuild.pl
===================================================================
--- /main/trunk/greenstone2/bin/script/full-rebuild.pl	(revision 24746)
+++ /main/trunk/greenstone2/bin/script/full-rebuild.pl	(revision 24747)
@@ -43,4 +43,56 @@
 
 
+sub full_replace
+{
+    my ($site,$collect_dir,$collect,$build_dir,$index_dir) = @_;
+
+
+    if (!defined $build_dir) {
+	if (defined $collect_dir) {
+	    $build_dir = &util::filename_cat($collect_dir,$collect, "building");
+	}
+	else {
+	    if (defined $site) {
+		$build_dir = &util::filename_cat($ENV{'GSDL3HOME'},"sites",$site,"collect",$collect, "building");
+	    }
+	    else {
+		$build_dir = &util::filename_cat($ENV{'GSDLHOME'},"collect",$collect, "building");
+	    }
+	}
+    }
+    
+    if (!defined $index_dir) {
+	if (defined $collect_dir) {
+	    $index_dir = &util::filename_cat($collect_dir,$collect, "index");
+	}
+	else {
+	    if (defined $site) {
+		$index_dir = &util::filename_cat($ENV{'GSDL3HOME'},"sites",$site,"collect",$collect, "index");
+	    }
+	    else {
+		$index_dir = &util::filename_cat($ENV{'GSDLHOME'},"collect",$collect, "index");
+	    }
+	}
+    }
+    
+    if (-e $index_dir) {
+	print "\n";
+	print "************************\n";
+	print "* Removing \"index\"\n";
+	print "************************\n";
+
+	# An improvement would be to check on error status
+	&util::rm_r($index_dir);
+    }
+    
+    print "\n";
+    print "************************\n";
+    print "* Moving \"building\" -> \"index\"\n";
+    print "************************\n";
+    
+    # An improvement would be to check on error status
+    &util::mv($build_dir,$index_dir);    
+}
+
 sub main
 {
@@ -51,4 +103,8 @@
 
 	print STDERR "\n";
+	print STDERR "This program runs import.pl followed by buildcol.pl (in both cases removing any previously\n";
+	print STDERR "  generated files in 'archives' or 'building'), and then replaces the content of collection's\n";
+	print STDERR "  'index' directory with 'building'.";
+	print STDERR "\n";
 	print STDERR "Usage: $progname [option shared between import.pl and buildcol.pl] collection\n";
 	print STDERR "\n";
@@ -61,42 +117,47 @@
 
 
-    my @filtered_argv = ();
-
+    my @import_argv = ();
+    my @buildcol_argv = ();
+
+    my $site        = undef;
     my $collect_dir = undef;
-    my $build_dir  = undef;
+    my $build_dir   = undef;
+    my $index_dir   = undef;
 
     while (my $arg = shift @argv) {
-	if ($arg eq "-collectdir") {
+	if ($arg eq "-site") {
+	    $site = shift @argv;
+	    push(@import_argv,$arg,$site);
+	    push(@buildcol_argv,$arg,$site);
+	}
+	elsif ($arg eq "-collectdir") {
 	    $collect_dir = shift @argv;
-	    push(@filtered_argv,$arg,$collect_dir);
+	    push(@import_argv,$arg,$collect_dir);
+	    push(@buildcol_argv,$arg,$collect_dir);
+	}
+	elsif ($arg eq "-importdir") {
+	    # only makes sense in import.pl
+	    my $import_dir = shift @argv;
+	    push(@import_argv,$arg,$import_dir);
 	}
 	elsif ($arg eq "-builddir") {
+	    # only makes sense in buildcol.pl
 	    $build_dir = shift @argv;
-	    push(@filtered_argv,$arg,$build_dir);
-	}
-	else {
-	    push(@filtered_argv,$arg);
-	}
-    }
-
-
-    if (!defined $collect_dir) {
-	$collect_dir = &util::filename_cat($ENV{'GSDLHOME'},"collect");
-    }
-    my $this_collect_dir = &util::filename_cat($collect_dir,$collect);
-
-    if (!-d $this_collect_dir) {
-	print STDERR "Error: $collect_dir does not exist\n";
-	exit(-1);
-    }
-
-
-    if (!defined $build_dir) {
-	$build_dir = &util::filename_cat($this_collect_dir,"building");
-	push(@filtered_argv,"-builddir",$build_dir);
-    }
-
-    
-    my $quoted_argv = join(" ", map { "\"$_\"" } @argv);
+	    push(@buildcol_argv,$arg,$build_dir);
+	}
+	elsif ($arg eq "-indexdir") {
+	    # only makes sense in buildcol.pl
+	    $index_dir = shift @argv;
+	    push(@buildcol_argv,$arg,$index_dir);
+	}
+	else {
+	    push(@import_argv,$arg);
+	    push(@buildcol_argv,$arg);
+	}
+    }
+
+    
+    my $quoted_import_argv = join(" ", map { "\"$_\"" } @import_argv);
+    my $quoted_buildcol_argv = join(" ", map { "\"$_\"" } @buildcol_argv);
     
     my $final_status = 0;
@@ -110,5 +171,5 @@
     print "************************\n";
 
-    my $import_cmd = $launch_cmd . "full-import.pl $quoted_argv \"$collect\"";
+    my $import_cmd = $launch_cmd . "full-import.pl $quoted_import_argv \"$collect\"";
 
     my $import_status = system($import_cmd)/256;
@@ -120,25 +181,10 @@
 	print "************************\n";
 	
-	my $buildcol_cmd = $launch_cmd . "full-buildcol.pl $quoted_argv \"$collect\"";
+	my $buildcol_cmd = $launch_cmd . "full-buildcol.pl $quoted_buildcol_argv \"$collect\"";
 	my $buildcol_status = system($buildcol_cmd)/256;
+
 	if ($buildcol_status == 0) {
-	    my $index_dir = &util::filename_cat($this_collect_dir,"index");
-	    
-	    if (-e $index_dir) {
-		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($build_dir,$index_dir);
-
+
+	    full_replace($site,$collect_dir,$collect,$build_dir,$index_dir);
 	}
 	else {
Index: /main/trunk/greenstone2/bin/script/incremental-buildcol.pl
===================================================================
--- /main/trunk/greenstone2/bin/script/incremental-buildcol.pl	(revision 24746)
+++ /main/trunk/greenstone2/bin/script/incremental-buildcol.pl	(revision 24747)
@@ -125,5 +125,5 @@
 	if ($buildcfg->{'buildtype'} ne $collectcfg->{'buildtype'}) {
 	    print STDERR "*****\n";
-	    print STDERR "* Change of indexer detected. Switching to full buildcol.pl.\n";
+	    print STDERR "* Change of indexer detected. Switching to full buildcol.pl (with -removeold).\n";
 	    print STDERR "*****\n";
 	    $buildcol_cmd .= " -removeold";
@@ -137,5 +137,5 @@
 	# build.cfg doesn't exit
 	print STDERR "*****\n";
-	print STDERR "* First time built. Switching to full buildcol.pl.\n";
+	print STDERR "* First time built. Switching to full buildcol.pl (with -removeold).\n";
 	print STDERR "*****\n";
 	$buildcol_cmd .= " -removeold";
Index: /main/trunk/greenstone2/bin/script/incremental-rebuild.pl
===================================================================
--- /main/trunk/greenstone2/bin/script/incremental-rebuild.pl	(revision 24746)
+++ /main/trunk/greenstone2/bin/script/incremental-rebuild.pl	(revision 24747)
@@ -50,4 +50,9 @@
 
 	print STDERR "\n";
+	print STDERR "This program runs -- incrementally where possible -- import.pl followed by buildcol.pl (retaining any\n";
+	print STDERR "  previously generated files in 'archives' or 'index').  The import.pl script can always be run\n";
+        print STDERR "  incrementally in Greenstone, however buildcol.pl will default to a full rebuild if the indexer\n";
+        print STDERR "  the collection uses (such as mg, or mgpp) does not support incremental indexing.\n";
+	print STDERR "\n";
 	print STDERR "Usage: $progname [shared import.pl and buildcol.pl options] collection\n";
 	print STDERR "\n";
@@ -62,15 +67,29 @@
     my @buildcol_argv = ();
 
-    my $a;
-    while ($a = shift @argv) {
-	if ($a eq "-manifest") {
-	    push(@import_argv,$a);
+    while (my $arg = shift @argv) {
 
-	    my $af = shift(@argv);
-	    push(@import_argv,$af);
+	if ($arg eq "-manifest") {
+	    # only makes sense in import.pl
+	    my $manifest = shift(@argv);
+	    push(@import_argv,$arg,$manifest);
+	}
+	elsif ($arg eq "-importdir") {
+	    # only makes sense in import.pl
+	    my $import_dir = shift @argv;
+	    push(@import_argv,$arg,$import_dir);
+	}
+	elsif ($arg eq "-builddir") {
+	    # only makes sense in build.pl
+	    my $build_dir = shift @argv;
+	    push(@buildcol_argv,$arg,$build_dir);
+	}
+	elsif ($arg eq "-indexdir") {
+	    # only makes sense in build.pl
+	    my $index_dir = shift @argv;
+	    push(@buildcol_argv,$arg,$index_dir);
 	}
 	else {
-	    push(@import_argv,$a);
-	    push(@buildcol_argv,$a);
+	    push(@import_argv,$arg);
+	    push(@buildcol_argv,$arg);
 	}
 
@@ -91,6 +110,4 @@
     
     my $import_cmd = $launch_cmd . "incremental-import.pl $quoted_import_argv \"$collect\"";
-
-    print STDERR "***** import cmd = $import_cmd\n";
 
     my $import_status = system($import_cmd)/256;
