Check for cockups in the schroot setup
[buildd-scripts.git] / bin / requeue
1 #!/bin/bash
2
3 # Helper script to requeue a build that has failed, due to missing
4 # source, missing build-deps etc.
5
6 IN=/home/build/in
7 LOGS=/home/build/logs
8 SOURCES=/mirror/debian/dists/unstable/main/source/Sources.gz
9 MAX_BUILD_NUM=$(ls -1 $IN | tail -1 | sed 's,\..*$,,')
10
11 cd $IN
12
13 for file in $@; do
14     if [ ! -e $file ] && [ -e $file.proc ]; then
15         file=$file.proc
16     fi
17     if [ ! -e $file ]; then
18         echo "Ignoring non-existent $file"
19         continue
20     fi
21     BASE=$(basename $file .proc)
22     PKG_VER_ARCH=$(cat $file)
23     PKG=$(echo $PKG_VER_ARCH | cut -d _ -f1)
24     VER=$(echo $PKG_VER_ARCH | cut -d _ -f2)
25     ARCH=$(echo $PKG_VER_ARCH | cut -d _ -f3)
26     if [ -f ${LOGS}/${ARCH}/PASS/${PKG}_${VER}_${ARCH}.log ]; then
27         echo "Ignoring successfully-built $file: $PKG_VER_ARCH"
28         continue
29     fi
30     if [ -f ${LOGS}/${ARCH}/FAIL/${PKG}_${VER}_${ARCH}.log ]; then
31         echo "Ignoring failed $file: $PKG_VER_ARCH"
32         continue
33     fi
34 #    echo "Original build attempt source-failed for $file: $PKG_VER_ARCH"
35     echo "  Old version was $VER"
36     echo "  Checking what version now exists"
37     NEW_VER=$(zcat $SOURCES | grep-dctrl -S -X ${PKG} -s version | awk '{print $2}' | tail -1)
38     if [ "$NEW_VER"x = ""x ]; then
39         echo "  Can't find any version for $PKG now, giving up"
40     else
41         if [ "$NEW_VER"x = "$VER"x ]; then
42             echo "  Same version still exists!"
43             if [ -f ${LOGS}/${ARCH}/FAIL_SOURCE/${PKG}_${VER}_${ARCH}.log ]; then
44                 echo "  Moving old log file to one side"
45                 mv ${LOGS}/${ARCH}/FAIL_SOURCE/${PKG}_${VER}_${ARCH}.log ${LOGS}/${ARCH}/FAIL_SOURCE/${PKG}_${VER}_${ARCH}.log.1
46             fi
47             echo "  And requeueing"
48             rm -f $BASE.proc
49             echo "${PKG}_${VER}_${ARCH}" > $BASE.q
50         else
51             echo "  Version moved from $VER to $NEW_VER"
52             echo "  Deleting old log file"
53             rm -f  ${LOGS}/${ARCH}/FAIL_SOURCE/${PKG}_${VER}_${ARCH}.log
54             echo "  And queueing new version"
55             MAX_BUILD_NUM=$(($MAX_BUILD_NUM + 1))
56             echo "${PKG}_${NEW_VER}_${ARCH}" > ${MAX_BUILD_NUM}.q
57             ls -l ${MAX_BUILD_NUM}.q
58         fi
59     fi
60 done
61