]> git.decadent.org.uk Git - dak.git/commitdiff
Merge remote-tracking branch 'DktrKranz/fixes'
authorJoerg Jaspert <joerg@debian.org>
Sat, 2 Jan 2016 13:34:47 +0000 (14:34 +0100)
committerJoerg Jaspert <joerg@debian.org>
Sat, 2 Jan 2016 13:34:47 +0000 (14:34 +0100)
* DktrKranz/fixes:
  Removal dep check only considers latest sources (Closes: #792578)
  Allow closing bugs if more than one source version is available.

Signed-off-by: Joerg Jaspert <joerg@debian.org>
config/debian/common
config/debian/cron.reboot
config/debian/cronscript
config/debian/dinstall.functions
config/debian/dinstall.variables
config/debian/hourly.functions
config/debian/unchecked.functions [new file with mode: 0644]
config/debian/vars

index bc3248c7470dd6cad1b5f8f44398d5bfcffccc6d..0754159ea93b41e7fbd0cd50dce0627def7d429c 100644 (file)
@@ -4,7 +4,7 @@
 # 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}[$$]: $@"
+    echo "$(date +"%b %d %H:%M:%S") ${HOSTNAME} ${prefix}[$$]: $@"
 }
 
 # log the message using log() but then also send a mail
@@ -12,7 +12,7 @@ function log () {
 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}
+        echo "$@" | mail -a "X-Debian: DAK" -e -s "[$PROGRAM@${HOSTNAME}] ERROR [$$]" -a "From: Debian FTP Masters <ftpmaster@ftp-master.debian.org>" ${MAILTO}
     fi
 }
 
@@ -347,7 +347,7 @@ function stage() {
 
     # Now we should make sure that we have a usable ${PROGRAM}.log, so
     # append the $STAGEFILE.log to it.
-    cat "${STAGEFILE}.log" >> "${LOGFILE}"
+    /usr/bin/ts "%b %d %H:%M:%S ${HOSTNAME} ${PROGRAM}[$$]: ${FUNC} " < "${STAGEFILE}.log"
     rm -f "${STAGEFILE}.log"
 
     log "########## ${PROGRAM} END: ${FUNC} ##########"
index 78c0e9ba62e3cfbbb0386e7f6541474aae8fe63b..dc802dc2579ad368b9fce4ff9f766d1a90f6a456 100755 (executable)
@@ -45,7 +45,7 @@ DEBUG=0
 PROGRAM="dinstall_reboot"
 
 # where do we want mails to go? For example log entries made with error()
-if [ "x$(hostname -s)x" != "xfranckx" ]; then
+if [[ ${HOSTNAME} != franck ]]; then
     # Not our ftpmaster host
     MAILTO=${MAILTO:-"root"}
 else
index 2418d79a75249ad441c8e6e8e4ad303a391a574d..595c6b6aa198c2388dae8b61c521220b23ae5857 100755 (executable)
@@ -1,7 +1,7 @@
 #!/bin/bash
 # No way I try to deal with a crippled sh just for POSIX foo.
 
-# Copyright (C) 2009-2015 Joerg Jaspert <joerg@debian.org>
+# Copyright (C) 2009-2016 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
@@ -38,9 +38,9 @@ set -u
 # the important part here)
 set -E
 
-# The extglob shell option is enabled using the shopt builtin, several
-# extended pattern matching operators are recognized. We use it for
-# the POSSIBLEARGS and the first case ${ARGS} matching
+# If the extglob shell option is enabled using the shopt builtin,
+# several extended pattern matching operators are recognized. We use
+# it for the POSSIBLEARGS and the first case ${ARGS} matching.
 shopt -s extglob
 
 # And use one locale, no matter what the caller has set
@@ -61,9 +61,6 @@ declare -lr ARG=${1:-"meh"}
 # program name is the (lower cased) first argument.
 PROGRAM="${ARG}"
 
-# And the following types of cronscripts exists
-declare -lr POSSIBLEARGS='+(unchecked|dinstall|hourly|daily|weekly|monthly|yearly)'
-
 # set DEBUG if you want to see a little more logs (needs to be used more)
 DEBUG=${DEBUG:-0}
 
@@ -78,14 +75,13 @@ case ${ARG} in
         ;;
     *)
         cat - <<EOF
-This is the FTPMaster cronscript. It needs an argument or it won't do
-anything for you.
+This is the cronscript. It needs an argument or it won't do anything
+for you.
 
-Currently accepted Arguments:
+Currently accepted Arguments: ${POSSIBLEARGS}
 
-   unchecked - Process the unchecked queue
-   dinstall  - Run a dinstall
-   yearly, hourly, daily, weekly - Run that part
+To see what they do, you want to look at the files
+\$ARGUMENT.{tasks,functions,variables} in ${configdir}.
 
 EOF
         exit 0
@@ -126,36 +122,11 @@ esac
     # Get rid of tempfiles at the end
     trap cleanup EXIT TERM HUP INT QUIT
 
