]> git.decadent.org.uk Git - dak.git/blobdiff - config/debian/cron.dinstall
Merge commit 'ftpmaster/master'
[dak.git] / config / debian / cron.dinstall
index dfd9e916ac33ee134a3af160cc60a0b22b25261a..1c9fa5afefff3284fd27f860fcb63d40d5aad16d 100755 (executable)
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 
+# Homer: Are you saying you're never going to eat any animal again? What
+#        about bacon?
+# Lisa: No.
+# Homer: Ham?
+# Lisa: No.
+# Homer: Pork chops?
+# Lisa: Dad, those all come from the same animal.
+# Homer: Heh heh heh. Ooh, yeah, right, Lisa. A wonderful, magical animal.
+
 # exit on errors
 set -e
 # make sure to only use defined variables
 set -u
+# 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
 
 # import the general variable set.
 export SCRIPTVARS=/srv/ftp.debian.org/dak/config/debian/vars
@@ -33,8 +46,7 @@ export SCRIPTVARS=/srv/ftp.debian.org/dak/config/debian/vars
 
 # Timestamp. Used for dinstall stat graphs
 function ts() {
-        TS=$(($TS+1));
-        echo "Archive maintenance timestamp $TS ($1): $(date +%H:%M:%S)"
+        echo "Archive maintenance timestamp ($1): $(date +%H:%M:%S)"
 }
 
 # Cleanup actions
@@ -46,7 +58,16 @@ function cleanup() {
 # If we error out this one is called, *FOLLOWED* by cleanup above
 function onerror() {
     ERRDATE=$(date "+%Y.%m.%d-%H:%M:%S")
-    cat "$LOGFILE" | mail -s "ATTENTION ATTENTION! dinstall error at ${ERRDATE} (Be quiet, Brain, or I'll stab you with a Q-tip)" cron@ftp-master.debian.org
+
+    subject="ATTENTION ATTENTION!"
+    if [ "${error}" = "false" ]; then
+        subject="${subject} (continued)"
+    else
+        subject="${subject} (interrupted)"
+    fi
+    subject="${subject} dinstall error at ${ERRDATE} in ${STAGEFILE} - (Be quiet, Brain, or I'll stab you with a Q-tip)"
+
+    cat "${STAGEFILE}.log" | mail -s "${subject}" -a "X-Debian: DAK" cron@ftp-master.debian.org
 }
 
 ########################################################################
@@ -61,7 +82,9 @@ Packages are currently being installed and indices rebuilt.
 Maintenance is automatic, starting at 01|07|13|19:52 UTC,
 and ending about an hour later.  This file is then removed.
 
-You should not mirror the archive during this period.
+You should not mirror the archive during this period. If you find this
+file on a Debian mirror please have a nice talk with the admin. They
+are doing something wrong.
 EOF
 }
 
