Initial commit of build scripts and config
[buildd-scripts.git] / bin / get_package
1 #!/bin/bash
2
3 CLIENT=$1
4 LOGDIR=/home/build/logs
5 LOGFILE=/var/log/builder.log
6
7 cd in
8
9 while true; do
10     FILE=$(ls -1 *.q | head -1)
11     NUM=$(echo $FILE | cut -d. -f1)
12     mv $NUM.q $NUM.proc
13     if [ $? -ne 0 ]; then # we clashed
14         echo NOPACKAGE
15         exit 1
16     fi
17
18     PKG_VER_ARCH=$(cat $NUM.proc)
19
20     DATE=$(date)
21
22     if [ -f ${LOGDIR}/${ARCH}/PASS/${PKG_VER_ARCH}.log ] || [ -f ${LOGDIR}/${ARCH}/FAIL/${PKG_VER_ARCH}.log ]; then
23         for file in ${LOGDIR}/${ARCH}/{PASS,FAIL}/${PKG_VER_ARCH}.log; do
24             # Ignore and try again
25             if [ -f  $file ]; then
26                 echo "$DATE: Ignoring package $NUM: $PKG_VER_ARCH, already have logfile $file" >> $LOGFILE
27             fi
28         done
29         continue
30     fi
31
32     # else
33     echo "$DATE: Queued package $NUM: $PKG_VER_ARCH on $CLIENT" >> $LOGFILE
34     echo "$NUM $PKG_VER_ARCH"
35     exit 0
36 done
37
38 exit 0
39