Detect misidentified architecture on the build system
[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 for file in $@; do
12     if [ ! -e $file ] && [ -e $file.proc ]; then
13         file=$file.proc
14     fi
15     if [ ! -e $file ]; then
16         echo "Ignoring non-existent $file"
17         continue
18     fi
19     BASE=$(basename $file .proc)
20     PKG_VER_ARCH=$(cat $file)
21     PKG=$(echo $PKG_VER_ARCH | cut -d _ -f1)
22     VER=$(echo $PKG_VER_ARCH | cut -d _ -f2)
23     ARCH=$(echo $PKG_VER_ARCH | cut -d _ -f3)
24     if [ -f ${LOGS}/${ARCH}/PASS/${PKG}_${VER}_${ARCH}.log ]; then
25         echo "Ignoring successfully-built $file: $PKG_VER_ARCH"
26         continue
27     fi
28     if [ -f ${LOGS}/${ARCH}/FAIL/${PKG}_${VER}_${ARCH}.log ]; then
29         echo "Ignoring failed $file: $PKG_VER_ARCH"
30         continue
31     fi
32 #    echo "Original build attempt source-failed for $file: $PKG_VER_ARCH"
33     echo "  Old version was $VER"
34     echo "  Checking what version now exists"
35     NEW_VER=$(zcat $SOURCES | grep-dctrl -S -X ${PKG} -s version | awk '{print $2}' | tail -1)
36     if [ "$NEW_VER"x = ""x ]; then
37         echo "  Can't find any version for $PKG now, giving up"
38     else
39         if [ "$NEW_VER"x = "$VER"x ]; then
40             echo "  Same version still exists!"
41             if [ -f ${LOGS}/${ARCH}/FAIL_SOURCE/${PKG}_${VER}_${ARCH}.log ]; then
42                 echo "  Moving old log file to one side"
43                 mv ${LOGS}/${ARCH}/FAIL_SOURCE/${PKG}_${VER}_${ARCH}.log ${LOGS}/${ARCH}/FAIL_SOURCE/${PKG}_${VER}_${ARCH}.log.1
44             fi
45             echo "  And requeueing"
46             rm -f $BASE.proc
47             echo "${PKG}_${VER}_${ARCH}" > $BASE.q
48         else
49             echo "  Version moved from $VER to $NEW_VER"
50             echo "  Deleting old log file"
51             rm -f  ${LOGS}/${ARCH}/FAIL_SOURCE/${PKG}_${VER}_${ARCH}.log
52             echo "  And queueing new version"
53             MAX_BUILD_NUM=$(($MAX_BUILD_NUM + 1))
54             echo "${PKG}_${NEW_VER}_${ARCH}" > ${MAX_BUILD_NUM}.q
55             ls -l ${MAX_BUILD_NUM}.q
56         fi
57     fi
58 done
59