]> git.decadent.org.uk Git - dak.git/blobdiff - config/debian/common
Adjust common functions
[dak.git] / config / debian / common
index 30237dafdfe22a16b301f3c8565f259e7833bfc6..b8a6e6cca5fc2c3c80544499baf210a59e51b9fc 100644 (file)
@@ -3,17 +3,17 @@
 #
 # Set $PROGRAM to a string to have it added to the output.
 function log () {
-        local prefix=${PROGRAM:-}
-        echo "$(date +"%b %d %H:%M:%S") $(hostname -s) ${prefix}[$$]: $@"
+    local prefix=${PROGRAM:-}
+    echo "$(date +"%b %d %H:%M:%S") $(hostname -s) ${prefix}[$$]: $@"
 }
 
 # log the message using log() but then also send a mail
 # to the address configured in MAILTO (if non-empty)
 function log_error () {
-        log "$@"
-        if [ -z "${MAILTO}" ]; then
-                echo "$@" | mail -a "X-Debian: DAK" -e -s "[$PROGRAM@$(hostname -s)] ERROR [$$]" -a "From: Debian FTP Masters <ftpmaster@ftp-master.debian.org>" ${MAILTO}
-        fi
+    log "$@"
+    if [ -z "${MAILTO}" ]; then
+        echo "$@" | mail -a "X-Debian: DAK" -e -s "[$PROGRAM@$(hostname -s)] ERROR [$$]" -a "From: Debian FTP Masters <ftpmaster@ftp-master.debian.org>" ${MAILTO}
+    fi
 }
 
 # debug log, only output when DEBUG=1
@@ -59,11 +59,15 @@ function cleanup() {
 
     cleantempfiles
 
-    exit $ERRVAL
+    return $ERRVAL
 }
 TEMPFILES=${TEMPFILES:-""}
 TMPFILES=${TMPFILES:-""}
 
+# Timestamp. Used for dinstall stat graphs
+function ts() {
+    echo "Archive maintenance timestamp ($1): $(date +%H:%M:%S)"
+}
 
 ########################################################################
 ########################################################################