@@ -187,6 +210,28 @@ function msfl() {
 function fingerprints() {
     log "Updating fingerprints"
     dak import-keyring -L /srv/keyring.debian.org/keyrings/debian-keyring.gpg
+
+    OUTFILE=$(mktemp)
+    dak import-keyring --generate-users "%s" /srv/keyring.debian.org/keyrings/debian-maintainers.gpg >"${OUTFILE}"
+
+    if [ -s "${OUTFILE}" ]; then
+        /usr/sbin/sendmail -odq -oi -t -f envelope@ftp-master.debian.org <<EOF
+From: Debian FTP Masters <ftpmaster@ftp-master.debian.org>
+To: <debian-project@lists.debian.org>
+Subject: Debian Maintainers Keyring changes
+Content-Type: text/plain; charset=utf-8
+MIME-Version: 1.0
+
+The following changes to the debian-maintainers keyring have just been activated:
+
+$(cat $OUTFILE)
+
+Debian distribution maintenance software,
+on behalf of the Keyring maintainers
+
+EOF
+    fi
+    rm -f "$OUTFILE"
 }
 
 function overrides() {
@@ -255,7 +300,7 @@ function scripts() {
 function mirror() {
     echo "Regenerating \"public\" mirror/ hardlink fun"
     cd ${mirrordir}
-    rsync -aH --link-dest ${ftpdir} --delete --delete-after --ignore-errors ${ftpdir}/. .
+    rsync -aH --link-dest ${ftpdir} --exclude Archive_Maintenance_In_Progress --delete --delete-after --ignore-errors ${ftpdir}/. .
 }
 
 function wb() {
@@ -310,9 +355,12 @@ function merkel3() {
     ssh -2 -o BatchMode=yes -o SetupTimeOut=30 -o ConnectTimeout=30 -i ~/.ssh/push_merkel_ddaccess dak@merkel.debian.org sleep 1
 }
 
-function runparts() {
-    log "Using run-parts to run scripts in $base/scripts/distmnt"
-    run-parts --report $base/scripts/distmnt
+function mirrorpush() {
+    log "Starting the mirrorpush"
+    date -u > /srv/ftp.debian.org/web/mirrorstart
+    echo "Using dak v1" >> /srv/ftp.debian.org/web/mirrorstart
+    echo "Running on host $(hostname -f)" >> /srv/ftp.debian.org/web/mirrorstart
+    sudo -H -u archvsync /home/archvsync/runmirrors > ~dak/runmirrors.log 2>&1 &
 }
 
 function i18n2() {
@@ -324,7 +372,7 @@ function i18n2() {
     dak control-suite -l testing > squeeze
     dak control-suite -l unstable > sid
     echo "${STAMP}" > timestamp
-    gpg --secret-keyring /srv/ftp.debian.org/s3kr1t/dot-gnupg/secring.gpg --keyring /srv/ftp.debian.org/s3kr1t/dot-gnupg/pubring.gpg --no-options --batch --no-tty --armour --default-key 6070D3A1 --detach-sign -o timestamp.gpg timestamp
+    gpg --secret-keyring /srv/ftp.debian.org/s3kr1t/dot-gnupg/secring.gpg --keyring /srv/ftp.debian.org/s3kr1t/dot-gnupg/pubring.gpg --no-options --batch --no-tty --armour --default-key 55BE302B --detach-sign -o timestamp.gpg timestamp
     rm -f md5sum
     md5sum * > md5sum
     cd ${webdir}/
@@ -354,15 +402,15 @@ function compress() {
     cd $base/backup/
     find -maxdepth 1 -mindepth 1 -type f -name 'dump_pre_*' -mtime +2 -print0 | xargs -0 --no-run-if-empty rm
 
-    find -maxdepth 1 -mindepth 1 -type f -name 'dump_*' \! -name '*.bz2' \! -name '*.gz' -mmin 720 |
+    find -maxdepth 1 -mindepth 1 -type f -name 'dump_*' \! -name '*.bz2' \! -name '*.gz' -mmin +720 |
     while read dumpname; do
         echo "Compressing $dumpname"
-        bzip2 -9v "$dumpname"
+        bzip2 -9fv "$dumpname"
     done
-    find -maxdepth 1 -mindepth 1 -type f -name "dumpall_*" \! -name '*.bz2' \! -name '*.gz' -mmin 720 |
+    find -maxdepth 1 -mindepth 1 -type f -name "dumpall_*" \! -name '*.bz2' \! -name '*.gz' -mmin +720 |
     while read dumpname; do
         echo "Compressing $dumpname"
-        bzip2 -9v "$dumpname"
+        bzip2 -9fv "$dumpname"
     done
     finddup -l -d $base/backup
 }
@@ -384,14 +432,14 @@ function maillogfile() {
 function renamelogfile() {
     if [ -f "${dbdir}/dinstallstart" ]; then
         NOW=$(cat "${dbdir}/dinstallstart")
-        maillogfile
-    mv "$LOGFILE" "$logdir/dinstall_${NOW}.log"
+#        maillogfile
+        mv "$LOGFILE" "$logdir/dinstall_${NOW}.log"
         logstats "$logdir/dinstall_${NOW}.log"
         bzip2 -9 "$logdir/dinstall_${NOW}.log"
     else
         error "Problem, I don't know when dinstall started, unable to do log statistics."
         NOW=`date "+%Y.%m.%d-%H:%M:%S"`
-        maillogfile
+#        maillogfile
         mv "$LOGFILE" "$logdir/dinstall_${NOW}.log"
         bzip2 -9 "$logdir/dinstall_${NOW}.log"
     fi
@@ -403,7 +451,9 @@ function testingsourcelist() {
 
 # do a last run of process-unchecked before dinstall is on.
 function process_unchecked() {
+    log "Processing the unchecked queue"
     acceptnew
+    UNCHECKED_WITHOUT_LOCK="-p"
     do_unchecked
     sync_debbugs
 }
@@ -414,13 +464,13 @@ function process_unchecked() {
 # Function to save which stage we are in, so we can restart an interrupted
 # dinstall. Or even run actions in parallel, if we dare to, by simply
 # backgrounding the call to this function. But that should only really be
-# done for things we dont care much about.
+# done for things we don't care much about.
 #
 # This should be called with the first argument being an array, with the
 # members
 #  - FUNC - the function name to call
 #  - ARGS - Possible arguments to hand to the function. Can be the empty string
-#  - TS   - The timestamp name. Can be the empty string
+#  - TIME - The timestamp name. Can be the empty string
 #  - ERR  - if this is the string false, then the call will be surrounded by
 #           set +e ... set -e calls, so errors in the function do not exit
 #           dinstall. Can be the empty string, meaning true.
@@ -431,8 +481,11 @@ function stage() {
     ARGS='GO[@]'
     local "${!ARGS}"
 
-    if [ -f "${stagedir}/${FUNC}" ]; then
-        stamptime=$(/usr/bin/stat -c %Z "${stagedir}/${FUNC}")
+    error=${ERR:-"true"}
+
+    STAGEFILE="${stagedir}/${FUNC}"
+    if [ -f "${STAGEFILE}" ]; then
+        stamptime=$(/usr/bin/stat -c %Z "${STAGEFILE}")
         unixtime=$(date +%s)
         difference=$(( $unixtime - $stamptime ))
         if [ ${difference} -ge 14400 ]; then
@@ -443,18 +496,23 @@ function stage() {
         return
     fi
 
-    debug "Now calling function ${FUNC}. Arguments: ${ARGS}. Timestamp: ${TS}"
+    debug "Now calling function ${FUNC}. Arguments: ${ARGS}. Timestamp: ${TIME}"
 
     # Make sure we are always at the same place. If a function wants to be elsewhere,
     # it has to cd first!
     cd ${configdir}
 
+    # Now redirect the output into $STAGEFILE.log. In case it errors out somewhere our
+    # errorhandler trap can then mail the contents of $STAGEFILE.log only, instead of a whole
+    # dinstall logfile. Short error mails ftw!
+    exec >> "${STAGEFILE}.log" 2>&1
+
     if [ -f "${LOCK_STOP}" ]; then
         log "${LOCK_STOP} exists, exiting immediately"
         exit 42
     fi
 
-    if [ "${ERR}" = "false" ]; then
+    if [ "${error}" = "false" ]; then
         set +e
     fi
     ${FUNC} ${ARGS}
@@ -465,12 +523,20 @@ function stage() {
     # Make sure we are always at the same place.
     cd ${configdir}
 
-    touch "${stagedir}/${FUNC}"
+    touch "${STAGEFILE}"
 
     if [ -n "${TIME}" ]; then
         ts "${TIME}"
     fi
 
+    # And the output goes back to the normal logfile
+    exec >> "$LOGFILE" 2>&1
+
+    # Now we should make sure that we have a usable dinstall.log, so append the $STAGEFILE.log
+    # to it.
+    cat "${STAGEFILE}.log" >> "${LOGFILE}"
+    rm -f "${STAGEFILE}.log"
+
     if [ -f "${LOCK_STOP}" ]; then
         log "${LOCK_STOP} exists, exiting immediately"
         exit 42
@@ -507,8 +573,6 @@ DINSTALLSTART="${lockdir}/dinstallstart"
 # Marker for dinstall end
 DINSTALLEND="${lockdir}/dinstallend"
 
-# Timestamps start at -1. so first gets 0
-TS=-1
 touch "${DINSTALLSTART}"
 ts "startup"
 
@@ -518,9 +582,12 @@ NOTICE="$ftpdir/Archive_Maintenance_In_Progress"
 # lock cron.unchecked (it immediately exits when this exists)
 LOCK_DAILY="$lockdir/daily.lock"
 
-# Lock process-new and cron.unchecked from doing work
+# Lock cron.unchecked from doing work
 LOCK_ACCEPTED="$lockdir/unchecked.lock"
 
+# Lock process-new from doing work
+LOCK_NEW="$lockdir/processnew.lock"
+
 # This file is simply used to indicate to britney whether or not
 # the Packages file updates completed sucessfully.  It's not a lock
 # from our point of view
@@ -558,7 +625,7 @@ GO=(
     ARGS=""
     ERR="false"
 )
-stage $GO
+stage $GO &
 
 GO=(
     FUNC="pgdump_pre"
@@ -574,7 +641,7 @@ GO=(
     ARGS=""
     ERR="false"
 )
-stage $GO
+stage $GO &
 
 GO=(
     FUNC="punew"
@@ -598,9 +665,10 @@ GO=(
     ARGS=""
     ERR="false"
 )
-stage $GO
+stage $GO &
 
 lockfile "$LOCK_ACCEPTED"
+lockfile "$LOCK_NEW"
 
 GO=(
     FUNC="process_unchecked"
@@ -636,6 +704,7 @@ GO=(
 stage $GO
 
 rm -f "$LOCK_ACCEPTED"
+rm -f "$LOCK_NEW"
 
 GO=(
     FUNC="msfl"
@@ -651,7 +720,7 @@ GO=(
     ARGS=""
     ERR="false"
 )
-stage $GO
+stage $GO &
 
 GO=(
     FUNC="overrides"
@@ -731,7 +800,7 @@ GO=(
     ARGS=""
     ERR=""
 )
-stage $GO
+stage $GO &
 
 rm -f "${NOTICE}"
 rm -f "${LOCK_DAILY}"
@@ -744,7 +813,7 @@ GO=(
     ARGS=""
     ERR=""
 )
-stage $GO
+stage $GO &
 
 GO=(
     FUNC="expire"
@@ -752,7 +821,7 @@ GO=(
     ARGS=""
     ERR=""
 )
-stage $GO
+stage $GO &
 
 GO=(
     FUNC="transitionsclean"
@@ -760,7 +829,7 @@ GO=(
     ARGS=""
     ERR=""
 )
-stage $GO
+stage $GO &
 
 GO=(
     FUNC="reports"
@@ -768,7 +837,7 @@ GO=(
     ARGS=""
     ERR=""
 )
-stage $GO
+stage $GO &
 
 GO=(
     FUNC="dm"
@@ -776,7 +845,7 @@ GO=(
     ARGS=""
     ERR=""
 )
-stage $GO
+stage $GO &
 
 GO=(
     FUNC="bts"
@@ -784,7 +853,7 @@ GO=(
     ARGS=""
     ERR="false"
 )
-stage $GO
+stage $GO &
 
 GO=(
     FUNC="merkel2"
@@ -792,11 +861,11 @@ GO=(
     ARGS=""
     ERR="false"
 )
-stage $GO
+stage $GO &
 
 GO=(
-    FUNC="runparts"
-    TIME="run-parts"
+    FUNC="mirrorpush"
+    TIME="mirrorpush"
     ARGS=""
     ERR="false"
 )
@@ -816,7 +885,7 @@ GO=(
     ARGS=""
     ERR="false"
 )
-stage $GO
+stage $GO &
 
 GO=(
     FUNC="testingsourcelist"
@@ -834,7 +903,7 @@ GO=(
     ARGS=""
     ERR="false"
 )
-stage $GO
+stage $GO &
 
 GO=(
     FUNC="aptftpcleanup"
@@ -842,7 +911,7 @@ GO=(
     ARGS=""
     ERR="false"
 )
-stage $GO
+stage $GO &
 
 GO=(
     FUNC="merkel3"
@@ -850,7 +919,7 @@ GO=(
     ARGS=""
     ERR="false"
 )
-stage $GO
+stage $GO &
 
 GO=(
     FUNC="compress"