]> git.decadent.org.uk Git - dak.git/blobdiff - config/debian/cron.unchecked
Loadsa changes to make new cronscript way work
[dak.git] / config / debian / cron.unchecked
index 0006f80e3a4c5ddaf0730e962e50ae996bdafbd2..916d4e5dd3d1f1b7734744a95449ded84cb3bd46 100755 (executable)
@@ -1,18 +1,52 @@
-#! /bin/bash
+#!/bin/bash
+# No way I try to deal with a crippled sh just for POSIX foo.
 
+# Copyright (C) 2009 Joerg Jaspert <joerg@debian.org>
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation; version 2.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+# exit on errors
 set -e
+set -o pipefail
+# make sure to only use defined variables
 set -u
-export SCRIPTVARS=/srv/ftp.debian.org/dak/config/debian/vars
-. $SCRIPTVARS
+# ERR traps should be inherited from functions too. (And command
+# substitutions and subshells and whatnot, but for us the functions is
+# the important part here)
+set -E
 
-# common functions are "outsourced"
-. "${configdir}/common"
+# import the general variable set.
+export SCRIPTVARS=/srv/ftp-master.debian.org/dak/config/debian/vars
+. $SCRIPTVARS
 
 LOCKDAILY=""
 LOCKFILE="$lockdir/unchecked.lock"
 NOTICE="$lockdir/daily.lock"
+LOCK_BUILDD="$lockdir/buildd.lock"
 
-if [ -e $NOTICE ]; then exit 0; fi
+# our name
+PROGRAM="unchecked"
+
+if [ -e $NOTICE ]; then
+    exit 0;
+fi
+
+########################################################################
+# Functions                                                            #
+########################################################################
+# common functions are "outsourced"
+. "${configdir}/common"
 
 STAMP=$(date "+%Y%m%d%H%M")
 
@@ -23,66 +57,46 @@ cleanup() {
     fi
 }
 
-# in case there is anything NEW processed, move it over into the accepted queue
-cd $newstage
-for file in $(find . -maxdepth 1 -mindepth 1 -type f -name \*.changes | sed -e "s,./,," | xargs); do
-    sed '1,/Files:/d' "${file}" | sed '/BEGIN PGP SIGNATURE/,$d' \
-        | while read notused1 notused2 notused3 notused4 NAME; do
-        if [ -z "${NAME}" ]; then
-            # Sometimes there is a newline after the Files:, ignore it
-            continue
-        fi
-        if [ -f "${NAME}" ]; then
-            mv --target-directory="${accepted}" "${NAME}"
-        else
-            log_error "Error, couldn't find file ${NAME} to move to ${accepted}"
-            exit 2
-        fi
-    done
-    mv --target-directory="${accepted}"  "${file}" "${file%%.changes}.dak"
-done
+function do_buildd () {
+    if lockfile -r3 $NOTICE; then
+        LOCKDAILY="YES"
+        make_buildd_dir
+        wbtrigger
+    fi
+}
+
+########################################################################
+# the actual unchecked functions follow                                #
+########################################################################
+
+# And use one locale, no matter what the caller has set
+export LANG=C
+export LC_ALL=C
 
 # only run one cron.unchecked
-if lockfile -r3 $LOCKFILE; then
-    trap cleanup 0
-    cd $unchecked
-
-    changes=$(find . -maxdepth 1 -mindepth 1 -type f -name \*.changes | sed -e "s,./,," | xargs)
-    report=$queuedir/REPORT
-    timestamp=$(date "+%Y-%m-%d %H:%M")
-
-    if [ ! -z "$changes" ]; then
-        echo "$timestamp": "$changes"  >> $report
-        dak process-unchecked -a -d "$unchecked" >> $report
-        echo "--" >> $report
-
-         # sync with debbugs
-        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
-
-        NOW=$(date +%s)
-        TSTAMP=$(stat -c %Y $lockdir/synced_bts_version)
-        DIFF=$(( NOW - TSTAMP ))
-        if [ $DIFF -ge 259200 ]; then
-            echo "Kids, you tried your best and you failed miserably. The lesson is, never try. (Homer Simpson)"
-        fi
-
-        if lockfile -r3 $NOTICE; then
-            LOCKDAILY="YES"
-            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
-            cd $overridedir
-            dak make-overrides &>/dev/null
-            rm -f override.sid.all3 override.sid.all3.src
-            for i in main contrib non-free main.debian-installer; do
-                cat override.sid.$i >> override.sid.all3
-                if [ "$i" != "main.debian-installer" ]; then
-                    cat override.sid.$i.src >> override.sid.all3.src
-                fi
-            done
-            make_buildd_dir
-
-            . $configdir/cron.buildd
-        fi
-    else
-        echo "$timestamp": Nothing to do >> $report
-    fi
+if ! lockfile -r8 $LOCKFILE 2> /dev/null; then
+    # echo "aborting cron.unchecked because $LOCKFILE has already been locked"
+    exit 0
 fi
+trap cleanup 0
+
+
+pg_timestamp preunchecked >/dev/null
+
+# Process policy queues
+punew stable-new
+opunew oldstable-new
+backports_policy
+dak clean-suites -a backports-policy,policy
+
+# Finally deal with unchecked
+do_unchecked
+
+if [ ! -z "$changes" ]; then
+    sync_debbugs
+    do_buildd
+fi
+
+dak contents -l 10000 scan-binary
+dak contents -l 1000 scan-source
+pg_timestamp postunchecked >/dev/null