]> git.decadent.org.uk Git - dak.git/blobdiff - config/debian/cron.dinstall
Use log() not echo() to get timestamps
[dak.git] / config / debian / cron.dinstall
index e3c6f4e672290c8e07ee96d6354b649ec4d49f0a..07e9b0d5671566f84e22ec36c19fb658f8397c3a 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 Joerg Jaspert <joerg@debian.org>
+# Copyright (C) 2009-2012 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
@@ -27,6 +27,7 @@
 
 # exit on errors
 set -e
+set -o pipefail
 # make sure to only use defined variables
 set -u
 # ERR traps should be inherited from functions too. (And command
@@ -35,7 +36,7 @@ set -u
 set -E
 
 # import the general variable set.
-export SCRIPTVARS=/srv/ftp.debian.org/dak/config/debian/vars
+export SCRIPTVARS=/srv/ftp-master.debian.org/dak/config/debian/vars
 . $SCRIPTVARS
 
 ########################################################################
@@ -72,7 +73,11 @@ function stage() {
 
     error=${ERR:-"true"}
 
-    STAGEFILE="${stagedir}/${FUNC}"
+    ARGS=${ARGS:-""}
+
+    log "########## DINSTALL BEGIN: ${FUNC} ${ARGS} ##########"
+    STAGEFILE="${stagedir}/${FUNC}_${ARGS}"
+    STAGEFILE=${STAGEFILE// /_}
     if [ -f "${STAGEFILE}" ]; then
         stamptime=$(/usr/bin/stat -c %Z "${STAGEFILE}")
         unixtime=$(date +%s)
@@ -129,6 +134,8 @@ function stage() {
     cat "${STAGEFILE}.log" >> "${LOGFILE}"
     rm -f "${STAGEFILE}.log"
 
+    log "########## DINSTALL END: ${FUNC} ##########"
+
     if [ -f "${LOCK_STOP}" ]; then
         log "${LOCK_STOP} exists, exiting immediately"
         exit 42
@@ -154,10 +161,12 @@ export LC_ALL=C
 
 touch "${DINSTALLSTART}"
 ts "startup"
+DINSTALLBEGIN="$(date -u +"%a %b %d %T %Z %Y (%s)")"
+state "Startup"
 
 lockfile -l 3600 "${LOCK_DAILY}"
 trap onerror ERR
-trap cleanup EXIT TERM HUP INT QUIT
+trap remove_daily_lock EXIT TERM HUP INT QUIT
 
 touch "${LOCK_BRITNEY}"
 
@@ -170,7 +179,7 @@ GO=(
 stage $GO
 
 GO=(
-    FUNC="merkel1"
+    FUNC="qa1"
     TIME="init"
     ARGS=""
     ERR="false"
@@ -178,9 +187,9 @@ GO=(
 stage $GO &
 
 GO=(
-    FUNC="pgdump_pre"
+    FUNC="pg_timestamp"
     TIME="pg_dump1"
-    ARGS=""
+    ARGS="predinstall"
     ERR=""
 )
 stage $GO
@@ -191,46 +200,50 @@ GO=(
     ARGS=""
     ERR="false"
 )
-stage $GO &
+stage $GO
 
 GO=(
-    FUNC="punew"
-    TIME="p-u-new"
-    ARGS="p-u-new"
-    ERR=""
+    FUNC="i18n1"
+    TIME="i18n 1"
+    ARGS=""
+    ERR="false"
 )
-### TODO: policy-new
-#stage $GO
+stage $GO
 
 GO=(
-    FUNC="opunew"
-    TIME="o-p-u-new"
-    ARGS="o-p-u-new"
-    ERR=""
+    FUNC="dep11"
+    TIME="dep11 1"
+    ARGS=""
+    ERR="false"
 )
-### TODO: policy-new
-#stage $GO
+stage $GO
+
+lockfile "$LOCK_ACCEPTED"
+trap remove_all_locks EXIT TERM HUP INT QUIT
 
 GO=(
-    FUNC="i18n1"
-    TIME="i18n 1"
-    ARGS=""
+    FUNC="punew"
+    TIME="p-u-new"
+    ARGS="stable-new"
     ERR="false"
 )
-stage $GO &
+stage $GO
 
-lockfile "$LOCK_ACCEPTED"
-lockfile "$LOCK_NEW"
+GO=(
+    FUNC="opunew"
+    TIME="o-p-u-new"
+    ARGS="oldstable-new"
+    ERR="false"
+)
+stage $GO
 
 GO=(
-    FUNC="process_unchecked"
-    TIME="unchecked"
+    FUNC="backports_policy"
+    TIME="backports-policy"
     ARGS=""
-    ERR=""
+    ERR="false"
 )
-# disabled until p-u is faster than now. it runs often enough, so wont hurt to save
-# the time here.
-#stage $GO
+stage $GO
 
 GO=(
     FUNC="cruft"
@@ -240,21 +253,20 @@ GO=(
 )
 stage $GO
 
-rm -f "$LOCK_ACCEPTED"
-rm -f "$LOCK_NEW"
+state "indices"
 
 GO=(
-    FUNC="msfl"
-    TIME="make-suite-file-list"
+    FUNC="dominate"
+    TIME="dominate"
     ARGS=""
     ERR=""
 )
 stage $GO
 
 GO=(
-    FUNC="filelist"
-    TIME="generate-filelist"
-    ARGS=""
+    FUNC="autocruft"
+    TIME="autocruft"
+    ARGS="unstable experimental"
     ERR=""
 )
 stage $GO
@@ -265,7 +277,7 @@ GO=(
     ARGS=""
     ERR="false"
 )
-stage $GO &
+stage $GO
 
 GO=(
     FUNC="overrides"
@@ -281,18 +293,18 @@ GO=(
     ARGS=""
     ERR="false"
 )
-stage $GO &
+stage $GO
 
+state "packages/contents"
 GO=(
     FUNC="packages"
     TIME="apt-ftparchive"
     ARGS=""
     ERR=""
 )
-# Careful: When we ever go and remove this monster-long thing, we have to check the backgrounded
-# functions before it. We no longer have a 1.5hour sync point then.
 stage $GO
 
+state "dists/"
 GO=(
     FUNC="pdiff"
     TIME="pdiff"
@@ -302,29 +314,30 @@ GO=(
 stage $GO
 
 GO=(
-    FUNC="release"
-    TIME="release files"
+    FUNC="gitpdiff"
+    TIME="gitpdiff"
     ARGS=""
     ERR=""
 )
-stage $GO
+#stage $GO
 
 GO=(
-    FUNC="dakcleanup"
-    TIME="cleanup"
+    FUNC="release"
+    TIME="release files"
     ARGS=""
     ERR=""
 )
 stage $GO
 
 GO=(
-    FUNC="buildd_dir"
-    TIME="buildd_dir"
+    FUNC="dakcleanup"
+    TIME="cleanup"
     ARGS=""
     ERR=""
 )
 stage $GO
 
+state "scripts"
 GO=(
     FUNC="mkmaintainers"
     TIME="mkmaintainers"
@@ -374,44 +387,46 @@ GO=(
 stage $GO
 
 GO=(
-    FUNC="wb"
-    TIME="w-b"
+    FUNC="ddaccess"
+    TIME="ddaccessible sync"
     ARGS=""
-    ERR=""
+    ERR="false"
 )
-stage $GO &
+stage $GO
 
-rm -f "${LOCK_DAILY}"
+remove_all_locks
+trap - EXIT TERM HUP INT QUIT
 
 ts "locked part finished"
+state "postlock"
 
 GO=(
-    FUNC="pgdump_post"
-    TIME="pg_dump2"
+    FUNC="changelogs"
+    TIME="changelogs"
     ARGS=""
-    ERR=""
+    ERR="false"
 )
 stage $GO &
 
 GO=(
-    FUNC="expire"
-    TIME="expire_dumps"
-    ARGS=""
+    FUNC="pg_timestamp"
+    TIME="pg_dump2"
+    ARGS="postdinstall"
     ERR=""
 )
-stage $GO &
+stage $GO
 
 GO=(
-    FUNC="transitionsclean"
-    TIME="transitionsclean"
+    FUNC="expire"
+    TIME="expire_dumps"
     ARGS=""
     ERR=""
 )
 stage $GO &
 
 GO=(
-    FUNC="reports"
-    TIME="reports"
+    FUNC="transitionsclean"
+    TIME="transitionsclean"
     ARGS=""
     ERR=""
 )
@@ -434,16 +449,16 @@ GO=(
 stage $GO &
 
 GO=(
-    FUNC="merkel2"
-    TIME="merkel projectb push"
+    FUNC="mirrorpush"
+    TIME="mirrorpush"
     ARGS=""
     ERR="false"
 )
 stage $GO &
 
 GO=(
-    FUNC="mirrorpush"
-    TIME="mirrorpush"
+    FUNC="mirrorpush-backports"
+    TIME="mirrorpush-backports"
     ARGS=""
     ERR="false"
 )
@@ -476,37 +491,16 @@ stage $GO &
 rm -f "${LOCK_BRITNEY}"
 
 GO=(
-    FUNC="pgdakdev"
-    TIME="dak-dev db"
-    ARGS=""
-    ERR="false"
-)
-stage $GO &
-
-GO=(
-    FUNC="merkel3"
-    TIME="merkel ddaccessible sync"
-    ARGS=""
-    ERR="false"
-)
-stage $GO &
-
-GO=(
-    FUNC="compress"
-    TIME="compress"
+    FUNC="cleantransactions"
+    TIME=""
     ARGS=""
     ERR=""
 )
-stage $GO &
-
-GO=(
-    FUNC="aptftpcleanup"
-    TIME="apt-ftparchive cleanup"
-    ARGS=""
-    ERR="false"
-)
 stage $GO
 
+# we need to wait for the background processes before the end of dinstall
+wait
+
 log "Daily cron scripts successful, all done"
 
 exec > "$logdir/afterdinstall.log" 2>&1
@@ -518,6 +512,7 @@ GO=(
     ERR="false"
 )
 stage $GO
+state "all done"
 
 
 # Now, at the very (successful) end of dinstall, make sure we remove