]> git.decadent.org.uk Git - dak.git/blobdiff - config/debian/cron.dinstall
dinstall
[dak.git] / config / debian / cron.dinstall
index dfd9e916ac33ee134a3af160cc60a0b22b25261a..7b0e38e48bcba2a7dddcfec0e257a3d36e5ef7ab 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
@@ -46,7 +59,7 @@ 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
+    cat "${STAGEFILE}.log" | mail -s "ATTENTION ATTENTION! dinstall error at ${ERRDATE} in ${STAGEFILE} - (Be quiet, Brain, or I'll stab you with a Q-tip)" cron@ftp-master.debian.org
 }
 
 ########################################################################
@@ -255,7 +268,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() {
@@ -354,15 +367,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
 }
@@ -403,7 +416,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
 }
@@ -431,8 +446,9 @@ function stage() {
     ARGS='GO[@]'
     local "${!ARGS}"
 
-    if [ -f "${stagedir}/${FUNC}" ]; then
-        stamptime=$(/usr/bin/stat -c %Z "${stagedir}/${FUNC}")
+    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
@@ -449,6 +465,11 @@ function stage() {
     # 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
@@ -465,12 +486,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
@@ -518,9 +547,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
@@ -601,6 +633,7 @@ GO=(
 stage $GO
 
 lockfile "$LOCK_ACCEPTED"
+lockfile "$LOCK_NEW"
 
 GO=(
     FUNC="process_unchecked"
@@ -636,6 +669,7 @@ GO=(
 stage $GO
 
 rm -f "$LOCK_ACCEPTED"
+rm -f "$LOCK_NEW"
 
 GO=(
     FUNC="msfl"