Index: trunk/ippScripts/scripts/dist_defineruns.pl
===================================================================
--- trunk/ippScripts/scripts/dist_queue_runs.pl	(revision 24198)
+++ trunk/ippScripts/scripts/dist_defineruns.pl	(revision 26030)
@@ -1,3 +1,6 @@
 #!/usr/bin/env perl
+#
+# dist_queue_runs.pl : run disttool -definebyquery for the various stages or one stage
+#
 
 use Carp;
@@ -40,10 +43,12 @@
 my ($stage, $stage_limit, $dist_root, $no_magic);
 my ($dbname, $save_temps, $verbose, $no_update, $logfile);
+my @labels;
 
 GetOptions(
+           'stage=s'        => \$stage,      # stage to queue
+           'label=s'        => \@labels,     # labels
+           'stage_limit=s'  => \$stage_limit,# maximum number of runs queued for each stage
            'dist_root=s'    => \$dist_root,  # root of distribution work area
-           'stage=s'        => \$stage,      # stage to queue
-           'stage_limit=s'  => \$stage_limit,# maximum number of runs queued for each stage
-           'no_magic'       => \$no_magic,   # queue runs without requiring magic
+           'no_magic'       => \$no_magic,   # queue runs without requiring magic (for testing only)
            'dbname=s'       => \$dbname,     # Database name
            'verbose'        => \$verbose,    # Print stuff?
@@ -54,9 +59,7 @@
 
 pod2usage( -msg => "Unknown option: @ARGV", -exitval => 2 ) if @ARGV;
-if (0) {
-pod2usage( -msg => "Required options: --stage",
+pod2usage( -msg => "Required options: --label",
            -exitval => 3) unless
-    defined $stage;
-}
+    (scalar @labels > 0);
 
 $ipprc->redirect_output($logfile) if $logfile;
@@ -67,5 +70,5 @@
 }
 
-my ($day, $month, $year) = (localtime)[3,4,5];
+my ($day, $month, $year) = (gmtime)[3,4,5];
 my $datestr = sprintf "%04d%02d%02d", $year+1900, $month + 1, $day;
 
@@ -82,26 +85,26 @@
 }
 
-# XXX: how shall we deal with labels?
-my $label = 'proc';
-
 foreach my $stage (@stages) {
-    my $command = "$disttool -definebyquery -stage $stage -workdir $workdir";
-    $command .= " -no_magic" if $no_magic;
-    $command .= " -dry_run" if $no_update;
-    $command .= " -limit $stage_limit" if $stage_limit;
-    $command .= " -set_label $label";
-    $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 $command error_code: $error_code", $error_code);
+    foreach my $label (@labels) {
+        my $command = "$disttool -definebyquery -stage $stage -workdir $workdir -label $label";
+        $command .= " -no_magic" if $no_magic;
+        $command .= " -dry_run" if $no_update;
+        $command .= " -limit $stage_limit" if $stage_limit;
+        $command .= " -set_label $label";
+        $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 $command error_code: $error_code", $error_code);
+        }
+        # display the output from the command
+        print STDERR join "", @$stdout_buf if $verbose;
     }
-    # display the output from the command
-    print STDERR join "", @$stdout_buf if $verbose;
 }
 
+if (0) {
+# notyet
 # queue rcRuns for any distRuns that have completed and have interested destinations
-{
     my $command = "$disttool -queuercrun";
     $command .= " -dbname $dbname" if defined $dbname;
