Grab the failed target name if we can
[buildd-scripts.git] / bin / get_package
index 3444f56..86d08b3 100755 (executable)
@@ -3,11 +3,17 @@
 CLIENT=$1
 LOGDIR=/home/build/logs
 LOGFILE=/var/log/builder.log
+STATEDIR=/home/build/state
 
 cd in
 
 while true; do
-    FILE=$(ls -1 *.q | head -1)
+    FILE=$(ls -1 *.q 2>/dev/null| head -1)
+    if [ "$FILE"x = ""x ]; then
+       # If we didn't find a job
+       echo NOPACKAGE
+       exit 1
+    fi
     NUM=$(echo $FILE | cut -d. -f1)
     mv $NUM.q $NUM.proc
     if [ $? -ne 0 ]; then # we clashed
@@ -31,6 +37,7 @@ while true; do
 
     # else
     echo "$DATE: Queued package $NUM: $PKG_VER_ARCH on $CLIENT" >> $LOGFILE
+    echo "$DATE: Queued package $NUM: $PKG_VER_ARCH on $CLIENT" > $STATEDIR/$NUM.running
     echo "$NUM $PKG_VER_ARCH"
     exit 0
 done