Index: trunk/ippScripts/scripts/chip_imfile.pl
===================================================================
--- trunk/ippScripts/scripts/chip_imfile.pl	(revision 19127)
+++ trunk/ippScripts/scripts/chip_imfile.pl	(revision 19178)
@@ -25,5 +25,5 @@
 
 # Parse the command-line arguments
-my ( $exp_id, $chip_id, $class_id, $uri, $camera, $outroot, $dbname, $reduction, $threads, $verbose,
+my ( $exp_id, $chip_id, $class_id, $uri, $camera, $outroot, $dbname, $run_state, $reduction, $threads, $verbose,
      $no_update, $no_op, $redirect );
 GetOptions(
@@ -36,4 +36,5 @@
     'dbname|d=s'    	=> \$dbname,    # Database name
     'reduction=s'   	=> \$reduction, # Reduction class
+    'run-state=s'       => \$run_state, # current state of the run (new, update)
     'threads=s'       	=> \$threads,   # Number of threads to use for ppImage
     'verbose'       	=> \$verbose,   # Print to stdout
@@ -52,4 +53,6 @@
     defined $camera and
     defined $outroot;
+
+if (not defined $run_state) { $run_state = 'new'; }
 
 $ipprc->define_camera($camera);
@@ -136,11 +139,27 @@
     ## XXX can we convert ppImage log and trace to use the filerules to generate consistent names
     ## XXX also stats: output should be implied by $outroot
-    my $command = "$ppImage -file $uri $outroot";
-    $command .= " -recipe PPIMAGE $recipe";
-    $command .= " -recipe PPSTATS CHIPSTATS";
-    $command .= " -stats $outputStats";
-    $command .= " -threads $threads" if defined $threads;
-    $command .= " -dbname $dbname" if defined $dbname;
-    $command .= " -tracedest $traceDest -log $logDest";
+    my $command;
+
+    if ($run_state eq "new") {
+	$command  = "$ppImage -file $uri $outroot";
+	$command .= " -recipe PPIMAGE $recipe";
+	$command .= " -recipe PPSTATS CHIPSTATS";
+	$command .= " -stats $outputStats";
+	$command .= " -threads $threads" if defined $threads;
+	$command .= " -dbname $dbname" if defined $dbname;
+	$command .= " -tracedest $traceDest -log $logDest";
+    } else {
+	## for the UPDATE processing, we need to determine the config file
+	my $configuration = $ipprc->filename("PPIMAGE.CONFIG", $outroot, $class_id) or 
+	    &my_die("Missing entry from camera config", $exp_id, $chip_id, $class_id, $PS_EXIT_CONFIG_ERROR);
+
+	$command  = "$ppImage -file $uri $outroot";
+	$command .= " -site $configuration";
+	# $command .= " -stats $outputStats"; XXX write stats to an alternate file and compare?
+	$command .= " -threads $threads" if defined $threads;
+	$command .= " -dbname $dbname" if defined $dbname;
+	# $command .= " -tracedest $traceDest -log $logDest"; XXX use an alternate trace and log file?
+	$command .= "-Db PPIMAGE:PHOTOM FALSE";
+    }
 
     my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
