Index: trunk/ippScripts/scripts/ipp_cleanup.pl
===================================================================
--- trunk/ippScripts/scripts/ipp_cleanup.pl	(revision 34773)
+++ trunk/ippScripts/scripts/ipp_cleanup.pl	(revision 34892)
@@ -203,4 +203,5 @@
     # loop over all of the imfiles, determine the path_base and class_id for each
     my $num_errors = 0;
+    my $num_updated = 0;
     foreach my $imfile (@$imfiles) {
         my $class_id = $imfile->{class_id};
@@ -323,4 +324,5 @@
                 }
                 set_destreak_goto_cleaned();
+                $num_updated++;
             }
         } else {
@@ -351,5 +353,17 @@
         }
     }
-    print "Cleanup completed for chip_id $stage_id.";
+    if ($num_updated eq 0 and $num_errors eq 0) {
+        # no chips were updated by this procedssing so set state to $done_state
+        my $command = "$chiptool -chip_id $stage_id -updaterun -set_state $done_state";
+        $command .= " -dbname $dbname" if defined $dbname;
+
+        my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
+            run(command => $command, verbose => $verbose);
+        unless ($success) {
+            $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
+            &my_die("Unable to perform chiptool: $error_code", "chip", $stage_id, $error_code);
+        }
+    }
+    print "Cleanup completed for chip_id $stage_id. num_updated: $num_updated";
     print " num_errors: $num_errors" if $num_errors;
     print "\n";
@@ -497,4 +511,5 @@
     my @files = ();
     my $num_errors = 0;
+    my $num_updated = 0;
     foreach my $skyfile (@$skyfiles) {
         my $path_base = $skyfile->{path_base};
@@ -599,4 +614,5 @@
 
                 set_destreak_goto_cleaned();
+                $num_updated++;
             }
 
@@ -625,6 +641,18 @@
         }
     }
-    print "Cleanup completed for warp_id $stage_id.";
-    print " num_errors: $num_errors" if $num_errors;
+    if ($num_updated eq 0 and $num_errors eq 0) {
+        # no skycells were updated by this procedssing so set state to $done_state
+        my $command = "$warptool -warp_id $stage_id -updaterun -set_state $done_state";
+        $command .= " -dbname $dbname" if defined $dbname;
+
+        my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
+            run(command => $command, verbose => $verbose);
+        unless ($success) {
+            $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
+            &my_die("Unable to perform warptool: $error_code", "warp", $stage_id, $error_code);
+        }
+    }
+    print "Cleanup completed for warp_id $stage_id. num_updated: $num_updated";
+    print " num_errors:  $num_errors" if $num_errors;
     print "\n";
     exit 0;
@@ -802,4 +830,5 @@
 
     my $num_errors = 0;
+    my $num_updated = 0;
     my @files = ();
     foreach my $skyfile (@{ $skyfiles }) {
@@ -926,4 +955,5 @@
                 }
                 set_destreak_goto_cleaned();
+                $num_updated++;
             }
 
@@ -953,5 +983,17 @@
         }
     }
-    print "Cleanup completed for diff_id $stage_id.";
+    if ($num_updated eq 0 and $num_errors eq 0) {
+        # no skycells were updated by this procedssing so set state to $done_state
+        my $command = "$difftool -diff_id $stage_id -updaterun -set_state $done_state";
+        $command .= " -dbname $dbname" if defined $dbname;
+
+        my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
+            run(command => $command, verbose => $verbose);
+        unless ($success) {
+            $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
+            &my_die("Unable to perform difftool: $error_code", "diff", $stage_id, $error_code);
+        }
+    }
+    print "Cleanup completed for diff_id $stage_id. num_updated: $num_updated";
     print " num_errors: $num_errors" if $num_errors;
     print "\n";