@@ -79,6 +83,7 @@ function wbtrigger() {
 # used by cron.dinstall *and* cron.unchecked.
 function make_buildd_dir () {
     # We generate straight into the static mirror location for incoming
+    log "Preparing buildd area"
     dak manage-build-queues -a
     dak generate-packages-sources2 -a build-queues
     dak generate-releases -a build-queues >/dev/null
@@ -87,6 +92,7 @@ function make_buildd_dir () {
     echo "<p>Last updated: `date -u`</p>" > ${incoming}/web/README.html
 
     # Tell the mirrors that we've updated
+    log "Pushing static for incoming.d.o"
     chronic /usr/local/bin/static-update-component incoming.debian.org
 }
 
@@ -114,17 +120,13 @@ function punew_do() {
 
 # These versions used in dinstall
 function punew() {
-    if [ "${PROGRAM}" = "dinstall" ]; then
-        log "Doing automated p-u-new processing"
-    fi
+    log "Doing automated p-u-new processing"
     cd "${queuedir}/p-u-new"
     punew_do "$1" "${queuedir}/p-u-new" "debian-release@lists.debian.org"
 }
 
 function opunew() {
-    if [ "${PROGRAM}" = "dinstall" ]; then
-        log "Doing automated o-p-u-new processing"
-    fi
+    log "Doing automated o-p-u-new processing"
     cd "${queuedir}/o-p-u-new"
     punew_do "$1" "${queuedir}/o-p-u-new" "debian-release@lists.debian.org"
 }
@@ -134,9 +136,7 @@ function backports_policy() {
     local qdir="/srv/backports-master.debian.org/queue/policy"
     local to="backports-team@debian.org"
 
-    if [ "${PROGRAM}" = "dinstall" ]; then
-        log "Doing automated ${queue} processing"
-    fi
+    log "Doing automated ${queue} processing"
 
     cd "${qdir}"
     punew_do "${queue}" "${qdir}" "${to}"
@@ -146,35 +146,39 @@ function backports_policy() {
 function do_unchecked () {
     cd $unchecked
 
-    changes=$(find . -maxdepth 1 -mindepth 1 -type f -name \*.changes | sed -e "s,./,," | xargs)
+    changes=$(find . -maxdepth 1 -mindepth 1 -type f \( -name \*.changes -o -name \*.dak-commands \) | sed -e "s,./,," | xargs)
     report=$queuedir/REPORT
     timestamp=$(date "+%Y-%m-%d %H:%M")
-    UNCHECKED_WITHOUT_LOCK=${UNCHECKED_WITHOUT_LOCK:-""}
-
-    echo "$timestamp": ${changes:-"Nothing to do"}  >> $report
-    dak process-upload -a ${UNCHECKED_WITHOUT_LOCK} -d "$unchecked" >> $report
-    dak process-commands -d "$unchecked" >> $report
 
     if [ ! -z "$changes" ]; then
+        log "Processing files ${changes}"
+        echo "${timestamp}: ${changes}"  >> $report
+        dak process-upload -a -d "$unchecked" >> $report
+        dak process-commands -d "$unchecked" >> $report
+
         sync_debbugs
         do_buildd
+    else
+        log "Nothing to do"
+        echo "Nothing to do" >> ${report}
     fi
 }
 
 # process NEW policy queue
 function do_new () {
-    if [ "${PROGRAM}" = "dinstall" ]; then
-       log "Doing NEW processing"
-    fi
+    log "Doing NEW processing"
     (dak process-policy new; dak process-policy byhand) | mail -a "X-Debian: DAK" -e -s "NEW and BYHAND processing" -a "From: Debian FTP Masters <ftpmaster@ftp-master.debian.org>" ftpmaster@ftp-master.debian.org
 
+    log "Processing Backports NEW"
     dak process-policy backports-new | mail -a "X-Debian: DAK" -e -s "NEW processing for backports-new" -a "From: Debian FTP Masters <ftpmaster@ftp-master.debian.org>" backports-team@debian.org
 
+    log "Cleanup NEW/Backports NEW"
     dak clean-suites -a new,backports-new
 }
 
 function sync_debbugs () {
     # sync with debbugs
+    log "Sync debbugs version tracking information"
     echo "--" >> $report
     timestamp=$(date "+%Y-%m-%d-%H:%M")
     mkdir -p $queuedir/bts_version_track_archive/${timestamp}
@@ -185,11 +189,12 @@ function sync_debbugs () {
     TSTAMP=$(stat -c %Y $lockdir/synced_bts_version)
     DIFF=$(( NOW - TSTAMP ))
     if [ $DIFF -ge 259200 ]; then
-        log "Kids, you tried your best and you failed miserably. The lesson is, never try. (Homer Simpson)"
+        log_error "Kids, you tried your best and you failed miserably. The lesson is, never try. (Homer Simpson)"
     fi
 }
 
 function clean_debbugs () {
+    log "Cleanup debbugs"
     # Delete files older than 60 days
     find $queuedir/bts_version_track_archive/ -mtime +60 -type f -delete
     # Delete empty directories
@@ -227,8 +232,8 @@ function get_archiveroot() {
 
 # Prepare the trees for buildds, then push wanna-build
 function do_buildd() {
-    if lockfile -r3 $NOTICE; then
-        TEMPFILES="${TEMPFILES} ${NOTICE}"
+    if lockfile -r3 ${LOCK_DAILY}; then
+        TMPFILES="${TMPFILES} ${LOCK_DAILY}"
         make_buildd_dir
         wbtrigger
     fi
@@ -246,8 +251,8 @@ function scancontents() {
 }
 
 function ddaccess() {
-    # Tell our dd accessible mirror to sync itself up. Including ftp dir.
-    log "Trigger dd accessible parts sync including ftp dir"
+    # Tell our dd accessible mirror to sync itself up.
+    log "Trigger dd accessible parts sync"
     ${scriptsdir}/sync-dd dd-sync dd-sync1 dd-sync2 sync
 }