-    case ${ARG} in
-        unchecked)
-            # Do not run during dinstall
-            if [[ -e ${LOCK_DAILY} ]]; then
-                exit 0;
-            fi
-            # only run one cron.unchecked and also lock against hourly (newoverview)
-            if ! lockfile -r8 ${LOCK_UNCHECKED} 2> /dev/null; then
-                # log "aborting cron.unchecked because $LOCK_UNCHECKED has already been locked"
-                exit 0
-            fi
-            TMPFILES="${TMPFILES} ${LOCK_UNCHECKED}"
-            ;;
-        dinstall)
-            ;;
-        hourly)
-            ;;
-        daily)
-            ;;
-        weekly)
-            ;;
-        monthly)
-            ;;
-        yearly)
-            ;;
-        *)
-            error "Unknown arg ${ARG}"
-            exit 42
-            ;;
-    esac
+    # If there is a precronscript function, we run it.
+    prefunc=$(type -t precronscript || echo "")
+    if [[ -n ${prefunc} ]] && [[ ${prefunc} = function ]]; then
+        precronscript
+    fi
 
     # An easy access by name for the current log
     ln -sf ${LOGFILE} ${logdir}/${PROGRAM}
@@ -236,32 +207,17 @@ esac
     # we need to wait for the background processes before the end of the cron script
     wait
 
-
     # Common to all cron scripts
     log "Cron script successful, all done"
     # Redirect output to another file, as we want to compress our logfile
     # and ensure its no longer used
     exec > "$logdir/after${PROGRAM}.log" 2>&1
 
-    case ${ARG} in
-        unchecked)
-        ;;
-        dinstall)
-            logstats ${LOGFILE}
-            state "all done"
-            touch "${DINSTALLEND}"
-            ;;
-        hourly)
-            ;;
-        daily)
-            ;;
-        weekly)
-            ;;
-        monthly)
-            ;;
-        yearly)
-            ;;
-    esac
+    # If there is a postcronscript function, we run it.
+    postfunc=$(type -t postcronscript || echo "")
+    if [[ -n ${postfunc} ]] && [[ ${postfunc} = function ]]; then
+        postcronscript
+    fi
 
     # Now, at the very (successful) end of this run, make sure we remove
     # our stage files, so the next dinstall run will do it all again.
index acfbee4de6fb265029655274ce9923a60eb0d04d..2ee713c98347a9ddbd65f4ce459db50d7dabbd04 100644 (file)
@@ -716,3 +716,9 @@ function startup() {
     touch "${LOCK_BRITNEY}"
     TMPFILES="${TMPFILES} ${LOCK_DAILY} ${LOCK_BRITNEY}"
 }
+
+function postcronscript() {
+    logstats ${LOGFILE}
+    state "all done"
+    touch "${DINSTALLEND}"
+}
\ No newline at end of file
index 092588198b28e82d0066bbc949f79edb986bf3f2..2587b2a8e760ac6c3f959b868950e6f447c998b1 100644 (file)
@@ -3,7 +3,7 @@
 DEBUG=0
 
 # where do we want mails to go? For example log entries made with error()
-if [ "x$(hostname -s)x" != "xfranckx" ]; then
+if [[ ${HOSTNAME} != franck ]]; then
     # Not our ftpmaster host
     MAILTO=${MAILTO:-"root"}
 else
index 6c1b093cf979802041091d0dc9ca3a0fec7e1657..5ba908537f307f9fab9d9e37ebb671c0c26db8e2 100644 (file)
@@ -67,7 +67,7 @@ function builddautosigning() {
     exec >>/dev/null 2>&1
 
     DATE=$(date -Is)
-    cat "${BUILDDFUN}" | mail -a "X-Debian: DAK" -e -s "[$(hostname -s)] Buildd key changes ${DATE}" -a "From: Debian FTP Masters <ftpmaster@ftp-master.debian.org>" buildd-keys@ftp-master.debian.org
+    cat "${BUILDDFUN}" | mail -a "X-Debian: DAK" -e -s "[${HOSTNAME}] Buildd key changes ${DATE}" -a "From: Debian FTP Masters <ftpmaster@ftp-master.debian.org>" buildd-keys@ftp-master.debian.org
 
     rm -f "${BUILDDFUN}"
 }
diff --git a/config/debian/unchecked.functions b/config/debian/unchecked.functions
new file mode 100644 (file)
index 0000000..87fbda0
--- /dev/null
@@ -0,0 +1,14 @@
+# -*- mode:sh -*-
+
+function precronscript() {
+    # Do not run during dinstall
+    if [[ -e ${LOCK_DAILY} ]]; then
+        exit 0;
+    fi
+    # only run one cron.unchecked and also lock against hourly (newoverview)
+    if ! lockfile -r8 ${LOCK_UNCHECKED} 2> /dev/null; then
+        # log "aborting cron.unchecked because $LOCK_UNCHECKED has already been locked"
+        exit 0
+    fi
+    TMPFILES="${TMPFILES} ${LOCK_UNCHECKED}"
+}
\ No newline at end of file
index a2bc5bd8e253af73b65911ec599491fd281d1ee8..d134d9c4faa4c730647ac717bbb1b473e79e62a4 100644 (file)
@@ -44,6 +44,10 @@ LOCK_DAILY="${lockdir}/daily.lock"
 LOCK_UNCHECKED="${lockdir}/unchecked.lock"
 LOCK_STOP="${lockdir}/archive.stop"
 
+# And the following types of cronscripts exists
+declare -lr POSSIBLEARGS='+(unchecked|dinstall|hourly|daily|weekly|monthly|yearly)'
+declare -r HOSTNAME=$(hostname -s)
+
 archs=$(dak admin a list | tr '\n' ' ')
 
 # Set the database variables