]> git.decadent.org.uk Git - dak.git/blob - config/debian/cron.unchecked
NEW
[dak.git] / config / debian / cron.unchecked
1 #! /bin/bash
2
3 set -e
4 set -u
5 export SCRIPTVARS=/srv/ftp.debian.org/dak/config/debian/vars
6 . $SCRIPTVARS
7
8 # common functions are "outsourced"
9 . "${configdir}/common"
10
11 LOCKDAILY=""
12 LOCKFILE="$lockdir/unchecked.lock"
13 NOTICE="$lockdir/daily.lock"
14
15 if [ -e $NOTICE ]; then exit 0; fi
16
17 STAMP=$(date "+%Y%m%d%H%M")
18
19 cleanup() {
20     rm -f "$LOCKFILE"
21     if [ ! -z "$LOCKDAILY" ]; then
22         rm -f "$NOTICE"
23     fi
24 }
25
26 # in case there is anything NEW processed, move it over into the accepted queue
27 cd $newstage
28 for file in $(find . -maxdepth 1 -mindepth 1 -type f -name \*.changes | sed -e "s,./,," | xargs); do
29     sed '1,/Files:/d' "${file}" | sed '/BEGIN PGP SIGNATURE/,$d' \
30         | while read notused1 notused2 notused3 notused4 NAME; do
31         if [ -z "${NAME}" ]; then
32             # Sometimes there is a newline after the Files:, ignore it
33             continue
34         fi
35         if [ -f "${NAME}" ]; then
36             mv --target-directory="${accepted}" "${NAME}"
37         else
38             log_error "Error, couldn't find file ${NAME} to move to ${accepted}"
39             exit 2
40         fi
41     done
42     mv --target-directory="${accepted}"  "${file}" "${file%%.changes}.dak"
43 done
44
45 # only run one cron.unchecked
46 if lockfile -r3 $LOCKFILE; then
47     trap cleanup 0
48     cd $unchecked
49
50     changes=$(find . -maxdepth 1 -mindepth 1 -type f -name \*.changes | sed -e "s,./,," | xargs)
51     report=$queuedir/REPORT
52     timestamp=$(date "+%Y-%m-%d %H:%M")
53
54     if [ ! -z "$changes" ]; then
55         echo "$timestamp": "$changes"  >> $report
56         dak process-unchecked -a -d "$unchecked" >> $report
57         echo "--" >> $report
58
59          # sync with debbugs
60         rsync -aq -e "ssh -o Batchmode=yes -o ConnectTimeout=30 -o SetupTimeout=30" --remove-source-files  $queuedir/bts_version_track/ bugs-sync:/org/bugs.debian.org/versions/queue/ftp-master/ 2>/dev/null && touch $lockdir/synced_bts_version || true
61
62         NOW=$(date +%s)
63         TSTAMP=$(stat -c %Y $lockdir/synced_bts_version)
64         DIFF=$(( NOW - TSTAMP ))
65         if [ $DIFF -ge 259200 ]; then
66             echo "Kids, you tried your best and you failed miserably. The lesson is, never try. (Homer Simpson)"
67         fi
68
69         if lockfile -r3 $NOTICE; then
70             LOCKDAILY="YES"
71             psql projectb -A -t -q -c "SELECT filename FROM queue_build WHERE queue = 0 AND suite = 5 AND in_queue = true AND filename ~ 'd(sc|eb)$'" > $dbdir/dists/unstable_accepted.list
72             cd $overridedir
73             dak make-overrides &>/dev/null
74             rm -f override.sid.all3 override.sid.all3.src
75             for i in main contrib non-free main.debian-installer; do
76                 cat override.sid.$i >> override.sid.all3
77                 if [ "$i" != "main.debian-installer" ]; then
78                     cat override.sid.$i.src >> override.sid.all3.src
79                 fi
80             done
81             make_buildd_dir
82
83             . $configdir/cron.buildd
84         fi
85     else
86         echo "$timestamp": Nothing to do >> $report
87     fi
88 fi